cryptocompare
Python3 wrapper to query cryptocurrency prices (and more) using the CryptoCompare API.
Install
pip3 install cryptocompare
Usage
import cryptocompare
API Key
If you have an API key, you can either set it as environment variable CRYPTOCOMPARE_API_KEY
or set it manually with:
cryptocompare.cryptocompare._set_api_key_parameter(KEY_HERE)
Coin List
cryptocompare.get_coin_list(format=False)
If format
is True
, the coin list is returned as Python list,
containing only the abbreviations (like BTC
).
Price
cryptocompare.get_price('BTC')
cryptocompare.get_price('BTC', currency='USD', full=True)
cryptocompare.get_price(['BTC', 'ETH'], ['EUR', 'GBP'])
Historical Prices
cryptocompare.get_historical_price('XMR', timestamp=datetime.datetime(2017,6,6), exchange='CCCAGG')
cryptocompare.get_historical_price('XMR', 'EUR', datetime.datetime(2017,6,6))
Day
cryptocompare.get_historical_price_day('BTC', currency='EUR')
cryptocompare.get_historical_price_day('BTC', currency='EUR', limit=30)
cryptocompare.get_historical_price_day('BTC', 'EUR', limit=24, exchange='CCCAGG', toTs=datetime.datetime(2019,6,6))
cryptocompare.get_historical_price_day('BTC', 'EUR', limit=24, exchange='CCCAGG', toTs=datetime.datetime(1559815200))
Hour
cryptocompare.get_historical_price_hour('BTC', currency='EUR')
cryptocompare.get_historical_price_hour('BTC', currency='EUR', limit=24)
cryptocompare.get_historical_price_hour('BTC', 'EUR', limit=24, exchange='CCCAGG')
cryptocompare.get_historical_price_hour('BTC', 'EUR', limit=24, exchange='CCCAGG', toTs=datetime.datetime(2019,6,6,12))
cryptocompare.get_historical_price_hour('BTC', 'EUR', limit=24, exchange='CCCAGG', toTs=datetime.datetime(1559815200))
Minute
cryptocompare.get_historical_price_minute('BTC', currency='EUR')
cryptocompare.get_historical_price_minute('BTC', currency='EUR', limit=1440)
cryptocompare.get_historical_price_minute('BTC', 'EUR', limit=24, exchange='CCCAGG', toTs=datetime.datetime.now())
Average
cryptocompare.get_avg('BTC', currency='EUR', exchange='Kraken')
Exchanges
cryptocompare.get_exchanges()
Pairs
cryptocompare.get_pairs()
pairs = cryptocompare.get_pairs(exchange='Kraken')
Developing
Tests run assuming you have an API key, otherwise they will error due to rate limiting. Install the dev dependencies and run the tests:
pip3 install -r requirements.txt
python3 -m pytest
Credit
Disclaimer
This is a hobby project, no guarantees.
If you find bugs or want additional features,
open an issue and/or create a pull request.