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

# GetHistoricalPrices

> Returns OHLC candlestick data for one market over a time range.

 Unlike most other endpoints, `market` only accepts the numeric
 `market_id` form of `MarketSelector`.



## OpenAPI

````yaml /developers/api-reference/openapi.yaml post /price_service.v1.PriceService/GetHistoricalPrices
openapi: 3.1.0
info:
  title: Fairground.Fi API
  description: |
    API for the Fairground Perpetuals trading platform.

    This API uses ConnectRPC which accepts JSON over HTTP POST requests.
    All service endpoints follow the pattern: `/package.ServiceName/MethodName`
  version: 1.0.0
  contact:
    name: Forte Service Company
    url: https://github.com/Forte-Service-Company-Ltd/perpetuals-api-server
  license:
    name: Proprietary
    identifier: UNLICENSED
servers:
  - url: https://api.fairground.fi
    description: Production API server
security:
  - bearerAuth: []
tags:
  - name: Trades
    description: Wallet trade/fill history
  - name: Markets
    description: Market configuration and summary endpoints
  - name: Orderbook
    description: Orderbook data retrieval
  - name: Orders
    description: Order management operations
  - name: Portfolio
    description: Aggregated per-wallet portfolio data
  - name: Positions
    description: Position management operations
  - name: Prices
    description: Oracle price and historical price data
paths:
  /price_service.v1.PriceService/GetHistoricalPrices:
    post:
      tags:
        - Prices
      summary: GetHistoricalPrices
      description: |-
        Returns OHLC candlestick data for one market over a time range.

         Unlike most other endpoints, `market` only accepts the numeric
         `market_id` form of `MarketSelector`.
      operationId: price_service.v1.PriceService.GetHistoricalPrices
      parameters:
        - name: Connect-Protocol-Version
          in: header
          required: true
          schema:
            $ref: '#/components/schemas/connect-protocol-version'
        - name: Connect-Timeout-Ms
          in: header
          schema:
            $ref: '#/components/schemas/connect-timeout-header'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/price_service.v1.GetHistoricalPricesRequest'
        required: true
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/price_service.v1.GetHistoricalPricesResponse
              example:
                prices: []
                totalCount: 0
                priceCandleSticks:
                  - timestamp: '2026-07-11T14:00:00Z'
                    open: 65200
                    high: 65550
                    low: 65100
                    close: 65420
                    mid: 0
                    volume: 0
components:
  schemas:
    connect-protocol-version:
      type: number
      title: Connect-Protocol-Version
      enum:
        - 1
      description: Define the version of the Connect protocol. If omitted, use 1.
      const: 1
      default: 1
    connect-timeout-header:
      type: number
      title: Connect-Timeout-Ms
      description: Define the timeout, in ms
    price_service.v1.GetHistoricalPricesRequest:
      type: object
      properties:
        market:
          description: |-
            Market to fetch history for. Only the `market_id` form is
            supported. `market_symbol` selector is not resolved and is
            treated as unset. Must be non-zero.
          oneOf:
            - type: object
              title: market_id
              properties:
                marketId:
                  type: string
                  format: int64
                  title: market_id
              required:
                - marketId
              additionalProperties: false
            - type: object
              title: market_symbol
              properties:
                marketSymbol:
                  $ref: '#/components/schemas/base_objects.v1.MarketSymbol'
                  title: market_symbol
              required:
                - marketSymbol
              additionalProperties: false
        startTime:
          $ref: '#/components/schemas/google.protobuf.Timestamp'
          title: start_time
          description: Start of the requested time range.
        endTime:
          $ref: '#/components/schemas/google.protobuf.Timestamp'
          title: end_time
          description: End of the requested time range.
        limit:
          type: integer
          title: limit
          description: Accepted but currently ignored by the server; no limit is applied.
        interval:
          type: string
          title: interval
          description: >-
            Candle interval. Supported values: `1S`, `1`, `60`, `1D`, `1W`,
            `1M`.
      title: GetHistoricalPricesRequest
      required:
        - market
      additionalProperties: false
    price_service.v1.GetHistoricalPricesResponse:
      type: object
      properties:
        prices:
          type: array
          items:
            $ref: '#/components/schemas/base_objects.v1.Price'
          title: prices
          description: >-
            Always empty. This endpoint returns data via `priceCandleSticks`
            instead.
        totalCount:
          type: integer
          title: total_count
          description: Always `0`. Not populated by this endpoint.
        priceCandleSticks:
          type: array
          items:
            $ref: '#/components/schemas/base_objects.v1.CandleStick'
          title: priceCandleSticks
          description: OHLC candles for the requested market and time range.
      title: GetHistoricalPricesResponse
      additionalProperties: false
    base_objects.v1.MarketSymbol:
      type: object
      properties:
        assetSymbol:
          type: string
          title: asset_symbol
          description: |-
            Underlying asset symbol, e.g. `"BTC"`. Matched case-insensitively
            and trimmed.
        quoteSymbol:
          type: string
          title: quote_symbol
          description: |-
            Quote symbol, e.g. `"PERP"`. Technically optional, but omitting
            it looks up a market named exactly by `assetSymbol` alone (e.g.
            `"BTC"`) rather than `"BTC-PERP"`, which will not resolve to any
            real market. In practice, always set this.
      title: MarketSymbol
      additionalProperties: false
    google.protobuf.Timestamp:
      type: string
      examples:
        - '2023-01-15T01:30:15.01Z'
        - '2024-12-25T12:00:00Z'
      format: date-time
    base_objects.v1.Price:
      type: object
      properties:
        marketId:
          type: string
          title: market_id
          format: int64
          description: On-chain market identifier.
        marketName:
          type: string
          title: market_name
          description: |-
            Same value as `symbol` on this object (both are set from
            whichever selector form the request used — see `symbol`).
        symbol:
          type: string
          title: symbol
          description: |-
            Echoes back however the market was identified in the request:
            the bare asset symbol (e.g. `"BTC"`) if the request used
            `market_symbol`, or the full market name (e.g. `"BTC-PERP"`) if
            the request used `market_id`. `marketName` always mirrors this
            same value.
        price:
          type: number
          title: price
          format: float
          description: Current price in USD.
        volume24h:
          type: number
          title: volume_24h
          format: float
          description: 24-hour trading volume in the market's quote units.
        priceChange24h:
          type: number
          title: price_change_24h
          format: float
          description: 24-hour price change, as a percentage.
        timestamp:
          $ref: '#/components/schemas/google.protobuf.Timestamp'
          title: timestamp
          description: When the price was recorded by the upstream pricing service.
        source:
          type: string
          title: source
          description: Price feed source
      title: Price
      additionalProperties: false
    base_objects.v1.CandleStick:
      type: object
      properties:
        timestamp:
          $ref: '#/components/schemas/google.protobuf.Timestamp'
          title: timestamp
          description: Start of this candle's interval.
        open:
          type: number
          title: open
          format: float
          description: Opening price for this interval, in USD.
        high:
          type: number
          title: high
          format: float
          description: Highest price during this interval, in USD.
        low:
          type: number
          title: low
          format: float
          description: Lowest price during this interval, in USD.
        close:
          type: number
          title: close
          format: float
          description: Closing price for this interval, in USD.
        mid:
          type: number
          title: mid
          format: float
          description: Always `0`. Not currently populated by `GetHistoricalPrices`.
        volume:
          type: integer
          title: volume
          description: Always `0`. Not currently populated by `GetHistoricalPrices`.
      title: CandleStick
      additionalProperties: false
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````