Python3 wrapper around the CoinGecko API (V3) enabling access to cryptocurrency market data, prices, exchanges, and NFT information.
—
Comprehensive coin data including metadata, market information, historical data, technical indicators, and supply metrics. This module provides detailed information about individual cryptocurrencies and their market performance over time.
Get comprehensive lists of all supported cryptocurrencies with various filtering and pagination options.
def get_coins(**kwargs):
"""
List all coins with comprehensive data including price, market cap, volume, and metadata.
Parameters:
- order (str): Sort order ('market_cap_desc', 'gecko_desc', 'gecko_asc', 'market_cap_asc', 'id_asc', 'id_desc')
- per_page (int): Number of results per page (1-250, default: 100)
- page (int): Page number (default: 1)
- localization (bool): Include localized names and descriptions (default: True)
- sparkline (bool): Include 7-day price sparkline data (default: False)
Returns:
list: List of coin objects with comprehensive market and metadata
"""
def get_coins_list(**kwargs):
"""
List all supported coins with ID, name, and symbol only (no pagination required).
Parameters:
- include_platform (bool): Include platform contract addresses (default: False)
Returns:
list: List of basic coin information (id, symbol, name, platforms)
"""
def get_coins_list_new(**kwargs):
"""
Get the latest 200 coins that recently listed on CoinGecko.
Returns:
list: List of newly listed coins with basic information
"""Usage Examples:
# Get top 50 coins by market cap
top_coins = cg.get_coins(order='market_cap_desc', per_page=50, page=1)
# Get basic list of all supported coins
all_coins = cg.get_coins_list()
# Get recently listed coins
new_coins = cg.get_coins_list_new()Get real-time market data for cryptocurrencies including prices, market caps, volumes, and rankings.
def get_coins_markets(vs_currency, **kwargs):
"""
List all supported coins with price, market cap, volume, and market-related data.
Parameters:
- vs_currency (str): Target currency for market data (e.g., 'usd')
- ids (str or list): Specific coin IDs to retrieve (optional)
- category (str): Filter by category (e.g., 'decentralized_finance_defi')
- order (str): Sort order ('market_cap_desc', 'gecko_desc', 'market_cap_asc', etc.)
- per_page (int): Results per page (1-250, default: 100)
- page (int): Page number (default: 1)
- sparkline (bool): Include 7-day price sparkline (default: False)
- price_change_percentage (str): Include price change percentages ('1h,24h,7d,14d,30d,200d,1y')
Returns:
list: List of coins with comprehensive market data
"""Usage Example:
# Get market data for top 100 coins in USD
markets = cg.get_coins_markets(
vs_currency='usd',
order='market_cap_desc',
per_page=100,
sparkline=True,
price_change_percentage='1h,24h,7d'
)Get detailed information about specific cryptocurrencies.
def get_coin_by_id(id, **kwargs):
"""
Get comprehensive data for a specific coin including exchange tickers.
Parameters:
- id (str): Coin ID (e.g., 'bitcoin')
- localization (bool): Include localized data (default: True)
- tickers (bool): Include ticker data (default: True)
- market_data (bool): Include market data (default: True)
- community_data (bool): Include community data (default: True)
- developer_data (bool): Include developer data (default: True)
- sparkline (bool): Include 7-day price sparkline (default: False)
Returns:
dict: Comprehensive coin data including description, links, market data, and statistics
"""
def get_coin_ticker_by_id(id, **kwargs):
"""
Get coin tickers from exchanges (paginated to 100 items).
Parameters:
- id (str): Coin ID (e.g., 'bitcoin')
- exchange_ids (str or list): Filter by specific exchange IDs
- include_exchange_logo (bool): Include exchange logos (default: False)
- page (int): Page number (default: 1)
- order (str): Sort order ('trust_score_desc', 'trust_score_asc', 'volume_desc')
- depth (bool): Include 2% order book depth (default: False)
Returns:
dict: Ticker data with exchange information, trading pairs, and volumes
"""Usage Examples:
# Get comprehensive Bitcoin data
bitcoin = cg.get_coin_by_id(id='bitcoin', sparkline=True)
# Get Bitcoin tickers from exchanges
tickers = cg.get_coin_ticker_by_id(id='bitcoin', order='volume_desc')Access historical price, market cap, and volume data for cryptocurrencies.
def get_coin_history_by_id(id, date, **kwargs):
"""
Get historical data for a coin at a specific date.
Parameters:
- id (str): Coin ID (e.g., 'bitcoin')
- date (str): Date in dd-mm-yyyy format (e.g., '30-12-2017')
- localization (bool): Include localized data (default: True)
Returns:
dict: Historical coin data for the specified date
"""
def get_coin_market_chart_by_id(id, vs_currency, days, **kwargs):
"""
Get historical market data including price, market cap, and 24h volume.
Parameters:
- id (str): Coin ID (e.g., 'bitcoin')
- vs_currency (str): Target currency (e.g., 'usd')
- days (str or int): Data range ('1', '7', '14', '30', '90', '180', '365', 'max')
- interval (str): Data interval ('minutely', 'hourly', 'daily')
Returns:
dict: Contains 'prices', 'market_caps', and 'total_volumes' arrays with [timestamp, value] pairs
"""
def get_coin_market_chart_range_by_id(id, vs_currency, from_timestamp, to_timestamp, **kwargs):
"""
Get historical market data within a specific timestamp range.
Parameters:
- id (str): Coin ID (e.g., 'bitcoin')
- vs_currency (str): Target currency (e.g., 'usd')
- from_timestamp (int): Start timestamp (Unix seconds)
- to_timestamp (int): End timestamp (Unix seconds)
Returns:
dict: Market data arrays for the specified time range
"""Usage Examples:
# Get Bitcoin data from December 30, 2017
historical = cg.get_coin_history_by_id(id='bitcoin', date='30-12-2017')
# Get Bitcoin price chart for last 30 days
chart = cg.get_coin_market_chart_by_id(id='bitcoin', vs_currency='usd', days=30)
# Get Bitcoin data for specific time range
range_data = cg.get_coin_market_chart_range_by_id(
id='bitcoin',
vs_currency='usd',
from_timestamp=1609459200, # Jan 1, 2021
to_timestamp=1640995200 # Jan 1, 2022
)Get Open, High, Low, Close (OHLC) candlestick data for technical analysis.
def get_coin_ohlc_by_id(id, vs_currency, days, **kwargs):
"""
Get OHLC (candlestick) data for a coin.
Parameters:
- id (str): Coin ID (e.g., 'bitcoin')
- vs_currency (str): Target currency (e.g., 'usd')
- days (str or int): Data range ('1', '7', '14', '30', '90', '180', '365')
Returns:
list: Array of [timestamp, open, high, low, close] arrays
"""
def get_coin_ohlc_by_id_range(id, vs_currency, from_timestamp, to_timestamp, interval, **kwargs):
"""
Get OHLC data within a specific timestamp range.
Parameters:
- id (str): Coin ID (e.g., 'bitcoin')
- vs_currency (str): Target currency (e.g., 'usd')
- from_timestamp (int): Start timestamp (Unix seconds)
- to_timestamp (int): End timestamp (Unix seconds)
- interval (str): Data interval ('4h', '1d', '3d', '1w')
Returns:
list: OHLC data arrays for the specified range
"""Usage Examples:
# Get Bitcoin OHLC data for last 7 days
ohlc = cg.get_coin_ohlc_by_id(id='bitcoin', vs_currency='usd', days=7)
# Get Bitcoin OHLC data for specific range with daily intervals
ohlc_range = cg.get_coin_ohlc_by_id_range(
id='bitcoin',
vs_currency='usd',
from_timestamp=1640995200,
to_timestamp=1672531200,
interval='1d'
)Access circulating and total supply data over time.
def get_coin_circulating_supply_chart(id, days, **kwargs):
"""
Get coin's circulating supply chart over time.
Parameters:
- id (str): Coin ID (e.g., 'bitcoin')
- days (str or int): Data range ('1', '7', '14', '30', '90', '180', '365', 'max')
Returns:
dict: Contains 'circulating_supply' array with [timestamp, supply] pairs
"""
def get_coin_circulating_supply_chart_range(id, from_timestamp, to_timestamp, **kwargs):
"""
Get circulating supply chart within a timestamp range.
Parameters:
- id (str): Coin ID (e.g., 'bitcoin')
- from_timestamp (int): Start timestamp (Unix seconds)
- to_timestamp (int): End timestamp (Unix seconds)
Returns:
dict: Circulating supply data for the specified range
"""
def get_coin_total_supply_chart(id, days, **kwargs):
"""
Get coin's total supply chart over time.
Parameters:
- id (str): Coin ID (e.g., 'bitcoin')
- days (str or int): Data range ('1', '7', '14', '30', '90', '180', '365', 'max')
Returns:
dict: Contains 'total_supply' array with [timestamp, supply] pairs
"""
def get_coin_total_supply_chart_range(id, from_timestamp, to_timestamp, **kwargs):
"""
Get total supply chart within a timestamp range.
Parameters:
- id (str): Coin ID (e.g., 'bitcoin')
- from_timestamp (int): Start timestamp (Unix seconds)
- to_timestamp (int): End timestamp (Unix seconds)
Returns:
dict: Total supply data for the specified range
"""Get coin information and market data using smart contract addresses.
def get_coin_info_from_contract_address_by_id(id, contract_address, **kwargs):
"""
Get coin information from its contract address.
Parameters:
- id (str): Platform ID (e.g., 'ethereum', 'binance-smart-chain')
- contract_address (str): Token contract address
Returns:
dict: Coin information including ID, symbol, name, and basic market data
"""
def get_coin_market_chart_from_contract_address_by_id(id, contract_address, vs_currency, days, **kwargs):
"""
Get historical market data using contract address.
Parameters:
- id (str): Platform ID (e.g., 'ethereum')
- contract_address (str): Token contract address
- vs_currency (str): Target currency (e.g., 'usd')
- days (str or int): Data range ('1', '7', '14', '30', '90', '180', '365', 'max')
Returns:
dict: Market chart data arrays (prices, market_caps, total_volumes)
"""
def get_coin_market_chart_range_from_contract_address_by_id(id, contract_address, vs_currency, from_timestamp, to_timestamp, **kwargs):
"""
Get market data range using contract address.
Parameters:
- id (str): Platform ID (e.g., 'ethereum')
- contract_address (str): Token contract address
- vs_currency (str): Target currency (e.g., 'usd')
- from_timestamp (int): Start timestamp (Unix seconds)
- to_timestamp (int): End timestamp (Unix seconds)
Returns:
dict: Market data for the specified time range
"""Usage Examples:
# Get USDC info by contract address
usdc_info = cg.get_coin_info_from_contract_address_by_id(
id='ethereum',
contract_address='0xa0b86a33e6441c1a0d077d82c79525ba6b14e2a3'
)
# Get USDC price chart by contract address
usdc_chart = cg.get_coin_market_chart_from_contract_address_by_id(
id='ethereum',
contract_address='0xa0b86a33e6441c1a0d077d82c79525ba6b14e2a3',
vs_currency='usd',
days=30
)Historical data endpoints return arrays with timestamp-value pairs:
{
"prices": [[timestamp1, price1], [timestamp2, price2], ...],
"market_caps": [[timestamp1, cap1], [timestamp2, cap2], ...],
"total_volumes": [[timestamp1, vol1], [timestamp2, vol2], ...]
}OHLC endpoints return arrays of candlestick data:
[
[timestamp, open, high, low, close],
[timestamp, open, high, low, close],
...
]All timestamps are Unix timestamps in milliseconds. Price and volume values are numeric.
Install with Tessl CLI
npx tessl i tessl/pypi-pycoingecko