Python Coin Market Cap Client
pip install coinmarketcap-client==2.5.3
A Python library to connect with Coin Market Cap APIs.
Supported APIs:
pip install coinmarketcap-client
tox
>>> from coinmarketcap.clients import CoinMarketCapClient
>>> client = CoinMarketCapClient()
Return the active list of cryptocurrencies.
>>> client.listing.get()
[{'id': 1, 'name': 'Bitcoin', 'symbol': 'BTC', 'website_slug': 'bitcoin'}, {'id': 2, 'name': 'Litecoin', 'symbol': 'LTC', 'website_slug': 'litecoin'}, ...
Return the ticker data for all active cryptocurrencies.
Parameters:
>>> client.tickers.get()
[{'id': 1, 'name': 'Bitcoin', 'symbol': 'BTC', 'website_slug': 'bitcoin', 'rank': 1, 'circulating_supply': 17073725.0, 'total_supply': 17073725.0, 'max_supply': 21000000.0, 'quotes': {'USD': {'price': 7600.48, 'volume_24h': 4943200000.0, 'market_cap': 129768505388.0, 'percent_change_1h': -0.32, 'percent_change_24h': -1.66, 'percent_change_7d': 4.4}}, 'last_updated': 1528100975}, {'id': 1027, 'name': 'Ethereum', 'symbol': 'ETH', 'website_slug': 'e...
Return the last ticker data for specific cryptocurrency.
Parameters:
>>> client.cryptocoin.get(coin_id=1)
{'id': 1, 'name': 'Bitcoin', 'symbol': 'BTC', 'website_slug': 'bitcoin', 'rank': 1, 'circulating_supply': 17083000.0, 'total_supply': 17083000.0, 'max_supply': 21000000.0, 'quotes': {'USD': {'price': 7635.7, 'volume_24h':4211460000.0, 'market_cap': 130440663100.0, 'percent_change_1h': -0.13, 'percent_change_24h': -0.6, 'percent_change_7d': 1.86}}, 'last_updated': 1528503874}
Returns the global summary data from Coin Market Cap.
Parameters:
>>> client.global_data.get()
{'active_cryptocurrencies': 1654, 'active_markets': 11318, 'bitcoin_percentage_of_market_cap': 38.08, 'quotes': {'USD': {'total_market_cap': 342680267176.0, 'total_volume_24h': 13469496559.0}}, 'last_updated': 1528506574}
You can create your own parser to customizing Coin Market Cap response.
class MyParser:
@classmethod
def parse(cls, data):
"""
Implement your customized parse classmethod.
"""
Then you can pass your custom parser MyParser by param into some client initialization.
client = TickerClient(MyParser) # Client to get tickers from Coin Market Cap
This way, you can customize the parsing method from any single client from this lib.
from coinmarketcap.clients import *
tickers_c = TickerClient(MyParser)
criptocoin_c = CryptoCoinTickerClient(MyParser)
listing_c = ListCryptoCoinClient(MyParser)
global_c = GlobalSummaryClient(MyParser)
But you also can customize the response from CoinMarketCapClient, like the example above:
client = CoinMarketCap()
MyParser.parse(client_c.tickers.get())