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

# OHLCV Historical

`GET /v2/cryptocurrency/ohlcv/historical`

[Back to Cryptocurrency endpoint index](https://coinmarketcap.com/api/documentation/pro-api-reference/cryptocurrency.md)

[Open this endpoint in interactive docs](https://coinmarketcap.com/api/documentation/pro-api-reference/cryptocurrency#ohlcv-historical)

Returns historical OHLCV (Open, High, Low, Close, Volume) data along with market cap for any cryptocurrency using time interval parameters. Currently daily and hourly OHLCV periods are supported. Volume is not currently supported for hourly OHLCV intervals before 2020-09-22.

**Please note**: This documentation relates to our updated V2 endpoint, which may be incompatible with our V1 versions. Documentation for deprecated endpoints can be found [the deprecated section](https://coinmarketcap.com/api/documentation/pro-api-reference/deprecated).

  
**Technical Notes**
- Only the date portion of the timestamp is used for daily OHLCV so it's recommended to send an ISO date format like "2018-09-19" without time for this "time_period". 
- One OHLCV quote will be returned for every "time_period" between your "time_start" (exclusive) and "time_end" (inclusive).  
- If a "time_start" is not supplied, the "time_period" will be calculated in reverse from "time_end" using the "count" parameter which defaults to 10 results.  
- If "time_end" is not supplied, it defaults to the current time.   
- If you don't need every "time_period" between your dates you may adjust the frequency that "time_period" is sampled using the "interval" parameter. For example with "time_period" set to "daily" you may set "interval" to "2d" to get the daily OHLCV for every other day. You could set "interval" to "monthly" to get the first daily OHLCV for each month, or set it to "yearly" to get the daily OHLCV value against the same date every year.  

**Implementation Tips**
- If querying for a specific OHLCV date your "time_start" should specify a timestamp of 1 interval prior as "time_start" is an exclusive time parameter (as opposed to "time_end" which is inclusive to the search). This means that when you pass a "time_start" results will be returned for the *next* complete "time_period". For example, if you are querying for a daily OHLCV datapoint for 2018-11-30 your "time_start" should be "2018-11-29".   
- If only specifying a "count" parameter to return latest OHLCV periods, your "count" should be 1 number higher than the number of results you expect to receive. "Count" defines the number of "time_period" intervals queried, *not* the number of results to return, and this includes the currently active time period which is incomplete when working backwards from current time. For example, if you want the last daily OHLCV value available simply pass "count=2" to skip the incomplete active time period.
- This endpoint supports requesting multiple cryptocurrencies in the same call. Please note the API response will be wrapped in an additional object in this case.  
  
**Interval Options**  
  
There are 2 types of time interval formats that may be used for "time_period" and "interval" parameters. For "time_period" these return aggregate OHLCV data from the beginning to end of each interval period. Apply these time intervals to "interval" to adjust how frequently "time_period" is sampled.  
  
The first are calendar year and time constants in UTC time:  
**"hourly"** - Hour intervals in UTC.  
**"daily"** - Calendar day intervals for each UTC day.  
**"weekly"** - Calendar week intervals for each calendar week.  
**"monthly"** - Calendar month intervals for each calendar month.    
**"yearly"** - Calendar year intervals for each calendar year.  
  
The second are relative time intervals.  
**"h"**: Get the first quote available every "h" hours (3600 second intervals). Supported hour intervals are: "1h", "2h", "3h", "4h", "6h", "12h".  
**"d"**: Time periods that repeat every "d" days (86400 second intervals). Supported day intervals are: "1d", "2d", "3d", "7d", "14d", "15d", "30d", "60d", "90d", "365d".  
  
Please note that "time_period" currently supports the "daily" and "hourly" options. "interval" supports all interval options.

- ~~Basic~~
- ~~Builder~~
- Startup (intraday: 1 month, daily: from 2010)
- Growth (intraday: 3 months, daily: from 2010)
- Professional (intraday: 12 months, daily: from 2010)
- Enterprise (intraday: from 2010, daily: from 2010)

**Note:** Intraday = `5m-12h` intervals, Daily = `1d-1y` intervals

**Cache / Update frequency:** Latest Daily OHLCV record is available ~5 to ~10 minutes after each midnight UTC. The latest hourly OHLCV record is available 5 minutes after each UTC hour.  
**Plan credit use:** 1 call credit per 100 OHLCV data points returned (rounded up) and 1 call credit per `convert` option beyond the first.

#### Code examples

cURL:

```bash
curl -G "https://pro-api.coinmarketcap.com/v2/cryptocurrency/ohlcv/historical" \
  --data-urlencode "id=1" \
  --data-urlencode "count=10" \
  -H "X-CMC_PRO_API_KEY: $CMC_PRO_API_KEY"
```

JavaScript / TypeScript, with the official SDK [`@coinmarketcap/sdk`](https://www.npmjs.com/package/@coinmarketcap/sdk) (`npm install @coinmarketcap/sdk`):

```typescript
import { CoinMarketCap } from "@coinmarketcap/sdk";

const cmc = new CoinMarketCap({
  apiKey: process.env.CMC_PRO_API_KEY,
});

const { data, error } = await cmc.api.cryptocurrency.ohlcvHistorical({
  query: { id: "1", count: 10 },
});
if (error) throw error;
console.log(data);
```

Python, with the official SDK [`coinmarketcap-sdk`](https://pypi.org/project/coinmarketcap-sdk/) (`pip install coinmarketcap-sdk`):

```python
import os

from coinmarketcap import CoinMarketCap

cmc = CoinMarketCap(api_key=os.environ["CMC_PRO_API_KEY"])

result = cmc.cryptocurrency.ohlcv_historical(id="1", count=10)
print(result)
```

Go, with the official SDK [`github.com/OpenCMC/coinmarketcap-api-go/v5`](https://pkg.go.dev/github.com/OpenCMC/coinmarketcap-api-go/v5) (`go get github.com/OpenCMC/coinmarketcap-api-go/v5`):

```go
package main

import (
	"context"
	"encoding/json"
	"fmt"
	"log"
	"os"

	"github.com/OpenCMC/coinmarketcap-api-go/v5"
)

func main() {
	cmc, err := coinmarketcap.New(coinmarketcap.WithAPIKey(os.Getenv("CMC_PRO_API_KEY")))
	if err != nil {
		log.Fatal(err)
	}

	result, err := cmc.Cryptocurrency.OhlcvHistorical(context.Background(), &coinmarketcap.CryptocurrencyOhlcvHistoricalParams{
		ID:    coinmarketcap.String("1"),
		Count: coinmarketcap.Float64(10),
	})
	if err != nil {
		log.Fatal(err)
	}

	out, _ := json.MarshalIndent(result, "", "  ")
	fmt.Println(string(out))
}
```

#### API Summary

```yaml
method: GET
path: /v2/cryptocurrency/ohlcv/historical
operationId: getV2CryptocurrencyOhlcvHistorical
parameters:
  - name: id
    in: query
    required: false
    schema:
      type: string
    description: 'One or more comma-separated CoinMarketCap cryptocurrency IDs. Example: "1,1027"'
  - name: slug
    in: query
    required: false
    schema:
      type: string
    description: 'Alternatively pass a comma-separated list of cryptocurrency slugs. Example: "bitcoin,ethereum"'
  - name: symbol
    in: query
    required: false
    schema:
      type: string
    description: 'Alternatively pass one or more comma-separated cryptocurrency symbols. Example: "BTC,ETH". At least one "id" *or* "slug" *or* "symbol" is required for this request.'
  - name: time_period
    in: query
    required: false
    schema:
      type: string
      enum:
        - daily
        - hourly
    description: Time period to return OHLCV data for. The default is "daily". If hourly, the open will be 01:00 and the close will be 01:59. If daily, the open will be 00:00:00 for the day and close will be 23:59:99 for the same day. See the main endpoint description for details.
  - name: time_start
    in: query
    required: false
    schema:
      type: string
    description: Timestamp (Unix or ISO 8601) to start returning OHLCV time periods for. Only the date portion of the timestamp is used for daily OHLCV so it's recommended to send an ISO date format like "2018-09-19" without time.
  - name: time_end
    in: query
    required: false
    schema:
      type: string
    description: Timestamp (Unix or ISO 8601) to stop returning OHLCV time periods for (inclusive). Optional, if not passed we'll default to the current time. Only the date portion of the timestamp is used for daily OHLCV so it's recommended to send an ISO date format like "2018-09-19" without time.
  - name: count
    in: query
    required: false
    schema:
      type: number
    description: Optionally limit the number of time periods to return results for. The default is 10 items. The current query limit is 10000 items.
  - name: interval
    in: query
    required: false
    schema:
      type: string
      enum:
        - hourly
        - daily
        - weekly
        - monthly
        - yearly
        - 1h
        - 2h
        - 3h
        - 4h
        - 6h
        - 12h
        - 1d
        - 2d
        - 3d
        - 7d
        - 14d
        - 15d
        - 30d
        - 60d
        - 90d
        - 365d
    description: Optionally adjust the interval that "time_period" is sampled. For example with interval=monthly&time_period=daily you will see a daily OHLCV record for January, February, March and so on. See main endpoint description for available options.
  - name: convert
    in: query
    required: false
    schema:
      type: string
    description: By default market quotes are returned in USD. Optionally calculate market quotes in up to 3 fiat currencies or cryptocurrencies.
  - name: convert_id
    in: query
    required: false
    schema:
      type: string
    description: "Optionally calculate market quotes by CoinMarketCap ID instead of symbol. This option is identical to `convert` outside of ID format. Ex: convert_id=1,2781 would replace convert=BTC,USD in your query. This parameter cannot be used when `convert` is used."
  - name: skip_invalid
    in: query
    required: false
    schema:
      type: boolean
    description: Pass `true` to relax request validation rules. When requesting records on multiple cryptocurrencies an error is returned if any invalid cryptocurrencies are requested or a cryptocurrency does not have matching records in the requested timeframe. If set to true, invalid lookups will be skipped allowing valid cryptocurrencies to still be returned.
responses:
  "200":
    description: Successful
    content:
      application/json:
        $ref: "#/components/schemas/Cryptocurrency_OHLCV_Historical_-_Response_Model"
  errors:
    - 400
    - 401
    - 403
    - 429
    - 500
```

## Components

```yaml
components:
  schemas:
    Cryptocurrency_OHLCV_Historical_-_Response_Model:
      type: object
      required:
        - data
      properties:
        data:
          description: A single object when you request one cryptocurrency, and an object map keyed by cryptocurrency ID when you request several.
          oneOf:
            - type: object
              additionalProperties:
                $ref: "#/components/schemas/Cryptocurrency_OHLCV_Historical_-_Results_object"
            - $ref: "#/components/schemas/Cryptocurrency_OHLCV_Historical_-_Results_object"
        status:
          $ref: "#/components/schemas/API_Status_Object"
    Cryptocurrency_OHLCV_Historical_-_Results_object:
      type: object
      description: Results of your query returned as an object.
      required:
        - id
        - name
        - symbol
        - quotes
      properties:
        id:
          type: integer
          description: The CoinMarketCap cryptocurrency ID.
        name:
          type: string
          description: The cryptocurrency name.
        symbol:
          type: string
          description: The cryptocurrency symbol.
        quotes:
          $ref: "#/components/schemas/Cryptocurrency_OHLCV_Historical_-_Interval_Quotes_array"
    API_Status_Object:
      type: object
      description: Standardized status object for API calls.
      required:
        - timestamp
        - error_code
        - error_message
        - elapsed
        - credit_count
      properties:
        timestamp:
          type: string
          format: yyyy-MM-dd'T'HH:mm:ss.SSSZ
          description: Current timestamp (ISO 8601) on the server.
        error_code:
          type:
            - integer
            - string
          description: An internal error code for the current error. If a unique platform error code is not available the HTTP status code is returned. `0` is returned if there is no error. Some endpoints return this code as a string, for example `"0"`.
        error_message:
          type:
            - string
            - "null"
          description: An error message to go along with the error code.
        elapsed:
          type: integer
          description: Number of milliseconds taken to generate this response.
        credit_count:
          type: integer
          description: Number of API call credits that were used for this call.
        notice:
          type:
            - string
            - "null"
          description: Optional notice about API key information.
        total_count:
          type: integer
          description: Total number of results available for this request. Only returned by some list endpoints.
    Cryptocurrency_OHLCV_Historical_-_Interval_Quotes_array:
      type: array
      description: An array of OHLCV quotes for the supplied interval.
      required:
        - Cryptocurrency OHLCV Historical - Interval Quote object
      items:
        $ref: "#/components/schemas/Cryptocurrency_OHLCV_Historical_-_Interval_Quote_object"
    Cryptocurrency_OHLCV_Historical_-_Interval_Quote_object:
      type: object
      description: An OHLCV quote for the supplied interval.
      required:
        - time_open
        - time_close
        - time_high
        - time_low
        - quote
      properties:
        time_open:
          type: string
          format: yyyy-MM-dd'T'HH:mm:ss.SSSZ
          description: Timestamp (ISO 8601) of the start of this time series interval.
        time_close:
          type: string
          format: yyyy-MM-dd'T'HH:mm:ss.SSSZ
          description: Timestamp (ISO 8601) of the end of this time series interval.
        time_high:
          type: string
          format: yyyy-MM-dd'T'HH:mm:ss.SSSZ
          description: Timestamp (ISO 8601) of the high of this time series interval.
        time_low:
          type: string
          format: yyyy-MM-dd'T'HH:mm:ss.SSSZ
          description: Timestamp (ISO 8601) of the low of this time series interval.
        quote:
          $ref: "#/components/schemas/Cryptocurrency_OHLCV_Historical_-_Quote_map"
    Cryptocurrency_OHLCV_Historical_-_Quote_map:
      type: object
      description: A map of market quotes in different currency conversions. The default map included is USD.
      additionalProperties:
        $ref: "#/components/schemas/Cryptocurrency_OHLCV_Historical_-_Quote_object"
    Cryptocurrency_OHLCV_Historical_-_Quote_object:
      type: object
      description: A market quote in each currency conversion option.
      required:
        - open
        - high
        - low
        - close
        - volume
        - market_cap
        - timestamp
      properties:
        open:
          type: number
          description: Opening price for time series interval.
        high:
          type: number
          description: Highest price during this time series interval.
        low:
          type: number
          description: Lowest price during this time series interval.
        close:
          type: number
          description: Closing price for this time series interval.
        volume:
          type: number
          description: Adjusted volume for this time series interval. Volume is not currently supported for hourly OHLCV intervals before 2020-09-22.
        market_cap:
          type: number
          description: Market cap by circulating supply for this time series interval.
        timestamp:
          type: string
          format: yyyy-MM-dd'T'HH:mm:ss.SSSZ
          description: Timestamp (ISO 8601) of when the conversion currency's current value was referenced for this conversion.
```
