In this post we have explained about how to get bitcoin exchange rate API PHP script. First of all, we have to know about What is a bitcoin.? Bitcoin is a cryptocurrency. It is uses for digital transactions. It is a decentralized system without any third party mediator. Bitcoins workflow is based on BlockChain.
Here we have some API calls available with GET request.
Returns a JSON object with the currency codes as keys. This response is the 15 mins delayed market price.
Response: In above API returns currency symbol and last is the most recent exchange price.
Exchange currency rate API PHP script example:
$from_currency = "INR";
$to_currency = "BTC";
$amount = 500;
$url = "https://blockchain.info/tobtc?currency=$from_currency&value=$amount";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // On dev server only!
$result = curl_exec($ch);
echo "<h1> Exchange Rate From $from_currency TO BTC </h1>";
echo "<p> FROM: " . $amount . " " . $from_currency . "</p>";
echo "<p> TO: " . $result . " " . $to_currency . "</p>";
Thanks for reading this article. If you have any queries and please comment in that below.