Bitcoin Forum
December 03, 2016, 11:52:54 AM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1] 2 »  All
  Print  
Author Topic: Bitcoin API - solved!  (Read 14120 times)
dacoinminster
Legendary
*
expert
Offline Offline

Activity: 1106


Rational Exuberance


View Profile WWW
March 09, 2011, 06:04:10 PM
 #1

I have a bunch of bitcoin-powered website ideas I would love to work on. I have reasonable PHP/MySQL skills, but I'm not sure what is the best way to interface a website with bitcoin. I poked through the forums and found a couple different ways this might be done, but I'm not sure what is the simplest solution to just get something working.

Options:

1) bitcoind - I think this might be the same as configuring bitcoin to run as server. I believe it uses an RPC API to run transactions from the command line.
Pros: Everything stays on my server
Cons: I have to find a server that will let me compile and install this, rather than just some PHP/MySQL farm in the cloud, which is what I prefer

2) mybitcoin.com "shopping cart interface".
Pros: Seems to do everything I would need
Cons: I don't see anybody talking about using it. (Can anybody tell me how well this works?). Also have to install/compile/run something on my server, rather than just constructing/posting a URL and reading the results, which is what I prefer.

3) mtgox.com API:
Pros: Perfect API model (construct/post a URL, then read the results)
Cons: According to the documentation, I can send bitcoins via the API, but I don't see any way to generate a new address and then query if bitcoins have been received at that address. If I could do that, it would be perfect!

4) Manually parse webpage at mybitcoin.com or mtgox.com
Pros: I know how to do this
Cons: It would take a lot longer, it would be hacky, it would break when the webpage changed, and I'd have to find some way around the captcha at mybitcoin.com if I used that site

What do you guys (who have bitcoin-powered websites) do? If there is a really stupid-simple API to handle bitcoins from my webpage without installing anything, I've missed it.

Any help would be appreciated. I would like to point out that if such an API existed and was widely used/known, the difficulty in creating a new bitcoin-powered site would go down significantly.

Edit:

Thanks for the comments everyone. It looks like what I want doesn't exist yet, so I'll offer a small bounty: 20BTC

Payable to the first online wallet service (new or existing) who provides the world with a URL API something like this:

https://www.coolservice.com?user=dacoinminster&pwd=mypassword&action=spend&address=bitcoin_address_to_send_to&amount=#
(an equivalent one for this already exists at mtgox)

https://www.coolservice.com?user=dacoinminster&pwd=mypassword&action=getnewaddress
(returns new bitcoin address which I can give to a customer)

https://www.coolservice.com?user=dacoinminster&pwd=mypassword&action=seecoins
(returns my BTC balance)

https://www.coolservice.com?user=dacoinminster&pwd=mypassword&action=seecoins&address=bitcoin_address_of_mine
(returns number of BTC sent to that address, and number of confirmations received so far)

https://www.coolservice.com?user=dacoinminster&pwd=mypassword&action=seetransactions
(returns all my transactions ever, with addresses and # of confirmations for each one)

Bounty is only payable if the service is free to everyone. Website must be either already trusted, or must establish a trustworthy reputation. Hopefully others interested in having a service like this will add to my little bounty.

Edit: Problem solved, and bounty expired paid: http://bitcointalk.org/index.php?topic=4324.msg77187#msg77187

1480765974
Hero Member
*
Offline Offline

Posts: 1480765974

View Profile Personal Message (Offline)

Ignore
1480765974
Reply with quote  #2

1480765974
Report to moderator
1480765974
Hero Member
*
Offline Offline

Posts: 1480765974

View Profile Personal Message (Offline)

Ignore
1480765974
Reply with quote  #2

1480765974
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1480765974
Hero Member
*
Offline Offline

Posts: 1480765974

View Profile Personal Message (Offline)

Ignore
1480765974
Reply with quote  #2

1480765974
Report to moderator
1480765974
Hero Member
*
Offline Offline

Posts: 1480765974

View Profile Personal Message (Offline)

Ignore
1480765974
Reply with quote  #2

1480765974
Report to moderator
mndrix
Michael Hendricks
VIP
Sr. Member
*
Offline Offline

Activity: 447


View Profile
March 09, 2011, 06:41:47 PM
 #2

1) bitcoind - I think this might be the same as configuring bitcoin to run as server. I believe it uses an RPC API to run transactions from the command line.
Pros: Everything stays on my server
Cons: I have to find a server that will let me compile and install this, rather than just some PHP/MySQL farm in the cloud, which is what I prefer

