
Security News
Another Round of TEA Protocol Spam Floods npm, But It’s Not a Worm
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.
python-coinmarketcap
Advanced tools
This is a non-official (but working) Python package to wrap the CoinMarketCap API. With this you can monitor and watch the crypto market.
pip install python-coinmarketcap
from coinmarketcapapi import CoinMarketCapAPI
cmc = CoinMarketCapAPI()
rep = cmc.cryptocurrency_info(symbol='BTC') # See methods below
print(rep.data) # Whole repsonse payload
print(rep.data["BTC"]["logo"]) # Some data in response
print(rep.credit_count) # API credits
print(rep.total_elapsed) # Request time in ms
# ...
Synopsis
CoinMarketCapAPI(api_key=None, [debug=False, logger=None, sandbox=False, version='v1'])
debug: set verbosity.sandbox: In case of default sandbox API key changes, see Issue #1.logger: you can give a custom logger.version: set the version in the URL, for futures version.Methods
You have to pass to the following methods the parameters detailed in the official documentation.
| Methods and 📄documentation | Endpoint (version) |
|---|---|
| cryptocurrency_map | /cryptocurrency/map |
| cryptocurrency_info | /cryptocurrency/info (v2) |
| cryptocurrency_listings_latest | /cryptocurrency/listings/latest |
| cryptocurrency_listings_historical | /cryptocurrency/listings/historical |
| cryptocurrency_quotes_latest | /cryptocurrency/quotes/latest (v2) |
| cryptocurrency_quotes_historical | /cryptocurrency/quotes/historical (v2) |
| cryptocurrency_marketpairs_latest | /cryptocurrency/market-pairs/latest (v2) |
| cryptocurrency_ohlcv_latest | /cryptocurrency/ohlcv/latest (v2) |
| cryptocurrency_ohlcv_historical | /cryptocurrency/ohlcv/historical (v2) |
| cryptocurrency_priceperformancestats_latest | /cryptocurrency/price-performance-stats/latest (v2) |
| cryptocurrency_categories | /cryptocurrency/categories |
| cryptocurrency_category | /cryptocurrency/category |
| cryptocurrency_airdrops | /cryptocurrency/airdrops |
| cryptocurrency_airdrop | /cryptocurrency/airdrop |
| cryptocurrency_trending_latest | /cryptocurrency/trending/latest |
| cryptocurrency_trending_mostvisited | /cryptocurrency/trending/most-visited |
| cryptocurrency_trending_gainerslosers | /cryptocurrency/trending/gainers-losers |
| exchange_map | /exchange/map |
| exchange_info | /exchange/info |
| exchange_listings_latest | /exchange/listings/latest |
| exchange_quotes_latest | /exchange/quotes/latest |
| exchange_quotes_historical | /exchange/quotes/historical |
| exchange_marketpairs_latest | /exchange/market-pairs/latest |
| globalmetrics_quotes_latest | /global-metrics/quotes/latest |
| globalmetrics_quotes_historical | /global-metrics/quotes/historical |
| tools_priceconversion | /tools/price-conversion (v2) |
| tools_postman | /tools/postman |
| blockchain_statistics_latest | /blockchain/statistics/latest |
| fiat_map | /fiat/map |
| partners_flipsidecrypto_fcas_listings_latest | /partners/flipside-crypto/fcas/listings/latest |
| partners_flipsidecrypto_fcas_quotes_latest | /partners/flipside-crypto/fcas/quotes/latest |
| key_info | /key/info |
| content_posts_top | /content/posts/top |
| content_posts_latest | /content/posts/latest |
| content_posts_comments | /content/posts/comments |
| content_latest | /content/latest |
| fearandgreed_latest | /fear-and-greed/latest (v3) |
| fearandgreed_historical | /fear-and-greed/historical (v3) |
| exchange_assets | /exchange/assets |
| community_trending_token | /community/trending/token |
| community_trending_topic | /community/trending/topic |
Additionnal Parameters
api_version (str): if given, will fetch the given version of the endpoint (default is equal to the given version in the CoinMarketCapAPI instance wich is actually v1). As mentioned in the list above, some endpoints are "v2" by default.Example
Assuming you want to get informations about bitcoin. First, read the documentation of the corresponding cryptocurrency_info endpoint.
symbol parameter like : cmc.cryptocurrency_info(symbol='BTC')slug parameter : cmc.cryptocurrency_info(slug='bitcoin')You can switch easly in the sandbox mode without giving an API key or by setting it to None :
cmc = CoinMarketCapAPI() # You are in sandbox environnementYou can enable a debuging mode, just set debug to True to main class:
cmc = CoinMarketCapAPI(debug=True)
cmc.cryptocurrency_info(symbol='BTC')
This will produce this output :
2019-04-06 16:03:04,716 root DEBUG GET SANDBOX 'v1/cryptocurrency/info'
PARAMETERS: {'symbol': 'BTC'}
2019-04-06 16:03:05,004 root DEBUG RESPONSE: 288ms OK: {u'BTC': {u'category': u'coin', u'name': u'Bitcoin', u'tags': [u'mineable'], u'symbol': u'BTC', u'id': 1, [...]}
Optionnaly, you can pass (on-the-fly) a specific version of an endpoint by given the api_version keyword argument directly to a method:
cmc.cryptocurrency_listings_latest(..., api_version="v1.1")
See also
Synopsis
You get results of the API in a Response instance.
Property
Corresponding to standards and conventions:
data (dict): will give you the result.status (dict): the status object always included for both successful calls and failures.credit_count (int): the number of credits this call utilized.elapsed (int): the number of milliseconds it took to process the request to the server.total_elapsed (int): the total number of milliseconds it took to process the request.timesamp (str): current time on the server when the call was executed.error_code (str | None): In case of an error has been raised, this property will give you the status error code.error_message (str | None): In case of an error has been raised, this property will give details about error.error (bool): True if an error has been raised.Example
r = cmc.cryptocurrency_info(symbol='BTC')
print(repr(r.status))
print(repr(r.data))
print(repr(r.credit_count))
Synopsis
If API returns an error, CoinMarketCapAPI will raise a CoinMarketCapAPIError.
Property
rep (Response | None): will give you a Response instance or None if request failed for an other reason than a server error.Example
from coinmarketcapapi import CoinMarketCapAPI, CoinMarketCapAPIError
cmc = CoinMarketCapAPI('{YOUR_API_KEY}') # Pro environnement
# cmc = CoinMarketCapAPI() # Sandbox environnement
try:
r = cmc.cryptocurrency_info(symbol='BTC')
except CoinMarketCapAPIError as e:
r = e.rep
print(repr(r.error))
print(repr(r.status))
print(repr(r.data))
JSONDecodeError as CoinMarketCapAPIError../test.py.api_key default to Sandbox mode.v2 for some endpoints :
api_version keyword argument to all endpoints to change on-the-fly the api version to use.deflate, gzip encoding to receive data fast and efficiently.FAQs
CoinMarketCap Python API Wrapper
We found that python-coinmarketcap demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.

Security News
PyPI adds Trusted Publishing support for GitLab Self-Managed as adoption reaches 25% of uploads

Research
/Security News
A malicious Chrome extension posing as an Ethereum wallet steals seed phrases by encoding them into Sui transactions, enabling full wallet takeover.