> ## 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.

# Fetch volume and outcome-pressure metrics for a contract

> Returns aggregate trade metrics (volume, per-outcome volume split, trade count) for a single `(provider, contract_id)` over a lookback window, computed from Kairos's own ingested trade store — same data source as `/trades/history`, not a live upstream proxy. There is no buy/sell-side breakdown: metrics are split by outcome (`outcome_0`/`outcome_1`) rather than trade direction, since trade direction cannot be reliably determined from exchange data for all providers.

**Auth**: requires the `trade:read` scope (admin/JWT bypass the scope check; API keys need `trade:read`), plus API access to the requested provider being enabled for API-key callers — 403 if disabled.

**Staleness**: if `trigger_ingest=true` and ingestion coverage for the window is low, the service triggers a backfill/ingestion job and reports it via the `indexing` flag on the returned metrics object.




## OpenAPI

````yaml /openapi/data-api.yaml get /trades/metrics
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:
  /trades/metrics:
    get:
      tags:
        - Trades
      summary: Fetch volume and outcome-pressure metrics for a contract
      description: >
        Returns aggregate trade metrics (volume, per-outcome volume split, trade
        count) for a single `(provider, contract_id)` over a lookback window,
        computed from Kairos's own ingested trade store — same data source as
        `/trades/history`, not a live upstream proxy. There is no buy/sell-side
        breakdown: metrics are split by outcome (`outcome_0`/`outcome_1`) rather
        than trade direction, since trade direction cannot be reliably
        determined from exchange data for all providers.


        **Auth**: requires the `trade:read` scope (admin/JWT bypass the scope
        check; API keys need `trade:read`), plus API access to the requested
        provider being enabled for API-key callers — 403 if disabled.


        **Staleness**: if `trigger_ingest=true` and ingestion coverage for the
        window is low, the service triggers a backfill/ingestion job and reports
        it via the `indexing` flag on the returned metrics object.
      operationId: getTradeMetrics
      parameters:
        - name: provider
          in: query
          required: true
          schema:
            type: string
          description: >-
            Venue identifier, matched case-insensitively against the live
            provider registry.
          example: kalshi
        - name: contract_id
          in: query
          required: true
          schema:
            type: string
            minLength: 1
            maxLength: 128
          description: >-
            Provider-specific contract identifier. Empty or >128 chars returns
            400.
        - name: window_seconds
          in: query
          required: false
          schema:
            type: integer
            minimum: 3600
            maximum: 86400
            default: 86400
          description: >-
            Lookback window in seconds, ending "now". Clamped to [3600, 86400]
            (1 hour to 24 hours).
        - name: trigger_ingest
          in: query
          required: false
          schema:
            type: boolean
            default: false
          description: >-
            If true, triggers ingestion when coverage for this window is low,
            rather than computing metrics from partial/stale data alone.
      responses:
        '200':
          description: Aggregate volume/pressure metrics for the window.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TradesMetricsResponse'
        '400':
          description: >-
            Invalid trade metrics request (unknown provider, invalid
            contract_id, or a request the service itself rejected as malformed).
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    example: Invalid trade metrics request
        '401':
          $ref: '#/components/responses/DataUnauthorized'
        '403':
          description: >-
            API-key credential lacks the `trade:read` scope, or API access to
            the requested provider is currently disabled.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
        '422':
          $ref: '#/components/responses/DataValidationError'
        '429':
          $ref: '#/components/responses/DataRateLimited'
        '500':
          description: Trade metrics fetch failed on the backend.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    example: Trade metrics fetch failed
        '503':
          description: Per-venue API-access flag could not be read or validated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DataError'
components:
  schemas:
    TradesMetricsResponse:
      type: object
      required:
        - metrics
      properties:
        metrics:
          $ref: '#/components/schemas/TradesMetrics'
    DataError:
      type: object
      description: Handler error envelope (FastAPI HTTPException).
      required:
        - detail
      properties:
        detail:
          type: string
          description: Human-readable error message.
          example: Invalid provider
    TradesMetrics:
      type: object
      description: >
        Aggregate volume/pressure metrics. Split by outcome (outcome_0 vs
        outcome_1), not by buy/sell direction — trade direction is not reliably
        derivable from every provider's exchange data.
      required:
        - volume_usd
        - outcome_0_volume_usd
        - outcome_1_volume_usd
        - outcome_0_pressure_pct
        - trade_count
        - window_seconds
        - coverage_pct
        - source
        - indexing
      properties:
        volume_usd:
          type: number
          description: Total notional volume in the window, in USD.
          example: 154320.55
        outcome_0_volume_usd:
          type: number
          description: >-
            Notional volume attributed to the first/primary outcome (e.g.
            "yes").
          example: 98210.1
        outcome_1_volume_usd:
          type: number
          description: Notional volume attributed to the second outcome (e.g. "no").
          example: 56110.45
        outcome_0_pressure_pct:
          type: number
          description: >-
            Share of total volume_usd attributed to outcome_0, as a percentage
            (0-100).
          example: 63.65
        trade_count:
          type: integer
          description: Number of trades included in the aggregation.
          example: 842
        window_seconds:
          type: integer
          description: Window width the metrics were computed over, in seconds.
          example: 86400
        coverage_pct:
          type: number
          description: >-
            Estimated data coverage for the window as a percentage (0-100); 100
            for live upstream proxies (Kalshi/Polymarket) and for fully-ingested
            windows.
          example: 100
        source:
          type: string
          description: >-
            Opaque internal marker indicating how the response was produced. NOT
            a stable part of the contract — its value may change without notice;
            do not depend on or switch on it.
        indexing:
          type: boolean
          description: >-
            True if an ingestion/backfill job was triggered or is in progress
            for this window (only meaningful when the caller passed
            `trigger_ingest=true`); coverage may be incomplete when true.
          example: false
  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
    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.