This is what I use for CoinPal, CoinCard and JJGames.  I like having local control of my Bitcoins and getting access to all the APIs bitcoind provides.  Several times I've found it valuable to use `minconf` options when calculating balances and payments received.  I also use the `listtransactions` API frequently.  I don't think those are available in any of the other APIs you mention.

Quote
3) mtgox.com API:
Pros: Perfect API model (construct/post a URL, then read the results)
Cons: According to the documentation, I can send bitcoins via the API, but I don't see any way to generate a new address and then query if bitcoins have been received at that address. If I could do that, it would be perfect!

I do a lot of work with the Mt. Gox APIs and they're excellent.  However, I wouldn't personally want to run a Bitcoin business using them alone because they don't provide enough access to the low-level details.

If you do find a Mt. Gox API for creating new Bitcoin addresses and querying when coins have arrived, let me know.  It would be convenient for me too.
Gavin Andresen
Legendary
*
qt
Offline Offline

Activity: 1652


Chief Scientist


View Profile WWW
March 09, 2011, 07:18:53 PM
 #3

1) bitcoind - I think this might be the same as configuring bitcoin to run as server. I believe it uses an RPC API to run transactions from the command line.
Pros: Everything stays on my server
Cons: I have to find a server that will let me compile and install this, rather than just some PHP/MySQL farm in the cloud, which is what I prefer

You can run the front-end on one server and the back-end on another (and communicate via JSON-RPC over HTTPS).  That's how I'm able to run the Faucet and ClearCoin on Google's App Engine (they talk with bitcoind processes running on linode.com and aws.amazon.com servers).  bitcoind doesn't take much memory, bandwidth, or CPU (just don't turn on coin generation), so, for now, anyway, you can even use an Amazon "micro" server (which costs something like $100 per year).

I'm not selling anything so can't comment on the shopping cart interfaces.  Screen-scraping web pages is a bad idea for lots of reasons.

How often do you get the chance to work on a potentially world-changing project?
LZ
Staff
Legendary
*
Offline Offline

Activity: 1470


Satoshi everywhere!


View Profile WWW
March 09, 2011, 08:10:49 PM
 #4

I prefer the first option (through HTTPS or SSH) using Python.

You may just use getnewaddress "sometradeid" and getbalance "sometradeid".

And do not forget to use backupwallet "somepath" as often as possible. Ideally,
after each transaction. You may generate filenames with the current date/time.

Links to the additional information:

"Never invest unless you can afford to lose your entire investment." © S3052
jav
Sr. Member
****
Offline Offline

Activity: 249


View Profile
March 09, 2011, 08:36:18 PM
 #5

For bitcoinmonitor.com I also run bitcoind directly. I'm using a VPS from prmgr.com. Currently I'm on their 256 MiB offer - as Gavin said, the daemon doesn't need many resources.

But I think you listed pretty much all the possible options. And you are right that for your typical PHP-only webhosting the options are a little limited right now. But options 2) and 3) are probably your best bet there. For mybitcoin.com you write that you have to "install/compile/run something". I haven't used the API myself, but I looked briefly at it and I think you are overestimating the amount of "installing" involved there. It is basically just some code that goes on and does that 'constructing/posting a URL' that you mentioned. If you really wanted to, you could probably construct those HTTP requests yourself, but then you would just reimplemented what the API package already provides. So if you are saying that their API gives you everything you need, then I would suggest to have a closer look at it again.

Hive, a beautiful wallet with an app platform for Mac OS X, Android and Mobile Web. Translators wanted! iOS and OS X devs see BitcoinKit. Tweets @hivewallet. Donations appreciated at 1HLRg9C1GsfEVH555hgcjzDeas14jen2Cn.
dacoinminster
Legendary
*
expert
Offline Offline

Activity: 1106


Rational Exuberance


View Profile WWW
March 09, 2011, 08:48:41 PM
 #6

For mybitcoin.com you write that you have to "install/compile/run something". I haven't used the API myself, but I looked briefly at it and I think you are overestimating the amount of "installing" involved there. It is basically just some code that goes on and does that 'constructing/posting a URL' that you mentioned. If you really wanted to, you could probably construct those HTTP requests yourself, but then you would just reimplemented what the API package already provides. So if you are saying that their API gives you everything you need, then I would suggest to have a closer look at it again.

I took a closer look, and I have a couple more objections to the mybitcoin.com API:

1) No way to generate a new address. This is handled internally at mybitcoin.com - I just send the user there and wait for the site to do a callback.

2) No way to query if a user has paid, and how many confirmations have passed. I just have to wait for a callback.

