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

# Get Candles

> OHLC candles for one market at the requested timeframe.

Backed by a ClickHouse AggregatingMergeTree materialized view per
timeframe (see db/migrations/001_candles.sql). Reading uses the
*Merge combinators to collapse partial aggregates.



## OpenAPI

````yaml get /v1/candles
openapi: 3.1.0
info:
  title: PolyQuantLab API
  version: 0.1.0
  description: >-
    Sub-second Polymarket orderbook data, walk-the-book backtests, paper
    trading, and the live arb audit. Same endpoints the PolyQuantLab dashboard
    uses internally — Bearer-token auth, JSON-over-HTTPS, predictable
    pagination.
  contact:
    email: contact@polyquantlab.com
    url: https://polyquantlab.com/contact
  license:
    name: Proprietary
servers:
  - url: https://api.polyquantlab.com
    description: Production
security:
  - ApiKeyAuth: []
paths:
  /v1/candles:
    get:
      summary: Get Candles
      description: |-
        OHLC candles for one market at the requested timeframe.

        Backed by a ClickHouse AggregatingMergeTree materialized view per
        timeframe (see db/migrations/001_candles.sql). Reading uses the
        *Merge combinators to collapse partial aggregates.
      operationId: get_candles_v1_candles_get
      parameters:
        - name: market_id
          in: query
          required: true
          schema:
            type: string
            title: Market Id
        - name: timeframe
          in: query
          required: true
          schema:
            type: string
            examples:
              - 5m
              - 15m
              - 1h
              - 4h
              - 24h
            title: Timeframe
        - name: start
          in: query
          required: true
          schema:
            type: string
            format: date-time
            title: Start
        - name: end
          in: query
          required: true
          schema:
            type: string
            format: date-time
            title: End
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            maximum: 10000
            default: 1000
            title: Limit
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetCandlesVCandlesGetResponse'
              example:
                market_id: 0x4a8f31...c2
                timeframe: 5m
                count: 2
                candles:
                  - ts: '2026-06-06T03:55:00+00:00'
                    open: 0.5
                    high: 0.62
                    low: 0.49
                    close: 0.61
                    volume: 3210.5
                    trade_count: 47
                  - ts: '2026-06-06T04:00:00+00:00'
                    open: 0.61
                    high: 0.83
                    low: 0.6
                    close: 0.82
                    volume: 5640.2
                    trade_count: 84
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    GetCandlesVCandlesGetResponse:
      type: object
      properties:
        market_id:
          type: string
          description: Polymarket market identifier (hex 0x…).
        timeframe:
          type: string
          enum:
            - 5m
            - 15m
            - 1h
            - 4h
            - 24h
        count:
          type: integer
          format: int64
        candles:
          type: array
          items:
            type: object
            properties:
              ts:
                type: string
                format: date-time
              open:
                type: number
                format: double
              high:
                type: number
                format: double
              low:
                type: number
                format: double
              close:
                type: number
                format: double
              volume:
                type: number
                format: double
              trade_count:
                type: integer
                format: int64
            required:
              - ts
              - open
              - high
              - low
              - close
              - volume
              - trade_count
      required:
        - market_id
        - timeframe
        - count
        - candles
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key

````