Historical Data
This API allows you to get historical candle data for a symbol over a date range and resolution.
USE CASE
Fetch past candles to draw a chart, calculate indicators or backtest a strategy.
Details
To receive completed candle data, send a timestamp prior to the current minute. Sending a timestamp for the current minute returns partial data because the minute is not yet finished. Always use a range_to timestamp of the previous minute to receive completed candle data.
Current Time (seconds can be 1-59): 12:10:20 PM
Input Parameters:
range_from: 12:08:00 PM
range_to: 12:09:20 PM (Current Time - 1 minute)
Output Summary: Returns 2 candles (12:08 PM & 12:09 PM). This example is for 1-minute candles; for other resolutions, subtract the resolution time from range_to to get completed candles only.
- Your app needs the Market Data permission (Historical data, Market Depth and Quotes).
- Set date_format to 0 to pass range_from and range_to as epoch values, or to 1 to pass them as yyyy-mm-dd dates.
- Set cont_flag to 1 for continuous data of futures and options, and oi_flag to 1 to include open interest in each candle.
- Each candle is an array: epoch time, open, high, low, close and volume (open interest is added when oi_flag is 1).
- Unlimited number of stocks history data can be downloaded in a day.
- Up to 100 days of data per request for resolutions of 1, 2, 3, 5, 10, 15, 20, 30, 45, 60, 120, 180, and 240 minutes (Data available from July 3, 2017).
- For 1D, 1W, and 1M resolutions, up to 366 days of data per request.
- For Seconds Charts, history is available for 30-Trading Days only.
Plan limits
Standard plan
- Daily candles: last 5 years (from 2021); the window moves forward every year
- Intraday candles: last 1 year (from 2025)
- Seconds data: not available
Prime plan
- Daily candles: entire available history, 25+ years
- Intraday candles: entire available history, 5+ years
- Seconds data: available
For rate limits and all other plan details, see Plans & rate limits.
Request Attributes
| Attribute | Data Type | Description |
|---|---|---|
symbol* | string |
|
resolution* | string |
|
date_format* | int | date_format is a boolean flag. 0 to enter the epoch value. Eg:670073472. 1 to enter the date format as yyyy-mm-dd. |
range_from* | string |
|
range_to* | string |
|
cont_flag | int | set cont flag 1 for continues data and future options. |
oi_flag | int | set flag to "1" enable oi as a part of candle. |
Response Attributes
| Attribute | Data Type | Description |
|---|---|---|
s | string | ok / error |
Candels | array |
|