Index of every page on this site: llms.txt
All skills
vo1ganin avatar

/coinmarketcap

@8100600
Run it yourself

Expert assistant for CoinMarketCap Pro API — price quotes, listings, historical OHLCV, market metrics, Fear & Greed Index, CMC100/CMC20 indices, exchange data, DEX data, airdrops, trending, community sentiment. Covers 10+ endpoint categories across REST + MCP + x402 pay-per-call modes. Use when the user wants: current or historical crypto prices, market cap rankings, top gainers/losers, trending coins, OHLCV candles, exchange volume data, DEX token details, Fear & Greed Index readings, global market metrics (total mcap, BTC dominance), airdrop discovery, or fiat conversion rates. Enforces: budget awareness (credits, not requests), CMC IDs over symbols, aggressive batching (100-200 items per call), client-side caching, live credit_count logging.

Use this Skill: https://skilld.dev/gh/vo1ganin/crypto-claude-skills/coinmarketcap

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencespatterns.md

≈1.5k tokens on demand. Your agent reads this file only when SKILL.md points to it.

CoinMarketCap — Patterns & Optimization

1. Resolve symbols → IDs once, cache forever

Symbols are unstable (BTC could map to multiple CMC IDs; symbols can change). IDs are permanent.

# Once at app start
r = httpx.get(
    "https://pro-api.coinmarketcap.com/v1/cryptocurrency/map",
    params={"symbol": "BTC,ETH,SOL,USDC,BONK"},
    headers={"X-CMC_PRO_API_KEY": KEY},
)
# Cache {symbol: id} map in a local file or Redis

Cache invalidation: refresh the map monthly at most. IDs don't change.

2. Batch IDs — up to 100 per call for most endpoints

Never:

# DON'T — 100 credits
for sym in ["BTC","ETH","SOL",...,]:
    quote = httpx.get(f"{BASE}/v2/cryptocurrency/quotes/latest?symbol={sym}", ...)

Always:

# DO — 1 credit
ids = ",".join(map(str, coin_ids))  # up to 100 IDs
quote = httpx.get(f"{BASE}/v2/cryptocurrency/quotes/latest?id={ids}", ...)

listings/latest accepts limit up to 5000 but each 200 slice = 1 credit — use limit=200 for top-tier and batch through start cursor if you need more.

3. Cache aggressively on your side

Typical data freshness:

  • Listings / quotes: updated once per minute server-side. Cache 30-60s on client.
  • Historical OHLCV: immutable past data. Cache indefinitely.
  • Trending: updates slowly. Cache 5-15 min.
  • Fear & Greed: daily update. Cache 1h+.
  • Global metrics: minute-level updates. Cache 60s.
  • Exchange metadata (info, map): monthly refresh.

Every cached hit is a credit saved.

from functools import lru_cache
import time

@lru_cache(maxsize=256)
def get_map_for_symbol(symbol: str) -> int:
    # Once per symbol per process lifetime
    r = httpx.get(f"{BASE}/v1/cryptocurrency/map?symbol={symbol}", headers=HEADERS)
    return r.json()["data"][0]["id"]

_quotes_cache: dict[tuple, tuple[float, dict]] = {}

def get_quotes(ids: tuple[int, ...], ttl: int = 60) -> dict:
    key = tuple(sorted(ids))
    now = time.time()
    if key in _quotes_cache and now - _quotes_cache[key][0] < ttl:
        return _quotes_cache[key][1]
    r = httpx.get(f"{BASE}/v2/cryptocurrency/quotes/latest",
                  params={"id": ",".join(map(str, key))}, headers=HEADERS)
    data = r.json()["data"]
    _quotes_cache[key] = (now, data)
    return data

4. Avoid convert= unless you need it

Every extra currency beyond the first adds 1 credit. If you only use USD, don't pass convert=USD,EUR,GBP "just in case".

# Default is already USD — no need to specify for most cases
params = {"id": ids}                           # 1 credit
# params = {"id": ids, "convert": "USD,EUR"}   # 2 credits

