> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kairos.trade/llms.txt
> Use this file to discover all available pages before exploring further.

# Get up to 200 candle series in one request

> Batched form of `GET /v1/candles`: fetches up to 200 independent
`(provider, contract_id, timeframe_seconds, start, end, outcome)`
series concurrently and returns them in request order, with
**per-index partial failure** — one item's validation or fetch
error does not fail the others.

Each item is validated and aligned exactly as in `GET /v1/candles`
(same clamping, rollup, and inversion rules). Body accepts either a
`requests` array or a legacy `items` alias; if `requests` is
non-empty it is used, otherwise `items` is used.
`timeframe_seconds` and `outcome` in each item may be a JSON number
or a numeric string. The request body is capped at 4 MiB.

**Rate limiting / cost.** Admitted at the base cost of 1
`light`-bucket unit. Larger batches — more items, wider windows,
finer timeframes — consume more of your quota; any excess is
charged as a deferred extra charge against your next request.

**Caching.** Batch responses are always `Cache-Control: no-store`
and never carry an ETag.

**Binary format.** Pass `?fmt=binary` or
`Accept: application/x-kairos-candles` to receive a single
multi-result binary frame (`num_results = len(requests)`) — one
columnar result section per request index, in input order. An item
that failed sets the high bit (`0x80000000`) of its section's
`count`, so it stays distinguishable from a genuinely empty window;
mask the bit off to read the (always zero) count. Per-item error
messages are only available in the JSON response.

**Failure semantics.** Returns `500` only when *every* item in the
batch failed. Otherwise `200` with a mix of populated and
empty/errored entries.




## OpenAPI

