> ## 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 full market metadata (rules, images, contract spec)

> Returns the full metadata document for one market. Resolution order: (1) a fast cached-metadata path — for Polymarket, a cache hit derives status/category/images from the cached upstream payload; (2) on a miss, falls back to a live provider-API fetch (Kalshi ticker + event metadata for images; Polymarket; Opinion; predict.fun) — this covers markets too new to be indexed yet (e.g. short-lived 15-minute crypto markets); (3) if the cache hit is non-null but carries **empty** `resolution_rules` (both `primary` and `secondary` blank), an extra provider-API call backfills `resolution_rules` (and `description` if also empty) without discarding the rest of the cached document. Only the cached-metadata path populates `condition_id`/`event_id`/`contract.settlement_ts` — the live provider-API fallback leaves those `null`. Finally, for `polymarket`/`predictfun`, a best-effort liquidity-rewards enrichment mutates `extra` in place (never blocks or fails the response): Polymarket sets `extra.clobRewards` (`[{rewardsDailyRate}]` or `[]`), `extra.rewardsMaxSpread`, `extra.rewardsMinSize`; predict.fun sets `extra.rewards.current` (an active reward-window object, or `null`). 404 only if no source has the market at all.




## OpenAPI

````yaml /openapi/data-api.yaml get /markets/metadata
openapi: 3.1.0
info:
  title: Kairos Data API
  version: 1.0.0
  summary: >-
    The full Kairos data plane — markets, candles, trades, search, discover,
    sports, trader analytics, and PnL.
  description: |
    The Kairos Data API at `data.kairos.trade` is the platform's primary data
    plane: market metadata and prices, OHLCV candles, live venue trade proxies,
    normalized trade history, full-text search, discovery feeds, the sports
    catalog, public trader analytics, and account PnL.

    ## Authentication

    Most endpoints accept a Kairos **API key** (`X-Client-Id` + `X-Api-Key` +
    `X-Api-Secret`, all three) or a first-party session JWT. Endpoints tagged
    `public` (trader analytics, provider configs, several sports feeds) need
    no credentials at all. Some endpoints additionally require an API-key
    **scope** (`trade:read`, `position:read`) — stated per operation.

    For high-volume market-data consumption (candles/trades/metadata at
    scale), prefer the dedicated **Market Data API** at `md.kairos.trade` —
    it has higher budgets, ETag caching, and a binary candle format.

    ## Rate limits

    Rate limits use a sliding window keyed on the authenticated user (JWT
    `sub`) or, for anonymous callers, the trusted client IP. Routes belong to
    a named **bucket** (`x-kairos-bucket`) whose per-minute budget is shared
    by every route in it; routes with no bucket run under the service default
    of 100/minute. `x-kairos-rate-limit` states the bucket's compile-time
    default — operators can raise or lower a bucket at runtime, so treat the
    documented number as the baseline, not a contract. 429 responses carry
    `Retry-After` and `X-RateLimit-*`.

    ## Conventions

    - Prices are on the **0–100 cents scale** unless a field says otherwise
      (trader-analytics position/trade prices use the 0–1 scale; each field's
      description states its scale).
    - Errors: `{"detail": "<message>"}` for handler errors; FastAPI's
      standard validation envelope for 422s. Errors surfaced from a venue
      adapter instead use `{"error", "provider", "operation", "message"}` —
      see `DataProviderError`. Unhandled failures always return the generic
      500 body; internal details are logged, never returned.
    - Every request body is capped at 8 MiB service-wide (413).
  contact:
    name: Kairos
    url: https://app.kairos.trade/docs/api-reference
  termsOfService: https://kairos.trade/terms
servers:
  - url: https://data.kairos.trade
    description: Production
  - url: https://staging-data.kairos.trade
    description: Staging
security:
  - apiKeyClientId: []
    apiKeyKey: []
    apiKeySecret: []
paths:
  /markets/metadata:
    get:
      tags:
        - Markets
      summary: Get full market metadata (rules, images, contract spec)
      description: >
        Returns the full metadata document for one market. Resolution order: (1)
        a fast cached-metadata path — for Polymarket, a cache hit derives
        status/category/images from the cached upstream payload; (2) on a miss,
        falls back to a live provider-API fetch (Kalshi ticker + event metadata
        for images; Polymarket; Opinion; predict.fun) — this covers markets too
        new to be indexed yet (e.g. short-lived 15-minute crypto markets); (3)
        if the cache hit is non-null but carries **empty** `resolution_rules`
        (both `primary` and `secondary` blank), an extra provider-API call
        backfills `resolution_rules` (and `description` if also empty) without
        discarding the rest of the cached document. Only the cached-metadata
        path populates `condition_id`/`event_id`/`contract.settlement_ts` — the
        live provider-API fallback leaves those `null`. Finally, for
        `polymarket`/`predictfun`, a best-effort liquidity-rewards enrichment
        mutates `extra` in place (never blocks or fails the response):
        Polymarket sets `extra.clobRewards` (`[{rewardsDailyRate}]` or `[]`),
        `extra.rewardsMaxSpread`, `extra.rewardsMinSize`; predict.fun sets
        `extra.rewards.current` (an active reward-window object, or `null`). 404
        only if no source has the market at all.
      operationId: getMarketMetadata
      parameters:
        - name: ticker
          in: query
          required: true
          schema:
            type: string
          description: Market ticker/ID.
          example: KXBTC15M-26JUL221600-00
        - name: provider
          in: query
          required: true
          schema:
            type: string
          description: >-
            kalshi or polymarket (also accepts any other active provider — e.g.
            predictfun, opinion — via the API fallback path).
          example: polymarket
      responses:
        '200':
          description: Full market metadata.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MarketsMetadataResponse'
        '400':
          description: Invalid/unknown provider, or a downstream `ValueError`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
        '401':
          $ref: '#/components/responses/DataUnauthorized'
        '403':
          $ref: '#/components/responses/DataForbidden'
        '404':
          description: Market not found in cached metadata or any provider API.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    example: 'Market not found: KXFOO-99'
        '422':
          $ref: '#/components/responses/DataValidationError'
        '429':
          $ref: '#/components/responses/DataRateLimited'
        '500':
          description: Metadata lookup failed.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    example: Metadata fetch failed