5. Paginate listings with start cursor

For > 200 coins:

page = 1
while True:
    r = httpx.get(f"{BASE}/v1/cryptocurrency/listings/latest",
                  params={"start": (page - 1) * 200 + 1, "limit": 200},
                  headers=HEADERS)
    data = r.json()["data"]
    if not data:
        break
    process(data)
    page += 1
# 1 credit per page of 200

Avoid limit=5000 in a single call unless you really need all 5000 points — it's 25 credits vs 1-25 paginated.

6. Use /v1/key/info as the first call of any session

Costs 0 credits. Tells you:

  • Remaining monthly budget (plan ahead)
  • Current rate-limit window
  • Plan details
def check_budget():
    r = httpx.get(f"{BASE}/v1/key/info", headers=HEADERS)
    data = r.json()["data"]
    used = data["usage"]["current_month"]["credits_used"]
    limit = data["plan"]["credit_limit_monthly"]
    print(f"CMC: {used:,}/{limit:,} credits used ({100*used/limit:.1f}%)")
    return data

Stop batch jobs if credits_left drops below threshold (e.g., 5% of monthly).

7. Use listings/historical snapshots, not loops over quotes/historical

If you need "top 100 by mcap on a specific past date":

# ONE call: 1 credit per 100 cryptos (since historical is 100 not 200)
r = httpx.get(f"{BASE}/v1/cryptocurrency/listings/historical",
              params={"date": "2024-01-15", "limit": 100},
              headers=HEADERS)
# = 1 credit, done

Don't loop quotes/historical over 100 coins — that's 100 calls.

8. Retry with exponential backoff on 500

import time, httpx

def fetch_with_retry(url, params, max_retries=5):
    for attempt in range(max_retries):
        r = httpx.get(url, params=params, headers=HEADERS, timeout=30)
        if r.status_code in (500, 502, 504):
            time.sleep(2 ** attempt)
            continue
        if r.status_code == 429:
            time.sleep(60)  # wait full minute window
            continue
        r.raise_for_status()
        return r.json()
    raise RuntimeError("Max retries exceeded")

9. Log status.credit_count on every call

Production bots should track running credit spend per session:

total_spent = 0

def cmc_get(path, **params):
    global total_spent
    r = httpx.get(f"{BASE}{path}", params=params, headers=HEADERS).json()
    spent = r["status"]["credit_count"]
    total_spent += spent
    print(f"[cmc] {path} → {spent} credits (session total {total_spent})", file=sys.stderr)
    return r["data"]

Helps catch unexpected expensive calls early.

10. When to use CMC MCP / CLI / x402 instead of Pro API

Alternatives listed in official docs:

Option When
Pro API (this skill) Production apps, custom integrations
CMC MCP (/api/mcp/) AI agents with tool-use (Claude, Cursor, Windsurf, ChatGPT, Codex)
CMC CLI Interactive terminal exploration
x402 (USDC pay-per-call) One-off queries, no API key, no subscription

This skill focuses on the Pro API (REST) path. For MCP integration, see docs/coinmarketcap/llms-full.txt sections "CMC MCP", "CMC MCP for Claude Code" etc.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts1mo3 checks · Risk SAFE
  • Gen Agent Trust Hub1mo

    The skill provides a comprehensive interface for the CoinMarketCap Pro API, including scripts for batch price fetching, historical data, and global market metrics. It focuses on budget efficiency and proper API usage. A low-risk finding is identified in the indirect prompt injection category because the skill ingests external content from API endpoints that could potentially contain instructions intended to influence the agent's behavior.

  • Socket1mo

    No alerts

  • Snyk1mo

    Risk: LOW · No issues

Signed by skilld at 8100600. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated 7 months ago
compatibility
{
  "tools": [
    "Bash",
    "Write",
    "Read"
  ]
}

README badge

README badge for vo1ganin/crypto-claude-skills/coinmarketcap