Skip to main content

Python Coin Market Cap Client

A Python library to connect with Coin Market Cap APIs.

Supported APIs:

Install

pip install coinmarketcap-client

Tests

tox

Usage

>>> from coinmarketcap.clients import CoinMarketCapClient
>>> client = CoinMarketCapClient()

List cryptocurrencies

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'}, ...

Get tickers

Return the ticker data for all active cryptocurrencies.

Parameters:

  • limit[optional]: Return a maximum of [limit] results (default is 100; max is 100)
  • start[optional]: Return results from rank [start] and above
  • sort[optional]: Return results sorted by [sort] . Possible values are "id", "rank", "volume_24h" and "percent_change_24h" (default is rank).
  • currency[optional]: Return pricing info in terms of another currency (default is USD)
    • Supported values are: "AUD", "BRL", "CAD", "CHF", "CLP", "CNY", "CZK", "DKK", "EUR", "GBP", "HKD", "HUF", "IDR", "ILS", "INR", "JPY", "KRW", "MXN", "MYR", "NOK", "NZD", "PHP", "PKR", "PLN", "RUB", "SEK", "SGD", "THB", "TRY", "TWD", "ZAR"
    • Also supports these cryptocurrency values: "BTC", "ETH" "XRP", "LTC", and "BCH"
>>> 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...

Get ticker by Cryptocurrency

Return the last ticker data for specific cryptocurrency.

Parameters:

  • coin_id: The cryptocurrency id in Coin Market Cap API.
  • currency[optional]: Return pricing info in terms of another currency (default is USD)
    • Supported values are: "AUD", "BRL", "CAD", "CHF", "CLP", "CNY", "CZK", "DKK", "EUR", "GBP", "HKD", "HUF", "IDR", "ILS", "INR", "JPY", "KRW", "MXN", "MYR", "NOK", "NZD", "PHP", "PKR", "PLN", "RUB", "SEK", "SGD", "THB", "TRY", "TWD", "ZAR"
    • Also supports these cryptocurrency values: "BTC", "ETH" "XRP", "LTC", and "BCH"
>>> 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}

Get global summary data

Returns the global summary data from Coin Market Cap.

Parameters:

  • currency[optional]: Return pricing info in terms of another currency (default is USD)
    • Supported values are: "AUD", "BRL", "CAD", "CHF", "CLP", "CNY", "CZK", "DKK", "EUR", "GBP", "HKD", "HUF", "IDR", "ILS", "INR", "JPY", "KRW", "MXN", "MYR", "NOK", "NZD", "PHP", "PKR", "PLN", "RUB", "SEK", "SGD", "THB", "TRY", "TWD", "ZAR"
    • Also supports these cryptocurrency values: "BTC", "ETH" "XRP", "LTC", and "BCH"
>>> 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}

Customizing

Parsing response data from Coin Market Cap API

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())

Metadata

Release files for coinmarketcap-client 2.5.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for coinmarketcap-client 2.5.3
File Size Uploaded
coinmarketcap-client-2.5.3.tar.gz 6.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for coinmarketcap-client 2.5.3
File Interpreter ABI Platform
coinmarketcap_client-2.5.3-py3-none-any.whl Python 3 none any Details

Total release size: 13.8 kB

Release files / coinmarketcap-client-2.5.3.tar.gz

Download URL coinmarketcap-client-2.5.3.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
583e4868b4adc24a66e137ef27bdcead537509f7024b2133982bbf12b760cc57
BLAKE2b-256 checksum
How to use checksums
566fa3be5d19c6516dfc68c9baf217c36ef1c935702335ef5b6ffe6d3c931d3d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / coinmarketcap_client-2.5.3-py3-none-any.whl

Download URL coinmarketcap_client-2.5.3-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d642831f18f6f766b82d14e8dd168c014f7fd3515c5ecaa152cc0ce19b63bd5c
BLAKE2b-256 checksum
How to use checksums
ee7a3a3a4885330d2cd520369173482cb994f203079bdf92468c6f942ebfa2a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

2.5.3 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page