<?php
$hidekeyifdropped = "https://console.pool.bitcoin.com/srv/api/user?apikey=YOUR_KEY";
$api_url = $hidekeyifdropped;
$mining_data = json_decode(file_get_contents($api_url), true);
//From here you could echo JSON representations for any (or all, or some, or together) of the following:
$coins = array(
'bchbalance' => $mining_data['bitcoinCashBalance'],
'btcbalance' => $mining_data['bitcoinBalance'],
'bchreward' => $mining_data['bccBlockRewardBonusPercent'],
'btcreward' => $mining_data['btcBlockRewardBonusPercent'],
'hashratenow' => $mining_data['hashrateNowTerahashes'],
'hashrate10minutes' => $mining_data['hashrateAverage10minTerahashes'],
'hashrate1hour' => $mining_data['hashrateAverage1hrTerahashes'],
'hashrate24hours' => $mining_data['hashrateAverage24hrsTerahashes']
);
echo json_encode($coins);
// NOTE: You could also use the url of the location of this php file you've create as a new API itself. The new API would circumvent the CORS issue when using JS
// 'Access-Control-Allow-Origin' header has a value 'http://stbitts.com' that is not equal to the supplied origin. Origin 'null' is therefore not allowed access.
// NOTE: Although you'll probably have to add this to your php file: header('Access-Control-Allow-Origin: *');
?>
//Returns this:
{"bchbalance":null,"btcbalance":null,"bchreward":null,"btcreward":null,"hashratenow":null,"hashrate10minutes":null,"hashrate1hour":null,"hashrate24hours":null}