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 requires clients to login first.
After successful login, a JWT token is generated in the response which is required to be validated first with the JWT validation API. After passing this JWT token and client code in the payload of the API, client can validate the JWT token.
Request URL https://openapi.5paisa.com/VendorsAPI/Service1.svc/ValidateClientToken
Request Method POST
Request format JSON
Request Header Content-Type: application/json
| Field Name | Description | Data Type | Validation | Sample Value |
|---|---|---|---|---|
| ClientCode | This the client code of particular client | String | Cannot be empty | Dummy |
| JwtCode | This is the token received in the response of login API | String | Cannot be empty | - |
| Field Name | Description | Data Type | List of Values | Sample Value |
|---|---|---|---|---|
| Status | Returns the status code of the response. | Integer | 0-Authorization Successful 1-Invalid Authorization |
0 |
| Message | Returns the message of the response. | String | A. Authorization Successful B. Invalid Authorization |
Authorization Successful |
The API with the GET request method is used to fetch the historical candle data which After token validation, the historical data can be fetched for any scrip code using GET method. It provides OHLCV (open, high, low, close and volume) and volume data along with timestamps for scrip codes passed in the request. Now get 6 months of historical intraday data for the following time intervals(frames):-
Request Method GET
Request format JSON
| 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 | 1660 |
| 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-01-01 |
| EndDate | Date to which candle data needs to be fetched (Format: YYYY-MM-DD) | 2021-05-30 |
| Field Name | Description | Data Type | Validation |
|---|---|---|---|
| x-clientcode | Client code of the customer | String | Cannot be empty |
| x-auth-token | JWT token generated after login | String | Cannot be empty |
| Ocp-Apim-Subscription-Key | Ocp-Apim-Subscription-Key already provided | String | Cannot be empty |
Sample Request URL: https://openapi.5paisa.com/historical/n/c/1594/5m?from=2021-05-24&end=2021-05-27
| 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 | [[ Datetime,Open,High,Low,Close,Volume],[Datetime,Open,High,Low,Close,Volume]] |
| 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 | 1480.2 |
| High | This is the high rate at given time stamp | Double | 1501.35 |
| Low | This is the low rate at given time stamp | Double | 1420 |
| Close | This is the close rate at given time stamp | Double | 1492.95 |
| Volume | This is the volume at given time stamp | Integer | 39003540 |
{
"ClientCode": "Dummy",
"JwtCode":
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6IlNVUlZJTkhBIiwicm9sZS I6IjYwIiwibmJmIjoxNjIxOTU3NjU1LCJleHAiOjE2MjE5NjEyNTUsImlhdCI6MTYyMTk1NzY1 NX0.DYO96m-OTF2-_WJ-Aw6VWlZQChaI8aIyn5wLafIdjHk"
}
{
"body": {
"Message": "Authorization Successful",
"Status": 0
}
}
{
"body": {
"Message": "Invalid Authorization",
"Status": 1
}
}
{
"status": "success",
"data": {
"candles": [
[
“2021-04-29T09:15:00”,
1488.85,
1503.65,
1461.0,
1471.65,
12002248
],
[
“2021-04-30T09:15:00”,
1450.0,
1450.0,
1407.65,
1412.9,
17538562
]
]
}
}
{
"status": "Maximum permissible data range limit reached",
"data": {
"candles": null
}
}
{
"head": {
"ResponseCode": "RPOpenAPI",
"Status": 1,
"Status_description": "Error While Processing", }
"body": null
}