# Python-CoinMarketCap API Wrapper
This is a non-official (but working) Python package to wrap the CoinMarketCap API. With this you can monitor and watch the crypto market.
- Read the official [API documentation](https://coinmarketcap.com/api/documentation/v1/)
- For the pro version, get an API Key on the [Developper Portal](https://coinmarketcap.com/api/)
- Be sure to replace the API Key in sample code with your own.
[](https://pepy.tech/project/python-coinmarketcap)
---
## Installation
__Via pip__
- pip install __python-coinmarketcap__
> /!\ *Don't confuse this with the coinmarketcap package.*
## Example
```python
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
# ...
```
---
## Wrapper References
### CoinMarketCapAPI
__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](https://github.com/rsz44/python-coinmarketcap/issues/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](https://coinmarketcap.com/api/documentation/v1/).
| Methods and documentation | Endpoint (version) |
|-|-|
| [📄 __cryptocurrency_map__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyMap) | /cryptocurrency/map |
| [📄 __cryptocurrency_info__](https://coinmarketcap.com/api/documentation/v1/#operation/getV2CryptocurrencyInfo) | /cryptocurrency/info (v2) |
| [📄 __cryptocurrency_listings_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyListingsLatest) | /cryptocurrency/listings/latest |
| [📄 __cryptocurrency_listings_historical__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyListingsHistorical) | /cryptocurrency/listings/historical |
| [📄 __cryptocurrency_quotes_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV2CryptocurrencyQuotesLatest) | /cryptocurrency/quotes/latest (v2) |
| [📄 __cryptocurrency_quotes_historical__](https://coinmarketcap.com/api/documentation/v1/#operation/getV2CryptocurrencyQuotesHistorical) | /cryptocurrency/quotes/historical (v2) |
| [📄 __cryptocurrency_marketpairs_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV2CryptocurrencyMarketpairsLatest) | /cryptocurrency/market-pairs/latest (v2) |
| [📄 __cryptocurrency_ohlcv_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV2CryptocurrencyOhlcvLatest) | /cryptocurrency/ohlcv/latest (v2) |
| [📄 __cryptocurrency_ohlcv_historical__](https://coinmarketcap.com/api/documentation/v1/#operation/getV2CryptocurrencyOhlcvHistorical) | /cryptocurrency/ohlcv/historical (v2) |
| [📄 __cryptocurrency_priceperformancestats_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV2CryptocurrencyPriceperformancestatsLatest) | /cryptocurrency/price-performance-stats/latest (v2) |
| [📄 __cryptocurrency_categories__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyCategories) | /cryptocurrency/categories |
| [📄 __cryptocurrency_category__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyCategory) | /cryptocurrency/category |
| [📄 __cryptocurrency_airdrops__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyAirdrops) | /cryptocurrency/airdrops |
| [📄 __cryptocurrency_airdrop__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyAirdrop) | /cryptocurrency/airdrop |
| [📄 __cryptocurrency_trending_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyTrendingLatest) | /cryptocurrency/trending/latest |
| [📄 __cryptocurrency_trending_mostvisited__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyTrendingMostvisited) | /cryptocurrency/trending/most-visited |
| [📄 __cryptocurrency_trending_gainerslosers__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyTrendingGainerslosers) | /cryptocurrency/trending/gainers-losers |
| [📄 __exchange_map__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1ExchangeMap) | /exchange/map |
| [📄 __exchange_info__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1ExchangeInfo) | /exchange/info |
| [📄 __exchange_listings_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1ExchangeListingsLatest) | /exchange/listings/latest |
| [📄 __exchange_listings_historical__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1ExchangeListingsHistorical) | /exchange/listings/historical |
| [📄 __exchange_quotes_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1ExchangeQuotesLatest) | /exchange/quotes/latest |
| [📄 __exchange_quotes_historical__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1ExchangeQuotesHistorical) | /exchange/quotes/historical |
| [📄 __exchange_marketpairs_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1ExchangeMarketpairsLatest) | /exchange/market-pairs/latest |
| [📄 __globalmetrics_quotes_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1GlobalmetricsQuotesLatest) | /global-metrics/quotes/latest |
| [📄 __globalmetrics_quotes_historical__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1GlobalmetricsQuotesHistorical) | /global-metrics/quotes/historical |
| [📄 __tools_priceconversion__](https://coinmarketcap.com/api/documentation/v1/#operation/getV2ToolsPriceconversion) | /tools/price-conversion (v2) |
| [📄 __tools_postman__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1ToolsPostman) | /tools/postman |
| [📄 __blockchain_statistics_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1BlockchainStatisticsLatest) | /blockchain/statistics/latest |
| [📄 __fiat_map__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1FiatMap) | /fiat/map |
| [📄 __partners_flipsidecrypto_fcas_listings_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1PartnersFlipsidecryptoFcasListingsLatest) | /partners/flipside-crypto/fcas/listings/latest |
| [📄 __partners_flipsidecrypto_fcas_quotes_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1PartnersFlipsidecryptoFcasQuotesLatest) | /partners/flipside-crypto/fcas/quotes/latest |
| [📄 __key_info__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1KeyInfo) | /key/info |
| [📄 __content_posts_top__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1ContentPostsTop) | /content/posts/top |
| [📄 __content_posts_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1ContentPostsLatest) | /content/posts/latest |
| [📄 __content_posts_comments__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1ContentPostsComments) | /content/posts/comments |
| [📄 __content_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1ContentLatest) | /content/latest |
__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]((https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyInfo)) of the corresponding __cryptocurrency_info__ endpoint.
- You can pass the `symbol` parameter like : `cmc.cryptocurrency_info(symbol='BTC')`
- or with the `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 environnement`
You can enable a __debuging mode__, just set `debug` to `True` to main class:
```python
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:
```python
cmc.cryptocurrency_listings_latest(..., api_version="v1.1")
```
__See also__
- [Quick Start Guide](https://coinmarketcap.com/api/documentation/v1/#section/Quick-Start-Guide)
### Response
__Synopsis__
You get results of the API in a `Response` instance.
__Property__
Corresponding to [standards and conventions](https://coinmarketcap.com/api/documentation/v1/#section/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__
```python
r = cmc.cryptocurrency_info(symbol='BTC')
print(repr(r.status))
print(repr(r.data))
print(repr(r.credit_count))
```
### CoinMarketCapAPIError
__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__
```python
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))
```
---
## See this project on
- [PyPi](https://pypi.org/project/python-coinmarketcap/)
- [Github](https://github.com/rsz44/python-coinmarketcap)
## Some reading about the wrapper
- [CoinMarketCap API Python Tutorial (2022)](https://analyzingalpha.com/coinmarketcap-api-python-tutorial), Leo Smigel, _analyzingalpha.com_
- A fairly comprehensive tutorial on how the API works and who uses this package.
- [CoinMarketCap API - An Introductory Guide](https://algotrading101.com/learn/coinmarketcap-api-guide/), Igor Radovanovic, _algotrading101.com_
- A short guide that gives you an overview of the API and provides examples of its uses.
## ChangeLog
- 4 nov 2022: Version 0.5
- Remove an unfortunate debug that could display text unnecessarily during an error.
- Yanked version 0.4
- 4 nov 2022: Version 0.4
- Adding new endpoints (Aug 18/Sep 19):
+ /v1/content/posts/top
+ /v1/content/posts/latest
+ /v1/content/posts/comments
+ /v1/content/latest
+ /v1/tools/postman
+ This last one will clearly be useful to extend the wrapper according to the received schemes.
- Fix `api_key` default to Sandbox mode.
- Fix the logger, [Issue#4](https://github.com/rsz44/python-coinmarketcap/issues/4) from AlverGan.
- Fix install_requires, requests was missing.
- Changing the default API version to `v2` for some endpoints :
+ /v2/cryptocurrency/info
+ /v2/cryptocurrency/quotes/latest
+ /v2/cryptocurrency/quotes/historical
+ /v2/cryptocurrency/market-pairs/latest
+ /v2/cryptocurrency/ohlcv/latest
+ /v2/cryptocurrency/ohlcv/historical
+ /v2/cryptocurrency/price-performance-stats/latest
+ /v2/tools/price-conversion
- On the Readme:
+ Adding new methods references.
+ Modification of the methods table to improve readability.
+ Some grammatical corrections in README (Thanks to [__@tactipus__](https://github.com/tactipus) !).
+ Small changes and removal of some unnecessary spaces in the example codes.
+ Adding reading references about the API and the package (Thanks to their respective authors !).
- Adding docstring to classes.
- 31 aug 2021: Version 0.3
- Adding new endpoints (Aug 17):
+ /v1/cryptocurrency/categories
+ /v1/cryptocurrency/category
+ /v1/cryptocurrency/airdrops
+ /v1/cryptocurrency/airdrop
+ /v1/cryptocurrency/trending/latest
+ /v1/cryptocurrency/trending/most-visited
+ /v1/cryptocurrency/trending/gainers-losers
- PEP 8 style
- Adding `api_version` keyword argument to all endpoints to change on-the-fly the api version to use.
- 8 sept 2020: Version 0.2
- Adding missing endpoints
- Fixing sandbox mode (see [Issue #1](https://github.com/rsz44/python-coinmarketcap/issues/1))
- Adding `deflate, gzip` encoding to receive data fast and efficiently.
- Documentation: adding usefull links
- 6 apr 2019: Version 0.1
## Give me a coffee
```
BTC: 39aosiow4nsUvYVA2kP1hZPNZ7ZbJ6ouKr
ETH: 0x45d940FDA3F1Ce91cA7CB478af72170bb6560201
```
Raw data
{
"_id": null,
"home_page": "https://github.com/rsz44/python-coinmarketcap",
"name": "python-coinmarketcap",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Remi SARRAZIN",
"author_email": "remi.sarrazin@gmx.com",
"download_url": "https://files.pythonhosted.org/packages/ff/df/3bb65054660d96606fa68fafe5cf053a3af97a490fc15d5caa71ea2d95f8/python-coinmarketcap-0.5.tar.gz",
"platform": null,
"description": "\n# Python-CoinMarketCap API Wrapper\n\nThis is a non-official (but working) Python package to wrap the CoinMarketCap API. With this you can monitor and watch the crypto market.\n\n- Read the official [API documentation](https://coinmarketcap.com/api/documentation/v1/)\n- For the pro version, get an API Key on the [Developper Portal](https://coinmarketcap.com/api/)\n- Be sure to replace the API Key in sample code with your own.\n\n[](https://pepy.tech/project/python-coinmarketcap)\n\n---\n\n## Installation\n\n__Via pip__\n\n- pip install __python-coinmarketcap__\n\n> /!\\ *Don't confuse this with the coinmarketcap package.*\n\n## Example\n\n```python\n\nfrom coinmarketcapapi import CoinMarketCapAPI\n\ncmc = CoinMarketCapAPI()\n \nrep = cmc.cryptocurrency_info(symbol='BTC') # See methods below\n\nprint(rep.data) # Whole repsonse payload\nprint(rep.data[\"BTC\"][\"logo\"]) # Some data in response\nprint(rep.credit_count) # API credits\nprint(rep.total_elapsed) # Request time in ms\n# ...\n\n```\n\n---\n\n## Wrapper References\n\n### CoinMarketCapAPI\n\n__Synopsis__\n\n```\nCoinMarketCapAPI(api_key=None, [debug=False, logger=None, sandbox=False, version='v1'])\n```\n\n- `debug`: set verbosity.\n- `sandbox`: In case of default sandbox API key changes, see [Issue #1](https://github.com/rsz44/python-coinmarketcap/issues/1).\n- `logger`: you can give a custom logger.\n- `version`: set the version in the URL, for futures version.\n\n__Methods__\n\nYou have to pass to the following methods the parameters detailed in the [official documentation](https://coinmarketcap.com/api/documentation/v1/).\n\n| Methods and documentation | Endpoint (version) |\n|-|-|\n| [\ud83d\udcc4 __cryptocurrency_map__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyMap) | /cryptocurrency/map |\n| [\ud83d\udcc4 __cryptocurrency_info__](https://coinmarketcap.com/api/documentation/v1/#operation/getV2CryptocurrencyInfo) | /cryptocurrency/info (v2) |\n| [\ud83d\udcc4 __cryptocurrency_listings_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyListingsLatest) | /cryptocurrency/listings/latest |\n| [\ud83d\udcc4 __cryptocurrency_listings_historical__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyListingsHistorical) | /cryptocurrency/listings/historical |\n| [\ud83d\udcc4 __cryptocurrency_quotes_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV2CryptocurrencyQuotesLatest) | /cryptocurrency/quotes/latest (v2) |\n| [\ud83d\udcc4 __cryptocurrency_quotes_historical__](https://coinmarketcap.com/api/documentation/v1/#operation/getV2CryptocurrencyQuotesHistorical) | /cryptocurrency/quotes/historical (v2) |\n| [\ud83d\udcc4 __cryptocurrency_marketpairs_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV2CryptocurrencyMarketpairsLatest) | /cryptocurrency/market-pairs/latest (v2) |\n| [\ud83d\udcc4 __cryptocurrency_ohlcv_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV2CryptocurrencyOhlcvLatest) | /cryptocurrency/ohlcv/latest (v2) |\n| [\ud83d\udcc4 __cryptocurrency_ohlcv_historical__](https://coinmarketcap.com/api/documentation/v1/#operation/getV2CryptocurrencyOhlcvHistorical) | /cryptocurrency/ohlcv/historical (v2) |\n| [\ud83d\udcc4 __cryptocurrency_priceperformancestats_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV2CryptocurrencyPriceperformancestatsLatest) | /cryptocurrency/price-performance-stats/latest (v2) |\n| [\ud83d\udcc4 __cryptocurrency_categories__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyCategories) | /cryptocurrency/categories |\n| [\ud83d\udcc4 __cryptocurrency_category__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyCategory) | /cryptocurrency/category |\n| [\ud83d\udcc4 __cryptocurrency_airdrops__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyAirdrops) | /cryptocurrency/airdrops |\n| [\ud83d\udcc4 __cryptocurrency_airdrop__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyAirdrop) | /cryptocurrency/airdrop |\n| [\ud83d\udcc4 __cryptocurrency_trending_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyTrendingLatest) | /cryptocurrency/trending/latest |\n| [\ud83d\udcc4 __cryptocurrency_trending_mostvisited__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyTrendingMostvisited) | /cryptocurrency/trending/most-visited |\n| [\ud83d\udcc4 __cryptocurrency_trending_gainerslosers__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyTrendingGainerslosers) | /cryptocurrency/trending/gainers-losers |\n| [\ud83d\udcc4 __exchange_map__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1ExchangeMap) | /exchange/map |\n| [\ud83d\udcc4 __exchange_info__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1ExchangeInfo) | /exchange/info |\n| [\ud83d\udcc4 __exchange_listings_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1ExchangeListingsLatest) | /exchange/listings/latest |\n| [\ud83d\udcc4 __exchange_listings_historical__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1ExchangeListingsHistorical) | /exchange/listings/historical |\n| [\ud83d\udcc4 __exchange_quotes_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1ExchangeQuotesLatest) | /exchange/quotes/latest |\n| [\ud83d\udcc4 __exchange_quotes_historical__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1ExchangeQuotesHistorical) | /exchange/quotes/historical |\n| [\ud83d\udcc4 __exchange_marketpairs_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1ExchangeMarketpairsLatest) | /exchange/market-pairs/latest |\n| [\ud83d\udcc4 __globalmetrics_quotes_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1GlobalmetricsQuotesLatest) | /global-metrics/quotes/latest |\n| [\ud83d\udcc4 __globalmetrics_quotes_historical__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1GlobalmetricsQuotesHistorical) | /global-metrics/quotes/historical |\n| [\ud83d\udcc4 __tools_priceconversion__](https://coinmarketcap.com/api/documentation/v1/#operation/getV2ToolsPriceconversion) | /tools/price-conversion (v2) |\n| [\ud83d\udcc4 __tools_postman__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1ToolsPostman) | /tools/postman |\n| [\ud83d\udcc4 __blockchain_statistics_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1BlockchainStatisticsLatest) | /blockchain/statistics/latest |\n| [\ud83d\udcc4 __fiat_map__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1FiatMap) | /fiat/map |\n| [\ud83d\udcc4 __partners_flipsidecrypto_fcas_listings_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1PartnersFlipsidecryptoFcasListingsLatest) | /partners/flipside-crypto/fcas/listings/latest |\n| [\ud83d\udcc4 __partners_flipsidecrypto_fcas_quotes_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1PartnersFlipsidecryptoFcasQuotesLatest) | /partners/flipside-crypto/fcas/quotes/latest |\n| [\ud83d\udcc4 __key_info__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1KeyInfo) | /key/info |\n| [\ud83d\udcc4 __content_posts_top__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1ContentPostsTop) | /content/posts/top |\n| [\ud83d\udcc4 __content_posts_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1ContentPostsLatest) | /content/posts/latest |\n| [\ud83d\udcc4 __content_posts_comments__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1ContentPostsComments) | /content/posts/comments |\n| [\ud83d\udcc4 __content_latest__](https://coinmarketcap.com/api/documentation/v1/#operation/getV1ContentLatest) | /content/latest |\n\n__Additionnal Parameters__\n\n- `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.\n\n__Example__\n\nAssuming you want to get informations about bitcoin. First, read the [documentation]((https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyInfo)) of the corresponding __cryptocurrency_info__ endpoint. \n - You can pass the `symbol` parameter like : `cmc.cryptocurrency_info(symbol='BTC')`\n - or with the `slug` parameter : `cmc.cryptocurrency_info(slug='bitcoin')`\n\nYou can switch easly in the __sandbox mode__ without giving an API key or by setting it to `None` :\n - `cmc = CoinMarketCapAPI() # You are in sandbox environnement`\n\nYou can enable a __debuging mode__, just set `debug` to `True` to main class:\n\n```python\ncmc = CoinMarketCapAPI(debug=True)\ncmc.cryptocurrency_info(symbol='BTC')\n```\n\nThis will produce this output :\n\n```\n2019-04-06 16:03:04,716 root DEBUG GET SANDBOX 'v1/cryptocurrency/info'\nPARAMETERS: {'symbol': 'BTC'}\n2019-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, [...]}\n```\n\n\nOptionnaly, you can pass (on-the-fly) a __specific version__ of an endpoint by given the `api_version` keyword argument directly to a method:\n```python\ncmc.cryptocurrency_listings_latest(..., api_version=\"v1.1\")\n```\n\n__See also__\n- [Quick Start Guide](https://coinmarketcap.com/api/documentation/v1/#section/Quick-Start-Guide)\n\n### Response\n\n__Synopsis__\n\nYou get results of the API in a `Response` instance. \n\n__Property__\n\nCorresponding to [standards and conventions](https://coinmarketcap.com/api/documentation/v1/#section/Standards-and-Conventions):\n\n- `data` (__dict__): will give you the result.\n- `status` (__dict__): the status object always included for both successful calls and failures.\n- `credit_count` (__int__): the number of credits this call utilized.\n- `elapsed` (__int__): the number of milliseconds it took to process the request to the server.\n- `total_elapsed` (__int__): the total number of milliseconds it took to process the request.\n- `timesamp` (__str__): current time on the server when the call was executed.\n- `error_code` (__str | None__): In case of an error has been raised, this property will give you the status error code.\n- `error_message` (__str | None__): In case of an error has been raised, this property will give details about error.\n- `error` (__bool__): True if an error has been raised.\n\n__Example__\n\n```python\nr = cmc.cryptocurrency_info(symbol='BTC')\nprint(repr(r.status))\nprint(repr(r.data))\nprint(repr(r.credit_count))\n```\n\n### CoinMarketCapAPIError\n\n__Synopsis__\n\nIf API returns an error, `CoinMarketCapAPI` will raise a `CoinMarketCapAPIError`.\n\n__Property__\n\n- `rep` (__Response | None__): will give you a `Response` instance or `None` if request failed for an other reason than a server error.\n\n__Example__\n\n```python\n\nfrom coinmarketcapapi import CoinMarketCapAPI, CoinMarketCapAPIError\n\ncmc = CoinMarketCapAPI('{YOUR_API_KEY}') # Pro environnement\n# cmc = CoinMarketCapAPI() # Sandbox environnement\n\ntry:\n r = cmc.cryptocurrency_info(symbol='BTC')\nexcept CoinMarketCapAPIError as e:\n r = e.rep\n print(repr(r.error))\n print(repr(r.status))\n print(repr(r.data))\n\n```\n\n---\n\n## See this project on\n\n- [PyPi](https://pypi.org/project/python-coinmarketcap/)\n- [Github](https://github.com/rsz44/python-coinmarketcap)\n\n## Some reading about the wrapper\n\n- [CoinMarketCap API Python Tutorial (2022)](https://analyzingalpha.com/coinmarketcap-api-python-tutorial), Leo Smigel, _analyzingalpha.com_\n - A fairly comprehensive tutorial on how the API works and who uses this package.\n- [CoinMarketCap API - An Introductory Guide](https://algotrading101.com/learn/coinmarketcap-api-guide/), Igor Radovanovic, _algotrading101.com_\n - A short guide that gives you an overview of the API and provides examples of its uses.\n\n## ChangeLog\n\n- 4 nov 2022: Version 0.5\n - Remove an unfortunate debug that could display text unnecessarily during an error.\n - Yanked version 0.4\n- 4 nov 2022: Version 0.4\n - Adding new endpoints (Aug 18/Sep 19):\n + /v1/content/posts/top\n + /v1/content/posts/latest\n + /v1/content/posts/comments\n + /v1/content/latest\n + /v1/tools/postman\n + This last one will clearly be useful to extend the wrapper according to the received schemes.\n - Fix `api_key` default to Sandbox mode.\n - Fix the logger, [Issue#4](https://github.com/rsz44/python-coinmarketcap/issues/4) from AlverGan.\n - Fix install_requires, requests was missing.\n - Changing the default API version to `v2` for some endpoints :\n + /v2/cryptocurrency/info\n + /v2/cryptocurrency/quotes/latest\n + /v2/cryptocurrency/quotes/historical\n + /v2/cryptocurrency/market-pairs/latest\n + /v2/cryptocurrency/ohlcv/latest\n + /v2/cryptocurrency/ohlcv/historical\n + /v2/cryptocurrency/price-performance-stats/latest\n + /v2/tools/price-conversion\n - On the Readme:\n + Adding new methods references.\n + Modification of the methods table to improve readability.\n + Some grammatical corrections in README (Thanks to [__@tactipus__](https://github.com/tactipus) !).\n + Small changes and removal of some unnecessary spaces in the example codes.\n + Adding reading references about the API and the package (Thanks to their respective authors !).\n - Adding docstring to classes.\n- 31 aug 2021: Version 0.3\n - Adding new endpoints (Aug 17):\n + /v1/cryptocurrency/categories\n + /v1/cryptocurrency/category\n + /v1/cryptocurrency/airdrops\n + /v1/cryptocurrency/airdrop\n + /v1/cryptocurrency/trending/latest\n + /v1/cryptocurrency/trending/most-visited\n + /v1/cryptocurrency/trending/gainers-losers\n - PEP 8 style\n - Adding `api_version` keyword argument to all endpoints to change on-the-fly the api version to use.\n- 8 sept 2020: Version 0.2\n - Adding missing endpoints\n - Fixing sandbox mode (see [Issue #1](https://github.com/rsz44/python-coinmarketcap/issues/1))\n - Adding `deflate, gzip` encoding to receive data fast and efficiently.\n - Documentation: adding usefull links\n- 6 apr 2019: Version 0.1\n\n## Give me a coffee\n\n```\n BTC: 39aosiow4nsUvYVA2kP1hZPNZ7ZbJ6ouKr\n ETH: 0x45d940FDA3F1Ce91cA7CB478af72170bb6560201\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "CoinMarketCap Python API Wrapper",
"version": "0.5",
"project_urls": {
"Homepage": "https://github.com/rsz44/python-coinmarketcap"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9b6b3514dab6bcc949a1b77f08a003d6166e150dd6796d7cfb5a359ed8489212",
"md5": "6b927ae79b9b5263d8978e6fb5a6f044",
"sha256": "2ed71c168a92b60292ae5c5c59df77d4d6e5f9b3ae724a4a4ad43e93c6bee427"
},
"downloads": -1,
"filename": "python_coinmarketcap-0.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6b927ae79b9b5263d8978e6fb5a6f044",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 10225,
"upload_time": "2022-11-04T14:03:27",
"upload_time_iso_8601": "2022-11-04T14:03:27.400083Z",
"url": "https://files.pythonhosted.org/packages/9b/6b/3514dab6bcc949a1b77f08a003d6166e150dd6796d7cfb5a359ed8489212/python_coinmarketcap-0.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ffdf3bb65054660d96606fa68fafe5cf053a3af97a490fc15d5caa71ea2d95f8",
"md5": "484fb7e3e038e72db676a4b6f2482782",
"sha256": "ffc93759b23a8bad366d1f4f3decb593fdd7451bd90b80db708a6e9108aa220b"
},
"downloads": -1,
"filename": "python-coinmarketcap-0.5.tar.gz",
"has_sig": false,
"md5_digest": "484fb7e3e038e72db676a4b6f2482782",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 13345,
"upload_time": "2022-11-04T14:03:29",
"upload_time_iso_8601": "2022-11-04T14:03:29.705287Z",
"url": "https://files.pythonhosted.org/packages/ff/df/3bb65054660d96606fa68fafe5cf053a3af97a490fc15d5caa71ea2d95f8/python-coinmarketcap-0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-11-04 14:03:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "rsz44",
"github_project": "python-coinmarketcap",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "python-coinmarketcap"
}