On this page

One endpoint returns price history: TPSeries. This guide takes you from "I know the name of a stock" to a clean OHLCV series at whatever interval you want, and is honest about the two places the API will not help you.

Read this before you build on it

Two limits shape everything below, and neither is a matter of opinion:

  • There is no interval parameter. TPSeries takes a start time and an end time and nothing else. The API specification publishes no way to ask for 5-minute or daily candles. You aggregate them yourself, and the code to do it is below.
  • There is no end-of-day endpoint. No daily bars, no adjusted closes, no corporate-action history. TPSeries is the whole of the historical surface.

The whole flow

Four steps, and only the last two need credentials.

  1. Download the symbol masterA public ZIP per segment, no token required. Instruments & the symbol master covers every file and its column layout.
  2. Find the contract and take its TokenTPSeries is addressed by numeric token, not by trading symbol. RELIANCE-EQ is token 2885; NIFTY INDEX is 26000.
  3. Convert your date range to Unix secondsst and et are seconds since 1 January 1970. Indian markets run on IST, which is UTC+5:30, and getting that offset wrong is the most common reason an empty array comes back.
  4. Call TPSeries and merge the candlesNewest first, as strings, in a JSON array on success and a JSON object on failure.
StepNeeds a token?What you get
1. Download <SEG>_symbols.txt.zipnoEvery contract on that segment, with its numeric Token.
2. Look up your contract by TradingSymbolnoThe Token and the Exchange that owns it.
3. Convert your dates to Unix secondsnost and et, in IST.
4. POST to TPSeriesyesCandles, newest first, as strings.
5. Aggregate to the interval you wantno5m, 15m, 30m, 1h or daily bars.

What TPSeries takes

FieldValueNotes
uidrequiredIN001The logged-in user ID.
exchrequiredNSEThe segment the token belongs to. A token queried against the wrong segment returns nothing, not an error.
tokenrequired2885The numeric contract token from the symbol master. Not the trading symbol.
stoptional1759722300Start time, Unix seconds. Interpret your dates as IST.
etoptional1759744800End time, Unix seconds.
intervaldoes not exist-Documentation information not available. No candle-interval parameter is published, and none is documented as a default. The published sample shows one-minute candles.

Both exchanges below work the same way. The segment goes in exch and must be the segment the token belongs to - an NSE token with exch: "NFO" returns nothing rather than an error.

MarketexchSymbol masterTrading hours (IST)
NSE cash and indicesNSENSE_symbols.txt.zip09:15 – 15:30
NSE equity derivativesNFONFO_symbols.txt.zip09:15 – 15:30
NSE currencyCDSCDS_symbols.txt.zip09:00 – 17:00
NSE commodityNCOMNCOM_symbols.txt.zip09:00 – 23:30
BSE cashBSEBSE_symbols.txt.zip09:15 – 15:30
BSE equity derivativesBFOBFO_symbols.txt.zip09:15 – 15:30
MCX commodityMCXMCX_symbols.txt.zip09:00 – 23:30

Converting a date range to st and et

This is where most of the mistakes happen. The exchange day is IST; your server is probably UTC.

Dates and times to epoch seconds, correctly
from datetime import datetime
from zoneinfo import ZoneInfo          # Python 3.9+

IST = ZoneInfo("Asia/Kolkata")


def epoch(date_str, time_str="09:15:00"):
  """'2026-10-06', '09:15:00' -> Unix seconds, read as IST.

  Naive datetimes are interpreted by Python as LOCAL time, which on a
  UTC server is 5 hours 30 minutes adrift -- enough to return the
  previous session, or nothing at all.
  """
  stamp = datetime.strptime(f"{date_str} {time_str}", "%Y-%m-%d %H:%M:%S")
  return int(stamp.replace(tzinfo=IST).timestamp())


# A single session: 09:15 to 15:30 IST.
start = epoch("2026-10-06", "09:15:00")
end = epoch("2026-10-06", "15:30:00")
print(start, end)                      # 1759722300 1759744800
Market hours, so you can sanity-check your numbers

NSE and BSE equities trade 09:15 to 15:30 IST. MCX runs 09:00 to 23:30 IST (23:55 when US daylight saving is in effect). A range entirely outside those hours returns an empty array, not an error - which looks exactly like a broken request.

Complete worked example

Get 5-minute candles for RELIANCE-EQ on NSE, from 2026-10-06 09:15 to 15:30 IST.

RELIANCE-EQ is token 2885, verified against NSE_symbols.txt. The API has no 5-minute mode, so this asks for the full session and aggregates.

historical.py — the whole thing, start to finish
"""Fetch a session of candles from Infinn and resample them.

  python historical.py

Needs INFINN_ACCESS_TOKEN in the environment. Get one from
/getting-started/authentication/.
"""
import json
import os
from datetime import datetime, timedelta
from zoneinfo import ZoneInfo

import requests

URL = "https://api.infinn.in/NorenWClientAPI/TPSeries"
IST = ZoneInfo("Asia/Kolkata")

