My project is to draw a line chart with chart.js from historical coinbase price data. The result should be similar to Googles crypto chart. I allready have found a simple way to get the live prices of any cryptocurrency, but I don't know how to get the historical data. My project is written in PHP, you can see my live price grabber function below.
/**
* coinbase api call prices
*/
function api_call_price($from, $to) {
$from = (trim(strtoupper($from)));
$to = (trim(strtoupper($to)));
$url = 'curl -s -H "CB-VERSION: 2017-12-06" "https://api.coinbase.com/v2/prices/'.$from.'-'.$to.'/spot"';
$tmp = shell_exec($url);
$data = json_decode($tmp, true);
if ($data && $data['data'] && $data['data']['amount']) {
return (float)$data['data']['amount'];
}
return null;
}
// Usage: api_call_price("BTC", "EUR");