This is a simple composer package that implements CoinDesk Bitcoin Price Index API for PHP.
- PHP 7 with curl and json extensions enabled
composer require kristapsk/php-coindesk-api
Or just copy src/BPI.php
to your project, it has no other dependencies.
In all examples last parameter of methods called specifies currency. Supported currencies are EUR
, GBP
and USD
. It can be ommited, will default to USD
.
use kristapsk\CoinDesk\BPI;
// returns float or null on failure
var_dump(BPI::currentPrice('EUR'));
use kristapsk\CoinDesk\BPI;
// returns array with Y-m-d format date string as key and float price as value
// or null on failure
var_dump(BPI::historical(strtotime('2021-03-01'), strtotime('2021-03-16'), 'EUR'));
This package is released under the MIT License. See the bundled LICENSE file for details.
This project is not in any way affiliated with CoinDesk.