@pencil-agent/nano-pencil 2.0.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +267 -267
- package/dist/build-meta.json +3 -3
- package/dist/core/export-html/AGENT.md +11 -11
- package/dist/core/export-html/template.css +971 -971
- package/dist/core/export-html/template.html +54 -54
- package/dist/core/model/custom-providers.js +1 -1
- package/dist/core/model-registry.js +5 -5
- package/dist/extensions/builtin/AGENT.md +115 -115
- package/dist/extensions/builtin/browser/AGENT.md +17 -17
- package/dist/extensions/builtin/browser/agent-workspace/agent_helpers.py +12 -12
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/amazon/product-search.md +198 -198
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/archive-org/scraping.md +341 -341
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/arxiv/scraping.md +311 -311
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/arxiv-bulk/scraping.md +333 -333
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/atlas/overview.md +70 -70
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/booking-com/scraping.md +578 -578
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/capterra/scraping.md +440 -440
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/centilebrain/generate-estimates.md +110 -110
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/coingecko/scraping.md +325 -325
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/coinmarketcap/scraping.md +463 -463
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/coursera/scraping.md +360 -360
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/craigslist/scraping.md +390 -390
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/crossref/scraping.md +568 -568
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/dev-to/scraping.md +323 -323
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/duckduckgo/scraping.md +349 -349
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/ebay/scraping.md +435 -435
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/etsy/scraping.md +506 -506
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/eventbrite/scraping.md +363 -363
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/expedia/automation.md +168 -168
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/facebook/groups.md +236 -236
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/facebook/pages.md +295 -295
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/framer/editor.md +108 -108
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/fred/scraping.md +493 -493
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/g2/scraping.md +580 -580
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/genius/scraping.md +511 -511
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/github/repo-actions.md +65 -65
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/github/scraping.md +184 -184
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/glassdoor/scraping.md +543 -543
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/gmail/compose.md +122 -122
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/goodreads/scraping.md +461 -461
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/gutenberg/scraping.md +383 -383
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/hackernews/scraping.md +243 -243
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/howlongtobeat/scraping.md +473 -473
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/imdb/scraping.md +271 -271
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/itch-io/scraping.md +436 -436
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/job-boards/indeed-glassdoor.md +1021 -1021
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/letterboxd/scraping.md +349 -349
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/linkedin/invitation-manager.md +109 -109
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/loom/folder-enumeration.md +170 -170
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/macrotrends/scraping.md +537 -537
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/medium/article-hydration.md +120 -120
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/medium/scraping.md +414 -414
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/metacritic/scraping.md +477 -477
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/musicbrainz/scraping.md +478 -478
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/nasa/scraping.md +339 -339
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/news-aggregation/multi-source.md +205 -205
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/open-library/scraping.md +472 -472
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/openalex/scraping.md +470 -470
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/openstreetmap/scraping.md +490 -490
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/package-registries/npm-pypi.md +478 -478
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/polymarket/scraping.md +234 -234
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/producthunt/scraping.md +307 -307
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/pubmed/scraping.md +421 -421
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/quora/scraping.md +364 -364
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/rawg/scraping.md +352 -352
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/reddit/scraping.md +124 -124
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/rest-countries/scraping.md +233 -233
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/sec-edgar/scraping.md +361 -361
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/shopify-admin/README.md +36 -36
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/shopify-admin/embedded-apps.md +72 -72
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/shopify-admin/knowledge-base.md +109 -109
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/shopify-admin/polaris-inputs.md +137 -137
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/soundcloud/scraping.md +362 -362
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/spotify/scraping.md +339 -339
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/stackoverflow/scraping.md +435 -435
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/steam/scraping.md +575 -575
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/substack/scraping.md +338 -338
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/thetechgeeks/pricing.md +52 -52
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/tiktok/upload.md +107 -107
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/tradingview/scraping.md +309 -309
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/trello/boards-and-lists.md +88 -88
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/trustpilot/scraping.md +375 -375
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/walmart/scraping.md +444 -444
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/wayback-machine/scraping.md +306 -306
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/weather/scraping.md +398 -398
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/wellfound/scraping.md +596 -596
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/world-bank/scraping.md +356 -356
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/xiaohongshu/scraping.md +84 -84
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/youtube/scraping.md +418 -418
- package/dist/extensions/builtin/browser/agent-workspace/domain-skills/zillow/scraping.md +433 -433
- package/dist/extensions/builtin/browser/browser.md +73 -73
- package/dist/extensions/builtin/browser/install.md +142 -142
- package/dist/extensions/builtin/browser/interaction-skills/connection.md +48 -48
- package/dist/extensions/builtin/browser/interaction-skills/cookies.md +3 -3
- package/dist/extensions/builtin/browser/interaction-skills/cross-origin-iframes.md +3 -3
- package/dist/extensions/builtin/browser/interaction-skills/dialogs.md +64 -64
- package/dist/extensions/builtin/browser/interaction-skills/downloads.md +3 -3
- package/dist/extensions/builtin/browser/interaction-skills/drag-and-drop.md +3 -3
- package/dist/extensions/builtin/browser/interaction-skills/dropdowns.md +3 -3
- package/dist/extensions/builtin/browser/interaction-skills/iframes.md +3 -3
- package/dist/extensions/builtin/browser/interaction-skills/network-requests.md +3 -3
- package/dist/extensions/builtin/browser/interaction-skills/print-as-pdf.md +3 -3
- package/dist/extensions/builtin/browser/interaction-skills/profile-sync.md +90 -90
- package/dist/extensions/builtin/browser/interaction-skills/screenshots.md +17 -17
- package/dist/extensions/builtin/browser/interaction-skills/scrolling.md +3 -3
- package/dist/extensions/builtin/browser/interaction-skills/shadow-dom.md +3 -3
- package/dist/extensions/builtin/browser/interaction-skills/tabs.md +69 -69
- package/dist/extensions/builtin/browser/interaction-skills/uploads.md +1 -1
- package/dist/extensions/builtin/browser/interaction-skills/viewport.md +3 -3
- package/dist/extensions/builtin/browser/src/browser_harness/AGENT.md +15 -15
- package/dist/extensions/builtin/browser/src/browser_harness/__init__.py +8 -8
- package/dist/extensions/builtin/browser/src/browser_harness/_ipc.py +90 -90
- package/dist/extensions/builtin/browser/src/browser_harness/admin.py +722 -722
- package/dist/extensions/builtin/browser/src/browser_harness/daemon.py +328 -328
- package/dist/extensions/builtin/browser/src/browser_harness/helpers.py +396 -396
- package/dist/extensions/builtin/browser/src/browser_harness/run.py +103 -103
- package/dist/extensions/builtin/debug/index.js +9 -9
- package/dist/extensions/builtin/discipline/skills/brainstorming/SKILL.md +33 -33
- package/dist/extensions/builtin/discipline/skills/executing-plans/SKILL.md +25 -25
- package/dist/extensions/builtin/discipline/skills/finishing-development-branch/SKILL.md +25 -25
- package/dist/extensions/builtin/discipline/skills/receiving-code-review/SKILL.md +22 -22
- package/dist/extensions/builtin/discipline/skills/requesting-code-review/SKILL.md +31 -31
- package/dist/extensions/builtin/discipline/skills/systematic-debugging/SKILL.md +28 -28
- package/dist/extensions/builtin/discipline/skills/test-driven-development/SKILL.md +32 -32
- package/dist/extensions/builtin/discipline/skills/using-git-worktrees/SKILL.md +25 -25
- package/dist/extensions/builtin/discipline/skills/verification-before-completion/SKILL.md +27 -27
- package/dist/extensions/builtin/discipline/skills/writing-plans/SKILL.md +26 -26
- package/dist/extensions/builtin/goal/README.md +67 -67
- package/dist/extensions/builtin/goal/index.js +6 -6
- package/dist/extensions/builtin/grub/README.md +112 -112
- package/dist/extensions/builtin/link-world/agent-workspace/README.md +16 -16
- package/dist/extensions/builtin/link-world/internet-search/internet-search.md +65 -65
- package/dist/extensions/builtin/link-world/link-world-agent.md +82 -82
- package/dist/extensions/builtin/link-world/linkworld.md +313 -313
- package/dist/extensions/builtin/link-world/network-routing/network-routing.md +67 -67
- package/dist/extensions/builtin/loop/README.md +92 -92
- package/dist/extensions/builtin/mcp/figma-design.md +68 -68
- package/dist/extensions/builtin/mcp/mcp-management.md +85 -85
- package/dist/extensions/builtin/recap/AGENT.md +15 -15
- package/dist/extensions/builtin/sal/README.md +72 -72
- package/dist/extensions/builtin/security-audit/README.md +289 -289
- package/dist/extensions/builtin/team/AGENT.md +112 -112
- package/dist/extensions/builtin/team/TESTING.md +299 -299
- package/dist/extensions/builtin/token-save/README.md +56 -56
- package/dist/extensions/optional/AGENT.md +10 -10
- package/dist/modes/interactive/controllers/input-submit-controller.js +2 -2
- package/dist/modes/interactive/controllers/stream-render-controller.js +2 -2
- package/dist/modes/interactive/interactive-mode.js +19 -19
- package/dist/modes/interactive/theme/dark.json +85 -85
- package/dist/modes/interactive/theme/light.json +84 -84
- package/dist/modes/interactive/theme/theme-schema.json +335 -335
- package/dist/modes/interactive/theme/warm.json +81 -81
- package/dist/node_modules/@pencil-agent/ai/dist/cli.js +0 -0
- package/dist/node_modules/@pencil-agent/ai/dist/models.generated.js +1 -1
- package/docs/ACP/345/215/217/350/256/256/351/233/206/346/210/220/345/274/200/345/217/221/346/226/207/346/241/243.md +851 -0
- package/docs/SDK-TESTING.md +364 -0
- package/docs/codex-goal-command-impl.md +1055 -1055
- package/docs/codex-goal-vs-grub.md +500 -500
- package/docs/custom-provider.md +27 -27
- package/docs/extensions.md +27 -27
- package/docs/keybindings.md +27 -27
- package/docs/loop /351/207/215/346/236/204/345/256/214/346/210/220/346/200/273/347/273/223.md" +250 -250
- package/docs/loop /351/207/215/346/236/204/345/256/214/346/210/220/346/212/245/345/221/212.md" +122 -122
- package/docs/loop /351/207/215/346/236/204/346/226/271/346/241/210.md" +1222 -1222
- package/docs/loop /351/207/215/346/236/204/346/226/271/346/241/210/345/256/236/347/216/260/346/212/245/345/221/212.md" +158 -158
- package/docs/loop /351/207/215/346/236/204/346/226/271/346/241/210/345/257/271/346/257/224/345/210/206/346/236/220.md" +128 -128
- package/docs/loop /351/207/215/346/236/204/350/256/241/345/210/222.md" +320 -320
- package/docs/loop-usage-examples.md +214 -214
- package/docs/mem-core/346/212/200/346/234/257/346/226/207/346/241/243.md +593 -0
- package/docs/models.md +27 -27
- package/docs/packages.md +27 -27
- package/docs/pi-design-philosophy.md +457 -457
- package/docs/planmode.md +1987 -1987
- package/docs/prompt-templates.md +27 -27
- package/docs/providers.md +27 -27
- package/docs/sdk.md +27 -27
- package/docs/skills.md +27 -27
- package/docs/startup-performance-optimization.md +301 -0
- package/docs/themes.md +27 -27
- package/docs/tui.md +27 -27
- package/docs//350/256/244/347/237/245/345/234/260/345/233/276.md +47 -0
- package/package.json +190 -190
- package/docs/cc-agent-design.md +0 -1297
- package/docs/cc-tui-design.md +0 -1333
- package/docs/nanoPencil-/345/255/246/344/271/240/350/256/241/345/210/222.md +0 -170
- package/docs/scan-report.md +0 -3820
- package/docs//345/257/271/346/240/207Claude-Code.md +0 -1775
- package/docs//351/230/277/351/207/214/345/267/264/345/267/264/350/264/242/346/212/245/345/210/206/346/236/220/344/271/246.md +0 -261
|
@@ -1,325 +1,325 @@
|
|
|
1
|
-
# CoinGecko — Data Extraction
|
|
2
|
-
|
|
3
|
-
`https://api.coingecko.com/api/v3` — no API key needed for free tier. Pure JSON REST API, no browser required.
|
|
4
|
-
|
|
5
|
-
## Do this first
|
|
6
|
-
|
|
7
|
-
**Use the API directly with `http_get` — no browser, no parsing, fully structured JSON.**
|
|
8
|
-
|
|
9
|
-
```python
|
|
10
|
-
import json
|
|
11
|
-
data = json.loads(http_get("https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd"))
|
|
12
|
-
print(data['bitcoin']['usd']) # 76286
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
**Rate limit is tight: ~3 calls per minute on the free tier.** The API returns HTTP 429 with `Retry-After: 60` when you exceed it. Always add `time.sleep(5)` between calls in a loop. Confirmed: rapid-fire calls hit 429 on call 3-4 with no delay; with 5s gaps you stay safe.
|
|
16
|
-
|
|
17
|
-
## Rate limits (confirmed live)
|
|
18
|
-
|
|
19
|
-
- **Free tier**: ~3 calls/minute per IP (no API key)
|
|
20
|
-
- **429 response**: includes `Retry-After: 60` header — wait 60 seconds before retrying
|
|
21
|
-
- **Coin ID lookup** (`/coins/list`) counts against the limit — call it once and cache
|
|
22
|
-
- **`/ping`** still counts — don't use it as a keep-alive
|
|
23
|
-
|
|
24
|
-
```python
|
|
25
|
-
import time, urllib.error, json
|
|
26
|
-
|
|
27
|
-
def safe_get(url, retries=2):
|
|
28
|
-
for attempt in range(retries + 1):
|
|
29
|
-
try:
|
|
30
|
-
return json.loads(http_get(url))
|
|
31
|
-
except urllib.error.HTTPError as e:
|
|
32
|
-
if e.code == 429 and attempt < retries:
|
|
33
|
-
print(f"Rate limited, sleeping 65s...")
|
|
34
|
-
time.sleep(65)
|
|
35
|
-
else:
|
|
36
|
-
raise
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Coin ID vs symbol — critical distinction
|
|
40
|
-
|
|
41
|
-
**IDs are kebab-case strings, not ticker symbols.** The API ignores symbols entirely.
|
|
42
|
-
|
|
43
|
-
| Intent | Wrong | Right |
|
|
44
|
-
|--------|-------|-------|
|
|
45
|
-
| Bitcoin price | `ids=BTC` | `ids=bitcoin` |
|
|
46
|
-
| Solana price | `ids=SOL` | `ids=solana` |
|
|
47
|
-
| Ethereum | `ids=ETH` | `ids=ethereum` |
|
|
48
|
-
|
|
49
|
-
- Unknown or wrong IDs return an **empty `{}` dict** — no error, no warning
|
|
50
|
-
- Symbols are not unique: 17+ coins share the symbol `sol` (bridged versions, wrapped, etc.)
|
|
51
|
-
- Use `/coins/list` to resolve symbol → id, or just know the canonical id
|
|
52
|
-
|
|
53
|
-
```python
|
|
54
|
-
# Resolve symbol to id
|
|
55
|
-
coins_list = json.loads(http_get("https://api.coingecko.com/api/v3/coins/list"))
|
|
56
|
-
# 17,564 entries as of April 2026
|
|
57
|
-
# Each: {'id': 'bitcoin', 'symbol': 'btc', 'name': 'Bitcoin'}
|
|
58
|
-
sol_coins = [c for c in coins_list if c['symbol'].lower() == 'sol']
|
|
59
|
-
# Returns 5+ entries — pick by name to get the real Solana: id='solana'
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## Common workflows
|
|
63
|
-
|
|
64
|
-
### Simple price (one or many coins)
|
|
65
|
-
|
|
66
|
-
```python
|
|
67
|
-
import json
|
|
68
|
-
data = json.loads(http_get(
|
|
69
|
-
"https://api.coingecko.com/api/v3/simple/price"
|
|
70
|
-
"?ids=bitcoin,ethereum,solana"
|
|
71
|
-
"&vs_currencies=usd,eur"
|
|
72
|
-
"&include_market_cap=true"
|
|
73
|
-
"&include_24hr_change=true"
|
|
74
|
-
))
|
|
75
|
-
for coin, info in data.items():
|
|
76
|
-
print(f"{coin}: ${info['usd']:,.0f} | 24h: {info['usd_24h_change']:.1f}% | MCap: ${info['usd_market_cap']/1e9:.1f}B")
|
|
77
|
-
# bitcoin: $76,286 | 24h: 1.4% | MCap: $1528.0B
|
|
78
|
-
# ethereum: $2,361 | 24h: 0.8% | MCap: $284.9B
|
|
79
|
-
# solana: $87 | 24h: -1.0% | MCap: $50.2B
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
Response keys for each coin (when all flags enabled):
|
|
83
|
-
`usd`, `usd_market_cap`, `usd_24h_change`, `eur`, `eur_market_cap`, `eur_24h_change`
|
|
84
|
-
|
|
85
|
-
### Top coins by market cap (paginated)
|
|
86
|
-
|
|
87
|
-
```python
|
|
88
|
-
import json
|
|
89
|
-
data = json.loads(http_get(
|
|
90
|
-
"https://api.coingecko.com/api/v3/coins/markets"
|
|
91
|
-
"?vs_currency=usd"
|
|
92
|
-
"&order=market_cap_desc"
|
|
93
|
-
"&per_page=10" # max 250
|
|
94
|
-
"&page=1" # 1-indexed; page=2 gives ranks 11-20 etc.
|
|
95
|
-
"&sparkline=false"
|
|
96
|
-
"&price_change_percentage=1h,7d,30d" # optional extra columns
|
|
97
|
-
))
|
|
98
|
-
for c in data:
|
|
99
|
-
print(f"#{c['market_cap_rank']} {c['symbol'].upper()} ${c['current_price']:,.2f} | {c['price_change_percentage_24h']:.1f}%")
|
|
100
|
-
# #1 BTC $76,281.00 | 1.4%
|
|
101
|
-
# #2 ETH $2,360.45 | 0.8%
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
Full fields per entry: `id`, `symbol`, `name`, `image`, `current_price`, `market_cap`, `market_cap_rank`, `fully_diluted_valuation`, `total_volume`, `high_24h`, `low_24h`, `price_change_24h`, `price_change_percentage_24h`, `market_cap_change_24h`, `market_cap_change_percentage_24h`, `circulating_supply`, `total_supply`, `max_supply`, `ath`, `ath_change_percentage`, `ath_date`, `atl`, `atl_change_percentage`, `atl_date`, `roi`, `last_updated`
|
|
105
|
-
|
|
106
|
-
Extra columns added by `price_change_percentage=1h,7d,30d`: `price_change_percentage_1h_in_currency`, `price_change_percentage_7d_in_currency`, `price_change_percentage_30d_in_currency`
|
|
107
|
-
|
|
108
|
-
Pagination: use `page=2`, `page=3`, etc. with `per_page` up to 250. Results are 1-indexed — page 2 with per_page=5 returns ranks 6–10.
|
|
109
|
-
|
|
110
|
-
### Coin detail (full metadata)
|
|
111
|
-
|
|
112
|
-
```python
|
|
113
|
-
import json
|
|
114
|
-
data = json.loads(http_get(
|
|
115
|
-
"https://api.coingecko.com/api/v3/coins/bitcoin"
|
|
116
|
-
"?localization=false" # skip 40+ language translations
|
|
117
|
-
"&tickers=false" # skip exchange ticker list (can be huge)
|
|
118
|
-
"&market_data=true"
|
|
119
|
-
"&community_data=false"
|
|
120
|
-
"&developer_data=false"
|
|
121
|
-
))
|
|
122
|
-
print(data['name']) # Bitcoin
|
|
123
|
-
print(data['symbol']) # btc
|
|
124
|
-
print(data['market_cap_rank']) # 1
|
|
125
|
-
print(data['market_data']['current_price']['usd']) # 76279
|
|
126
|
-
print(data['market_data']['ath']['usd']) # 126080
|
|
127
|
-
print(data['market_data']['ath_date']['usd']) # 2025-10-06T18:57:42.558Z
|
|
128
|
-
print(data['market_data']['circulating_supply']) # 20017459.0
|
|
129
|
-
print(data['description']['en'][:200])
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
Top-level keys: `id`, `symbol`, `name`, `web_slug`, `asset_platform_id`, `platforms`, `categories`, `description`, `links`, `image`, `genesis_date`, `sentiment_votes_up_percentage`, `market_cap_rank`, `market_data`, `last_updated`
|
|
133
|
-
|
|
134
|
-
`market_data` sub-keys include: `current_price`, `ath`, `ath_change_percentage`, `ath_date`, `atl`, `atl_change_percentage`, `atl_date`, `market_cap`, `fully_diluted_valuation`, `total_volume`, `high_24h`, `low_24h`, `price_change_percentage_24h`, `price_change_percentage_7d`, `price_change_percentage_14d`, `price_change_percentage_30d`, `price_change_percentage_60d`, `price_change_percentage_200d`, `price_change_percentage_1y`, `circulating_supply`, `total_supply`, `max_supply`
|
|
135
|
-
|
|
136
|
-
All price/market fields are objects keyed by currency code: `data['market_data']['current_price']['usd']`, `['eur']`, `['btc']`, etc.
|
|
137
|
-
|
|
138
|
-
### Historical OHLCV
|
|
139
|
-
|
|
140
|
-
```python
|
|
141
|
-
import json
|
|
142
|
-
# OHLCV candles: granularity auto-determined by `days`
|
|
143
|
-
# 1d = 30-min candles, 7d = 4-hr candles, 14d+ = daily candles
|
|
144
|
-
data = json.loads(http_get(
|
|
145
|
-
"https://api.coingecko.com/api/v3/coins/ethereum/ohlc?vs_currency=usd&days=7"
|
|
146
|
-
))
|
|
147
|
-
print(len(data)) # 42 candles for 7-day window
|
|
148
|
-
print(data[-1]) # [1776499200000, 2407.32, 2412.96, 2402.21, 2405.03]
|
|
149
|
-
# [timestamp_ms, open, high, low, close]
|
|
150
|
-
|
|
151
|
-
# Convert timestamp:
|
|
152
|
-
import datetime
|
|
153
|
-
ts_ms = data[-1][0]
|
|
154
|
-
dt = datetime.datetime.fromtimestamp(ts_ms / 1000, tz=datetime.timezone.utc)
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
`days` options: `1`, `7`, `14`, `30`, `90`, `180`, `365`, `max`
|
|
158
|
-
|
|
159
|
-
### Market chart (price + volume + market cap time series)
|
|
160
|
-
|
|
161
|
-
```python
|
|
162
|
-
import json
|
|
163
|
-
# interval='daily' gives one point per day; omit for auto (hourly for <=90 days)
|
|
164
|
-
chart = json.loads(http_get(
|
|
165
|
-
"https://api.coingecko.com/api/v3/coins/bitcoin/market_chart"
|
|
166
|
-
"?vs_currency=usd&days=7&interval=daily"
|
|
167
|
-
))
|
|
168
|
-
# Keys: 'prices', 'market_caps', 'total_volumes'
|
|
169
|
-
# Each is a list of [timestamp_ms, value]
|
|
170
|
-
print(len(chart['prices'])) # 8 points for 7-day daily
|
|
171
|
-
print(chart['prices'][-1]) # [1776508393000, 76286.699...]
|
|
172
|
-
print(chart['total_volumes'][-1]) # [1776508393000, 80459560788.47...]
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
### Market chart by date range
|
|
176
|
-
|
|
177
|
-
```python
|
|
178
|
-
import json, time
|
|
179
|
-
now = int(time.time())
|
|
180
|
-
thirty_days_ago = now - 30 * 86400
|
|
181
|
-
chart = json.loads(http_get(
|
|
182
|
-
f"https://api.coingecko.com/api/v3/coins/bitcoin/market_chart/range"
|
|
183
|
-
f"?vs_currency=usd&from={thirty_days_ago}&to={now}"
|
|
184
|
-
))
|
|
185
|
-
# Granularity: <1 day → minutely, 1-90 days → hourly, >90 days → daily
|
|
186
|
-
print(len(chart['prices'])) # 174 points for 7-day range (hourly)
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
### Search
|
|
190
|
-
|
|
191
|
-
```python
|
|
192
|
-
import json
|
|
193
|
-
results = json.loads(http_get("https://api.coingecko.com/api/v3/search?query=solana"))
|
|
194
|
-
# Top-level keys: 'coins', 'exchanges', 'icos', 'categories', 'nfts'
|
|
195
|
-
for c in results['coins'][:3]:
|
|
196
|
-
print(f"{c['id']} | {c['symbol']} | rank {c['market_cap_rank']}")
|
|
197
|
-
# solana | SOL | rank 7
|
|
198
|
-
# solana-name-service | SNS | rank 1902
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
Search returns coins ordered by relevance, not market cap. First result is usually the canonical coin.
|
|
202
|
-
|
|
203
|
-
### Trending (top 7 searched in last 24h)
|
|
204
|
-
|
|
205
|
-
```python
|
|
206
|
-
import json
|
|
207
|
-
trending = json.loads(http_get("https://api.coingecko.com/api/v3/search/trending"))
|
|
208
|
-
# Top-level keys: 'coins', 'nfts', 'categories'
|
|
209
|
-
for item in trending['coins']:
|
|
210
|
-
c = item['item']
|
|
211
|
-
print(f"{c['name']} ({c['symbol']}) #{c['market_cap_rank']}")
|
|
212
|
-
# Item keys: id, coin_id, name, symbol, market_cap_rank, thumb, small, large,
|
|
213
|
-
# slug, price_btc, score, data
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
`data` sub-object includes sparkline image URL, price/volume/market cap info if available.
|
|
217
|
-
|
|
218
|
-
### Global market overview
|
|
219
|
-
|
|
220
|
-
```python
|
|
221
|
-
import json
|
|
222
|
-
global_data = json.loads(http_get("https://api.coingecko.com/api/v3/global"))
|
|
223
|
-
gd = global_data['data']
|
|
224
|
-
print(f"Total market cap: ${gd['total_market_cap']['usd']/1e12:.2f}T") # $2.66T
|
|
225
|
-
print(f"24h volume: ${gd['total_volume']['usd']/1e9:.1f}B") # $156.6B
|
|
226
|
-
print(f"BTC dominance: {gd['market_cap_percentage']['btc']:.1f}%") # 57.3%
|
|
227
|
-
print(f"Active coins: {gd['active_cryptocurrencies']}") # 17,564
|
|
228
|
-
print(f"Active exchanges: {gd['markets']}") # 1,475
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
### Coin categories (market cap by sector)
|
|
232
|
-
|
|
233
|
-
```python
|
|
234
|
-
import json
|
|
235
|
-
cats = json.loads(http_get(
|
|
236
|
-
"https://api.coingecko.com/api/v3/coins/categories?order=market_cap_desc"
|
|
237
|
-
))
|
|
238
|
-
# 691 categories as of April 2026
|
|
239
|
-
for cat in cats[:5]:
|
|
240
|
-
print(f"{cat['name']}: ${cat['market_cap']/1e9:.1f}B | 24h: {cat['market_cap_change_24h']:.1f}%")
|
|
241
|
-
# Smart Contract Platform: $2204.8B | 24h: 0.9%
|
|
242
|
-
# Layer 1 (L1): $2171.5B | 24h: 1.1%
|
|
243
|
-
|
|
244
|
-
# Category keys: id, name, market_cap, market_cap_change_24h, content,
|
|
245
|
-
# top_3_coins_id, top_3_coins, volume_24h, updated_at
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
### Token price by contract address (ERC-20 and other chains)
|
|
249
|
-
|
|
250
|
-
```python
|
|
251
|
-
import json
|
|
252
|
-
# Platform IDs: ethereum, binance-smart-chain, polygon-pos, avalanche, solana, etc.
|
|
253
|
-
token = json.loads(http_get(
|
|
254
|
-
"https://api.coingecko.com/api/v3/simple/token_price/ethereum"
|
|
255
|
-
"?contract_addresses=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" # USDC
|
|
256
|
-
"&vs_currencies=usd"
|
|
257
|
-
))
|
|
258
|
-
print(token)
|
|
259
|
-
# {'0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48': {'usd': 0.999861}}
|
|
260
|
-
# Key is the lowercased contract address
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
## vs_currencies options
|
|
264
|
-
|
|
265
|
-
63 currencies supported (confirmed live). Common ones:
|
|
266
|
-
|
|
267
|
-
**Fiat**: `usd`, `eur`, `gbp`, `jpy`, `aud`, `cad`, `chf`, `cny`, `inr`, `krw`, `brl`, `mxn`, `sgd`, `hkd`, `nok`, `sek`, `dkk`, `nzd`, `zar`, `thb`, `try`, `aed`, `sar`, `myr`, `php`, `idr`, `pln`, `czk`, `huf`, `ron`
|
|
268
|
-
|
|
269
|
-
**Crypto**: `btc`, `eth`, `ltc`, `bch`, `bnb`, `eos`, `xrp`, `xlm`, `link`, `dot`, `yfi`, `sol`
|
|
270
|
-
|
|
271
|
-
**Commodities**: `xag` (silver), `xau` (gold)
|
|
272
|
-
|
|
273
|
-
Get the full list:
|
|
274
|
-
```python
|
|
275
|
-
currencies = json.loads(http_get("https://api.coingecko.com/api/v3/simple/supported_vs_currencies"))
|
|
276
|
-
# Returns list of 63 strings
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
## Endpoints that require Pro API (return HTTP 401)
|
|
280
|
-
|
|
281
|
-
- `/coins/{id}/history?date=DD-MM-YYYY` — historical price on a specific date
|
|
282
|
-
- `/coins/markets` with `category=` filter (the parameter is silently ignored, not 401)
|
|
283
|
-
- `/coins/{id}/contract/{address}` — full contract token details
|
|
284
|
-
|
|
285
|
-
Free tier alternatives:
|
|
286
|
-
- For historical price on date: use `/market_chart/range` with a narrow time window
|
|
287
|
-
- For category filtering: fetch `/coins/markets` unfiltered and filter client-side using `id` from `/coins/categories`
|
|
288
|
-
|
|
289
|
-
## Ping / health check
|
|
290
|
-
|
|
291
|
-
```python
|
|
292
|
-
import json
|
|
293
|
-
ping = json.loads(http_get("https://api.coingecko.com/api/v3/ping"))
|
|
294
|
-
print(ping) # {'gecko_says': '(V3) To the Moon!'}
|
|
295
|
-
```
|
|
296
|
-
|
|
297
|
-
Note: ping still counts against the rate limit. Don't use it to check if a 429 has resolved — just wait 65 seconds and retry your actual call.
|
|
298
|
-
|
|
299
|
-
## Gotchas
|
|
300
|
-
|
|
301
|
-
- **Rate limit is much stricter than advertised** — The official docs say "30 calls/min" but in practice you get 429 on call 3-4 with no delay between calls. Observed `Retry-After: 60` in the response header. Treat it as "3 calls/minute, wait 65s on 429." Using `time.sleep(5)` between calls in a loop is safe.
|
|
302
|
-
|
|
303
|
-
- **Unknown coin IDs return `{}`, not an error** — `?ids=BTC` (uppercase) and `?ids=not_a_real_coin` both return an empty dict `{}`. Always check that the key you expect exists before accessing it.
|
|
304
|
-
|
|
305
|
-
- **Symbol lookup requires `/coins/list` + client-side filter** — There's no "get by symbol" endpoint. Multiple coins share any given symbol. After fetching the list (17,564 entries), filter by `symbol` and pick by `name`.
|
|
306
|
-
|
|
307
|
-
- **Coin ID casing matters** — IDs are always lowercase kebab-case: `bitcoin`, `ethereum`, `shiba-inu`. Uppercase or camelCase will silently return `{}`.
|
|
308
|
-
|
|
309
|
-
- **OHLCV granularity is automatic** — The `days` parameter determines candle size automatically: `1` → 30-min candles, `7`/`14` → 4-hr candles, `30`+ → daily candles. You cannot override this on the free tier.
|
|
310
|
-
|
|
311
|
-
- **`interval=daily` in market_chart affects point count** — Without `interval=daily`, a 7-day window returns hourly data (~168 points). With it, you get ~8 points. Choose based on whether you need resolution or summary.
|
|
312
|
-
|
|
313
|
-
- **market_chart timestamps are in milliseconds** — Divide by 1000 for standard Unix time: `datetime.fromtimestamp(ts / 1000)`.
|
|
314
|
-
|
|
315
|
-
- **`/coins/list` is expensive (rate-limit-wise)** — It returns 17,564 entries and costs one API call. Fetch once, store in a variable, filter locally. Don't call it in a loop.
|
|
316
|
-
|
|
317
|
-
- **Pagination is 1-indexed** — `page=1` returns items 1–N, `page=2` returns N+1–2N. `page=0` returns the same as `page=1` (it doesn't error).
|
|
318
|
-
|
|
319
|
-
- **`per_page` max is 250** — Requesting more than 250 per page silently returns 250. To get the full top-500, make two calls: `page=1&per_page=250` then `page=2&per_page=250`.
|
|
320
|
-
|
|
321
|
-
- **Contract address keys are lowercased** — When using `/simple/token_price`, the response key is the lowercased contract address regardless of what case you sent. Always call `.lower()` before using addresses as dict keys.
|
|
322
|
-
|
|
323
|
-
- **`tickers=false` is important for `/coins/{id}`** — Without it, the response includes a massive list of exchange tickers that can make the payload very large and slow to parse. Always set `tickers=false` unless you specifically need exchange data.
|
|
324
|
-
|
|
325
|
-
- **ETH priced against BTC is supported** — `vs_currencies=btc` works: `ethereum` returns `{'btc': 0.03095861}`. Crypto-to-crypto pairs work the same as fiat pairs.
|
|
1
|
+
# CoinGecko — Data Extraction
|
|
2
|
+
|
|
3
|
+
`https://api.coingecko.com/api/v3` — no API key needed for free tier. Pure JSON REST API, no browser required.
|
|
4
|
+
|
|
5
|
+
## Do this first
|
|
6
|
+
|
|
7
|
+
**Use the API directly with `http_get` — no browser, no parsing, fully structured JSON.**
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
import json
|
|
11
|
+
data = json.loads(http_get("https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd"))
|
|
12
|
+
print(data['bitcoin']['usd']) # 76286
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**Rate limit is tight: ~3 calls per minute on the free tier.** The API returns HTTP 429 with `Retry-After: 60` when you exceed it. Always add `time.sleep(5)` between calls in a loop. Confirmed: rapid-fire calls hit 429 on call 3-4 with no delay; with 5s gaps you stay safe.
|
|
16
|
+
|
|
17
|
+
## Rate limits (confirmed live)
|
|
18
|
+
|
|
19
|
+
- **Free tier**: ~3 calls/minute per IP (no API key)
|
|
20
|
+
- **429 response**: includes `Retry-After: 60` header — wait 60 seconds before retrying
|
|
21
|
+
- **Coin ID lookup** (`/coins/list`) counts against the limit — call it once and cache
|
|
22
|
+
- **`/ping`** still counts — don't use it as a keep-alive
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
import time, urllib.error, json
|
|
26
|
+
|
|
27
|
+
def safe_get(url, retries=2):
|
|
28
|
+
for attempt in range(retries + 1):
|
|
29
|
+
try:
|
|
30
|
+
return json.loads(http_get(url))
|
|
31
|
+
except urllib.error.HTTPError as e:
|
|
32
|
+
if e.code == 429 and attempt < retries:
|
|
33
|
+
print(f"Rate limited, sleeping 65s...")
|
|
34
|
+
time.sleep(65)
|
|
35
|
+
else:
|
|
36
|
+
raise
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Coin ID vs symbol — critical distinction
|
|
40
|
+
|
|
41
|
+
**IDs are kebab-case strings, not ticker symbols.** The API ignores symbols entirely.
|
|
42
|
+
|
|
43
|
+
| Intent | Wrong | Right |
|
|
44
|
+
|--------|-------|-------|
|
|
45
|
+
| Bitcoin price | `ids=BTC` | `ids=bitcoin` |
|
|
46
|
+
| Solana price | `ids=SOL` | `ids=solana` |
|
|
47
|
+
| Ethereum | `ids=ETH` | `ids=ethereum` |
|
|
48
|
+
|
|
49
|
+
- Unknown or wrong IDs return an **empty `{}` dict** — no error, no warning
|
|
50
|
+
- Symbols are not unique: 17+ coins share the symbol `sol` (bridged versions, wrapped, etc.)
|
|
51
|
+
- Use `/coins/list` to resolve symbol → id, or just know the canonical id
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
# Resolve symbol to id
|
|
55
|
+
coins_list = json.loads(http_get("https://api.coingecko.com/api/v3/coins/list"))
|
|
56
|
+
# 17,564 entries as of April 2026
|
|
57
|
+
# Each: {'id': 'bitcoin', 'symbol': 'btc', 'name': 'Bitcoin'}
|
|
58
|
+
sol_coins = [c for c in coins_list if c['symbol'].lower() == 'sol']
|
|
59
|
+
# Returns 5+ entries — pick by name to get the real Solana: id='solana'
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Common workflows
|
|
63
|
+
|
|
64
|
+
### Simple price (one or many coins)
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
import json
|
|
68
|
+
data = json.loads(http_get(
|
|
69
|
+
"https://api.coingecko.com/api/v3/simple/price"
|
|
70
|
+
"?ids=bitcoin,ethereum,solana"
|
|
71
|
+
"&vs_currencies=usd,eur"
|
|
72
|
+
"&include_market_cap=true"
|
|
73
|
+
"&include_24hr_change=true"
|
|
74
|
+
))
|
|
75
|
+
for coin, info in data.items():
|
|
76
|
+
print(f"{coin}: ${info['usd']:,.0f} | 24h: {info['usd_24h_change']:.1f}% | MCap: ${info['usd_market_cap']/1e9:.1f}B")
|
|
77
|
+
# bitcoin: $76,286 | 24h: 1.4% | MCap: $1528.0B
|
|
78
|
+
# ethereum: $2,361 | 24h: 0.8% | MCap: $284.9B
|
|
79
|
+
# solana: $87 | 24h: -1.0% | MCap: $50.2B
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Response keys for each coin (when all flags enabled):
|
|
83
|
+
`usd`, `usd_market_cap`, `usd_24h_change`, `eur`, `eur_market_cap`, `eur_24h_change`
|
|
84
|
+
|
|
85
|
+
### Top coins by market cap (paginated)
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
import json
|
|
89
|
+
data = json.loads(http_get(
|
|
90
|
+
"https://api.coingecko.com/api/v3/coins/markets"
|
|
91
|
+
"?vs_currency=usd"
|
|
92
|
+
"&order=market_cap_desc"
|
|
93
|
+
"&per_page=10" # max 250
|
|
94
|
+
"&page=1" # 1-indexed; page=2 gives ranks 11-20 etc.
|
|
95
|
+
"&sparkline=false"
|
|
96
|
+
"&price_change_percentage=1h,7d,30d" # optional extra columns
|
|
97
|
+
))
|
|
98
|
+
for c in data:
|
|
99
|
+
print(f"#{c['market_cap_rank']} {c['symbol'].upper()} ${c['current_price']:,.2f} | {c['price_change_percentage_24h']:.1f}%")
|
|
100
|
+
# #1 BTC $76,281.00 | 1.4%
|
|
101
|
+
# #2 ETH $2,360.45 | 0.8%
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Full fields per entry: `id`, `symbol`, `name`, `image`, `current_price`, `market_cap`, `market_cap_rank`, `fully_diluted_valuation`, `total_volume`, `high_24h`, `low_24h`, `price_change_24h`, `price_change_percentage_24h`, `market_cap_change_24h`, `market_cap_change_percentage_24h`, `circulating_supply`, `total_supply`, `max_supply`, `ath`, `ath_change_percentage`, `ath_date`, `atl`, `atl_change_percentage`, `atl_date`, `roi`, `last_updated`
|
|
105
|
+
|
|
106
|
+
Extra columns added by `price_change_percentage=1h,7d,30d`: `price_change_percentage_1h_in_currency`, `price_change_percentage_7d_in_currency`, `price_change_percentage_30d_in_currency`
|
|
107
|
+
|
|
108
|
+
Pagination: use `page=2`, `page=3`, etc. with `per_page` up to 250. Results are 1-indexed — page 2 with per_page=5 returns ranks 6–10.
|
|
109
|
+
|
|
110
|
+
### Coin detail (full metadata)
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
import json
|
|
114
|
+
data = json.loads(http_get(
|
|
115
|
+
"https://api.coingecko.com/api/v3/coins/bitcoin"
|
|
116
|
+
"?localization=false" # skip 40+ language translations
|
|
117
|
+
"&tickers=false" # skip exchange ticker list (can be huge)
|
|
118
|
+
"&market_data=true"
|
|
119
|
+
"&community_data=false"
|
|
120
|
+
"&developer_data=false"
|
|
121
|
+
))
|
|
122
|
+
print(data['name']) # Bitcoin
|
|
123
|
+
print(data['symbol']) # btc
|
|
124
|
+
print(data['market_cap_rank']) # 1
|
|
125
|
+
print(data['market_data']['current_price']['usd']) # 76279
|
|
126
|
+
print(data['market_data']['ath']['usd']) # 126080
|
|
127
|
+
print(data['market_data']['ath_date']['usd']) # 2025-10-06T18:57:42.558Z
|
|
128
|
+
print(data['market_data']['circulating_supply']) # 20017459.0
|
|
129
|
+
print(data['description']['en'][:200])
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Top-level keys: `id`, `symbol`, `name`, `web_slug`, `asset_platform_id`, `platforms`, `categories`, `description`, `links`, `image`, `genesis_date`, `sentiment_votes_up_percentage`, `market_cap_rank`, `market_data`, `last_updated`
|
|
133
|
+
|
|
134
|
+
`market_data` sub-keys include: `current_price`, `ath`, `ath_change_percentage`, `ath_date`, `atl`, `atl_change_percentage`, `atl_date`, `market_cap`, `fully_diluted_valuation`, `total_volume`, `high_24h`, `low_24h`, `price_change_percentage_24h`, `price_change_percentage_7d`, `price_change_percentage_14d`, `price_change_percentage_30d`, `price_change_percentage_60d`, `price_change_percentage_200d`, `price_change_percentage_1y`, `circulating_supply`, `total_supply`, `max_supply`
|
|
135
|
+
|
|
136
|
+
All price/market fields are objects keyed by currency code: `data['market_data']['current_price']['usd']`, `['eur']`, `['btc']`, etc.
|
|
137
|
+
|
|
138
|
+
### Historical OHLCV
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
import json
|
|
142
|
+
# OHLCV candles: granularity auto-determined by `days`
|
|
143
|
+
# 1d = 30-min candles, 7d = 4-hr candles, 14d+ = daily candles
|
|
144
|
+
data = json.loads(http_get(
|
|
145
|
+
"https://api.coingecko.com/api/v3/coins/ethereum/ohlc?vs_currency=usd&days=7"
|
|
146
|
+
))
|
|
147
|
+
print(len(data)) # 42 candles for 7-day window
|
|
148
|
+
print(data[-1]) # [1776499200000, 2407.32, 2412.96, 2402.21, 2405.03]
|
|
149
|
+
# [timestamp_ms, open, high, low, close]
|
|
150
|
+
|
|
151
|
+
# Convert timestamp:
|
|
152
|
+
import datetime
|
|
153
|
+
ts_ms = data[-1][0]
|
|
154
|
+
dt = datetime.datetime.fromtimestamp(ts_ms / 1000, tz=datetime.timezone.utc)
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
`days` options: `1`, `7`, `14`, `30`, `90`, `180`, `365`, `max`
|
|
158
|
+
|
|
159
|
+
### Market chart (price + volume + market cap time series)
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
import json
|
|
163
|
+
# interval='daily' gives one point per day; omit for auto (hourly for <=90 days)
|
|
164
|
+
chart = json.loads(http_get(
|
|
165
|
+
"https://api.coingecko.com/api/v3/coins/bitcoin/market_chart"
|
|
166
|
+
"?vs_currency=usd&days=7&interval=daily"
|
|
167
|
+
))
|
|
168
|
+
# Keys: 'prices', 'market_caps', 'total_volumes'
|
|
169
|
+
# Each is a list of [timestamp_ms, value]
|
|
170
|
+
print(len(chart['prices'])) # 8 points for 7-day daily
|
|
171
|
+
print(chart['prices'][-1]) # [1776508393000, 76286.699...]
|
|
172
|
+
print(chart['total_volumes'][-1]) # [1776508393000, 80459560788.47...]
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Market chart by date range
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
import json, time
|
|
179
|
+
now = int(time.time())
|
|
180
|
+
thirty_days_ago = now - 30 * 86400
|
|
181
|
+
chart = json.loads(http_get(
|
|
182
|
+
f"https://api.coingecko.com/api/v3/coins/bitcoin/market_chart/range"
|
|
183
|
+
f"?vs_currency=usd&from={thirty_days_ago}&to={now}"
|
|
184
|
+
))
|
|
185
|
+
# Granularity: <1 day → minutely, 1-90 days → hourly, >90 days → daily
|
|
186
|
+
print(len(chart['prices'])) # 174 points for 7-day range (hourly)
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Search
|
|
190
|
+
|
|
191
|
+
```python
|
|
192
|
+
import json
|
|
193
|
+
results = json.loads(http_get("https://api.coingecko.com/api/v3/search?query=solana"))
|
|
194
|
+
# Top-level keys: 'coins', 'exchanges', 'icos', 'categories', 'nfts'
|
|
195
|
+
for c in results['coins'][:3]:
|
|
196
|
+
print(f"{c['id']} | {c['symbol']} | rank {c['market_cap_rank']}")
|
|
197
|
+
# solana | SOL | rank 7
|
|
198
|
+
# solana-name-service | SNS | rank 1902
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Search returns coins ordered by relevance, not market cap. First result is usually the canonical coin.
|
|
202
|
+
|
|
203
|
+
### Trending (top 7 searched in last 24h)
|
|
204
|
+
|
|
205
|
+
```python
|
|
206
|
+
import json
|
|
207
|
+
trending = json.loads(http_get("https://api.coingecko.com/api/v3/search/trending"))
|
|
208
|
+
# Top-level keys: 'coins', 'nfts', 'categories'
|
|
209
|
+
for item in trending['coins']:
|
|
210
|
+
c = item['item']
|
|
211
|
+
print(f"{c['name']} ({c['symbol']}) #{c['market_cap_rank']}")
|
|
212
|
+
# Item keys: id, coin_id, name, symbol, market_cap_rank, thumb, small, large,
|
|
213
|
+
# slug, price_btc, score, data
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
`data` sub-object includes sparkline image URL, price/volume/market cap info if available.
|
|
217
|
+
|
|
218
|
+
### Global market overview
|
|
219
|
+
|
|
220
|
+
```python
|
|
221
|
+
import json
|
|
222
|
+
global_data = json.loads(http_get("https://api.coingecko.com/api/v3/global"))
|
|
223
|
+
gd = global_data['data']
|
|
224
|
+
print(f"Total market cap: ${gd['total_market_cap']['usd']/1e12:.2f}T") # $2.66T
|
|
225
|
+
print(f"24h volume: ${gd['total_volume']['usd']/1e9:.1f}B") # $156.6B
|
|
226
|
+
print(f"BTC dominance: {gd['market_cap_percentage']['btc']:.1f}%") # 57.3%
|
|
227
|
+
print(f"Active coins: {gd['active_cryptocurrencies']}") # 17,564
|
|
228
|
+
print(f"Active exchanges: {gd['markets']}") # 1,475
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Coin categories (market cap by sector)
|
|
232
|
+
|
|
233
|
+
```python
|
|
234
|
+
import json
|
|
235
|
+
cats = json.loads(http_get(
|
|
236
|
+
"https://api.coingecko.com/api/v3/coins/categories?order=market_cap_desc"
|
|
237
|
+
))
|
|
238
|
+
# 691 categories as of April 2026
|
|
239
|
+
for cat in cats[:5]:
|
|
240
|
+
print(f"{cat['name']}: ${cat['market_cap']/1e9:.1f}B | 24h: {cat['market_cap_change_24h']:.1f}%")
|
|
241
|
+
# Smart Contract Platform: $2204.8B | 24h: 0.9%
|
|
242
|
+
# Layer 1 (L1): $2171.5B | 24h: 1.1%
|
|
243
|
+
|
|
244
|
+
# Category keys: id, name, market_cap, market_cap_change_24h, content,
|
|
245
|
+
# top_3_coins_id, top_3_coins, volume_24h, updated_at
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Token price by contract address (ERC-20 and other chains)
|
|
249
|
+
|
|
250
|
+
```python
|
|
251
|
+
import json
|
|
252
|
+
# Platform IDs: ethereum, binance-smart-chain, polygon-pos, avalanche, solana, etc.
|
|
253
|
+
token = json.loads(http_get(
|
|
254
|
+
"https://api.coingecko.com/api/v3/simple/token_price/ethereum"
|
|
255
|
+
"?contract_addresses=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" # USDC
|
|
256
|
+
"&vs_currencies=usd"
|
|
257
|
+
))
|
|
258
|
+
print(token)
|
|
259
|
+
# {'0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48': {'usd': 0.999861}}
|
|
260
|
+
# Key is the lowercased contract address
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
## vs_currencies options
|
|
264
|
+
|
|
265
|
+
63 currencies supported (confirmed live). Common ones:
|
|
266
|
+
|
|
267
|
+
**Fiat**: `usd`, `eur`, `gbp`, `jpy`, `aud`, `cad`, `chf`, `cny`, `inr`, `krw`, `brl`, `mxn`, `sgd`, `hkd`, `nok`, `sek`, `dkk`, `nzd`, `zar`, `thb`, `try`, `aed`, `sar`, `myr`, `php`, `idr`, `pln`, `czk`, `huf`, `ron`
|
|
268
|
+
|
|
269
|
+
**Crypto**: `btc`, `eth`, `ltc`, `bch`, `bnb`, `eos`, `xrp`, `xlm`, `link`, `dot`, `yfi`, `sol`
|
|
270
|
+
|
|
271
|
+
**Commodities**: `xag` (silver), `xau` (gold)
|
|
272
|
+
|
|
273
|
+
Get the full list:
|
|
274
|
+
```python
|
|
275
|
+
currencies = json.loads(http_get("https://api.coingecko.com/api/v3/simple/supported_vs_currencies"))
|
|
276
|
+
# Returns list of 63 strings
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
## Endpoints that require Pro API (return HTTP 401)
|
|
280
|
+
|
|
281
|
+
- `/coins/{id}/history?date=DD-MM-YYYY` — historical price on a specific date
|
|
282
|
+
- `/coins/markets` with `category=` filter (the parameter is silently ignored, not 401)
|
|
283
|
+
- `/coins/{id}/contract/{address}` — full contract token details
|
|
284
|
+
|
|
285
|
+
Free tier alternatives:
|
|
286
|
+
- For historical price on date: use `/market_chart/range` with a narrow time window
|
|
287
|
+
- For category filtering: fetch `/coins/markets` unfiltered and filter client-side using `id` from `/coins/categories`
|
|
288
|
+
|
|
289
|
+
## Ping / health check
|
|
290
|
+
|
|
291
|
+
```python
|
|
292
|
+
import json
|
|
293
|
+
ping = json.loads(http_get("https://api.coingecko.com/api/v3/ping"))
|
|
294
|
+
print(ping) # {'gecko_says': '(V3) To the Moon!'}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
Note: ping still counts against the rate limit. Don't use it to check if a 429 has resolved — just wait 65 seconds and retry your actual call.
|
|
298
|
+
|
|
299
|
+
## Gotchas
|
|
300
|
+
|
|
301
|
+
- **Rate limit is much stricter than advertised** — The official docs say "30 calls/min" but in practice you get 429 on call 3-4 with no delay between calls. Observed `Retry-After: 60` in the response header. Treat it as "3 calls/minute, wait 65s on 429." Using `time.sleep(5)` between calls in a loop is safe.
|
|
302
|
+
|
|
303
|
+
- **Unknown coin IDs return `{}`, not an error** — `?ids=BTC` (uppercase) and `?ids=not_a_real_coin` both return an empty dict `{}`. Always check that the key you expect exists before accessing it.
|
|
304
|
+
|
|
305
|
+
- **Symbol lookup requires `/coins/list` + client-side filter** — There's no "get by symbol" endpoint. Multiple coins share any given symbol. After fetching the list (17,564 entries), filter by `symbol` and pick by `name`.
|
|
306
|
+
|
|
307
|
+
- **Coin ID casing matters** — IDs are always lowercase kebab-case: `bitcoin`, `ethereum`, `shiba-inu`. Uppercase or camelCase will silently return `{}`.
|
|
308
|
+
|
|
309
|
+
- **OHLCV granularity is automatic** — The `days` parameter determines candle size automatically: `1` → 30-min candles, `7`/`14` → 4-hr candles, `30`+ → daily candles. You cannot override this on the free tier.
|
|
310
|
+
|
|
311
|
+
- **`interval=daily` in market_chart affects point count** — Without `interval=daily`, a 7-day window returns hourly data (~168 points). With it, you get ~8 points. Choose based on whether you need resolution or summary.
|
|
312
|
+
|
|
313
|
+
- **market_chart timestamps are in milliseconds** — Divide by 1000 for standard Unix time: `datetime.fromtimestamp(ts / 1000)`.
|
|
314
|
+
|
|
315
|
+
- **`/coins/list` is expensive (rate-limit-wise)** — It returns 17,564 entries and costs one API call. Fetch once, store in a variable, filter locally. Don't call it in a loop.
|
|
316
|
+
|
|
317
|
+
- **Pagination is 1-indexed** — `page=1` returns items 1–N, `page=2` returns N+1–2N. `page=0` returns the same as `page=1` (it doesn't error).
|
|
318
|
+
|
|
319
|
+
- **`per_page` max is 250** — Requesting more than 250 per page silently returns 250. To get the full top-500, make two calls: `page=1&per_page=250` then `page=2&per_page=250`.
|
|
320
|
+
|
|
321
|
+
- **Contract address keys are lowercased** — When using `/simple/token_price`, the response key is the lowercased contract address regardless of what case you sent. Always call `.lower()` before using addresses as dict keys.
|
|
322
|
+
|
|
323
|
+
- **`tickers=false` is important for `/coins/{id}`** — Without it, the response includes a massive list of exchange tickers that can make the payload very large and slow to parse. Always set `tickers=false` unless you specifically need exchange data.
|
|
324
|
+
|
|
325
|
+
- **ETH priced against BTC is supported** — `vs_currencies=btc` works: `ethereum` returns `{'btc': 0.03095861}`. Crypto-to-crypto pairs work the same as fiat pairs.
|