Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CoinMarketCap cryptocurrencies source #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
### Added

- This change log file.
- CoinMarketCap as a source for cryptocurrencies.

### Fixed

Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# PHP Crypto Currencies

This library provides up-to-date list of cryptocurrencies retrieved from various crypto exchanges. It uses the following crypto exchanges.
This library provides up-to-date list of cryptocurrencies retrieved from various sources. It uses the following sources.

- Binance
- [Binance](https://binance-docs.github.io/apidocs/spot/en/)
- [CoinMarketCap](https://coinmarketcap.com/api/)

Please be aware that this library solely exists to provide cryptocurrencies for [moneyphp/money](https://github.com/moneyphp/money). Using this library for other purposes is at your own risk.

Expand All @@ -13,6 +14,10 @@ Install using composer.
composer install
```

Add environment variable for CoinMarketCap API key.
```sh
export COIN_MARKET_CAP_API_KEY=YOUR_API_KEY
```
Update currencies using composer.
```sh
composer fetch-update
Expand Down
4 changes: 4 additions & 0 deletions bin/fetch-update.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types=1);

use MoneyPHP\CryptoCurrencies\Fetcher\BinanceFetcher;
use MoneyPHP\CryptoCurrencies\Fetcher\CoinMarketCapFetcher;
use MoneyPHP\CryptoCurrencies\Serializer\JsonSerializer;
use MoneyPHP\CryptoCurrencies\Serializer\PhpExportSerializer;
use MoneyPHP\CryptoCurrencies\Updater;
Expand All @@ -16,3 +17,6 @@
$updater->writeWith(new Writer(), $cryptocurrencies, 'binance', new JsonSerializer());
$updater->writeWith(new Writer(), $cryptocurrencies, 'binance', new PhpExportSerializer());

$cryptocurrencies = $updater->fetchWith(new CoinMarketCapFetcher('https://pro-api.coinmarketcap.com/v1/cryptocurrency/map'));
$updater->writeWith(new Writer(), $cryptocurrencies, 'coinmarketcap', new JsonSerializer());
$updater->writeWith(new Writer(), $cryptocurrencies, 'coinmarketcap', new PhpExportSerializer());
1 change: 1 addition & 0 deletions resources/coinmarketcap.json

Large diffs are not rendered by default.

Loading