Historical Candle Data V3โ
Compared to the standard Historical Candle Data API, API V3 allows users to retrieve data in custom time intervals for each unit (minutes
, hours
, days
, weeks
, and months
), enabling more granular data control and improved flexibility for analysis. The response structure maintains consistency with the standard Historical Candle Data API format, facilitating seamless integration with existing applications and systems.
The API is designed to handle large volumes of data efficiently, ensuring quick response times even for extensive historical queries.
This API is particularly useful for traders and analysts who need to analyze historical price movements and trends in the financial markets.
The API offers OHLC (Open, High, Low, Close) data for instruments across multiple timeframes, with different historical availability and retrieval constraints based on the selected unit and interval as per the below table:
Unit | Interval Options | Historical Availability | Max retrieval record limit |
---|---|---|---|
minutes | 1, 2, ... 300 | Available from January, 2022 | 1 month - Applicable for intervals ranging from 1 to 15 minutes. 1 quarter - Used for intervals greater than 15 minutes, up to the specified to_date. |
hours | 1, 2, ... 5 | Available from January, 2022 | 1 quarter leading up to the to_date. |
days | 1 | Available from January, 2000 | 1 decade leading up to the to_date. |
weeks | 1 | Available from January, 2000 | No limit. |
months | 1 | Available from January, 2000 | No limit. |
- Use the Intraday Candle Data API V3 to retrieve data specific to the current trading day with the wide range of units and intervals.
- It's important to note that if the retrieval record limit is exceeded, then the API will throw an error indicating that the request is invalid.
- This V3 API provides additional custom interval options that are not available in the standard Historical Candle Data API.
Header Parametersโ
Name | Required | Type | Description |
---|---|---|---|
Accept | true | string | Defines the content format the client expects, which should be set to application/json . |
Path Parametersโ
Name | Required | Type | Description |
---|---|---|---|
instrument_key | true | string | The unique identifier for the financial instrument for which historical data is being queried. For the regex pattern applicable to this field, see the Field Pattern Appendix. |
unit | true | string | Specifies the unit for the candles. Possible values: minutes , hours , days , weeks , months . |
interval | true | string | Specifies the interval for the candles. Possible values: 1 , 2 , 3 , ..., 300 for minutes. 1 , 2 , ..., 5 for hours. 1 for days, weeks, and months. |
to_date | true | string | The ending date (inclusive) for the historical data range. Format: 'YYYY-MM-DD'. |
from_date | false | string | The starting date for the historical data range. Format: 'YYYY-MM-DD'. |
- 200
- 4XX
Response Bodyโ
{
"status": "success",
"data": {
"candles": [
[
"2025-01-01T00:00:00+05:30",
53.1,
53.95,
51.6,
52.05,
235519861,
0
],
[
"2025-02-01T00:00:00+05:30",
50.35,
56.85,
49.35,
52.8,
1004998611,
0
]
]
}
}
Name | Type | Description |
---|---|---|
status | string | A string indicating the outcome of the request. Typically success for successful operations. |
data | object | Contains OHLC values for all instruments across various timeframes. |
data.candles | array[] | Array of candle data, each presented as an array with sequential elements representing trading activity. |
data.candle[0] | number | Timestamp : Indicating the start time of the candle's timeframe. |
data.candle[1] | number | Open : The opening price of the asset for the given timeframe. |
data.candle[2] | number | High : The highest price at which the asset traded during the timeframe. |
data.candle[3] | number | Low : The lowest price at which the asset traded during the timeframe. |
data.candle[4] | number | Close : The closing price of the asset for the given timeframe. |
data.candle[5] | number | Volume : The total amount of the asset that was traded during the timeframe. |
data.candle[6] | number | Open Interest : The total number of outstanding derivative contracts, such as options or futures. |
Error codesโ
Error code | Description |
---|---|
UDAPI1021 | Instrument key is of invalid format - The provided instrument key doesn't conform to the expected format. |
UDAPI1022 | to_date is required - You must specify the to_date in your request. |
UDAPI100011 | Invalid Instrument key - The instrument key you provided doesn't match any of the recognized keys in the system. |
UDAPI1015 | to_date must be greater than or equal to from_date and Date should be in valid format: yyyy-mm-dd - Ensure that to_date is greater than or equal to from_date and both are in the correct format. |
UDAPI1146 | Invalid unit - The unit you provided is not recognized. Valid options are minutes , hours , days , weeks , or months . |
UDAPI1147 | Invalid interval - The interval you provided is not valid for the specified unit. For example, if the unit is minutes , valid intervals are 1 to 300 . |
UDAPI1148 | Invalid date range - The date range specified in the request is not valid. Ensure that the from_date and to_date are within the acceptable limits for the selected interval. |
Examplesโ
A comprehensive set of examples is provided to illustrate various use cases and implementation scenarios for this API. To view detailed examples and access sample code, please refer to: API Examples.
GET /historical-candle/:instrument_key/:unit/:interval/:to_date/:from_date
Request
Request
curl -L -X GET 'https://api.upstox.com/v3/historical-candle/:instrument_key/:unit/:interval/:to_date/:from_date' \
-H 'Accept: application/json'
curl -L -X GET 'https://api.upstox.com/v3/historical-candle/:instrument_key/:unit/:interval/:to_date/:from_date' \
-H 'Accept: application/json'
curl -L -X GET 'https://api.upstox.com/v3/historical-candle/:instrument_key/:unit/:interval/:to_date/:from_date' \
-H 'Accept: application/json'
curl -L -X GET 'https://api.upstox.com/v3/historical-candle/:instrument_key/:unit/:interval/:to_date/:from_date' \
-H 'Accept: application/json'
curl -L -X GET 'https://api.upstox.com/v3/historical-candle/:instrument_key/:unit/:interval/:to_date/:from_date' \
-H 'Accept: application/json'
curl -L -X GET 'https://api.upstox.com/v3/historical-candle/:instrument_key/:unit/:interval/:to_date/:from_date' \
-H 'Accept: application/json'
curl -L -X GET 'https://api.upstox.com/v3/historical-candle/:instrument_key/:unit/:interval/:to_date/:from_date' \
-H 'Accept: application/json'
curl -L -X GET 'https://api.upstox.com/v3/historical-candle/:instrument_key/:unit/:interval/:to_date/:from_date' \
-H 'Accept: application/json'
curl -L -X GET 'https://api.upstox.com/v3/historical-candle/:instrument_key/:unit/:interval/:to_date/:from_date' \
-H 'Accept: application/json'