Coingecko Api Wrapper: Man C Pycoingecko
Coingecko Api Wrapper: Man C Pycoingecko
up
MIT License
Star Notifications
master
View code
README.md
Installation
PyPI
pip install pycoingecko
or from source
git clone https://github.com/man‐c/pycoingecko.git
cd pycoingecko
python3 setup.py install
Usage
Usage
from pycoingecko import CoinGeckoAPI
cg = CoinGeckoAPI()
Examples
The required parameters for each endpoint are defined as required ﴾mandatory﴿
parameters for the corresponding functions.
Any optional parameters can be passed using same names, as defined in CoinGecko
API doc ﴾https://www.coingecko.com/api/docs/v3﴿
Usage examples:
# /simple/price endpoint with the required parameters
>>> cg.get_price(ids='bitcoin', vs_currencies='usd')
{'bitcoin': {'usd': 3462.04}}
>>> cg.get_price(ids='bitcoin,litecoin,ethereum', vs_currencies='usd')
# OR (lists can be used for multiple‐valued arguments)
>>> cg.get_price(ids=['bitcoin', 'litecoin', 'ethereum'], vs_currencies='usd')
{'bitcoin': {'usd': 3461.27}, 'ethereum': {'usd': 106.92}, 'litecoin': {'usd': 32.72
>>> cg.get_price(ids='bitcoin,litecoin,ethereum', vs_currencies='usd,eur')
# OR (lists can be used for multiple‐valued arguments)
>>> cg.get_price(ids=['bitcoin', 'litecoin', 'ethereum'], vs_currencies=['usd', 'eur'
{'bitcoin': {'usd': 3459.39, 'eur': 3019.33}, 'ethereum': {'usd': 106.91, 'eur': 93.31
# optional parameters can be passed as defined in the API doc (https://www.coingecko.com/ap
>>> cg.get_price(ids='bitcoin', vs_currencies='usd', include_market_cap='true', include_24hr
{'bitcoin': {'usd': 3458.74, 'usd_market_cap': 60574330199.29028, 'usd_24h_vol': 4182664683
# OR (also booleans can be used for boolean type arguments)
>>> cg.get_price(ids='bitcoin', vs_currencies='usd', include_market_cap=True, include_24hr_v
{'bitcoin': {'usd': 3458.74, 'usd_market_cap': 60574330199.29028, 'usd_24h_vol': 4182664683
API documentation
https://www.coingecko.com/api/docs/v3
https://www.coingecko.com/api/docs/v3
Endpoints included
⚠ Endpoints documentation: To make sure that your are using properly each
endpoint you should check the API documentation. Return behaviour and
parameters of the endpoints, such as pagination, might have changed.
Any optional parameters defined in CoinGecko API doc can be passed as function
parameters using same parameters names with the API (see Examples above).
ping
/ping ﴾Check API server status﴿
cg.ping()
simple
/simple/price ﴾Get the current price of any cryptocurrencies in any other
supported currencies that you need﴿
cg.get_price()
cg.get_token_price()
cg.get_supported_vs_currencies()
coins
/coins/list ﴾List all supported coins id, name and symbol ﴾no pagination
required﴿﴿
cg.get_coins_list()
/coins/markets ﴾List all supported coins price, market cap, volume, and market
related data﴿
cg.get_coins_markets()
/coins/{id} ﴾Get current data ﴾name, price, market, ... including exchange
tickers﴿ for a coin﴿
cg.get_coin_by_id()
cg.get_coin_by_id()
cg.get_coin_ticker_by_id()
cg.get_coin_history_by_id()
cg.get_coin_market_chart_by_id()
cg.get_coin_market_chart_range_by_id()
cg.get_coin_status_updates_by_id()
cg.get_coin_ohlc_by_id()
contract
/coins/{id}/contract/{contract_address} ﴾Get coin info from contract address﴿
cg.get_coin_info_from_contract_address_by_id()
cg.get_coin_market_chart_from_contract_address_by_id()
cg.get_coin_market_chart_range_from_contract_address_by_id()
cg.get_coin_market_chart_range_from_contract_address_by_id()
asset_platforms
/asset_platforms ﴾List all asset platforms ﴾Blockchain networks﴿﴿
cg.get_asset_platforms()
categories
/coins/categories/list ﴾List all categories﴿
cg.get_coins_categories_list()
cg.get_coins_categories()
exchanges
/exchanges ﴾List all exchanges﴿
cg.get_exchanges_list()
cg.get_exchanges_id_name_list()
/exchanges/{id} ﴾Get exchange volume in BTC and top 100 tickers only﴿
cg.get_exchanges_by_id()
cg.get_exchanges_tickers_by_id()
cg.get_exchanges_status_updates_by_id()
cg.get_exchanges_volume_chart_by_id()
finance
/finance_platforms ﴾List all finance platforms﴿
cg.get_finance_platforms()
cg.get_finance_products()
indexes
/indexes ﴾List all market indexes﴿
cg.get_indexes()
cg.get_indexes_by_market_id_and_index_id()
cg.get_indexes_list()
derivatives
/derivatives ﴾List all derivative tickers﴿
cg.get_derivatives()
cg.get_derivatives_exchanges()
cg.get_derivatives_exchanges_by_id()
cg.get_derivatives_exchanges_list()
status_updates
/status_updates ﴾List all status_updates with data ﴾description, category,
created_at, user, user_title and pin﴿﴿
cg.get_status_updates()
events
/events ﴾Get events, paginated by 100﴿
cg.get_events()
cg.get_events_countries()
cg.get_events_types()
exchange_rates
/exchange_rates ﴾Get BTC‐to‐Currency exchange rates﴿
cg.get_exchange_rates()
trending
/search/trending ﴾Get trending search coins ﴾Top‐7﴿ on CoinGecko in the last
24 hours﴿
cg.get_search_trending()
global
/global ﴾Get cryptocurrency global data﴿
cg.get_global()
cg.get_global_decentralized_finance_defi()
companies (beta)
/companies/public_treasury/{coin_id} ﴾Get public companies data﴿
cg.get_companies_public_treasury_by_coin_id()
Test
Run unit tests with:
# after installing pytest using pip3
pytest tests
License
MIT
Releases
16 tags
Packages
No packages published
Used by 735
+ 727
Contributors 9
Languages
Python 100.0%