Code to show the price of Bitcoin on your WEB

From tecnologia.net we continue to give you codes to use on your website, there are more and more sites that show the Bitcoin value on their web pages, that's why we have made a small plugin to easily integrate it and let your users know what Bitcoin price today.

It uses the blockchain.info API, which is one of the most famous online wallets. To avoid overloading the server with queries, the price is cached every 15 minutes, so we will not have problems with the blockchain. To cache the price we do it by writing it to a file inside a folder with a name that we will call “cache”, giving this folder read and write permissions (chmod 777).

To use the plugin we will do this.

Step 1. We will include the call to the plugin file after jquery:

Step 2. In our html name any element with a name that we can later identify, for example:

One bitcoin is currently worth €

3. We use the plugin, passing as a parameter the currency we want to use (USD, EUR, …). If we do not pass any parameters, the default currency will be used, which is EUR:

$(function(){  $(‘.jbtc’).jmybitcoin(‘EUR’);});