Official documentation on the Blockchain Exchange Rates API page.
$Blockchain = new \Blockchain\Blockchain($api_code);
// Make calls on the $Blockchain->Rates object
Get the amount of Bitcoin that could be purchased for a given fiat amount. Returns a float
.
$btc_amount = $Blockchain->Rates->toBTC(500, 'USD');
Get the amount of a given fiat currency for a given bitcoin amount (in satoshi). Returns a float
.
/*
* Optional param:
* $symbol - the fiat currency to convert to ('USD' by default)
*/
$one_btc_in_usd = $Blockchain->Rates->fromBTC(100000000);
Get a set of exchange rate tickers for various currencies. Returns an associative array with the currency code for keys and Ticker
objects for values.
$rates = $Blockchain->Rates->get();
// $rates array has currency code for keys
foreach($rates as $cur=>$ticker) { ... }
class Ticker {
public $m15; // float
public $last; // float
public $buy; // float
public $sell; // float
public $cur; // string
public $symbol; // string
}