ACCESS_TOKEN = os.environ["INFINN_ACCESS_TOKEN"]
USER_ID = os.environ.get("INFINN_USER_ID", "IN001")


def epoch(date_str, time_str):
  stamp = datetime.strptime(f"{date_str} {time_str}", "%Y-%m-%d %H:%M:%S")
  return int(stamp.replace(tzinfo=IST).timestamp())


def fetch(exch, token, start, end):
  """Returns candles oldest-first, or raises with a readable reason."""
  payload = {
      "uid": USER_ID,
      "exch": exch,
      "token": str(token),
      "st": str(start),
      "et": str(end),
  }

  response = requests.post(
      URL,
      headers={
          "Authorization": f"Bearer {ACCESS_TOKEN}",
          "Content-Type": "text/plain",
      },
      data="jData=" + json.dumps(payload),
      timeout=30,
  )

  # Layer 1. A rejected token gives 401 with an EMPTY body, so this has
  # to happen before any attempt to parse.
  if response.status_code != 200:
      raise RuntimeError(
          f"HTTP {response.status_code}. If 403: check the token, and "
          f"that this machine's public IP is registered on your profile."
      )
  if not response.text.strip():
      raise RuntimeError("empty body with HTTP 200")

  data = response.json()

  # Layer 2. Success is an ARRAY; failure is an OBJECT with stat/emsg.
  if isinstance(data, dict):
      raise RuntimeError(data.get("emsg", "Not_Ok with no emsg"))
  if not data:
      raise RuntimeError(
          "no candles. Check the range is inside market hours, that the "
          "token belongs to this exch, and that the day was a trading day."
      )

  candles = []
  for row in data:
      # Every row carries its own stat. A partial failure is possible.
      if row.get("stat") != "Ok":
          continue
      candles.append({
          "time": datetime.strptime(row["time"], "%d-%m-%Y %H:%M:%S")
                          .replace(tzinfo=IST),
          "open": float(row["into"]),
          "high": float(row["inth"]),
          "low": float(row["intl"]),
          "close": float(row["intc"]),
          "volume": int(row["intv"]),
          "vwap": float(row["intvwap"]),
          "oi": int(row["oi"]) if row.get("oi") else None,
      })

  # The API returns newest first. Nobody wants that.
  candles.sort(key=lambda c: c["time"])
  return candles


def resample(candles, minutes):
  """Aggregates 1-minute candles into `minutes`-minute candles.

  OHLCV aggregation is not elementwise: open is the FIRST open, close
  the LAST close, high the max, low the min, volume the sum. Getting
  this wrong by averaging is a classic and silent error.
  """
  if not candles:
      return []

  buckets = {}
  for c in candles:
      # Floor to the bucket start.
      minute = (c["time"].hour * 60 + c["time"].minute) // minutes * minutes
      key = c["time"].replace(hour=minute // 60, minute=minute % 60,
                              second=0, microsecond=0)
      buckets.setdefault(key, []).append(c)

  out = []
  for key in sorted(buckets):
      group = buckets[key]
      out.append({
          "time": key,
          "open": group[0]["open"],
          "high": max(g["high"] for g in group),
          "low": min(g["low"] for g in group),
          "close": group[-1]["close"],
          "volume": sum(g["volume"] for g in group),
      })
  return out


if __name__ == "__main__":
  start = epoch("2026-10-06", "09:15:00")
  end = epoch("2026-10-06", "15:30:00")

  try:
      raw = fetch("NSE", 2885, start, end)
  except RuntimeError as err:
      raise SystemExit(f"TPSeries failed: {err}")

  print(f"{len(raw)} raw candles")

  for size in (5, 15, 30, 60):
      bars = resample(raw, size)
      print(f"{size:>3}m -> {len(bars):>4} bars")

  for bar in resample(raw, 5)[:3]:
      print(bar["time"].strftime("%Y-%m-%d %H:%M"),
            bar["open"], bar["high"], bar["low"], bar["close"],
            bar["volume"])
Authentication required - this example cannot be executed without valid credentials

TPSeries needs a Bearer token, and the account's registered IP must match the machine making the call. The code above was run as part of this site's test suite and reached the API; without credentials it returns HTTP 401 with an empty body, which is exactly the path its first error branch handles.

The response shown below is therefore the documented example response, reproduced in the exact shape the API specifies. It is not output captured from a live authenticated call, and this page does not pretend otherwise.

The response

An array, newest candle first, every value a string.

