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

# Historical

> Provides historical OHLCV (Open, High, Low, Close, Volume) data for Spot market trading pairs, enabling analysis of price movements and trading volumes over time across supported exchanges.

<Accordion title="BitMEX Volume Calculation Warning">
  <Warning>
    BitMEX’s `volume` field represents the **number of contracts traded**, not the volume in the base asset.

    To obtain the correct volume, users must adjust for **contract size** using the `underlyingToPositionMultiplier` from our [Reference endpoint](/http/md/spot-exchanges-reference).

    For details on this calculation and how to retrieve the correct values, see our [Changelog Update](/changelog/bitmex-volume-mapping).
  </Warning>
</Accordion>

<Warning>
  The maximum time range (difference between `startDate` and `endDate`) is **731 days (2 years)**.
</Warning>

<Note>
  If the `startDate` and `endDate` query parameters are not provided, the API will return the data from the previous 12 months of daily data.
</Note>


## OpenAPI

````yaml get /spot/ohlcv/{instrument}
openapi: 3.1.0
info:
  title: market-api
  version: '2'
servers:
  - url: https://api.amberdata.com/markets
security:
  - ApiKeyAuth: []
paths:
  /spot/ohlcv/{instrument}:
    get:
      summary: Historical
      description: >-
        Provides historical OHLCV (Open, High, Low, Close, Volume) data for Spot
        market trading pairs, enabling analysis of price movements and trading
        volumes over time across supported exchanges.
      operationId: get-historical-ohlc
      parameters:
        - name: instrument
          in: path
          description: The market pair for which to retrieve open-high-low-close.
          schema:
            type: string
            default: eth_usd
          required: true
        - name: exchange
          in: query
          description: >-
            The exchange(s) for which to retrieve OHLCV. Example:
            exchange=bitfinex,bitstamp
          required: true
          schema:
            type: string
            default: bitfinex
        - name: startDate
          in: query
          description: >-
            **[Optional]** Payload only includes data after this date
            (inclusive).  **[Formats]** `seconds | milliseconds | iso8601`
            **[Examples]** `1578531600 | 1578531600000 | 2020-09-01T01:00:00`
          schema:
            type: string
            format: date-time
        - name: endDate
          in: query
          description: >-
            **[Optional]** Payload only includes data before this date
            (exclusive).  **[Formats]** `seconds | milliseconds | iso8601`
            **[Examples]** `1578531600 | 1578531600000 | 2020-09-01T01:00:00`
          schema:
            type: string
            format: date-time
        - name: timeInterval
          in: query
          description: >-
            **[Optional]** Time interval. **[Defaults]** `minutes | hours |
            days*`
          schema:
            type: string
        - name: timeFormat
          in: query
          description: >-
            **[Optional]** Time format of the timestamps in the return payload.
            **[Defaults]** `milliseconds | ms* | iso | iso8601 | hr |
            human_readable`
          schema:
            type: string
        - name: sortDirection
          in: query
          description: >-
            **[Optional]** Specifies the direction in which the data is sorted
            (by timestamp).   **[Defaults]** asc (ascending order).   **[Usage
            Conditions]** This parameter can only be used if the `startDate` and
            `endDate` timeframe is within the most recent 24 hours, or if the
            `startDate` and `endDate` parameters are not used at all.  
            **[Examples]** ascending | descending | asc | desc
          schema:
            type: string
        - name: Accept-Encoding
          in: header
          required: true
          description: ''
          schema:
            type: string
            default: gzip, deflate, br
        - name: api-version
          in: header
          schema:
            type: string
      responses:
        '200':
          description: '200'
          content:
            application/json:
              examples:
                Success:
                  value:
                    status: 200
                    title: OK
                    description: Successful request
                    payload:
                      metadata:
                        next: >-
                          https://api.amberdata.com/markets/spot/ohlcv/btc_usd?cursor=N4IgpgHgxgFghgOwOZhALhEgJnCIA0IUArgE4DOA9qegsQDb2HkAucpLAInC6mgIwA2AJwB2ABwAWQZIAM8%2BYTAIs3Xun6iATJoCss0dq37CLAJYBbMAEkEvUgDc49dKARwr6EDgCe5AiDkAI70AHIefN5wPgHBYREACvRkzl44ZvQxhFhgAGZwDCzoAMxCWlpyCrKEFrjogsUVkuJV1SD0lJQA1gBGcFBdCWCkZpRY6FqyAL6EZghQyTkAqgjkxAAO69S8WACi0PDIYP5o%2BfTkYKaWYABi1LVFGBYZ9GYXUJQq-oS59zxeACsqAgAvQ4KwAOKkSgbVyYHB4NCgcxWVgedYaEQSaSVBRXVFsCzrcIISjvT5YE5tOY5RHTKZTIA
                        api-version: '2023-09-30'
                      data:
                        - instrument: btc_usd
                          exchange: gdax
                          exchangeTimestamp: 1690156800000
                          open: 30081.61
                          high: 30099.99
                          low: 28850
                          close: 29176.98
                          volume: 14484.27543962
              schema:
                oneOf:
                  - title: Success
                    type: object
                    properties:
                      status:
                        type: integer
                        example: 200
                        default: 0
                      title:
                        type: string
                        example: OK
                      description:
                        type: string
                        example: Successful request
                      payload:
                        type: object
                        properties:
                          metadata:
                            type: object
                            properties:
                              next:
                                type: string
                                example: >-
                                  https://api.amberdata.com/markets/spot/ohlcv/btc_usd?cursor=N4IgpgHgxgFghgOwOZhALhEgJnCIA0IUArgE4DOA9qegsQDb2HkAucpLAInC6mgIwA2AJwB2ABwAWQZIAM8%2BYTAIs3Xun6iATJoCss0dq37CLAJYBbMAEkEvUgDc49dKARwr6EDgCe5AiDkAI70AHIefN5wPgHBYREACvRkzl44ZvQxhFhgAGZwDCzoAMxCWlpyCrKEFrjogsUVkuJV1SD0lJQA1gBGcFBdCWCkZpRY6FqyAL6EZghQyTkAqgjkxAAO69S8WACi0PDIYP5o%2BfTkYKaWYABi1LVFGBYZ9GYXUJQq-oS59zxeACsqAgAvQ4KwAOKkSgbVyYHB4NCgcxWVgedYaEQSaSVBRXVFsCzrcIISjvT5YE5tOY5RHTKZTIA
                              api-version:
                                type: string
                                example: '2023-09-30'
                          data:
                            type: array
                            items:
                              type: object
                              properties:
                                instrument:
                                  type: string
                                  example: btc_usd
                                exchange:
                                  type: string
                                  example: gdax
                                exchangeTimestamp:
                                  type: integer
                                  example: 1690156800000
                                  default: 0
                                open:
                                  type: number
                                  example: 30081.61
                                  default: 0
                                high:
                                  type: number
                                  example: 30099.99
                                  default: 0
                                low:
                                  type: integer
                                  example: 28850
                                  default: 0
                                close:
                                  type: number
                                  example: 29176.98
                                  default: 0
                                volume:
                                  type: number
                                  example: 14484.27543962
                                  default: 0
      deprecated: false
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````