Finding BitCoin current price and status in PHP (CoinDesk)

Posted By: Matpal - March 09, 2018
CoinDesk provides a REST API for bitcoin price. In this example I am showing how we can call CoinDesk API through PHP. CoinDesk returns a JSON as response.

$ch = curl_init();

curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$result = curl_exec($ch);

echo $result;

Following is the output as JSON
{"time":{"updated":"Mar 9, 2018 17:25:00 UTC","updatedISO":"2018-03-09T17:25:00+00:00",
"updateduk":"Mar 9, 2018 at 17:25 GMT"},
"disclaimer":"This data was produced from the CoinDesk Bitcoin Price Index (USD). 
Non-USD currency data converted using hourly conversion rate from",
"bpi":{"USD":{"code":"USD","rate":"8,823.5550","description":"United States Dollar",


Post a Comment

Note: Only a member of this blog may post a comment.