# rate-hub > Indicative fiat and crypto exchange rates over a small HTTP API and an MCP server. One catalog of assets with stable integer uids, live prices, a top list, immutable daily history and chart series. Prices are decimal strings. Start with search_assets (or GET /v1/assets) to find the uid of an asset, then price it with get_rates (or POST /v1/rates). Do not guess uids. - Auth: there is no API key. Send the credit token in the header Authorization: Bearer on every /v1/* request and on MCP tools/call. Discovery routes (/llms.txt, /openapi.yaml, /docs, /healthz, /readyz) and MCP initialize, tools/list, resources/list and resources/read need no token. Every other call without a valid token answers 402; see Pay with x402 below. - Uids are ranged by class: uid = class*1e8 + seq. Fiat is 1xxxxxxxx (usd is 100000001), crypto is 2xxxxxxxx (btc is 200000001). Coins registered on demand use 250000001 and up; they can expire and come back under a new uid, so match them by symbol or name (search again), not by stored uid. - Prices and percent changes are decimal strings, never JSON numbers. Parse them with a decimal type. - A rate with status pending is not priced yet; wait retry_after seconds for that asset and ask again. Honor Retry-After (integer seconds) on 429 and 503, back off with jitter. - A daily rate with status out_of_range is final: do not retry it (a day after today UTC, a day before the archive, a crypto day before the first day of its history, or no price that day). - Ignore unknown JSON fields. Treat an unknown enum value as unknown. - Errors carry a stable string code and a numeric id; the dictionary is GET /v1/errors. ## Connect over MCP - [MCP endpoint](/mcp): streamable HTTP, JSON-RPC 2.0, POST only (GET and DELETE answer 405). Same credit token, rate limits and overload guard as /v1. A JSON-RPC batch that carries a paid method, or a request the MCP SDK rejects, is refused with the offer when it has a payment or no credentials, before anything is settled (HTTP 402, or an isError result for a single tools/call with a usable id); with a credit token the 400 comes back (invalid_body for a batch) and the credit counts as used, as for any client error on /v1 (4xx spends a credit, 5xx refunds). A batch of free methods only is rejected with 400 invalid_body. A token holder must send Accept with both application/json and text/event-stream. The body is capped at max_body_bytes (413 body_too_large). - Claude Code: claude mcp add --transport http rate-hub /mcp --header "Authorization: Bearer " (replace with the origin this file was served from). ## MCP tools - get_rates: batch indicative prices for catalog uids (POST /v1/rates). Arguments: assets (uids, at most 100), vs (quote codes such as usd, eur, btc, at most 3), optional include (change, market, sparkline; sparkline is large), optional source (a code such as s1: that source's own price, unsupported when it has none). Limits shown are defaults; get_meta returns the live ones. Over-limit errors name the number, e.g. "assets exceeds max_assets (100)". - search_assets: find uids (GET /v1/assets). Arguments: q (free text), symbol (non-unique, all matches returned), symbols (several tickers in one call, e.g. btc, eth, sol), candidate (the uid of a candidates entry from an earlier q search; registers that coin on demand; use alone), chain+contract (an unknown Solana mint can be registered on demand; mints are case-sensitive, never lower-case them), limit (1..1000; 0 is an error) and after for paging. Without any filter the default limit is 50; candidates are capped at 5. - get_top: top crypto assets by market rank with price, change and market (GET /v1/top). Arguments: limit (1..250, default 20), vs, include_market (default true; false drops the market block). - get_daily: immutable daily rates for uids and UTC days (POST /v1/rates/daily). Arguments: assets, vs, days (past UTC days, YYYY-MM-DD). Item status: ok, out_of_range (final: before the archive, after today UTC, crypto before the first day of its history, or before listing; crypto history older than about a year is served from s8 daily candles), pending (retry), unsupported (unknown uid). - get_series: price history of one asset for charts (GET /v1/rates/series). Arguments: uid (crypto, any range; a fiat uid: 1d and 7d about 30 minute points, 30d, 90d, 1y and max one point per UTC day from the archive start, a cold range may need a retry to fill), vs, range (1d, 7d, 30d, 90d, 1y, max), max_points (2..500, default 100; MCP downsamples, REST always returns up to 500). - get_categories: coin categories (layer-1, stablecoins, ...) with the catalog uids in each (GET /v1/categories). No arguments. Refreshed about once a day (as_of); a 503 not_ready means the first refresh has not run yet, a 404 means the server has categories off. - get_meta: limits, supported quote currencies and API version (GET /v1/meta). ## MCP resources - ratehub://docs/behavior (text/markdown): the behaviour notes, the same text as /docs/behavior.md. Read it with resources/read; resources/list shows it. The tool descriptions point to it. ## HTTP API - [OpenAPI contract](/openapi.yaml): the full wire contract, OpenAPI 3.1. - [Swagger UI](/docs): human-readable docs. - [Behaviour notes](/docs/behavior.md): edge cases the schema does not show (dynamic coins, icons, series limits, data lifetimes). - [Error dictionary](/v1/errors): every error code with numeric id, origin and meaning (credit token required). - [POST /v1/rates](/openapi.yaml): batch indicative prices, optionally from one named source code. - [GET /v1/top](/openapi.yaml): top crypto assets by rank. - [GET /v1/snapshot/{class}](/openapi.yaml): one cacheable document of live rates for a class (crypto top 250, or fiat), with ETag and 304, for app cold start. - [POST /v1/rates/daily](/openapi.yaml): immutable daily rates for uids and UTC days. - [GET /v1/rates/daily/{day}](/openapi.yaml): all fiat assets for one UTC day. - [GET /v1/rates/series](/openapi.yaml): price history of one asset over a range. - [GET /v1/assets](/openapi.yaml): catalog lookup. - [POST /v1/assets/lookup](/openapi.yaml): batch lookup of catalog assets by chain and token contract. - [GET /v1/categories](/openapi.yaml): coin categories with the catalog uids in each. - [GET /v1/icons/{uid}](/openapi.yaml): coin icon bytes for one non-fiat asset. - [GET /v1/meta](/openapi.yaml): limits, quote currencies, version. ## Feedback - Feedback and feature requests are welcome at https://heaven8.com/feedback. Start your message with "rate-hub:" so the owner knows which service it is about. There is no commitment to build them. ## Optional - [Liveness](/healthz): process is serving HTTP. - [Readiness](/readyz): 200 once the first rate snapshot is loaded. - [Version](/version): API version and build id, no key needed. ## Pay with x402 This deployment sells access, not keys. One payment of 0.05 USDC (exact scheme, x402 v2) buys 500 requests valid for 30 days: $0.0001 per request. The amount in the payment requirements is the price of the whole pack, not of one call. 1. Call any paid route without credentials (GET /v1/x402 describes the offer for free): the answer is HTTP 402 with the requirements in the PAYMENT-REQUIRED header (base64 JSON) and in the body. 2. Sign a payment for one entry of accepts and repeat the request with the PAYMENT-SIGNATURE header (base64 JSON PaymentPayload). The payment is verified and settled first; the answer is the normal response plus X-Credit-Token (your credit token) and X-Credit-Remaining. 3. Keep the token and send it as Authorization: Bearer on every /v1/* request and on /mcp tools/call. Each served request costs one credit, including one answered with a client error (4xx); a 5xx answer is refunded. X-Credit-Remaining shows what is left. A 402 with invalid_credit_token means the pack is spent or expired: pay again. 4. The token is returned once, on the paying response. A replayed payment is refused with 402 payment_already_redeemed and never returns it, so store the token as soon as you get it. 5. Every payment problem on /v1 answers 402 (never 400) with PAYMENT-REQUIRED and a snake_case reason in the error field: invalid_payload, invalid_x402_version, invalid_network, invalid_payment_requirements, a recipient or value mismatch, a facilitator reason, payment_already_redeemed, invalid_credit_token. On /mcp the same applies to one tools/call, but the answers are shaped for MCP clients. Pay with the PAYMENT-SIGNATURE header or use the token as on /v1. The paying call returns x402/credit-token, x402/credit-remaining and x402/payment-response in result._meta (besides the HTTP headers); a call with a token returns x402/credit-remaining. A payment problem or any gate error on such a call is an HTTP 200 JSON-RPC response with the request id and a tool result with isError true; structuredContent (and content[0].text, the same JSON) holds the offer (PaymentRequired, with the reason in error) or the API error body. Check isError, not the HTTP status. A payment on /mcp is accepted only on a single tools/call to a known tool, as a JSON-RPC message with "jsonrpc": "2.0" and a string or integer id, sent with Content-Type: application/json, the Accept header the transport requires (both application/json and text/event-stream) and, if you send MCP-Protocol-Version, a version the server supports (2025-11-25, 2025-06-18, 2025-03-26, 2024-11-05; a missing header is fine); otherwise nothing is charged. A tool that fails on the server side (an isError result with a server-class error such as not_ready or upstream_unavailable) is refunded like a 5xx on /v1: x402/credit-remaining shows the refunded count. A client error (invalid arguments) still costs a credit. A JSON-RPC batch that carries a paid method, and any request the MCP SDK rejects, is refused with the offer when it comes with a payment or with no credentials, before anything is settled (an HTTP 402, or the isError result above for a single tools/call with a usable id). With a credit token such a request reaches the SDK, which answers its HTTP 4xx (400 invalid_body for a batch) and the credit counts as used, as for any client error on /v1. A token holder must send an Accept header with both application/json and text/event-stream, or the SDK refuses the call with a 400 and the credit is spent. Other /mcp messages keep plain HTTP answers. Free without a token: /llms.txt, /openapi.yaml, /openapi.json, /.well-known/x402, /docs and everything under it (/docs/behavior.md), /healthz, /readyz, /version, GET /v1/x402, and MCP initialize, ping, tools/list, resources/list, resources/read and notifications. Networks: - eip155:8453: USDC contract 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913, payTo 0x97837b167517FaD8d55be4B4cb0b7F98Aa6c1446