Chart Data
The Chart Data API retrieves historical candlestick (OHLCV) data for financial instruments across Equity, Futures & Options (F&O), Currency, and Commodity markets. Each candlestick provides the Open, High, Low, Close (OHLC) prices and Volume traded for a specific interval between the requested from_date and to_date.
This endpoint is designed for algorithmic trading strategies, technical indicators (e.g., Moving Averages, RSI, MACD), backtesting engines, and charting visualizations.
Endpoint: /api/v1/charts
Method-Type: GET
Headers
| Header Name | Value | Description |
|---|---|---|
| Authorization | Bearer <your_access_token> | Valid Bearer access token for authentication |
| clientid | <client_id> | Unique client identifier |
| accept | application/json | Response content type format |
Query Parameters
| Parameter | Data Type | Required | Description |
|---|---|---|---|
exchange | String | Yes | Exchange identifier (e.g. NSE, BSE, NFO, BFO, CDS, MCX). |
token | String | Yes | Unique instrument token of the contract or security (e.g. 500470). |
candletype | String | Yes | Timeframe interval identifier (e.g. 1 for 1-minute candles). |
from_date | String | Yes | Start timestamp in ISO 8601 format: YYYY-MM-DDTHH:mm:ss (e.g. 2025-01-01T09:15:00). |
to_date | String | Yes | End timestamp in ISO 8601 format: YYYY-MM-DDTHH:mm:ss (e.g. 2025-01-01T15:30:00). |
Segment Mapping for F&O and Market Data
When querying contracts or market data across different asset classes, instruments belong to specific exchange segments (e.g., Capital for Equity Cash, FutOpt for Futures and Options, Currency for Currency Derivatives).
You can use the following segment mapping:JavaScript / TypeScriptPython
export const segment = {
NSE: "Capital",
BSE: "Capital",
NFO: "FutOpt",
BFO: "FutOpt",
CDS: "Currency",
MCX: "FutOpt",
};
| Exchange | Segment | Market Description |
|---|---|---|
NSE | Capital | National Stock Exchange – Cash / Equity |
BSE | Capital | Bombay Stock Exchange – Cash / Equity |
NFO | FutOpt | NSE Futures & Options (Equity & Index F&O) |
BFO | FutOpt | BSE Futures & Options (Equity & Index F&O) |
CDS | Currency | Currency Derivatives Segment |
MCX | FutOpt | Multi Commodity Exchange (Commodity Derivatives) |
Example
response = pocket.getChartData(
exchange="BSE",
token="500470",
candletype=1,
from_date="2025-01-01T09:15:00",
to_date="2025-01-01T15:30:00"
)
Example cURL Request
curl -X 'GET' \
'https://algo.pocketful.in/api/v1/charts?exchange=BSE&token=500470&candletype=1&from_date=2025-01-01T09%3A15%3A00&to_date=2025-01-01T15%3A30%3A00' \
-H 'accept: application/json' \
-H 'clientid: <client_id>' \
-H 'Authorization: Bearer <your_access_token>'
Response
{
"status": "success",
"data": {
"candles": [
[
"2025-01-01T09:15:00+0530",
138.35,
138.35,
137.75,
137.85,
16699
],
[
"2025-01-01T09:16:00+0530",
137.85,
137.85,
137.4,
137.7,
19642
]
]
}
}
Candle Data Structure
Each item in the candles array is an ordered array representing [timestamp, open, high, low, close, volume]:
| Index | Field Name | Data Type | Description |
|---|---|---|---|
[0] | timestamp | String | Timestamp of the candle interval with timezone (e.g. 2025-01-01T09:15:00+0530). |
[1] | open | Float | Opening price of the candle interval. |
[2] | high | Float | Highest traded price during the candle interval. |
[3] | low | Float | Lowest traded price during the candle interval. |
[4] | close | Float | Closing price of the candle interval. |
[5] | volume | Integer | Total traded volume (shares/contracts) during the candle interval. |
Response Parameters
| Key | Data Type | Description |
|---|---|---|
status | String | Status of the API request (success or error). |
data | Object | Main container holding the candle records. |
candles | Array | List of OHLCV candle arrays ordered chronologically. |
Error Response
{
"status": "error",
"message": "Invalid parameters",
"data": {}
}