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

# Time-series price points for the chart UI

> Returns a gap-free series of `(ts, price)` tuples for the requested `range` and `outcome`. `price` is `(bestBid + bestAsk) / 2` when both book sides are populated, last-trade fallback otherwise, with carry-forward through inactive intervals — the FE never receives an empty `points` array on an active market.

Replaces the legacy `/ohlc` endpoint for the new chart UX:
- Single `range` parameter — backend owns the (grain, window) mapping, so a UX change ("LIVE shows 10 min instead of 5") does not require a frontend deploy.
- `mid` semantics match the displayed pill price the FE renders from the orderbook, so the chart line aligns with the headline percentage.

Bucket counts: `live` ≈ 300 (1s), `1h` = 60 (1m), `1d` = 48 (30m), `1w` = 28 (6h), `1m` = 60 (12h).



## OpenAPI

````yaml /api-reference/openapi.json get /api/markets/{symbol}/price-history
openapi: 3.1.0
info:
  title: PredictStreet core-api
  description: >-
    Client-facing HTTP gateway for the PredictStreet prediction-market platform.
    This spec is hand-written against the NestJS controllers and DTOs in
    core-api/src/modules/. For the source-of-truth live spec, run
    `./scripts/pull-openapi.sh` against a running core-api (NestJS exposes it at
    /api/docs-json). **Partner kinds.** Every authenticated endpoint resolves a
    request's *effective wallet* from the partner row. `single_wallet` partners
    bind to one `associatedWallet` set at creation. `multi_wallet` partners
    declare the actor on every request via an `X-User-Wallet: 0x<40-hex>`
    header. See the [Partner kinds](/auth/api-keys#partner-kinds) doc for the
    full contract.
  version: '2026-06-16'
  contact:
    name: PredictStreet partners
    email: partners@predictstreet.com
servers:
  - url: https://core.api.dev.predictstreet.sde.adifoundation.ai
    description: Testnet (partner integrator API — final domain TBD)
security: []
tags:
  - name: Deposits
    description: >-
      Gasless USDC deposit relay - submit a signed EIP-2612 permit and the
      platform broadcasts the on-chain deposit for you (no gas).
  - name: Events
    description: >-
      Polymarket-style event grouping with football metadata (group, stage,
      teams, tags).
  - name: Tags
    description: Curated tag taxonomy used to filter events.
  - name: Markets
    description: 'Public market data: list, detail, orderbook, trades, OHLC.'
  - name: Orders
    description: >-
      Signed-order place / cancel / read. Requires `X-Api-Key` with
      `orders:read` / `orders:write` scope; every write additionally requires an
      EIP-712 signature over the order.
  - name: Portfolio
    description: >-
      Balances, positions, trades, fees, vault info for the key's
      `associatedWallet`. Requires `X-Api-Key` with `portfolio:read` scope.
  - name: Matches
    description: >-
      admin.matches aggregate — groups several events into one fixture/card (1X2
      + first-scorer + over-under under one matchup).
  - name: Vault
    description: >-
      Backend co-signatures for ERC-1155 split / merge, and recovery for
      off-chain locks when the corresponding chain tx never confirmed. Requires
      `X-Api-Key` with `vault:write` scope plus an EIP-712 signature over the
      operation.
  - name: Leaderboard
    description: Public ranked leaderboard across PnL / volume buckets.
  - name: Search
    description: Global search across users, events, and matches.
  - name: Withdrawal Security
    description: >-
      Self-service withdrawal 2FA (TOTP) and withdrawal-address whitelist. Same
      endpoints serve the frontend (Privy JWT) and API-key integrators.
      Mutations need `vault:write`, reads `portfolio:read`. Both are opt-in per
      wallet and only gate withdrawals once the platform enables
      withdrawal-security enforcement.
paths:
  /api/markets/{symbol}/price-history:
    get:
      tags:
        - Markets
      summary: Time-series price points for the chart UI
      description: >-
        Returns a gap-free series of `(ts, price)` tuples for the requested
        `range` and `outcome`. `price` is `(bestBid + bestAsk) / 2` when both
        book sides are populated, last-trade fallback otherwise, with
        carry-forward through inactive intervals — the FE never receives an
        empty `points` array on an active market.


        Replaces the legacy `/ohlc` endpoint for the new chart UX:

        - Single `range` parameter — backend owns the (grain, window) mapping,
        so a UX change ("LIVE shows 10 min instead of 5") does not require a
        frontend deploy.

        - `mid` semantics match the displayed pill price the FE renders from the
        orderbook, so the chart line aligns with the headline percentage.


        Bucket counts: `live` ≈ 300 (1s), `1h` = 60 (1m), `1d` = 48 (30m), `1w`
        = 28 (6h), `1m` = 60 (12h).
      operationId: PriceHistoryController_priceHistory
      parameters:
        - $ref: '#/components/parameters/MarketSymbol'
        - name: range
          in: query
          required: true
          schema:
            type: string
            enum:
              - live
              - 1h
              - 1d
              - 1w
              - 1m
          description: >-
            `live` = last 5 min @ 1s buckets · `1h` = last 1h @ 1m · `1d` = last
            24h @ 30m · `1w` = last 7d @ 6h · `1m` = last 30d @ 12h.
        - name: outcome
          in: query
          required: false
          schema:
            type: string
            default: 'YES'
          description: >-
            Outcome to project. Binary markets accept `YES` / `NO`; N-ary
            markets accept the integer index (0-based). Defaults to `YES`.
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PriceHistoryRespDto'
        '400':
          description: Missing/invalid `range` or unrecognised `outcome`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '404':
          description: Market symbol not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
      security:
        - {}
components:
  parameters:
    MarketSymbol:
      name: symbol
      in: path
      required: true
      description: >-
        Market symbol, e.g. `UAE-CUP-FINAL-20260425`. Used by sub-resource
        endpoints (`/orderbook`, `/trades`, `/ohlc`, `/traders`). The root
        market-detail endpoint `/api/markets/{slug}` accepts the slug instead —
        see `MarketSlug`.
      schema:
        type: string
  schemas:
    PriceHistoryRespDto:
      type: object
      required:
        - symbol
        - outcome
        - range
        - from
        - to
        - points
      properties:
        symbol:
          type: string
          example: WC26-FIN-ARG-FRA
        outcome:
          type: string
          description: Echoed `outcome` query parameter (label or raw integer).
          example: 'YES'
        range:
          type: string
          enum:
            - live
            - 1h
            - 1d
            - 1w
            - 1m
        from:
          type: string
          format: date-time
          description: Window lower bound (inclusive).
        to:
          type: string
          format: date-time
          description: Window upper bound (inclusive).
        points:
          type: array
          items:
            $ref: '#/components/schemas/PriceHistoryPoint'
    ErrorEnvelope:
      type: object
      required:
        - error
      properties:
        status:
          type: integer
          example: 400
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              example: bad_request
            message:
              type: string
            details:
              type: object
              additionalProperties: true
            trace_id:
              type: string
    PriceHistoryPoint:
      type: object
      required:
        - ts
        - price
      properties:
        ts:
          type: string
          format: date-time
          description: ISO-8601 bucket boundary (UTC).
          example: '2026-05-09T15:00:00.000Z'
        price:
          type: string
          nullable: true
          description: >-
            User-view price at this bucket (post canon→user-view flip). Computed
            as `mid = (bestBid + bestAsk) / 2` when both sides of the orderbook
            are populated; falls back to the last trade when only one side is
            present; carries the previous value forward through gaps so the line
            never breaks. `null` only when the market has had no two-sided book
            and no trades at any point up to this bucket.
          example: '0.530000'

````