$npx -y skills add agiprolabs/claude-trading-skills --skill coingecko-apiBroad crypto market data from CoinGecko covering 13,000+ tokens. Global market stats, historical price data going back years, exchange volumes, trending tokens, and category filters. Best for macro analysis and long-term historical data.
| 1 | # CoinGecko API Skill |
| 2 | |
| 3 | Query the CoinGecko API for comprehensive crypto market data — prices, historical |
| 4 | charts, exchange volumes, trending tokens, global stats, and category breakdowns. |
| 5 | The free tier requires no API key and supports 30 calls/min. |
| 6 | |
| 7 | ## When to Use This Skill |
| 8 | |
| 9 | - **Macro analysis**: Global market cap, BTC dominance, total volume trends |
| 10 | - **Historical data**: Daily/hourly OHLCV going back years (not minutes-level) |
| 11 | - **Cross-exchange comparisons**: Exchange volume rankings and trust scores |
| 12 | - **Trending/discovery**: What tokens are trending on CoinGecko in the last 24h |
| 13 | - **Category analysis**: Compare DeFi vs L1 vs meme coin market caps |
| 14 | - **Token research**: Full metadata including links, description, community stats |
| 15 | |
| 16 | Use **Birdeye** or **DexScreener** instead for real-time Solana DEX data, new token |
| 17 | launches, or sub-daily granularity on Solana tokens. |
| 18 | |
| 19 | ## Quick Start |
| 20 | |
| 21 | ### Get Current Prices |
| 22 | |
| 23 | ```python |
| 24 | import httpx |
| 25 | |
| 26 | # No API key needed for free tier |
| 27 | resp = httpx.get( |
| 28 | "https://api.coingecko.com/api/v3/simple/price", |
| 29 | params={"ids": "solana,bitcoin,ethereum", "vs_currencies": "usd", |
| 30 | "include_24hr_change": "true"}, |
| 31 | ) |
| 32 | data = resp.json() |
| 33 | for coin, info in data.items(): |
| 34 | print(f"{coin}: ${info['usd']:.2f} ({info['usd_24h_change']:+.1f}%)") |
| 35 | ``` |
| 36 | |
| 37 | ### Get Top Coins by Market Cap |
| 38 | |
| 39 | ```python |
| 40 | import httpx |
| 41 | |
| 42 | resp = httpx.get( |
| 43 | "https://api.coingecko.com/api/v3/coins/markets", |
| 44 | params={"vs_currency": "usd", "order": "market_cap_desc", |
| 45 | "per_page": 10, "page": 1, "sparkline": "false"}, |
| 46 | ) |
| 47 | for coin in resp.json(): |
| 48 | print(f"{coin['symbol'].upper():>6} ${coin['current_price']:>10,.2f} " |
| 49 | f"MCap: ${coin['market_cap']/1e9:.1f}B " |
| 50 | f"24h: {coin['price_change_percentage_24h']:+.1f}%") |
| 51 | ``` |
| 52 | |
| 53 | ### Get Historical Price Data |
| 54 | |
| 55 | ```python |
| 56 | import httpx |
| 57 | import pandas as pd |
| 58 | |
| 59 | resp = httpx.get( |
| 60 | "https://api.coingecko.com/api/v3/coins/solana/market_chart", |
| 61 | params={"vs_currency": "usd", "days": "90", "interval": "daily"}, |
| 62 | ) |
| 63 | data = resp.json() |
| 64 | df = pd.DataFrame(data["prices"], columns=["timestamp", "price"]) |
| 65 | df["date"] = pd.to_datetime(df["timestamp"], unit="ms") |
| 66 | df = df.set_index("date").drop(columns=["timestamp"]) |
| 67 | print(df.describe()) |
| 68 | ``` |
| 69 | |
| 70 | ### Get OHLC Candle Data |
| 71 | |
| 72 | ```python |
| 73 | import httpx |
| 74 | |
| 75 | resp = httpx.get( |
| 76 | "https://api.coingecko.com/api/v3/coins/solana/ohlc", |
| 77 | params={"vs_currency": "usd", "days": "30"}, |
| 78 | ) |
| 79 | # Returns [[timestamp, open, high, low, close], ...] |
| 80 | candles = resp.json() |
| 81 | for c in candles[-5:]: |
| 82 | print(f" O={c[1]:.2f} H={c[2]:.2f} L={c[3]:.2f} C={c[4]:.2f}") |
| 83 | ``` |
| 84 | |
| 85 | ### Global Market Stats |
| 86 | |
| 87 | ```python |
| 88 | import httpx |
| 89 | |
| 90 | resp = httpx.get("https://api.coingecko.com/api/v3/global") |
| 91 | g = resp.json()["data"] |
| 92 | print(f"Total Market Cap: ${g['total_market_cap']['usd']/1e12:.2f}T") |
| 93 | print(f"24h Volume: ${g['total_volume']['usd']/1e9:.0f}B") |
| 94 | print(f"BTC Dominance: {g['market_cap_percentage']['btc']:.1f}%") |
| 95 | print(f"Active Coins: {g['active_cryptocurrencies']:,}") |
| 96 | ``` |
| 97 | |
| 98 | ### Trending Coins |
| 99 | |
| 100 | ```python |
| 101 | import httpx |
| 102 | |
| 103 | resp = httpx.get("https://api.coingecko.com/api/v3/search/trending") |
| 104 | for item in resp.json()["coins"]: |
| 105 | coin = item["item"] |
| 106 | print(f"#{coin['market_cap_rank'] or '?':>4} {coin['name']} ({coin['symbol']})") |
| 107 | ``` |
| 108 | |
| 109 | ## Authentication |
| 110 | |
| 111 | The free tier requires no API key (30 calls/min). For higher limits, get a Pro |
| 112 | key from https://www.coingecko.com/en/api/pricing and set: |
| 113 | |
| 114 | ```bash |
| 115 | export COINGECKO_API_KEY="CG-xxxxxxxxxxxxxxxxxxxx" |
| 116 | ``` |
| 117 | |
| 118 | Pro requests use a different base URL and header: |
| 119 | |
| 120 | ```python |
| 121 | import os, httpx |
| 122 | |
| 123 | API_KEY = os.getenv("COINGECKO_API_KEY", "") |
| 124 | if API_KEY: |
| 125 | BASE_URL = "https://pro-api.coingecko.com/api/v3" |
| 126 | HEADERS = {"x-cg-pro-api-key": API_KEY} |
| 127 | else: |
| 128 | BASE_URL = "https://api.coingecko.com/api/v3" |
| 129 | HEADERS = {} |
| 130 | ``` |
| 131 | |
| 132 | ## Rate Limiting |
| 133 | |
| 134 | Free tier: 30 requests/min. Implement backoff on 429 responses: |
| 135 | |
| 136 | ```python |
| 137 | import time, httpx |
| 138 | |
| 139 | def cg_get(url: str, params: dict, max_retries: int = 3) -> dict: |
| 140 | """GET with retry on rate limit.""" |
| 141 | for attempt in range(max_retries): |
| 142 | resp = httpx.get(url, params=params, headers=HEADERS, timeout=15.0) |
| 143 | if resp.status_code == 429: |
| 144 | wait = 2 ** attempt * 10 |
| 145 | print(f"Rate limited, waiting {wait}s...") |
| 146 | time.sleep(wait) |
| 147 | continue |
| 148 | resp.raise_for_status() |
| 149 | return resp.json() |
| 150 | raise RuntimeError("Max retries exceeded") |
| 151 | ``` |
| 152 | |
| 153 | ## Finding CoinGecko Token IDs |
| 154 | |
| 155 | CoinGecko uses slug-style IDs (e.g., `solana`, `bitcoin`, `usd-coin`). To find |
| 156 | an ID from a contract address or name, see `references/id_mapping.md`. |
| 157 | |
| 158 | Quick lookup by cont |