Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kristapsk/php-coindesk-api
CoinDesk Bitcoin Price Index API package for PHP
https://github.com/kristapsk/php-coindesk-api
bitcoin coindesk coindesk-api php
Last synced: 4 days ago
JSON representation
CoinDesk Bitcoin Price Index API package for PHP
- Host: GitHub
- URL: https://github.com/kristapsk/php-coindesk-api
- Owner: kristapsk
- License: mit
- Created: 2021-03-19T10:23:13.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-03-19T18:33:15.000Z (over 3 years ago)
- Last Synced: 2024-10-11T20:32:25.061Z (about 1 month ago)
- Topics: bitcoin, coindesk, coindesk-api, php
- Language: PHP
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CoinDesk Bitcoin Price Index API for PHP
[![tippin.me](https://badgen.net/badge/%E2%9A%A1%EF%B8%8Ftippin.me/@kristapsk/F0918E)](https://tippin.me/@kristapsk)
This is a simple composer package that implements [CoinDesk Bitcoin Price Index API](https://www.coindesk.com/coindesk-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
```php
use kristapsk\CoinDesk\BPI;// returns float or null on failure
var_dump(BPI::currentPrice('EUR'));
```### Get historical Bitcoin prices
```php
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](LICENSE) file for details.
## Disclaimer
This project is not in any way affiliated with CoinDesk.