OHLCV

API calls described in this section are related to downloading OHLCV (Open, High, Low, Close, Volume) timeseries data. Each data point of this timeseries represents several indicators calculated from transactions activity inside a time range (period).

List all periods GET

curl https://rest.coinapi.io/v1/ohlcv/periods \
  --request GET
  --header "X-CoinAPI-Key: 73034021-THIS-IS-SAMPLE-KEY"

Get full list of supported time periods available for requesting OHLCV timeseries data.

HTTP Request

GET /v1/ohlcv/periods

The above command returns JSON structured like this:

[
  {
    "period_id": "1SEC",
    "length_seconds": 1,
    "length_months": 0,
    "unit_count": 1,
    "unit_name": "second",
    "display_name": "1 Second"
  },
  {
    "period_id": "10DAY",
    "length_seconds": 864000,
    "length_months": 0,
    "unit_count": 10,
    "unit_name": "day",
    "display_name": "10 Days"
  },
  {
    "period_id": "2YRS",
    "length_seconds": 0,
    "length_months": 24
    "unit_count": 2,
    "unit_name": "year",
    "display_name": "2 Years"
  }
]

Available periods

Time unitPeriod identifiers
Second1SEC, 2SEC, 3SEC, 4SEC, 5SEC, 6SEC, 10SEC, 15SEC, 20SEC, 30SEC
Minute1MIN, 2MIN, 3MIN, 4MIN, 5MIN, 6MIN, 10MIN, 15MIN, 20MIN, 30MIN
Hour1HRS, 2HRS, 3HRS, 4HRS, 6HRS, 8HRS, 12HRS
Day1DAY, 2DAY, 3DAY, 5DAY, 7DAY, 10DAY
Month1MTH, 2MTH, 3MTH, 4MTH, 6MTH
Year1YRS, 2YRS, 3YRS, 4YRS, 5YRS

Output variables

VariableDescription
period_idPeriod identifier, used in other API calls
length_secondsSeconds part of period length
length_monthsMonths part of period length
unit_countPeriod length in units
unit_nameType of unit (second/minute/hour/day/month/year)
display_nameDisplay name of period length

Latest data GET

curl https://rest.coinapi.io/v1/ohlcv/BITSTAMP_SPOT_BTC_USD/latest?period_id=1MIN \
  --request GET
  --header "X-CoinAPI-Key: 73034021-THIS-IS-SAMPLE-KEY"

The above command returns JSON structured like this:

[
  {
    "time_period_start": "2017-08-09T14:31:00.0000000Z",
    "time_period_end": "2017-08-09T14:32:00.0000000Z",
    "time_open": "2017-08-09T14:31:01.0000000Z",
    "time_close": "2017-08-09T14:31:46.0000000Z",
    "price_open": 3255.590000000,
    "price_high": 3255.590000000,
    "price_low": 3244.740000000,
    "price_close": 3244.740000000,
    "volume_traded": 16.903274550,
    "trades_count": 31
  },
  {
    "time_period_start": "2017-08-09T14:30:00.0000000Z",
    "time_period_end": "2017-08-09T14:31:00.0000000Z",
    "time_open": "2017-08-09T14:30:05.0000000Z",
    "time_close": "2017-08-09T14:30:35.0000000Z",
    "price_open": 3256.000000000,
    "price_high": 3256.010000000,
    "price_low": 3247.000000000,
    "price_close": 3255.600000000,
    "volume_traded": 58.131397920,
    "trades_count": 33
  }
]

Get OHLCV latest timeseries data returned in time descending order. Data can be requested by the period and for the specific symbol eg BITSTAMP_SPOT_BTC_USD, if you need to query timeseries by asset pairs eg. BTC/USD, then please reffer to the Exchange Rates Timeseries data

HTTP Request

GET /v1/ohlcv/{symbol_id}/latest?period_id={period_id}&limit={limit}&include_empty_items={include_empty_items}

URL Parameters