The documented TPSeries response
[
{
  "stat": "Ok",
  "time": "02-06-2020 15:46:23",
  "into": "0.00",
  "inth": "0.00",
  "intl": "0.00",
  "intc": "0.00",
  "intvwap": "0.00",
  "intv": "0",
  "intoi": "0",
  "v": "980515",
  "oi": "128702"
},
{
  "stat": "Ok",
  "time": "02-06-2020 15:43:23",
  "into": "1287.00",
  "inth": "1287.00",
  "intl": "0.00",
  "intc": "1287.00",
  "intvwap": "128702.00",
  "intv": "4",
  "intoi": "128702",
  "v": "980515",
  "oi": "128702"
}
]
FieldMeaningIn the sample
statPer-candle status. Check it per row, not just once - a partial failure is possible."Ok"
timeCandle timestamp, dd-mm-yyyy HH:MM:SS, IST. Day first."02-06-2020 15:46:23"
intoOpen of the interval."1287.00"
inthHigh of the interval."1287.00"
intlLow of the interval."0.00"
intcClose of the interval."1287.00"
intvVolume traded in the interval."4"
intvwapVolume-weighted average price for the interval."128702.00"
intoiChange in open interest over the interval. Derivatives only."128702"
vCumulative volume for the day so far - not the interval's volume."980515"
oiOpen interest outstanding at the end of the interval."128702"
Four things about this response that will bite you
  1. It is newest-first. The sample descends: 15:46, then 15:43. Sort by time rather than assuming order.
  2. Every number is a string. "1287.00", not 1287.0. Convert explicitly.
  3. Zeros are real. The first candle in the sample has into, inth, intl and intc all "0.00" with intv: "0" - a minute in which nothing traded. Do not plot those as a price crash; skip zero-volume candles or carry the previous close.
  4. Failure changes the type. Success is an array, failure is an object. data[0] on a failure gives you a dictionary key, not a candle.

The timestamp format

"02-06-2020 15:46:23" is dd-mm-yyyy HH:MM:SS in IST - day first, not month first. Parsing it as %m-%d-%Y succeeds silently for the first twelve days of any month and then throws, which is the worst possible failure mode.

Parsing it
from datetime import datetime
from zoneinfo import ZoneInfo

stamp = datetime.strptime("02-06-2020 15:46:23", "%d-%m-%Y %H:%M:%S")
stamp = stamp.replace(tzinfo=ZoneInfo("Asia/Kolkata"))
# 2020-06-02 15:46:23+05:30  -- the 2nd of June, not the 6th of February

Getting 5-minute, 15-minute and daily candles

The API has no interval parameter, so the answer is to aggregate. The resample function above does it; this is the rule it implements, because OHLCV does not aggregate elementwise:

Output fieldHow it is derived from the minutes in the bucket
OpenThe first minute's open. Not an average.
HighThe maximum of the minutes' highs.
LowThe minimum of the minutes' lows - excluding zero-volume minutes, whose low is 0.00.
CloseThe last minute's close. Not an average.
VolumeThe sum of intv. Never sum v, which is already cumulative.
VWAPRecompute as ∑(price × volume) / ∑volume. Averaging the per-minute VWAPs is wrong unless every minute had equal volume.
Do not average the open and close

The single most common error in home-made resampling. A 5-minute candle's open is the first minute's open and its close is the last minute's close. Averaging them produces a chart that looks plausible, smooths away every gap, and is wrong everywhere.

Daily candles

Same function, one bucket per session - but request one day at a time rather than a wide range, and key the bucket by date:

A daily series, built from sessions
from datetime import date, timedelta


def daily(exch, token, first, last):
  """One bar per trading day between two dates, inclusive."""
  bars = []
  day = first
  while day <= last:
      start = epoch(day.isoformat(), "00:00:00")
      end = epoch(day.isoformat(), "23:59:59")
      try:
          candles = fetch(exch, token, start, end)
      except RuntimeError:
          # Weekend, holiday, or a day before the contract listed.
          day += timedelta(days=1)
          continue

      bars.append({
          "date": day,
          "open": candles[0]["open"],
          "high": max(c["high"] for c in candles),
          "low": min(c["low"] for c in candles if c["low"] > 0),
          "close": candles[-1]["close"],
          "volume": sum(c["volume"] for c in candles),
      })
      day += timedelta(days=1)
  return bars


# Mind the rate limit: 20 orders per second and 200 orders per minute. One call per day
# means a year of history is roughly 250 calls -- well inside the minute
# budget if you pace it, and instantly over if you do not.
Note the <code>c["low"] > 0</code> filter

Without it, a single zero-volume minute drags the day's low to 0.00. The same trap applies to any aggregation over a period that might contain an untraded minute.

What is not available

What you might wantWhat there is instead
A candle-interval parameternot availableRequest the range and aggregate the result yourself.
An end-of-day / daily-bar endpointnot availableOne TPSeries call per session, bucketed by date.
Split- and dividend-adjusted historynot availableNothing. Infinn publishes no corporate-action endpoint.
A documented maximum range per callnot availableDocumentation information not available. No limit is published; assume one exists and page by day.
A documented history depthnot availableDocumentation information not available. How far back TPSeries goes is not stated.
Tick-by-tick historynot availableThe WebSocket gives live ticks only. Record them yourself if you need them.

Next

Esc
↑↓ navigate↵ openEsc close/ to search