> Last verified: 2026-10-08

# rate-hub behaviour notes

Edge cases a client must know that the [OpenAPI schema](/openapi.yaml) ([Swagger UI](/docs)) does not spell out. Field lists, error codes and `Cache-Control` values for normal answers live in the spec; this page does not repeat them.

## Dynamic coins

The catalog has a fixed static part. Any other coin the service can price can be added on demand.

**Registering.** A `q` search with few catalog hits returns coins that are not in the catalog in `candidates`, each with a `uid` reserved for it (the uid it keeps once registered; until then it has no price). `GET /v1/assets?candidate=<uid>` confirms the coin and registers it. The answer is the new asset with `dynamic: true` and a uid of `250000001` or more. A coin that cannot be registered is an empty `assets` list, and that miss is remembered for 1 hour, so retrying it sooner costs nothing and changes nothing. The same empty list comes back for every candidate while dynamic registration is switched off on the server. A uid that is not a catalog coin and was never shown as a candidate is `400 invalid_query`, always with the same message. When the uid of a candidate cannot be reserved right now (the shared uid store does not answer), the search carries no `candidates` and `candidates_status` is `upstream_error`; the catalog hits are returned as usual. The removed `provider`, `id` and `s1` parameters of `/v1/assets` are `400 invalid_query` too, never ignored.

**Tokens by contract.** `GET /v1/assets?chain=solana&contract=<mint>` for a Solana mint that is not in the catalog registers it as a dynamic token when the server has this switched on, with the same limits, errors, expiry and 1 hour miss memory as above. Mints are case-sensitive: send the address exactly as you hold it, never lower-cased. The answer is `type: token`, `dynamic: true`, the mint in `contracts`. A mint the service does not know, cannot price, or flags as unverified or suspicious is an empty `assets`, the same as every unknown mint while the feature is off. Such a token has the `change` capability only: no `market`, no `sparkline` (an `include` of those is simply absent), a series answers `unsupported`, and a daily crypto rate answers `out_of_range`. It is priced from a single source, shown as its own code in `source`.

**First price.** Right after registration the rate can be `pending` for a short time, until the collector has priced the coin (seconds). After that the coin is polled in every crypto cycle exactly like a hot static coin (default cycle: 5 minutes).

**Contract lookup, any chain.** `GET /v1/assets?chain=<slug>&contract=<address>` also answers for EVM chains (`ethereum`, `base`, `arbitrum-one`, `polygon-pos`, `bsc`, ...). It reads the contracts the catalog carries and a contract index the server refreshes once a day, and it never calls an upstream: an unknown EVM contract is an empty `assets`,; a contract whose coin is not in the catalog is empty too. `POST /v1/assets/lookup` does the same for up to 100 `{chain, contract}` pairs at once and answers one item per pair in request order, `uid` set for a known contract and `null` otherwise, on every chain including Solana (it never registers a mint). Hex (`0x`) addresses are case-insensitive; a Solana mint is exact, send it as you hold it. If the daily refresh fails the server keeps serving its last index.

**Expiry.** A dynamic coin lives 7 days after its last use. Use means a request that resolves its uid: `/v1/rates`, `/v1/rates/daily`, `/v1/rates/series`, `/v1/icons/{uid}`, a `candidate` lookup, or an exact `chain=solana&contract=` lookup. A search by `symbol` or `q`, and the full catalog listing, do not count. Renewal is throttled to about once per hour per coin per API replica, so expiry is decided with roughly 1 hour of slack. A coin that nobody uses for 7 days is dropped and stops being polled.

**Identity.** After expiry, or after the server's Valkey was reset, the same coin registers again and may get a **new uid**; the old uid then answers `unsupported`. Uids also differ between deployments, because each deployment has its own registry. So:

- Match a dynamic coin by symbol or name (or, for a token registered by contract, by `chain` and `contract`), never persist its uid as its identity.
- On an `unsupported` rate for a dynamic uid, search again by `q` or `symbol` (a coin that expired comes back in `candidates`; register it with its `uid`), or repeat the `chain` and `contract` lookup, and use the uid it returns.
- Catalog (static) uids never change.

**Limits and failures.** All are `503` with `Retry-After`; the codes are listed in the spec.

- `catalog_full`: the registry holds the most dynamic coins it allows (150 at most, possibly fewer so that hot and dynamic coins fit one upstream request). `Retry-After` is 3600: the cap moves only when the operator changes it, so do not poll.
- `not_ready`: the registry is being restored (for example right after a Valkey reset, before the collector has rebuilt it). Retry after `Retry-After`; it is transient.
- `budget_exhausted`, `upstream_unavailable`: per-host conditions, see the spec. A failure on one host says nothing about another.

## Icons

- `Asset.icon` is `/v1/icons/{uid}` for every non-fiat asset and absent for fiat. Fetch it with the same credentials as any other `/v1` call (on an x402 deployment it costs one credit like the rest).
- An asset without any image source (no image source) gets a neutral placeholder PNG, not an error: `200` with `X-Icon-Placeholder: true` and `Cache-Control: public, max-age=3600`. A newly registered coin can also show the placeholder until its first price, which carries the image URL, has landed.
- The placeholder is never stored server-side. A real icon may appear later, so when the header is present, re-fetch after `max-age` (1 hour) and replace what you cached.
- A real icon carries `Cache-Control: public, max-age=86400` and a strong `ETag`; send it back in `If-None-Match` for `304`. Server-side the copy is fresh for 24 hours. If every image source is down, the expired copy is served for up to 7 days.
- `503` (`upstream_unavailable`) only when every source failed and nothing is cached; it affects that one icon.

