Historical Candles

POSTJSONRest API
115534

Daily API Calls

99.97%

Success Rate

65.05ms

Avg. Response Time


Purpose of the API: To provide historical candle data for various scrip codes for the purpose of strategy deployment.

Authentication: Requires clients to log in, and upon successful login, a token is generated in the response. This token needs to be validated using a JWT validation API.

Data Provided:

  • OHLC Data: Open, high, low, and close rates.
  • Volume Data: Information about the trading volume.
  • Timestamps: Time information associated with the provided data.

Interval Size:

  • Maximum Permissible Interval Size: 6 months.
  • Day Wise Data: No restrictions on the size of the interval; maximum data can be fetched when the interval is a day.

Supported Intervals:

  • 1 minute
  • 5 minutes
  • 10 minutes
  • 15 minutes
  • 30 minutes
  • 60 minutes
  • Day-based interval

Note: The API allows fetching data for any time duration within the specified interval limits.

REQUEST URL

https://openapi.5paisa.com/V2/historical/N/C/1630/1d?from={FromDate}&end={EndDate}

Headers

KEYVALUE

x-clientcode

5paisa client code of the user.

x-auth-token

JWT token received in the response of login.

It should be passed after validating it with the JWT Validation API.

Ocp-Apim-Subscription-Key

Received along with API credentials

URL Parameters

FIELD NAMEMANDATORYDESCRIPTION

Exch

STRING

Yes

This indicates the exchange name of the instrument.

N: NSE
B: BSE
M: MCX
n: NCDEX (If exchange type is ‘X’)

ExchType

STRING

Yes

It specifies the exchange segment of the instrument.

c: Cash
d: Derivatives (FnO for NSE, BSE & MCX)
u: Currency Derivatives
x: NCDEX Commodity
y: NSE & BSE Commodity

ScripCode

STRING

Yes

This is the unique numerical code defined for the instrument.

It can be fetched from the scripmaster.

Interval

STRING

Yes

Interval range for the candles.

1m: 1 minute
5m: 5 minute
10m: 10 minute
15m: 15 minute
30m: 30 minute
60m: 60 minute
1d: 1 day

FromDate

DATETIME

Yes

Date from which candle data needs to be fetched (Format: YYYY-MM-DD)

EndDate

DATETIME

Yes

Date to which candle data needs to be fetched (Format: YYYY-MM-DD)

SAMPLE REQUEST BODY  :

curl --location 'https://openapi.5paisa.com/V2/historical/N/C/1630/1d?from=2023-02-23&end=2023-04-23' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6IjUwMDUyNzcwIiwicm9sZSI6IjEwMzQ1IiwiU3RhdGUiOiIiLCJSZWRpcmVjdFNlcnZlciI6IkEiLCJuYmYiOjE3MDU1MDE1NjUsImV4cCI6MTcwNTUxNjE5OSwiaWF0IjoxNzA1NTAxNTY1fQ.4Tr9txu_Wowf-AXmTD2yAm98d3TZl5KgKFOFEE6EMco' \
--header 'Cookie: 5paisacookie=ysri4csgzdpr0vqhr45qq4gk' \
--data ''

Response body

FIELD NAMEVALUESDESCRIPTION

status

STRING

success

This is the status description of the API call.

data

candles

ARRAY

 

It provides open, high, close and low rates along with the timestamp for each candle in an array.

candles

FIELD NAMEVALUESDESCRIPTION

Timestamp

DATETIME

-

This is the timestamp of the candle in the format of YYYY-MM-DDTHH:MM:SS

Open

DOUBLE

-

 

This is the open rate at given time stamp of the candle

High

DOUBLE

-

This is the high rate at given time stamp of the candle

Low

DOUBLE

-

This is the low rate at given time stamp of the candle

Close

DOUBLE

-

This is the close rate at given time stamp of the candle

Volume

INTEGER

-

This is the volume at given time stamp of the candle

 SAMPLE SUCCESS RESPONSE  

{
    "status": "success",
    "data": {
        "candles": [
            [
                "2022-07-15T00:00:00",
                292.0,
                294.0,
                289.5,
                293.55,
                11025420
            ],
            [
                "2022-07-18T00:00:00",
                295.0,
                296.3,
                293.75,
                295.3,
                11315876
            ],
            [
                "2022-07-19T09:15:00",
                295.2,
                295.6,
                292.7,
                294.45,
                9149737
            ]
        ]
    }
}

 SAMPLE FAILURE RESPONSE:  Failure due to wrong client code or JWT passed in the headers

{
    "head": {
        "ResponseCode": "RPOpenAPI",
        "Status": 1,
        "Status_description": "Error While Processing"
    },
    "body": null
}

On this Page

Knowledge base

Funds management system is the next thing to checkout
Funds Management System
How to use this API that suits your work flow best
Start using our APIs

Contribute and get rewarded

Help make these Dev Docs great, contribute to the APIs and get rewarded for your contribution

Need Help

Ask Developer Community

Contact Support

 

Changelog

Changes made to our APIs - Changelog

AVENUES