````yaml /openapi/market-data-api.yaml post /v1/candles/batch
openapi: 3.1.0
info:
  title: Kairos Market Data API
  version: 1.2.0
  summary: Read-only prediction and perpetual market data across venues.
  description: >
    The Kairos Market Data API provides read-only access

    to normalized prediction-market data across every venue Kairos integrates:

    OHLCV candles, the trade tape, market metadata, resolution lifecycles, and

    latest mark prices.


    ## No signup required


    Every endpoint works **without credentials** on the anonymous free tier,

    rate-limited per source IP (120 light units/min, 20 heavy units/min). Try
    any

    request from the interactive docs at

    [app.kairos.trade/docs/market-data](https://app.kairos.trade/docs/market-data)

    or straight from curl. For production budgets (1,200 light and 150 heavy

    units/min by default, raisable per credential), request an API key from the

    Kairos team.


    ## Authentication


    Three modes, resolved per request:


    - **Anonymous** — no credential headers at all. Free tier, IP-keyed limits.

    - **API key** — `X-Client-Id` + `X-Api-Key` + `X-Api-Secret` headers
      (all three; partial header sets are rejected with 401 rather than
      degrading to anonymous).
    - **First-party session** — `Authorization: Bearer` JWT (Kairos web app
      sessions only; not offered to API consumers).

    Resolution order is fixed: an `Authorization` header takes the bearer

    path, any of the three API-key headers takes the API-key path, and only

    a request carrying neither is eligible for the anonymous tier.


    On the API-key path, an unreachable credential store surfaces on **any**

    endpoint as `500` with `code: internal` and the message

    `authentication backend unavailable`. A source IP outside a credential's

    whitelist is `403 ip_not_whitelisted`; that is the only 403 this service

    emits.


    ## Rate limiting


    Weighted sliding-window budgets over one minute, in **units**, across two

    independent buckets: light (candles, metadata, resolutions, trade

    metrics) and heavy (trade history, marks, perpetual snapshots). Most

    requests cost 1 unit; larger requests may consume more of your quota —

    each operation's `x-kairos-rate-limit` states its exact cost model.

    Every admitted response carries `X-RateLimit-Bucket`, `X-RateLimit-Tier`,

    `X-RateLimit-Remaining`, and `X-RateLimit-Reset`; 429s add `Retry-After`.


    A separate per-IP admission gate runs *before* authentication to keep a

    flood off shared infrastructure. It also answers 429 `rate_limited`, but

    with `Retry-After: 60` and no `X-RateLimit-*` headers.


    Redis backs the weighted limiter and it fails **closed**: if it is

    unreachable the request is rejected with 503 `rate_limiter_unavailable`

    rather than let through unmetered.


    ## Conventions


    - **Prediction-market prices** are on the 0–100 scale (implied probability
      × 100) in the prediction candle, trade, and mark endpoints. Prediction
      USD notional = `size × price / 100`.
    - **Perpetual prices are direct venue prices**, not probabilities and not
      0–100 values. Perpetual quantities retain their declared native unit
      (`base_asset` or `contracts`). Never divide a perpetual price by 100 or
      compute contract notional without the instrument's authoritative contract
      multiplier; the snapshot does not synthesize a cross-venue notional.
    - **Hyperliquid is two products on one venue.** Its HIP-4 outcome markets
      are prediction markets, read with `provider=hyperliquid` on the
      prediction endpoints; its perpetuals are bare coins read under
      `/v1/perpetuals/hyperliquid/{instrument}/snapshot`, where the instrument
      is the canonical id `hl-mainnet-<symbol>-<quote>` (e.g.
      `hl-mainnet-btc-usdt`). Different id schemes, different price semantics;
      they are never interchangeable.
    - **Errors** all use one envelope:
      `{"error": {"code": "...", "message": "..."}}`.
    - **Providers** are case-insensitive; `kalshi_offchain` aliases `kalshi`,
      `dome` aliases `polymarket`, and `opinion` is resolvable for historic
      reads only.
  contact:
    name: Kairos
    url: https://app.kairos.trade/docs/market-data
  termsOfService: https://kairos.trade/terms
servers:
  - url: https://md.kairos.trade
    description: Production
  - url: https://staging-md.kairos.trade
    description: Staging
security:
  - {}
  - apiKeyClientId: []
    apiKeyKey: []
    apiKeySecret: []
tags:
  - name: Candles
    description: OHLCV candle series (1s → 1d), JSON or compact columnar binary.
  - name: Trades
    description: Trade tape and aggregate volume metrics.
  - name: Markets
    description: Market metadata, batch lookup, identifier resolution, and enumeration.
  - name: Resolutions
    description: Resolution outcomes and UMA-style lifecycle state/timelines.
  - name: Marks
    description: Latest mark (last trade price) per outcome token.
  - name: Perpetuals
    description: Live perpetual books, trades, candles, funding, and market state. Beta.
  - name: Status
    description: Health and readiness probes.
paths:
  /v1/candles/batch:
    post:
      tags:
        - Candles
      summary: Get up to 200 candle series in one request
      description: |
        Batched form of `GET /v1/candles`: fetches up to 200 independent
        `(provider, contract_id, timeframe_seconds, start, end, outcome)`
        series concurrently and returns them in request order, with
        **per-index partial failure** — one item's validation or fetch
        error does not fail the others.

        Each item is validated and aligned exactly as in `GET /v1/candles`
        (same clamping, rollup, and inversion rules). Body accepts either a
        `requests` array or a legacy `items` alias; if `requests` is
        non-empty it is used, otherwise `items` is used.
        `timeframe_seconds` and `outcome` in each item may be a JSON number
        or a numeric string. The request body is capped at 4 MiB.

        **Rate limiting / cost.** Admitted at the base cost of 1
        `light`-bucket unit. Larger batches — more items, wider windows,
        finer timeframes — consume more of your quota; any excess is
        charged as a deferred extra charge against your next request.

        **Caching.** Batch responses are always `Cache-Control: no-store`
        and never carry an ETag.

        **Binary format.** Pass `?fmt=binary` or
        `Accept: application/x-kairos-candles` to receive a single
        multi-result binary frame (`num_results = len(requests)`) — one
        columnar result section per request index, in input order. An item
        that failed sets the high bit (`0x80000000`) of its section's
        `count`, so it stays distinguishable from a genuinely empty window;
        mask the bit off to read the (always zero) count. Per-item error
        messages are only available in the JSON response.

        **Failure semantics.** Returns `500` only when *every* item in the
        batch failed. Otherwise `200` with a mix of populated and
        empty/errored entries.
      operationId: postCandlesBatch
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CandleBatchRequest'
            example:
              requests:
                - provider: polymarket
                  contract_id: >-
                    21742633143463906290569050155826241533067272736897614950488156847949938836455
                  timeframe_seconds: 3600
                  start: '2026-07-15T00:00:00Z'
                  end: '2026-07-16T00:00:00Z'
                  outcome: 0
                - provider: kalshi
                  contract_id: KXHIGHNY-26JUL15-T50
                  timeframe_seconds: 60
                  start: '2026-07-15T12:00:00Z'
                  end: '2026-07-15T13:00:00Z'
      responses:
        '200':
          description: >-
            Per-index results (populated, empty, or errored). Order matches the
            request array.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CandleBatchResponse'
              examples:
                mixedResult:
                  value:
                    results:
                      - index: 0
                        candles:
                          - contract_id: >-
                              21742633143463906290569050155826241533067272736897614950488156847949938836455
                            timeframe_seconds: 3600
                            bucket_start: '2026-07-15T00:00:00+00:00'
                            open: 61.5
                            high: 63
                            low: 60.8
                            close: 62.4
                            volume: 184230
                      - index: 1
                        candles: []
                        error: unknown provider "acme"
            application/x-kairos-candles:
              schema:
                $ref: '#/components/schemas/CandleBinaryFrame'
        '400':
          description: Malformed body, empty/oversized `requests` array.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                tooLarge:
                  value:
                    error:
                      code: invalid_request
                      message: batch size 250 exceeds maximum 200
                empty:
                  value:
                    error:
                      code: invalid_request
                      message: requests array is required
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/IPNotWhitelisted'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          description: Every item in the batch failed (validation or fetch).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                default:
                  value:
                    error:
                      code: internal
                      message: all batch items failed
        '503':
          $ref: '#/components/responses/RateLimiterUnavailable'
components:
  schemas:
    CandleBatchRequest:
      type: object
      description: >
        Request body of `POST /v1/candles/batch`. Provide either `requests` or
        the legacy `items` alias — if `requests` is non-empty it takes
        precedence, otherwise `items` is used. At least one entry is required
        across the two fields, and the effective array may not exceed 200
        entries.
      properties:
        requests:
          type: array
          items:
            $ref: '#/components/schemas/CandleBatchItem'
          maxItems: 200
        items:
          type: array
          items:
            $ref: '#/components/schemas/CandleBatchItem'
          maxItems: 200
          description: >-
            Legacy alias for `requests`, used only when `requests` is absent or
            empty.
    CandleBatchResponse:
      type: object
      description: Response body of `POST /v1/candles/batch` in JSON mode.
      required:
        - results
      properties:
        results:
          type: array
          items:
            $ref: '#/components/schemas/CandleBatchResult'
    CandleBinaryFrame:
      type: string
      format: binary
      description: >
        Columnar binary candle frame (`Content-Type:
        application/x-kairos-candles`), returned by both candle endpoints when
        negotiated via `?fmt=binary` or an `Accept:
        application/x-kairos-candles` header. Byte layout (little-endian): `u8
        magic=0xCA, u8 version=1, u16 num_results`, then for each section `u32
        index, u32 count`, followed by six columnar arrays of length `count`:
        `u32[] t` (bucket start, epoch seconds), `u16[] o,h,l,c` (prices scaled
        ×100 of the 0-100 float, clamped to [0, 10000]), and `i64[] vol` (volume
        ×100). In a batch frame, a failed item sets the high bit (`0x80000000`)
        of its section's `count` — mask it off before using the count, and treat
        a set bit as "this series errored" rather than "no data". The error
        message itself is only available in the JSON response.
    ErrorResponse:
      type: object
      description: Canonical error envelope emitted by every Market Data API endpoint.
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              description: Machine-readable error code.
              example: invalid_request
            message:
              type: string
              description: Human-readable detail.
              example: market_ids exceeds maximum 200
    CandleBatchItem:
      type: object
      description: >-
        One series request inside a batch. Same validation rules as the `GET
        /v1/candles` query parameters.
      required:
        - provider
        - contract_id
        - timeframe_seconds
        - start
        - end
      properties:
        provider:
          type: string
          enum:
            - kalshi
            - polymarket
            - opinion
            - predictfun
            - hyperliquid
            - dome
            - kalshi_offchain
          example: polymarket
        contract_id:
          type: string
          maxLength: 128
          example: >-
            21742633143463906290569050155826241533067272736897614950488156847949938836455
        timeframe_seconds:
          description: >-
            Bucket width in seconds. Accepted as a JSON number or a numeric
            string. Valid values 1, 60, 300, 900, 3600, 14400, 86400.
          oneOf:
            - type: integer
            - type: string
          example: 3600
        start:
          type: string
          description: >-
            Same accepted formats as `GET /v1/candles`'s `start` parameter (RFC
            3339, bare datetime, or bare date).
          example: '2026-07-15T00:00:00Z'
        end:
          type: string
          description: Same accepted formats as `GET /v1/candles`'s `end` parameter.
          example: '2026-07-16T00:00:00Z'
        outcome:
          description: >-
            Zero-based outcome index. Accepted as a JSON number or a numeric
            string. Defaults to 0.
          oneOf:
            - type: integer
            - type: string
          default: 0
          example: 0
    CandleBatchResult:
      type: object
      description: Result for one input item, at the same array position as the request.
      required:
        - index
        - candles
      properties:
        index:
          type: integer
          description: Zero-based position in the input `requests`/`items` array.
          example: 0
        candles:
          type: array
          items:
            $ref: '#/components/schemas/CandleObject'
          description: >-
            Empty when the item's window was authoritatively empty OR when the
            item errored (check `error`).
        error:
          type: string
          description: >-
            Present only when this item failed validation or fetch. When
            present, `candles` is always `[]`.
          example: unknown provider "acme"
    CandleObject:
      type: object
      description: One OHLCV bucket. Prices are on a 0-100 scale (percentage probability).
      required:
        - contract_id
        - timeframe_seconds
        - bucket_start
        - open
        - high
        - low
        - close
        - volume
      properties:
        contract_id:
          type: string
          description: >-
            Echo of the request's `contract_id` (the caller-supplied id, not the
            resolved canonical market id).
          example: >-
            21742633143463906290569050155826241533067272736897614950488156847949938836455
        timeframe_seconds:
          type: integer
          enum:
            - 1
            - 60
            - 300
            - 900
            - 3600
            - 14400
            - 86400
          description: Bucket width in seconds, echoing the request.
          example: 3600
        bucket_start:
          type: string
          description: >-
            Bucket start timestamp, UTC, always rendered with an explicit
            `+00:00` offset (not `Z`).
          example: '2026-07-15T00:00:00+00:00'
        open:
          type: number
          format: double
          minimum: 0
          maximum: 100
          description: Opening price (0-100 scale).
          example: 61.5
        high:
          type: number
          format: double
          minimum: 0
          maximum: 100
          description: High price in the bucket (0-100 scale).
          example: 63
        low:
          type: number
          format: double
          minimum: 0
          maximum: 100
          description: Low price in the bucket (0-100 scale).
          example: 60.8
        close:
          type: number
          format: double
          minimum: 0
          maximum: 100
          description: Closing price (0-100 scale).
          example: 62.4
        volume:
          type: integer
          format: int64
          description: Traded volume in the bucket, provider-native units.
          example: 184230
        token_id:
          type: string
          description: >-
            Resolved per-outcome CLOB token id. Omitted entirely from the JSON
            object when empty.
          example: '704721957297303853272349184'
  responses:
    Unauthorized:
      description: >
        No valid credential presented. Every path returns `code: unauthorized`;
        the triggers differ:


        - An `Authorization` header on a deployment where bearer auth is not
        enabled (`bearer authentication is not enabled`).

        - A bearer token that fails verification (`invalid or expired session`),
        or whose token/session has been revoked (`session has been revoked`).

        - An incomplete or wrong API-key header set. Sending *any* of
        `X-Client-Id`, `X-Api-Key`, `X-Api-Secret` commits the request to the
        API-key path, so a partial set is rejected rather than silently
        degrading to anonymous limits (`valid X-Client-Id, X-Api-Key, and
        X-Api-Secret headers are required`).

        - No credential material at all while the anonymous free tier is
        unavailable — switched off for the deployment, forced off through the
        runtime kill switch, or not yet resolvable on a replica that has never
        read the flag (it fails closed).
      headers:
        WWW-Authenticate:
          schema:
            type: string
          description: >-
            `Bearer realm="market-data-api"` on bearer-verification failure,
            `APIKey realm="market-data-api", header="X-Client-Id, X-Api-Key,
            X-Api-Secret"` on missing/invalid API-key credentials. Absent on the
            revoked-session and bearer-disabled paths.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: unauthorized
              message: >-
                valid X-Client-Id, X-Api-Key, and X-Api-Secret headers are
                required
    IPNotWhitelisted:
      description: API key presented from a source IP not in that credential's whitelist.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: ip_not_whitelisted
              message: source IP not in credential whitelist
    RateLimited:
      description: >
        Two different gates return this status, both with `code: rate_limited`:


        - **Per-credential (or per-IP, when anonymous) weighted budget
        exhausted.** The message is `rate limit exceeded`, or, for anonymous
        callers, `anonymous rate limit exceeded — request an API key for higher
        limits (…)`. `Retry-After` is the whole number of seconds until the
        current one-minute window rolls over, floored at 1. All four
        `X-RateLimit-*` headers are present.

        - **Per-IP admission gate.** An in-process, pre-authentication guard
        that keeps a flood off the shared credential cache and database. The
        message is `too many requests from this address` and `Retry-After` is a
        flat `60`. Because this fires *before* authentication, the response
        carries **no** `X-RateLimit-*` headers at all.
      headers:
        Retry-After:
          schema:
            type: integer
          description: >-
            Seconds until the caller may retry — window-rollover seconds for the
            weighted limiter, a flat 60 for the IP admission gate.
        X-RateLimit-Bucket:
          schema:
            type: string
            enum:
              - light
              - heavy
        X-RateLimit-Tier:
          schema:
            type: string
            enum:
              - anonymous
              - api-key
              - user
        X-RateLimit-Remaining:
          schema:
            type: integer
        X-RateLimit-Reset:
          schema:
            type: integer
            description: Unix timestamp (seconds) when the current window resets.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: rate_limited
              message: rate limit exceeded
    RateLimiterUnavailable:
      description: >
        The rate limiter is unreachable. Fails CLOSED — the request is rejected
        rather than let through unmetered.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: rate_limiter_unavailable
              message: rate limiter temporarily unavailable
  securitySchemes:
    apiKeyClientId:
      type: apiKey
      in: header
      name: X-Client-Id
      description: >-
        Credential client id (`kairos_ck_...`). Must be sent together with
        X-Api-Key and X-Api-Secret.
    apiKeyKey:
      type: apiKey
      in: header
      name: X-Api-Key
      description: >-
        64-char hex API key. Must be sent together with X-Client-Id and
        X-Api-Secret.
    apiKeySecret:
      type: apiKey
      in: header
      name: X-Api-Secret
      description: >-
        64-char hex API secret. Must be sent together with X-Client-Id and
        X-Api-Key.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.