## Series

- `vs=usd` is native and never clipped. `vs=btc` divides each point by the BTC/USD point nearest in time from the same range.
- A non-USD fiat `vs` divides each point by that fiat's daily rate for the point's UTC day, and the fiat archive has a start day. Points before it are dropped, so a non-USD series of range `max` can start later than the USD series.
- If a day's fiat rate is not published yet, the nearest day that has one is used instead. The answer is still `ok` but is treated as incomplete: `Cache-Control: max-age=0`, so ask again later for exact values. The same `max-age=0` applies to every non-`ok` status.
- A fiat subject over `30d`, `90d`, `1y` or `max` is one point per UTC day (00:00) from the daily archive, in any `vs`; the archive has a start day, so `max` is that day to today (thinned to 500 points). A day with no document is skipped, never invented. A cold range is filled over a few requests (at most 100 uncached days are loaded per request, weekly days first): an early answer is `ok` with fewer points and `max-age=0`; ask again for the full series. Nothing available yet is `pending`.
- A fiat subject over `1d` and `7d` is different: rate-hub's own readings of that currency, about one point per fiat poll (30 minutes by default), kept for 7 days and never fetched from outside on request. History starts when collection starts. A fiat with no reading in the range is `unsupported`; `stale` means the newest reading is over 3 hours old.
- When no source can serve the series, the last cached series is returned as `stale` with its `fetched_at` (kept up to 7 days); with nothing cached the answer is `pending`.

## Snapshot documents

`GET /v1/snapshot/crypto` and `GET /v1/snapshot/fiat` are for an app's cold start: one answer per class, in the shape of `/v1/top` and `/v1/rates`. `crypto` is the ranked list (top 250 unless `limit`) with `change` and without `market`; `fiat` is every fiat code the service prices, ascending by `uid`, and takes no `limit`. An item that cannot be priced is left out, a `stale` one stays and says so, so a document is never an error because one source is down. The `ETag` is a hash of the content without `server_time`: it stays the same while nothing changed and changes when a price, a status or the item set does (the collector moves `fetched_at` every cycle, so expect a new one at least that often). Send it back in `If-None-Match` for `304`. The answer is `private, max-age=30`: reuse it for 30 seconds without asking. A `304` is a request like any other: the key is checked and, in x402 mode, a credit is taken; only a request your own cache answers is free.

## Statuses

`ok`, `stale`, `pending`, `unsupported` and their meanings are defined in the spec (`RateStatus`, `DailyRateStatus`, `SeriesStatus`). Dynamic-coin specifics are only these: `pending` is expected right after registration, and `unsupported` for a previously valid dynamic uid means it expired (see Identity above).

## Price from one source

`POST /v1/rates` (and MCP `get_rates`, v2 `GetRates`) takes an optional `source`, an opaque code such as `s1`. Each item is then that source's own reading: `source_code` equals the code, never `agg`, never another source's price. An asset the source has no reading for is `unsupported` (no price, no `retry_after`: waiting does not help); a reading older than the stale limit by its own `as_of` is `stale`, even while the price the server would pick is `ok`. A source's reading is dropped after 24 hours without a fresh one. A value that is not a code of the source table (malformed, unknown, `agg`) is `400 invalid_body`. A valid code the deployment does not run is `unsupported` for every asset, not an error; `upstreams_by_code` in `/v1/meta` shows which codes are alive.

Which codes can answer depends on the deployment. The exchange codes (`s4` to `s8`) have readings only when multi-source aggregation is on, and only for assets that aggregation covers (the top of the market-cap ranking); with aggregation off they answer `unsupported`. The code of the primary price source answers while it serves, and for aggregated assets from its kept reading. The code of the fallback source answers only after it has been polled, which happens at its own, slower cadence, so its readings are often `stale`.

Only the asset's own USD price is source-specific. Other quote currencies and `btc` convert through rate-hub's own fiat and btc quotes. `include` blocks (`change`, `market`, `sparkline`) are returned only when the requested source is the one that served the server's own quote; otherwise they are absent. A source-specific price skips the sanity hold on large jumps that the server's own price goes through: it is that source's raw value.

## Daily rates: final and transient answers

`out_of_range` is final: do not retry it. It covers days after today UTC, days before the start of the fiat archive, crypto days that no s8 daily candle covers (before the first candle of the asset, or an asset with no such market), and a coin with no price that day. History older than about a year is served at daily granularity from s8 daily candles (price = the open at 00:00 UTC of that day). A day after today UTC is final only for now: ask again once that UTC day has arrived. `pending` is transient (upstream failure, rate limit, a day not yet published for today or yesterday); wait `retry_after` seconds. Once a (uid, day) is answered `ok` or `out_of_range` for a past day, it does not change to `pending`.

## Time: everything is UTC

All day and period boundaries are UTC. A daily `day` is a UTC calendar date; the crypto value is the price at 00:00 UTC of that date, the fiat value the rate for that date. Today's UTC day is not final until it ends, so it is never served as `immutable`. `change` over 24h is a rolling 24 hours (whichever source served the quote), not a UTC day. Series points are UTC instants; a range ends now.

## Data lifetimes

Nothing the server keeps lasts longer than 7 days: dynamic coins without use, quote snapshots (72 hours by default, never above 7 days), cached daily rates, cached series and icons (including their stale copies). Whatever is missing is fetched from upstream again on demand. The only user-visible effect is a possible short `pending` or a slower first answer. Daily rates are immutable, so your own client may cache them as long as it likes (`max-age=31536000, immutable`).
