{
  "slug": "cache-crypto-pricing-api-edge",
  "title": "Cache Coinmarketcap Crypto Pricing API at Edge",
  "metaTitle": "Cache Coinmarketcap Crypto Pricing - RealComposer",
  "metaDescription": "Cache coinmarketcap crypto pricing api at edge. Shield CoinMarketCap with 300s GET edge cache; cache key uses query params on.",
  "headline": "Edge TTL shield for Frontend / Web CoinMarketCap calls",
  "category": "caching",
  "categoryLabel": "Edge Caching & Rate Limits",
  "urgency": 8,
  "clientPlatform": "Frontend / Web",
  "upstreamServices": [
    "CoinMarketCap"
  ],
  "searchIntentQuery": "cache coinmarketcap crypto pricing api at edge",
  "directAnswerSummary": "To cache coinmarketcap crypto pricing api at edge, set cacheTtlSeconds on a GET pipeline targeting https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?symbol={{query.symbol}}. Identical query strings reuse Cloudflare caches.default before upstream sees traffic.",
  "problem": {
    "title": "Uncached CoinMarketCap spikes cost and latency",
    "explanation": "Every Frontend / Web visitor can trigger a fresh CoinMarketCap call. Bursts exhaust per-minute quotas even when data changes slowly.",
    "risks": [
      "Thundering herds after cache expiry on the origin",
      "Analytics skewed by client-side retry storms",
      "Support tickets blaming \"API downtime\" during spikes"
    ]
  },
  "solutionSteps": [
    {
      "stepNumber": 1,
      "title": "Store upstream credentials in Secret Vault",
      "description": "Store COINMARKETCAP_API_KEY in the vault. Frontend / Web never embeds the raw secret, only a revocable rc_live_ client token."
    },
    {
      "stepNumber": 2,
      "title": "Configure upstream steps and output mapping",
      "description": "Use GET against https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?symbol={{query.symbol}}. Allowed origins on the client token should match set cache ttl to 300s so repeat gets with the same query string hit caches.default."
    },
    {
      "stepNumber": 3,
      "title": "Call from Frontend / Web",
      "description": "Allowed origins on the token should list every Frontend / Web host that calls this URL.",
      "codeSnippet": "const res = await fetch('https://realcomposer.com/v1/workspace/cache-crypto-pricing-api-edge', {\n  headers: { Authorization: 'Bearer rc_live_your_token' }\n});"
    }
  ],
  "pipelineConfig": {
    "name": "Cache Coinmarketcap Crypto Pricing API at Edge",
    "method": "GET",
    "cacheTtlSeconds": 300,
    "authMode": "client_token",
    "steps": [
      {
        "stepKey": "cmc",
        "upstreamUrlTemplate": "https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?symbol={{query.symbol}}",
        "httpMethod": "GET",
        "headersTemplate": {
          "X-CMC_PRO_API_KEY": "{{secrets.COINMARKETCAP_API_KEY}}"
        },
        "timeoutMs": 3000
      }
    ],
    "outputMapping": {
      "version": 1,
      "fields": [
        {
          "targetPath": "price",
          "sourcePath": "data.BTC.quote.USD.price",
          "type": "number",
          "sourceStep": "cmc"
        },
        {
          "targetPath": "symbol",
          "sourcePath": "data.BTC.symbol",
          "type": "string",
          "sourceStep": "cmc"
        }
      ]
    }
  },
  "sampleBloatedInput": {
    "requestId": "req_cache-cr",
    "upstreamLatencyMs": 142,
    "audit": {
      "region": "edge",
      "trace": "cache-crypto-pricing-api-edge"
    },
    "payload": {
      "id": "sample_id",
      "status": "active",
      "nested": {
        "tags": [
          "demo"
        ],
        "internal": true
      },
      "unused_blob": {
        "foo": "bar",
        "bar": "baz"
      }
    }
  },
  "sampleSlimmedOutput": {
    "price": "sample",
    "symbol": "sample"
  },
  "curlSnippet": "curl -X GET \"https://realcomposer.com/v1/workspace/cache-crypto-pricing-api-edge\" \\\n  -H \"Authorization: Bearer rc_live_client_token\"",
  "faqs": [
    {
      "question": "Can Frontend / Web call CoinMarketCap without holding the production key?",
      "answer": "Log request IDs for cache-crypto-pricing-api-edge, not raw CoinMarketCap payloads, because upstream bodies may include PII."
    },
    {
      "question": "How do I forward JSON bodies to POST upstreams?",
      "answer": "cache-crypto-pricing-api-edge forwards client JSON to POST upstreams unchanged; secrets interpolate only in URLs and header templates."
    },
    {
      "question": "What happens if an upstream step times out?",
      "answer": "Allowed origins on the cache-crypto-pricing-api-edge client token restrict which domains may call the edge URL."
    }
  ],
  "relatedRecipeSlugs": [
    "api-composition-tool-low-code",
    "cache-rest-api-without-redis",
    "call-stripe-from-flutterflow-securely"
  ],
  "updatedAt": "2026-11-20",
  "links": {
    "page": "https://realcomposer.com/recipes/cache-crypto-pricing-api-edge",
    "markdown": "https://realcomposer.com/recipes/cache-crypto-pricing-api-edge.md",
    "json": "https://realcomposer.com/recipes/cache-crypto-pricing-api-edge.json",
    "install": "https://realcomposer.com/dashboard/pipelines/new?recipe=cache-crypto-pricing-api-edge&via=agent"
  }
}