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

# Wallet-wide PnL totals across all markets

> Wallet-wide PnL totals aggregated across every market the wallet has touched, refreshed hourly — a fast point lookup rather than a live scan. For real-time per-market freshness on a single active market, use `/pnl/hover/{provider_id}/{wallet}/{contract_id}` instead. Same provider restriction as `/pnl/hover`: only `polymarket`, `opinion`, `predictfun` are accepted; `kalshi` and `hyperliquid` are rejected with 400 and must use `/pnl/{user_id}`. When the underlying pipeline is disabled, returns a well-formed zero payload (`market_count: 0`, `token_count: 0`, all dollar totals `0.0`, `snapshot_ts` set to the current time) instead of erroring. For API-key callers, the requested provider must additionally have its API access enabled.




## OpenAPI

````yaml /openapi/data-api.yaml get /pnl/wallet-totals/{provider_id}/{wallet}
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:
  /pnl/wallet-totals/{provider_id}/{wallet}:
    get:
      tags:
        - PnL
      summary: Wallet-wide PnL totals across all markets
      description: >
        Wallet-wide PnL totals aggregated across every market the wallet has
        touched, refreshed hourly — a fast point lookup rather than a live scan.
        For real-time per-market freshness on a single active market, use
        `/pnl/hover/{provider_id}/{wallet}/{contract_id}` instead. Same provider
        restriction as `/pnl/hover`: only `polymarket`, `opinion`, `predictfun`
        are accepted; `kalshi` and `hyperliquid` are rejected with 400 and must
        use `/pnl/{user_id}`. When the underlying pipeline is disabled, returns
        a well-formed zero payload (`market_count: 0`, `token_count: 0`, all
        dollar totals `0.0`, `snapshot_ts` set to the current time) instead of
        erroring. For API-key callers, the requested provider must additionally
        have its API access enabled.
      operationId: getWalletTotals
      parameters:
        - name: provider_id
          in: path
          required: true
          schema:
            type: string
            maxLength: 32
            enum:
              - polymarket
              - opinion
              - predictfun
          description: >-
            MV-pipeline provider id. `kalshi` and `hyperliquid` are rejected
            with 400.
          example: polymarket
        - name: wallet
          in: path
          required: true
          schema:
            type: string
            maxLength: 128
          description: >-
            Wallet address (opaque string; trimmed, length-checked — not
            format-validated at this layer).
          example: '0x1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b'
      responses:
        '200':
          description: >
            Wallet-wide PnL totals as of the last hourly snapshot. Returns a
            zeroed payload (not a 404) when the underlying PnL pipeline is
            disabled.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PnlWalletTotalsResponse'
        '400':
          description: >-
            Missing/oversized `wallet`, or `provider_id` is not a valid
            MV-pipeline provider (e.g. kalshi or hyperliquid).
        '401':
          $ref: '#/components/responses/DataUnauthorized'
        '403':
          description: >-
            API key missing `position:read` scope, or platform API access
            disabled for this provider.
        '422':
          $ref: '#/components/responses/DataValidationError'
        '429':
          $ref: '#/components/responses/DataRateLimited'
        '500':
          description: Unexpected error fetching wallet totals.
        '503':
          description: Per-venue API-access flag could not be read or validated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DataError'
components:
  schemas:
    PnlWalletTotalsResponse:
      type: object
      description: >
        Wallet-wide PnL totals across all markets, refreshed hourly. Returns a
        zeroed payload (`market_count: 0`, `token_count: 0`) instead of erroring
        when the underlying PnL pipeline is disabled.
      required:
        - provider_id
        - wallet_address
        - total_unrealized_pnl_usd
        - total_realized_pnl_usd
        - total_position_value_usd
        - total_cost_basis_usd
        - market_count
        - token_count
        - snapshot_ts
      properties:
        provider_id:
          type: string
          enum:
            - polymarket
            - opinion
            - predictfun
          example: polymarket
        wallet_address:
          type: string
          example: '0x1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b'
        total_unrealized_pnl_usd:
          type: number
          format: double
          example: 340.2
        total_realized_pnl_usd:
          type: number
          format: double
          example: 1250.4382
        total_position_value_usd:
          type: number
          format: double
          example: 980
        total_cost_basis_usd:
          type: number
          format: double
          example: 640
        market_count:
          type: integer
          example: 12
        token_count:
          type: integer
          example: 19
        snapshot_ts:
          type: string
          format: date-time
          description: >-
            ISO-8601 timestamp of the hourly snapshot this data was read from
            (or the current time when native_pnl_pipeline is disabled).
          example: '2026-07-22T13:00:00Z'
    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
    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.