Install & Compatibility
Where this runs
tested against v3.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.617s · 21.3MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 2.1s · import 0.552s · 22MB
19MB installed
● package 19MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
CoinGeckoAPI
✓ from pycoingecko import CoinGeckoAPI
Initializes the CoinGeckoAPI client and fetches the current price of Bitcoin in USD. It also includes a basic API status check. Users with Demo or Pro API keys should pass them during client initialization for higher rate limits and access to more endpoints.
import os
from pycoingecko import CoinGeckoAPI
# For Public API (no key required, but rate-limited)
# For Demo API with key: cg = CoinGeckoAPI(demo_api_key=os.environ.get('COINGECKO_DEMO_API_KEY', ''))
# For Pro API with key: cg = CoinGeckoAPI(api_key=os.environ.get('COINGECKO_PRO_API_KEY', ''))
cg = CoinGeckoAPI()
try:
price_data = cg.get_price(ids='bitcoin', vs_currencies='usd')
print(f"Bitcoin price in USD: {price_data.get('bitcoin', {}).get('usd')}")
status = cg.ping()
print(f"API Status: {status}")
except Exception as e:
print(f"An error occurred: {e}")
Debug
Known issues
gotchaPublic API Rate Limits: The free Public API has a strict rate limit of approximately 30 calls per minute. Exceeding this limit will result in 429 (Too Many Requests) errors. For higher throughput, consider using a Demo or Pro API key.fixImplement rate limiting/exponential backoff in your application. For increased limits, obtain a CoinGecko API key and pass it to the `CoinGeckoAPI` constructor (e.g., `CoinGeckoAPI(demo_api_key='YOUR_KEY')`).
affects: All versions
gotchaCoin IDs vs. Symbols: The CoinGecko API often requires specific CoinGecko IDs (e.g., 'bitcoin') for queries, rather than common ticker symbols (e.g., 'BTC'). Directly querying with symbols for detailed market data endpoints (like /simple/price) may not work as expected due to non-unique symbols.fixFirst, use `cg.get_coins_list()` or `cg.get_coins_markets()` to find the correct CoinGecko ID for a given symbol or name. Then, use this ID for subsequent API calls.
affects: All versions
breakingMarket Cap Rank Changes for Rehypothecated Tokens: Effective February 4th, 2026, the `market_cap_rank` field will return null for rehypothecated tokens. A new field, `market_cap_rank_with_rehypothecated`, is available to include these tokens in ranking calculations.fixUpdate your data processing logic to use `market_cap_rank_with_rehypothecated` if you need ranking visibility for all tokens, including rehypothecated ones.
affects: CoinGecko API data fetched after 2026-02-04
gotchaMissing Output in Console: When using the `pycoingecko` client methods, the return value is often a dictionary. If you don't explicitly `print()` the result, no output will appear in the console.fixAlways wrap your API calls in a `print()` statement or assign the result to a variable and then print the variable to see the output. E.g., `print(cg.ping())` instead of `cg.ping()`.
affects: All versions
gotchaFloating-point Precision for Low-Value Assets: For cryptocurrencies with extremely low prices (e.g., 0.00000001), standard floating-point parsers in Python might convert these to scientific notation or round them down to zero.fixIf precision for low-value assets is critical, consider implementing a custom data handling layer using high-precision data types like Python's `Decimal` to preserve exact values.
affects: All versions
Upgrade
Version history
3.2.0latest on PyPI · released Nov 13, 2024
Audit
Dependencies
No dependency data recorded yet.