{"uid":"cap_4o5j9aleM7UVZpVsbuRha","slug":"rate-hub-api-v1-rates-crypto-asset-rates-lookup-036cff7f","name":"rate-hub API – /v1/rates (Crypto & Asset Rates Lookup)","description":"**Access.** A deployment runs in one of two modes and the free `GET /v1/x402` tells which: it answers `200` with the offer on an x402 deployment and `404` on a classic one.\n\n- **x402 deployment** (the public one). There is no API key. A payment of USDC on Base buys a credit token for a pack of requests. Call a paid route without credentials: the answer is `402` with the offer in the `PAYMENT-REQUIRED` header (base64 JSON) and in the body. Pay by repeating the request with a `PAYMENT-SIGNATURE` header (base64 JSON x402 v2 `PaymentPayload`, scheme `exact`). The paying response is the normal answer plus `X-Credit-Token` (your token), `X-Credit-Remaining` and `PAYMENT-RESPONSE`. Keep the token and send `Authorization: Bearer <token>` on every later request. A token that is unknown, spent or expired, and any payment that cannot be accepted, answer `402` again: every payment problem is a `402` with a snake_case reason in `error`, never a `400`. On `/mcp` the same problems come back as `200` tool results, see `/mcp`. A `503` with `Retry-After` can mean the same payment is being processed right now: retry shortly. If the payment facilitator does not answer, the answer is `502` and nothing is charged.\n- **Classic deployment.** The client sends its key in the `X-API-Key` header. A missing or unknown key answers `401`.\n\nPaid routes: every `/v1` path except `GET /v1/x402`, and MCP `tools/call`. Free: `GET /v1/x402`, `/healthz`, `/readyz`, `/version`, `/openapi.yaml`, `/openapi.json` and `/.well-known/x402` (x402 deployments only), `/docs` (with `/docs/behavior` and `/docs/behavior.md`), `/llms.txt`, and the MCP methods `initialize`, `ping`, `tools/list` and `notifications/*`. On an x402 deployment every served request costs one credit, whatever its status, except `5xx`, which is refunded. Requests that match no route (`404`, `405`) are free.\n\nClient rules, in order. Read these before the paths.\n\n- Ignore unknown JSON fields. The server adds fields without a new major version.\n- Map an unknown enum value to an `unknown` case. A Swift `Codable` enum with no fallback crashes the decode and drops the whole response.\n- Honor `Retry-After` on `429` and `503`. The header is always an integer number of seconds, never an HTTP-date. `pending` rates carry `retry_after` in seconds for that asset only.\n- Fiat live quotes: `source_code` `s10` is a live rate table with no observation time of its own, so `as_of` is the fetch instant (about every 30 minutes by default); `day_change_pct` and `high_volatility` stay a move against the last rate of the previous UTC day, not against the previous poll. A currency that table does not cover keeps its last quote (`source_code` `s3`, `as_of` midnight UTC of that document's date) and turns `stale` after the fiat stale limit. Fiat daily quotes (`/v1/rates/daily`, `source_code` `s3`): `as_of` is midnight UTC of the upstream document date (the rate for that UTC calendar day), not the fetch instant. When present, optional `day` (`YYYY-MM-DD`) repeats that calendar day explicitly. Optional `fetched_at` is when rate-hub last received the live quote from upstream.\n- Freshness: live responses (`/v1/rates`, `/v1/top`, `/v1/assets`, `/v1/meta`, errors) carry `Cache-Control: no-cache`, so a client or CDN must ask again before reusing one. A refresh always returns the newest snapshot rate-api holds, so the collector's polling cadence is the floor on freshness. Judge a price by `as_of` (when the price was observed) and `fetched_at` (when rate-hub last refreshed it), not by when you asked.\n- `server_time`, quote `as_of`, and quote `fetched_at` use RFC3339 with millisecond precision (fractional seconds trimmed; no sub-millisecond noise).\n- Integration tests can observe `pending` by requesting a catalog uid that has no row in the loaded in-memory quote snapshot (for example a cold asset before the first lazy fetch).\n- Back off exponentially with jitter. Do not retry in a tight loop.\n- Prices and percent changes are decimal strings, never JSON numbers. Parse them with a decimal type. Do not use binary floating point.\n\nEdge cases this schema does not show (dynamic coins and their changing uids, placeholder icons, series limits, data lifetimes) are in the [behaviour notes](/docs/behavior) ([raw Markdown](/docs/behavior.md)).\n\nConventions: lowercase `snake_case`, full field names, statuses as strings, versioned under `/v1`. Changes inside v1 are additive only.\n\nPrices are rounded to 10 significant digits. This service is an indicative cache, not an oracle. Live `/v1/rates` quotes are not a full history product; additive `/v1/rates/daily` returns one immutable USD (or requested `vs`) rate per catalog uid per UTC calendar day for backfill and prewarm (see those paths for day definitions and archive limits).","url":"https://x402-v1.sky-1.org/v1/rates?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method","bodyType","body"],"properties":{"body":{"type":"object"},"type":{"type":"string","const":"http"},"method":{"enum":["POST","PUT","PATCH"],"type":"string"},"headers":{"type":"object","additionalProperties":{"type":"string"}},"bodyType":{"enum":["json","form-data","text"],"type":"string"},"queryParams":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object"}}}}},"responseSchema":{"type":"json","example":{"build":"0.18.0-a1b2c3d","rates":[{"uid":200000001,"type":"crypto","as_of":"2026-10-10T12:00:00.000Z","change":{"h24":"1.25","quote":"usd"},"market":{"rank":1,"quote":"usd","market_cap":"1330000000000","volume_24h":"28000000000"},"prices":{"usd":"67250.12"},"status":"ok","symbol":"btc","fetched_at":"2026-10-10T12:00:03.000Z","source_code":"agg"},{"uid":200000002,"type":"crypto","as_of":"2026-10-10T12:00:00.000Z","change":{"h24":"-0.4","quote":"usd"},"market":{"rank":2,"quote":"usd","market_cap":"314000000000","volume_24h":"14000000000"},"prices":{"usd":"2610.4"},"status":"ok","symbol":"eth","fetched_at":"2026-10-10T12:00:03.000Z","source_code":"agg"}],"server_time":"2026-10-10T12:00:03.500Z"}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.05","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.05/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.05","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.05","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_PQbVtS8qP0byOlYZ8PdKP","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.05","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Returns current prices, 24h change, market cap, and volume for one or more crypto assets (e.g. BTC, ETH) via an aggregated data feed.","exampleAgentPrompt":"What are the current prices, 24-hour changes, and market caps for Bitcoin and Ethereum right now?","exampleUseCases":[{"title":"Real-time crypto portfolio valuation","prompt":"Pull the latest USD prices and 24h changes for BTC and ETH so I can see how my portfolio is doing today."},{"title":"DeFi app market data feed","prompt":"Fetch the current aggregated prices, market caps, and 24h volumes for the top crypto assets to display on my DeFi dashboard."},{"title":"Crypto price alert threshold check","prompt":"Get me the current BTC price and its 24-hour percentage change — I want to know if it's moved more than 5% today."}],"resultDescription":"Returns a JSON object containing a build version, server timestamp, and an array of rate objects — each with symbol, type (crypto), USD price, 24h price change, market rank, market cap, 24h volume, status, fetched_at timestamp, and aggregated source code.","failureModes":["402 Payment Required — no valid Bearer token or payment provided; response includes offer details and x402 payment instructions","402 with snake_case error — token unknown, spent, or expired","404 — endpoint not found on classic (non-x402) deployment","500 — upstream aggregator data unavailable or server error","Malformed request body returns 402 (not 400) for payment-related issues"],"whenToPreferThis":"Choose this endpoint when you need aggregated, real-time cryptocurrency price data (USD prices, 24h change, market cap, volume) with per-call micropayment access via USDC on Base (x402 protocol) and no API key registration required. Prefer it for lightweight, pay-as-you-go crypto rate lookups without a subscription commitment.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-11T12:46:59.136Z","isFirstParty":false,"canonicalSlug":"rate-hub-api-v1-rates-crypto-asset-rates-lookup-036cff7f"}