ParameterTypeDescription
symbol_idstringSymbol identifier of requested timeseries (full list available here)
period_idstringIdentifier of requested timeseries period (required, e.g. 5SEC or 2MTH, full list here)
include_empty_itemsboolInclude items with no activity? (optional, default value is false, possible values are true or false)
limitintAmount of items to return (optional, mininum is 1, maximum is 100000, default value is 100, if the parameter is used then every 100 output items are counted as one request)

Output variables

VariableDescription
time_period_startPeriod starting time (range left inclusive)
time_period_endPeriod ending time (range right exclusive)
time_openTime of first trade inside period range
time_closeTime of last trade inside period range
price_openFirst trade price inside period range
price_highHighest traded price inside period range
price_lowLowest traded price inside period range
price_closeLast trade price inside period range
volume_tradedCumulative base amount traded inside period range
trades_countAmount of trades executed inside period range

Historical data GET

curl https://rest.coinapi.io/v1/ohlcv/BITSTAMP_SPOT_BTC_USD/history?period_id=1MIN&time_start=2016-01-01T00:00:00 \
  --request GET
  --header "X-CoinAPI-Key: 73034021-THIS-IS-SAMPLE-KEY"

The above command returns JSON structured like this:

[
  {
    "time_period_start": "2017-01-01T00:00:00.0000000Z",
    "time_period_end": "2017-01-02T00:00:00.0000000Z",
    "time_open": "2017-01-01T00:01:08.0000000Z",
    "time_close": "2017-01-01T23:59:46.0000000Z",
    "price_open": 966.340000000,
    "price_high": 1005.000000000,
    "price_low": 960.530000000,
    "price_close": 997.750000000,
    "volume_traded": 6850.593308590,
    "trades_count": 7815
  },
  {
    "time_period_start": "2017-01-02T00:00:00.0000000Z",
    "time_period_end": "2017-01-03T00:00:00.0000000Z",
    "time_open": "2017-01-02T00:00:05.0000000Z",
    "time_close": "2017-01-02T23:59:37.0000000Z",
    "price_open": 997.750000000,
    "price_high": 1032.000000000,
    "price_low": 990.010000000,
    "price_close": 1012.540000000,
    "volume_traded": 8167.381030180,
    "trades_count": 7871
  }
]

Get OHLCV timeseries data returned in time ascending order. Data can be requested by the period and for the specific symbol eg BITSTAMP_SPOT_BTC_USD, if you need to query timeseries by asset pairs eg. BTC/USD, then please reffer to the Exchange Rates Timeseries data

HTTP Request

GET /v1/ohlcv/{symbol_id}/history?period_id={period_id}&time_start={time_start}&time_end={time_end}&limit={limit}&include_empty_items={include_empty_items}

URL Parameters

ParameterTypeDescription
symbol_idstringSymbol identifier of requested timeseries (full list available here)
period_idstringIdentifier of requested timeseries period (required, e.g. 5SEC or 2MTH, full list here)
time_starttimestringTimeseries starting time in ISO 8601 (required)
time_endtimestringTimeseries ending time in ISO 8601 (optional, if not supplied then the data is returned to the end or when count of result elements reaches the limit)
include_empty_itemsboolInclude items with no activity? (optional, default value is false, possible values are true or false)
limitintAmount of items to return (optional, mininum is 1, maximum is 100000, default value is 100, if the parameter is used then every 100 output items are counted as one request)

Output variables

VariableDescription
time_period_startPeriod starting time (range left inclusive)
time_period_endPeriod ending time (range right exclusive)
time_openTime of first trade inside period range
time_closeTime of last trade inside period range
price_openFirst trade price inside period range
price_highHighest traded price inside period range
price_lowLowest traded price inside period range
price_closeLast trade price inside period range
volume_tradedCumulative base amount traded inside period range
trades_countAmount of trades executed inside period range

Copyright 2022 COINAPI LTD or its affiliates. All rights reserved.
StatusPage: