CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-pycoingecko

Python3 wrapper around the CoinGecko API (V3) enabling access to cryptocurrency market data, prices, exchanges, and NFT information.

Pending
Overview
Eval results
Files

global.mddocs/

Global Market Data

Cryptocurrency market overview, global statistics, market cap charts, and DeFi-specific metrics. This module provides macro-level insights into the overall cryptocurrency market performance and decentralized finance ecosystem.

Capabilities

Global Cryptocurrency Statistics

Get comprehensive overview of the entire cryptocurrency market including total market capitalization, trading volume, and market dominance metrics.

def get_global(**kwargs):
    """
    Get cryptocurrency global data including total market cap, volume, and market statistics.
    
    Returns:
    dict: Global cryptocurrency market data including total market cap, 24h volume, market cap percentage, and active cryptocurrencies count
    """

Usage Example:

# Get global cryptocurrency market data
global_data = cg.get_global()

# Access key metrics
total_market_cap = global_data['total_market_cap']['usd']
total_volume = global_data['total_volume']['usd']
btc_dominance = global_data['market_cap_percentage']['btc']
active_cryptocurrencies = global_data['active_cryptocurrencies']

Global Data Structure:

{
    "active_cryptocurrencies": 12500,
    "upcoming_icos": 0,
    "ongoing_icos": 49,
    "ended_icos": 3376,
    "markets": 789,
    "total_market_cap": {
        "btc": 53123456.78,
        "eth": 876543210.12,
        "usd": 1678901234567.89,
        "eur": 1456789012345.67,
        # ... other currencies
    },
    "total_volume": {
        "btc": 2341567.89,
        "eth": 38765432.10,
        "usd": 89012345678.90,
        "eur": 76543210987.65,
        # ... other currencies
    },
    "market_cap_percentage": {
        "btc": 42.5,
        "eth": 18.7,
        "bnb": 4.2,
        "xrp": 3.1,
        "sol": 2.8,
        # ... top 10 cryptocurrencies by market cap
    },
    "market_cap_change_percentage_24h_usd": 2.34,
    "updated_at": 1701432000
}

DeFi Market Statistics

Access decentralized finance (DeFi) specific market data and metrics.

def get_global_decentralized_finance_defi(**kwargs):
    """
    Get cryptocurrency global decentralized finance (DeFi) data including TVL and market metrics.
    
    Returns:
    dict: DeFi-specific global data including total value locked, DeFi market cap, and volume
    """

Usage Example:

# Get DeFi market statistics
defi_data = cg.get_global_decentralized_finance_defi()

# Access DeFi metrics
defi_market_cap = defi_data['defi_market_cap']
defi_tvl = defi_data['eth_market_cap']  # Total Value Locked in ETH
defi_dominance = defi_data['defi_to_eth_ratio']

DeFi Data Structure:

{
    "defi_market_cap": 123456789012.34,
    "eth_market_cap": 234567890123.45,
    "defi_to_eth_ratio": 52.7,
    "trading_volume_24h": 12345678901.23,
    "defi_dominance": 8.2,
    "top_coin_name": "Uniswap",
    "top_coin_defi_dominance": 15.6
}

Global Market Cap Charts

Get historical total cryptocurrency market capitalization data over time.

def get_global_market_cap_chart(days, **kwargs):
    """
    Get cryptocurrency global market cap chart data showing total market evolution.
    
    Parameters:
    - days (str or int): Data range ('1', '7', '14', '30', '90', '180', '365', 'max')
    - vs_currency (str): Target currency for market cap data (default: 'usd')
    
    Returns:
    dict: Contains 'market_cap_chart' array with [timestamp, total_market_cap] pairs
    """

Usage Example:

# Get global market cap chart for last 90 days
market_cap_chart = cg.get_global_market_cap_chart(days=90, vs_currency='usd')

# Access chart data
chart_data = market_cap_chart['market_cap_chart']
for timestamp, market_cap in chart_data:
    # timestamp is Unix timestamp in milliseconds
    # market_cap is total market cap in specified currency
    pass

Public Companies Treasury Data

Get data about public companies that hold cryptocurrency in their treasury reserves.

def get_companies_public_treasury_by_coin_id(coin_id, **kwargs):
    """
    Get public companies treasury data for a specific cryptocurrency.
    
    Parameters:
    - coin_id (str): Cryptocurrency ID (e.g., 'bitcoin', 'ethereum')
    
    Returns:
    dict: Contains 'companies' array with company holdings, market values, and metadata
    """

Usage Example:

# Get companies holding Bitcoin in treasury
btc_treasuries = cg.get_companies_public_treasury_by_coin_id(coin_id='bitcoin')

# Access company data
companies = btc_treasuries['companies']
for company in companies:
    name = company['name']
    symbol = company['symbol']
    holdings = company['total_holdings']
    value_usd = company['total_current_value_usd']
    print(f"{name} ({symbol}): {holdings} BTC worth ${value_usd:,.2f}")

# Get summary statistics
total_holdings = btc_treasuries['total_holdings']
total_value = btc_treasuries['total_value_usd']
market_cap_percentage = btc_treasuries['market_cap_dominance']

Companies Treasury Data Structure:

{
    "total_holdings": 193456.789,
    "total_value_usd": 8345672901.23,
    "market_cap_dominance": 0.92,
    "companies": [
        {
            "name": "MicroStrategy Inc.",
            "symbol": "MSTR",
            "country": "US",
            "total_holdings": 152800,
            "total_entry_value_usd": 4680000000.00,
            "total_current_value_usd": 6587200000.00,
            "percentage_of_total_supply": 0.728
        },
        {
            "name": "Tesla, Inc.",
            "symbol": "TSLA", 
            "country": "US",
            "total_holdings": 9720,
            "total_entry_value_usd": 1500000000.00,
            "total_current_value_usd": 418644000.00,
            "percentage_of_total_supply": 0.046
        }
        # ... more companies
    ]
}

Exchange Rates

Get Bitcoin-to-fiat and Bitcoin-to-cryptocurrency exchange rates.

def get_exchange_rates(**kwargs):
    """
    Get BTC-to-Currency exchange rates for all supported currencies.
    
    Returns:
    dict: Contains 'rates' object with currency codes as keys and rate information as values
    """

Usage Example:

# Get all BTC exchange rates
rates = cg.get_exchange_rates()

# Access specific rates
btc_to_usd = rates['rates']['usd']['value']
btc_to_eur = rates['rates']['eur']['value']
btc_to_eth = rates['rates']['eth']['value']

# Access rate metadata
usd_info = rates['rates']['usd']
rate_name = usd_info['name']        # "US Dollar"
rate_unit = usd_info['unit']        # "usd"
rate_value = usd_info['value']      # 43250.50
rate_type = usd_info['type']        # "fiat" or "crypto"

Exchange Rates Data Structure:

{
    "rates": {
        "usd": {
            "name": "US Dollar",
            "unit": "usd",
            "value": 43250.50,
            "type": "fiat"
        },
        "eur": {
            "name": "Euro",
            "unit": "eur", 
            "value": 39876.25,
            "type": "fiat"
        },
        "eth": {
            "name": "Ether",
            "unit": "eth",
            "value": 17.234,
            "type": "crypto"
        }
        # ... all supported currencies
    }
}

Key Metrics Explained

Market Cap Percentage

Shows the dominance of top cryptocurrencies as a percentage of total market capitalization. Bitcoin typically represents 40-50% of total crypto market cap.

Market Cap Change 24h

The percentage change in total cryptocurrency market capitalization over the past 24 hours, indicating overall market trend.

DeFi Dominance

The percentage of DeFi tokens' market cap compared to the total cryptocurrency market cap, showing the relative size of the DeFi ecosystem.

DeFi to ETH Ratio

The ratio of DeFi market cap to Ethereum's market cap, indicating how much value is locked in DeFi protocols relative to Ethereum's base value.

Data Refresh Frequency

Global market data is typically updated every few minutes. The updated_at timestamp in responses indicates when the data was last refreshed (Unix timestamp in seconds).

Currency Support

Global market data supports all major fiat currencies and cryptocurrencies for market cap and volume calculations:

  • Fiat: USD, EUR, GBP, JPY, KRW, CNY, etc.
  • Crypto: BTC, ETH, LTC, BCH, BNB, etc.

Use the get_supported_vs_currencies() function to get the complete list of supported currencies.

Install with Tessl CLI

npx tessl i tessl/pypi-pycoingecko

docs

coins.md

exchanges.md

global.md

index.md

nfts.md

price-market.md

search.md

system-utils.md

tile.json