Skip to main content
Historical candles and trade history/metrics. Use these endpoints to chart a market, replay its tape, or read aggregate volume for a contract. Full parameter reference and a live tester: API Reference.

Base URL

All paths on this page are relative to that host.

Authentication

Every endpoint on this page is a public read: it works with no credentials on a reduced per-IP anonymous tier. With a credential it accepts an API key (X-Client-Id + X-Api-Key + X-Api-Secret) or a first-party session JWT. A bad API key is still a 401 or 403; it never degrades to the anonymous tier. An invalid or expired JWT is served as anonymous. Examples below read credentials from KAIROS_CLIENT_ID, KAIROS_API_KEY, and KAIROS_API_SECRET in your shell. Candle routes (GET /candles, POST /candles/batch) need no scope and are not platform-gated. They share one candles rate-limit group at 200 requests/minute (100 anonymous), so the two endpoints draw on a single budget; an operator tier can raise or lower it at runtime. /trades/* routes need the trade:read scope on API-key credentials (JWT callers bypass the scope check). They also enforce platform access for API-key callers on the provider query value. Both routes share one trades rate-limit group at 120 requests/minute (60 anonymous). Limits are keyed on the session user or API key, or on the client IP when you send no credentials.

Get candles

Fetch OHLCV candles for a single (provider, contract_id, outcome) series over [start, end), bucketed at timeframe_seconds. Auth: public; no scope required. 200 requests/minute, 100 anonymous (shared candles group).

Request

Unless rebuild=true, the handler first checks for a byte-identical cached response and streams it straight back — a miss (or rebuild=true) falls through to reconstructing the candles from the underlying trade data and repopulates the cache. There is no “wait for ingestion” mode.
Gotcha: start is silently clamped, never rejected. Each timeframe has a maximum lookback measured back from end; asking for more returns the clamped window rather than an error. Compare candles[].bucket_start against the start you sent if the exact window matters.
end is likewise clamped forward to the current bucket. A 1-second request whose window ends more than 24 hours ago is past retention and returns "candles": [] — not an error.

Response

Batch candles

Fetch up to 200 candle series in one call. Each item accepts the same fields as GET /candles. Auth: same as GET /candles. 200 requests/minute — the same candles limit group, so the two endpoints share one budget.

Request

Every item is checked against the cache in parallel first; only the uncached tail is rebuilt from the underlying trade data. There is also a whole-batch size budget. After clamping, the estimated bar count across every item must not exceed 400,000; over that the request fails with 400 batch implies <n> candles; maximum is 400000. The request body itself is capped at 8 MiB (413 beyond that). A single bad or failed item never fails the whole batch. An empty window comes back as "candles": [], not an error. If the rebuild step fails after some items were already cached, those still return normally and every uncached item instead gets "candles": [], "error": "<message>". Only when no item could be served at all does the request fail with 500. Check results[].error per item rather than relying on the HTTP status.

Response

Trade history

Normalized trade history for one (provider, contract_id), served from Kairos’s own trade store. Coverage depends on how much history has been backfilled/streamed for that contract. Auth: public; API-key credentials need trade:read and the requested provider must be enabled for them. 120 requests/minute, 60 anonymous (shared trades group).

Request

The window trails before: the query covers [before − window_seconds, before), or the last window_seconds when you omit before. To walk backwards, feed the oldest returned timestamp into before while has_more is true. If that window matches nothing, the endpoint retries once with the lower bound removed and returns the newest trades before before instead — so an empty trades array means the contract has no ingested trades at all, not merely none in the window. A taker request skips this retry, so an empty result there means that wallet has no trades on the contract. trigger_ingest is inert. It is validated and ignored: no ingestion job is started, and indexing is always false on this endpoint.

Response

Gotcha: trades[].timestamp and oldest_available_ts are unix seconds (fractional), not milliseconds. Multiplying by 1000 before feeding a JavaScript Date is the usual fix.

Volume metrics

Aggregate volume and outcome-pressure metrics for one (provider, contract_id) over a lookback window — the same backing store as /trades/history, not a live upstream proxy. There’s no buy/sell breakdown: metrics split by outcome (outcome_0/outcome_1), since trade direction can’t be reliably derived from every provider’s exchange data. Auth: same as /trades/history. 100 requests/minute.

Request

Responses are cached per (provider, contract_id, window_seconds), with a shorter TTL when coverage_pct came back low.

Response

An empty window is not an error. It returns zeroed volumes, trade_count: 0, coverage_pct: 0.0, and outcome_0_pressure_pct: 50.0 — the neutral midpoint, not a measurement. Read trade_count before you trust a pressure value.

Errors

Errors are returned as { "detail": "<message>" }. Two shapes deviate: 422s use FastAPI’s standard validation envelope, and 429s use { "error": "Rate limit exceeded: <limit>" } alongside X-RateLimit-* and Retry-After headers. The Code column holds the exact detail string the service returns; — means the body has no fixed message. A batch whose ClickHouse tail fails but whose cache answered part of the request does not return 500 — see Batch candles.