components:
  schemas:
    MarketsMetadataResponse:
      type: object
      required:
        - ticker
        - provider
        - name
        - description
        - resolution_rules
        - contract
        - images
        - ctf_neg_risk
        - extra
        - active
      properties:
        ticker:
          type: string
        provider:
          type: string
        name:
          type: string
        description:
          type: string
        resolution_rules:
          $ref: '#/components/schemas/MarketsResolutionRules'
        contract:
          $ref: '#/components/schemas/MarketsContractInfo'
        images:
          $ref: '#/components/schemas/MarketsImages'
        external_url:
          type:
            - string
            - 'null'
        condition_id:
          type:
            - string
            - 'null'
          description: >-
            Only populated for some response paths; null when the response comes
            from a provider-API fallback.
        event_id:
          type:
            - string
            - 'null'
          description: Only populated for some response paths.
        ctf_neg_risk:
          type: boolean
          default: false
        extra:
          type: object
          additionalProperties: true
          description: >
            Raw upstream/provider payload, plus router-side enrichment: for
            polymarket, `clobRewards` ([{rewardsDailyRate}] or []),
            `rewardsMaxSpread`, `rewardsMinSize`; for predictfun,
            `rewards.current` (active reward-window object or null).
        active:
          type: boolean
          default: true
          description: False if the market is delisted/resolved and not tradable.
    MarketsResolutionRules:
      type: object
      required:
        - primary
      properties:
        primary:
          type: string
        secondary:
          type:
            - string
            - 'null'
        source:
          type:
            - string
            - 'null'
    MarketsContractInfo:
      type: object
      properties:
        tick_size:
          type:
            - number
            - 'null'
        min_price:
          type:
            - number
            - 'null'
        max_price:
          type:
            - number
            - 'null'
        lot_size:
          type:
            - number
            - 'null'
        quote_currency:
          type:
            - string
            - 'null'
        settlement_ts:
          type:
            - string
            - 'null'
          description: Only populated for some response paths; null otherwise.
        expires_at:
          type:
            - string
            - 'null'
    MarketsImages:
      type: object
      properties:
        icon:
          type:
            - string
            - 'null'
        banner:
          type:
            - string
            - 'null'
    DataError:
      type: object
      description: Handler error envelope (FastAPI HTTPException).
      required:
        - detail
      properties:
        detail:
          type: string
          description: Human-readable error message.
          example: Invalid provider
  responses:
    DataUnauthorized:
      description: >
        No valid credential presented — missing/invalid API-key headers, or an
        invalid/expired session token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/DataError'
          example:
            detail: Not authenticated
    DataForbidden:
      description: >
        Authenticated but not permitted. Three distinct causes: the session user
        is not invited

        (`Invite required`), the API key lacks the operation's scope, or API-key
        access to the

        requested venue is switched off (`API access is disabled for
        <provider>`). Admin and API-key

        callers bypass the invite check; session and admin callers bypass scope
        and venue checks.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/DataError'
          example:
            detail: Invite required
    DataValidationError:
      description: Request failed FastAPI parameter validation.
      content:
        application/json:
          schema:
            type: object
            required:
              - detail
            properties:
              detail:
                type: array
                description: >-
                  One entry per failed field, with location, message, and error
                  type.
                items:
                  type: object
                  additionalProperties: true
    DataRateLimited:
      description: >
        Rate limit exceeded for this route's sliding window, keyed on the
        session `sub` when

        authenticated and on the trusted client IP otherwise. Honor
        `Retry-After`. A per-API-key

        data ceiling (set per credential) rejects with `{"detail": "API key data
        rate limit

        exceeded"}` instead of the `error` envelope below.
      headers:
        Retry-After:
          schema:
            type: integer
        X-RateLimit-Limit:
          schema:
            type: integer
        X-RateLimit-Remaining:
          schema:
            type: integer
        X-RateLimit-Reset:
          schema:
            type: integer
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                example: 'Rate limit exceeded: 100 per 1 minute'
  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.
    apiKeySecret:
      type: apiKey
      in: header
      name: X-Api-Secret
      description: 64-char hex API secret.

````

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