Historical Candle Data
PURPOSE
Historical candle data is the backbone for any strategy deployed and this API provides the support by providing archived data for various scrip codes. The API works in an active session and require clients to login first. After successful login, a token is generated in the response which is required to be validated first with the JWT validation API. After token validation, the historical data can be fetched for any scrip code using GET method. It provides OHLC (open, high, low and close rates) and volume data along with timestamps for scrip codes passed in the request.
JWT VALIDATION
The API with the POST request method is used to validate the JWT token generated after successful login. The field name for the token in the response of login is “Token”. After passing this token and client code in the payload of the API, client can validate the token.
Request Method: POST
Request format: JSON
Request Header:
Content-Type: application/json
Ocp-Apim-Subscription-Key:
to be provided after registration
REQUEST BODY
BODY
Field Name | Description | Data Type | Validation | Sample Value |
---|---|---|---|---|
ClientCode | This the clientcode of particular client | String | Cannot be empty. | Dummy123 |
JwtCode | This is the token received in the response of login API | String | Cannot be empty. | - |
SAMPLE REQUEST:
{
"ClientCode": "Dummy123",
"JwtCode": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6IlNVUlZJTkhBIiwicm9sZSI6IjYwIiwibmJmIjoxNjIxOTU3NjU1LCJleHAiOjE2MjE5NjEyNTUsImlhdCI6MTYyMTk1NzY1NX0.DYO96m-OTF2-_WJ-Aw6VWlZQChaI8aIyn5wLaecfdoY"
}
RESPONSE BODY
BODY
Field Name | Description | Data Type | List of Values | Sample Value |
---|---|---|---|---|
Status | Returns the status codeof the response. | Integer | 0-Authorization Successful 1-Invalid Authorization |
0 |
Message | Returns the status codeof the response. | String | A. Authorization Successful B. Invalid Authorization |
Authorization Successful |
Success Response
{
"body": {
"Message": "Authorization Successful",
"Status": 0
}
}
Failure Response
{
"body": {
"Message": "Invalid Authorization",
"Status": 1
}
}
HISTORICAL CANDLE DATA
The API with the GET request method is used to fetch the historical candle data which provides an array of OHLC (open, high, low and close rates) and volume along with timestamps in the response. The API works only after successful JWT validation call. The maximum permissible interval size that can be kept in a API call is of 6 months. But the data can be fetched for any time duration. The day wise data doesn’t have any restrictions on the size of the interval and maximum data can be fetched when the interval is day. The API helps clients to fetch the candle data in 1 minute, 5 minutes, 10 minutes, 15 minutes, 30 minutes, 60 minutes and day based interval.
Request Method: GET
Request format: JSON
REQUEST URL
URL PARAMETERS
Field Name | Description | Sample Value |
---|---|---|
Exch | Exchange of the scrip n – NSE b – BSE m – MCX (ExchType will be D) n – NCDEX (only if ExchType is X) |
n b m |
ExchType | Exchange segment of the scrip c – Cash d – Derivative (Commodity if exchange is M) u – Currency Derivative x – NCDEX commodity y – Commodity |
c d u x y |
ScripCode | Unique number for particular scrip | 1330 |
Interval | Interval for candle data. 1m – 1 minute 5m – 5 minute 10m – 10 minute 15m – 15 minute 30m – 30 minute 60m – 60 minute 1d – 1 day |
1m 5m 10m 15m 30m 60m 1d |
FromDate | Date from which candle data needs to be fetched (Format: YYYY-MM-DD) | 2021-04-01 |
EndDate | Date to which candle data needs to be fetched (Format: YYYY-MM-DD) | 2021-04-30s |
REQUEST HEADERS
HEADERS
Field Name | Description | Data Type | Validation |
---|---|---|---|
x-clientcode | Status of the response | String | Cannot be empty |
x-auth-token | JWT token generated after login | String | Cannot be empty |
Ocp-Apim-Subscription-Key | Provided by IIFL at the time of registration | String | Cannot be empty |
RESPONSE BODY
BODY
Field Name | Description | Data Type | Sample Value |
---|---|---|---|
status | Status of the response | String | Cannot be empty |
data | Contains the data of requested candles | - | |
candles | An array of the OHLC and volume data along with timestamp | Array |
CANDLES
Field Name | Description | Data Type | Sample Value |
---|---|---|---|
Timestamp | This is the timestamp of the data in the format of YYYY-MM-DDTHH:MM:SS | String | 2021-04-01T09:15:00 |
Open | This is the open rate at given time stamp | Double | 1488.85 |
High | This is the high rate at given time stamp | Double | 1503.65 |
Low | This is the low rate at given time stamp | Double | 1461.0 |
Close | This is the close rate at given time stamp | Double | 1471.65 |
Volume | This is the volume at given time stamp | Integer | 12002248 |
Success Response
{
"status": "success",
"data": {
"candles": [
[
"2021-04-29T09:15:00",
1488.85,
1503.65,
1461,
1471.65,
12002248
],
[
"2021-04-30T09:15:00",
1450,
1450,
1407.65,
1412.9,
17538562
]
]
}
}
Failure Response
{
"status": "Maximum permissible data range limit reached",
"data": {
"candles": null
}
}
Failure Response
{
"head": {
"ResponseCode": "RPOpenAPI",
"Status": 1,
"Status_description": "Error While Processing"
}
"body": "null",