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

# Historical candles



## OpenAPI

````yaml /developer/trading-api/openapi.json get /v1/{chain}/markets/{symbol}/candles
openapi: 3.1.0
info:
  title: Gains Trading API
  version: 1.0.0
  description: >-
    Native REST and WebSocket API for trading on Gains Network.
    Resource-oriented, JSON in and out, decimal strings for every price and
    size, one EIP-712 signing scheme, and an order lifecycle that hides the
    oracle two-step.
servers:
  - url: https://api.gains.trade
security: []
tags:
  - name: Markets
    description: Public market data
  - name: Account
    description: 'Private reads: balances, positions, orders, fills'
  - name: Orders
    description: Place, update and cancel orders
  - name: Positions
    description: Close and manage open positions
  - name: Agents
    description: Non-custodial agent authorisation
  - name: System
    description: Health
paths:
  /v1/{chain}/markets/{symbol}/candles:
    get:
      tags:
        - Markets
      summary: Historical candles
      operationId: getCandles
      parameters:
        - schema:
            type: string
            enum:
              - arbitrum
              - base
              - polygon
              - megaeth
              - arbitrum-sepolia
            example: arbitrum
          required: true
          name: chain
          in: path
        - schema:
            type: string
            example: BTC-USD
            description: Market symbol. `BTC-USD` and `BTC%2FUSD` are both accepted.
          required: true
          description: Market symbol. `BTC-USD` and `BTC%2FUSD` are both accepted.
          name: symbol
          in: path
        - schema:
            type: string
            enum:
              - 1m
              - 5m
              - 15m
              - 30m
              - 1h
              - 4h
              - 1d
            default: 1h
          required: false
          name: interval
          in: query
        - schema:
            type:
              - integer
              - 'null'
            description: Start, epoch milliseconds
          required: false
          description: Start, epoch milliseconds
          name: from
          in: query
        - schema:
            type:
              - integer
              - 'null'
            description: End, epoch milliseconds
          required: false
          description: End, epoch milliseconds
          name: to
          in: query
      responses:
        '200':
          description: Candles, oldest first
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Candle'
                required:
                  - data
        '400':
          description: Malformed request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '502':
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Candle:
      type: object
      properties:
        time:
          type: integer
          description: Candle open time, epoch milliseconds.
        open:
          type: string
          pattern: ^-?(?:0|[1-9]\d*)(?:\.\d+)?$
          example: '0.5'
          description: Decimal number encoded as a string to preserve precision.
        high:
          type: string
          pattern: ^-?(?:0|[1-9]\d*)(?:\.\d+)?$
          example: '0.5'
          description: Decimal number encoded as a string to preserve precision.
        low:
          type: string
          pattern: ^-?(?:0|[1-9]\d*)(?:\.\d+)?$
          example: '0.5'
          description: Decimal number encoded as a string to preserve precision.
        close:
          type: string
          pattern: ^-?(?:0|[1-9]\d*)(?:\.\d+)?$
          example: '0.5'
          description: Decimal number encoded as a string to preserve precision.
      required:
        - time
        - open
        - high
        - low
        - close
    Error:
      type: object
      properties:
        code:
          type: string
          enum:
            - VALIDATION_ERROR
            - UNAUTHENTICATED
            - INVALID_SIGNATURE
            - TIMESTAMP_OUT_OF_WINDOW
            - NONCE_REUSED
            - AGENT_UNKNOWN
            - API_KEY_UNKNOWN
            - AGENT_NOT_DELEGATED
            - AGENT_EXPIRED
            - AGENT_REVOKED
            - SCOPE_READ_ONLY
            - SCOPE_MARKET_NOT_ALLOWED
            - SCOPE_LEVERAGE_EXCEEDED
            - SCOPE_SPEND_CAP_EXCEEDED
            - TRADER_MISMATCH
            - CHAIN_NOT_FOUND
            - CHAIN_READ_ONLY
            - MARKET_NOT_FOUND
            - ORDER_NOT_FOUND
            - POSITION_NOT_FOUND
            - AGENT_NOT_FOUND
            - IDEMPOTENCY_CONFLICT
            - ORDER_NOT_MODIFIABLE
            - PRECISION_ERROR
            - LEVERAGE_OUT_OF_RANGE
            - SIZE_BELOW_MINIMUM
            - MARKET_CLOSED
            - COLLATERAL_NOT_SUPPORTED
            - SIMULATION_REVERTED
            - SUBMISSION_MISMATCH
            - UNSUPPORTED
            - RATE_LIMITED
            - INTERNAL
            - UPSTREAM_UNAVAILABLE
            - NOT_READY
        message:
          type: string
        details:
          type: object
          additionalProperties: {}
      required:
        - code
        - message

````