A callback procedure does not offer me enough visibility into what is happening.


Thanks for the comments everyone. It looks like what I want doesn't exist yet, so I'll offer a small bounty: 20BTC

Payable to the first online wallet service (new or existing) who provides the world with a URL API something like this:

https://www.coolservice.com?user=dacoinminster&pwd=mypassword&action=spend&address=bitcoin_address_to_send_to&amount=#
(an equivalent one for this already exists at mtgox)

https://www.coolservice.com?user=dacoinminster&pwd=mypassword&action=getnewaddress
(returns new bitcoin address which I can give to a customer)

https://www.coolservice.com?user=dacoinminster&pwd=mypassword&action=seecoins
(returns my BTC balance)

https://www.coolservice.com?user=dacoinminster&pwd=mypassword&action=seecoins&address=bitcoin_address_of_mine
(returns number of BTC sent to that address, and number of confirmations received so far)

https://www.coolservice.com?user=dacoinminster&pwd=mypassword&action=seetransactions
(returns all my transactions ever, with addresses and # of confirmations for each one)

Bounty is only payable if the service is free to everyone. Website must be either already trusted, or must establish a trustworthy reputation. Hopefully others interested in having a service like this will add to my little bounty.

I have added the bounty information to the first post in this thread. Future updates will be there.

bitcoinex
Sr. Member
****
Offline Offline

Activity: 350


probiwon.com


View Profile WWW
March 09, 2011, 08:50:16 PM
 #7

Useful if you make site on bitcoind:

http://bitcointalk.org/index.php?topic=703.msg7709#msg7709

New bitcoin lottery: probiwon.com
- Может, ты ещё и в Невидимую Руку Рынка веруешь? - Зачем же веровать в то, что можно наблюдать непосредственно?
error
Hero Member
*****
Offline Offline

Activity: 574



View Profile
March 09, 2011, 08:59:38 PM
 #8

Coincidentally, I am planning to implement a new online wallet service. I will be sure to add these features to it. Smiley

15UFyv6kfWgq83Pp3yhXPr8rknv9m6581W
dacoinminster
Legendary
*
expert
Offline Offline

Activity: 1106


Rational Exuberance


View Profile WWW
March 09, 2011, 09:03:53 PM
 #9

Coincidentally, I am planning to implement a new online wallet service. I will be sure to add these features to it. Smiley

Obviously things always take longer than expected, but do you have any idea how soon you will be launching?

error
Hero Member
*****
Offline Offline

Activity: 574



View Profile
March 09, 2011, 09:17:55 PM
 #10

Coincidentally, I am planning to implement a new online wallet service. I will be sure to add these features to it. Smiley

Obviously things always take longer than expected, but do you have any idea how soon you will be launching?

When it's ready. Grin

Hopefully in about a week or so I'll be able to open it for public testing. There are some features it will have that don't yet exist anywhere else, and that's going to take some work. That's all I'm gonna say about such features right now...

15UFyv6kfWgq83Pp3yhXPr8rknv9m6581W
theymos
Administrator
Legendary
*
expert
Offline Offline

Activity: 2492


View Profile
March 09, 2011, 09:23:19 PM
 #11

I'd just use bitcoind remotely. If you don't want to set up Bitcoin's own remote RPC ability, you could pretty easily create a PHP server that does what you want using GET parameters.

MyBitcoin is used on a lot of sites. I like the customer-side experience, though I've never used it on the server side.

1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
dacoinminster
Legendary
*
expert
Offline Offline

Activity: 1106


Rational Exuberance


View Profile WWW
March 09, 2011, 09:59:31 PM
 #12

I have an interesting social experiment I'm going to run, to try to turn my 20BTC pledge into a 200 BTC pledge:

If you are a trusted forum member, and you would like to see this feature happen, pledge on this thread. I will send you 1/10 of your pledge amount right now, (deducting it from my original pledge). This offer is subject to my deciding if you seem honest, trusted on this forum, and serious about your pledge.

LZ
Staff
Legendary
*
Offline Offline

Activity: 1470


Satoshi everywhere!


View Profile WWW
March 10, 2011, 01:38:06 AM
 #13

I do not think that it is a good idea. It is better to let someone do something, then you will pay.

Added. On the other hand, gavin or themos can make that web site in an hour or even faster...

"Never invest unless you can afford to lose your entire investment." © S3052
dacoinminster
Legendary
*
expert
Offline Offline

Activity: 1106


Rational Exuberance


View Profile WWW
March 30, 2011, 01:04:59 AM
 #14

I added this bounty to the list of active bounties: https://en.bitcoin.it/wiki/Active_Bounties

genjix
Legendary
*
expert
Offline Offline

Activity: 1232


View Profile
March 30, 2011, 05:56:43 AM
 #15

I wrote https://en.bitcoin.it/wiki/PHP_developer_intro
Alex Beckenham
Full Member
***
Offline Offline

Activity: 154


View Profile
March 30, 2011, 01:42:58 PM
 #16


Embarrassingly dumb question:

If using localhost, there's no risk of password-sniffing on http?
http://user:password@127.0.0.1:8332/
That kind of traffic never even leaves your box, correct?

dacoinminster
Legendary
*
expert
Offline Offline

Activity: 1106


Rational Exuberance


View Profile WWW
April 01, 2011, 03:58:47 PM
 #17

I added this bounty to the list of active bounties: https://en.bitcoin.it/wiki/Active_Bounties

I solved my problem, and I am hereby paying the bounty to myself the bounty has been paid to blockexplorer.com!

Problem:
Lazy web designer (me) wants to use bitcoins without dealing with installing bitcoin on a server, installing a shopping cart interface, or using ugly merchant services with callbacks.

Solution for sending bitcoins:
Use the MtGox API (https://mtgox.com/support/tradeAPI)

Solution for receiving bitcoins:
1) Input a list of bitcoin receiving addresses to your database
2) Give a bitcoin address to a potential customer
3) Have the customer tell you when they have sent the coins and have at least 1 confirmation (you can choose a number higher than 1 if you are worried about double-spending)
4) Check blockexplorer to see if they sent the right amount (i.e. http://blockexplorer.com/q/getreceivedbyaddress/19hMEAaRMbEhfSkeU4GT8mgSuyR4t4M6TH/1) - the /1 is the number of confirmations you require
5) Give them what they paid for
6) After a reasonable amount of time has passed, you can re-use the address for another customer

