kristapsk / php-coindesk-api
Composer package for the CoinDesk Bitcoin Price Index API
Installs: 29
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/kristapsk/php-coindesk-api
Requires
- ext-curl: *
- ext-json: *
This package is auto-updated.
Last update: 2025-08-07 00:28:20 UTC
README
This is a simple composer package that implements CoinDesk Bitcoin Price Index API for PHP.
Requirements
- PHP 7 with curl and json extensions enabled
Installation
composer require kristapsk/php-coindesk-api
Or just copy src/BPI.php to your project, it has no other dependencies.
Usage
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.
Get current Bitcoin price
use kristapsk\CoinDesk\BPI; // returns float or null on failure var_dump(BPI::currentPrice('EUR'));
Get historical Bitcoin prices
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'));
License
This package is released under the MIT License. See the bundled LICENSE file for details.
Disclaimer
This project is not in any way affiliated with CoinDesk.