Online blockchain

bitcoin blockchain

How To Build a Bitcoin Currency Converter Using the APIs, ProgrammableWeb

The rise of Bitcoin has resulted in the development of a variety of services that enable individuals and companies to track Bitcoin, create and manage Bitcoin wallets, and perform transactions using the cryptocurrency.

One of the most popular Bitcoin websites,, has a suite of Bitcoin APIs and in this tutorial, we’ll look at how two of those can be used to build a Bitcoin currency conversion application.

Getting started

To start, you will need a hosting account that supports PHP 5.0 or greater and has the PHP curl module installed. In the root web directory of your hosting account, create two empty PHP files, index.php and converter.php.

The index page

Our index page, index.php, should contain a form that we can use to prompt the user for information about the currency conversion desired. In the empty index.php file, paste the following code:

Now our index page is in place:

The converter script

To perform the currency conversion, our index page will post data submitted through its form to converter.php. In the empty converter.php file, paste the following code:

The code above calls two endpoints associated with’s Market Prices and Exchanges Rates API. The first endpoint allows us perform the actual currency conversion for the currency and amount supplied by the user. The second endpoint provides real-time currency conversion information, such as the current buy and sell prices and 15-minute average price. We can use this to display more information to the user about the state of the market in their chosen currency:

Adding a price chart offers a Statistics API that provides data that can be used to create charts. One of the endpoints provides historical data for the price of Bitcoin in U.S. dollars. To make Bitcoin-to-USD conversions more useful, we can add on to our converter.php script so it displays a chart of the BTC price over the past 60 days. To create the chart, we can use the Google Charts JavaScript API.

Replace the existing converter.php code with the following:

With our charting code in place, users performing currency conversions in U.S. dollars can now visualize how the price has changed over the past two months:

Ideas for further development has a set of Wallet APIs that can be used to create new Bitcoin wallets and send and receive payments using them. By integrating these into our application, we can allow users to make payments to others after performing a currency conversion. Additionally, APIs provided by popular third-party Bitcoin wallet providers and exchanges such as Coinbase could be used to allow our users to purchase Bitcoin once they have used the currency converter.



Did not work. Had lots of formatting that had to be adjusted jue to how we have to copy and paste. Once errors fixed and it ran, no prices from blockinfo.

I am glad you were able to get this working. If you see any error messages from your WAMP server that you want to share I would be happy to see if we can figure out what the issue was.

It did not work on my local WAMP server, which has CURL and PHP 5.34, but it did work once I uploaded it to a shared hosting environment. So I not sure what is actually needed exactly as my WAMP server which I develop on all the time didnt work.

that being said, thanks for the code!

Well, it runs, but it doesn’t display anything in the results. I guess it’s all to old now

Hi, I’m on OSX 10.11.5, PHP 5.6 and have Curl installed etc. The programs kind of work. Just no results are displayed. No errors, just no results. any ideas?

[kw] wallet api[/kw]

Related video: Come Aprire un E-WALLET di Bitcoin su Blockchain

Leave a Reply

Your email address will not be published. Required fields are marked *