You could avoid having a list of addresses and reusing them if one of the wallet services someday lets you get a new address via API call, but this will work for now.

Bad idea:
Selling bars of gold this way (owner of blockexplorer.com could rip you off)

Good(?) idea:
Selling naked pictures of your grandma this way (owner of blockexplorer.com won't bother)

Shameless begging:
If this info is useful to you, please consider a donation: 19hMEAaRMbEhfSkeU4GT8mgSuyR4t4M6TH

Maybe I'm the only one this lazy, but just in case, I added a page to the wiki: https://en.bitcoin.it/wiki/Lazy_API

Thanks to theymos for making changes to blockexplorer.com to make it even easier to do this. Because of those changes to better support what I want to do, I paid Theymos the 20BTC bounty. You can support blockexplorer.com too by donating to 1Cvvr8AsCfbbVQ2xoWiFD1Gb2VRbGsEf28

theymos
Administrator
Legendary
*
expert
Offline Offline

Activity: 2492


View Profile
April 02, 2011, 05:16:02 AM
 #18

I modified the wiki page to use BBE's API pages:
http://blockexplorer.com/q/getreceivedbyaddress/19hMEAaRMbEhfSkeU4GT8mgSuyR4t4M6TH
http://blockexplorer.com/q/getblockcount

You shouldn't scrape the HTML pages. The layout can change at any time.

1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
dacoinminster
Legendary
*
expert
Offline Offline

Activity: 1106


Rational Exuberance


View Profile WWW
April 03, 2011, 08:57:19 PM
 #19

I modified the wiki page to use BBE's API pages:
http://blockexplorer.com/q/getreceivedbyaddress/19hMEAaRMbEhfSkeU4GT8mgSuyR4t4M6TH
http://blockexplorer.com/q/getblockcount

You shouldn't scrape the HTML pages. The layout can change at any time.

Nice! That will be much easier. I updated my post above as well.

I found the complete API description here: http://blockexplorer.com/q/

It would be nice if the front page of blockexplorer.com linked to that page.

Hal
VIP
Sr. Member
*
expert
Offline Offline

Activity: 314



View Profile
April 04, 2011, 03:21:19 AM
 #20

I added a step to the wiki:

# Recheck blockexplorer to make sure the address still shows the right amount, in case the block chain reorganizes

Checking the address balance once, then waiting for more blocks, is not safe by itself as the transaction may go away.

(Just realized my solution is still vulnerable: the transaction could pay you, go away, you wait n blocks, and a different transaction pays you, you recheck the balance and it looks good, but then the 2nd transaction goes away.)

Hal Finney
Pages: [1] 2 »  All
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!