pocketful logo light
pocketful logo light

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 NameValueDescription
AuthorizationBearer <your_access_token>Valid Bearer access token for authentication
clientid<client_id>Unique client identifier
acceptapplication/jsonResponse content type format

Query Parameters

ParameterData TypeRequiredDescription
exchangeStringYesExchange identifier (e.g. NSE, BSE, NFO, BFO, CDS, MCX).
tokenStringYesUnique instrument token of the contract or security (e.g. 500470).
candletypeStringYesTimeframe interval identifier (e.g. 1 for 1-minute candles).
from_dateStringYesStart timestamp in ISO 8601 format: YYYY-MM-DDTHH:mm:ss (e.g. 2025-01-01T09:15:00).
to_dateStringYesEnd 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",
};
ExchangeSegmentMarket Description
NSECapitalNational Stock Exchange – Cash / Equity
BSECapitalBombay Stock Exchange – Cash / Equity
NFOFutOptNSE Futures & Options (Equity & Index F&O)
BFOFutOptBSE Futures & Options (Equity & Index F&O)
CDSCurrencyCurrency Derivatives Segment
MCXFutOptMulti 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]:

IndexField NameData TypeDescription
[0]timestampStringTimestamp of the candle interval with timezone (e.g. 2025-01-01T09:15:00+0530).
[1]openFloatOpening price of the candle interval.
[2]highFloatHighest traded price during the candle interval.
[3]lowFloatLowest traded price during the candle interval.
[4]closeFloatClosing price of the candle interval.
[5]volumeIntegerTotal traded volume (shares/contracts) during the candle interval.

Response Parameters

KeyData TypeDescription
statusStringStatus of the API request (success or error).
dataObjectMain container holding the candle records.
candlesArrayList of OHLCV candle arrays ordered chronologically.

Error Response

{
  "status": "error",
  "message": "Invalid parameters",
  "data": {}
}