TrueData TrueData Sheets
search
Searching...
functions Formulas
menu_book Pages
manage_search Content Match
search_off

No results for ""

Loading Content
history

Historical Data

All TD.Historical calls go inside TD.onStart (or an async function called from it) and must be awaited. These are REST calls — call once, never loop or poll (Rule 17).

warning records[0] is always the header row in every response below. Data rows start at records[1].

1. getBars — Bars for a time range

const data = await TD.Historical.getBars({
  symbol: "RELIANCE",
  from: "2026-06-19 11:58:00",
  to: "2026-06-19 12:00:00",
  interval: "1min",
});

Always check data.status === "Success" before using records. Error statuses include "error fetching data", "Invalid interval", and "Symbol does not exist" — each still returns the header row only.

Success response
{
  "status": "Success",
  "records": [
    ["Timestamp","Open","High","Low","Close","Volume","OpenInterest"],
    ["2026-06-19T11:58:00", 1327.7, 1327.7, 1327.3, 1327.3, 4646, 0],
    ["2026-06-19T11:59:00", 1327.3, 1327.6, 1327.3, 1327.5, 7502, 0]
  ]
}

2. getLastNBars — Last N bars

const data = await TD.Historical.getLastNBars({
  symbol: "RELIANCE",
  nbars: 20,
  interval: "1min",
});

If nbars: 0, only the last single bar is returned. Response and error shapes are the same as getBars.

3. getLastNTicks — Last N ticks

const data = await TD.Historical.getLastNTicks({
  symbol: "RELIANCE",
  nticks: 20,
  bidask: true, // false to exclude bid/ask columns
});
bidask: true
{
  "status": "Success",
  "records": [
    ["Timestamp","LTP","TickVolume","OpenInterest","Bid","BidQty","Ask","AskQty"],
    ["2026-06-19T12:13:56", 1326.1, 1413, 0, 1325.9, 93, 1326.1, 69]
  ]
}
bidask: false
{
  "status": "Success",
  "records": [
    ["Timestamp","LTP","TickVolume","OpenInterest"],
    ["2026-06-19T12:15:25", 1326.2, 16, 0]
  ]
}

4. getTicks — Ticks for a time range

Same as getLastNTicks but with from / to instead of nticks.

const data = await TD.Historical.getTicks({
  symbol: "RELIANCE",
  from: "2026-06-19 09:15:00",
  to: "2026-06-19 09:16:00",
  bidask: true,
});

5. getTopNGainers / getTopNLosers

warning Segment values: "NSEEQ" (NSE) or "BSEEQ" (BSE). Do NOT use "EQ" — that's reserved for Analytics calls (Rule 14).
const gainers = await TD.Historical.getTopNGainers({
  segment: "NSEEQ",
  topn: 5,
});

const losers = await TD.Historical.getTopNLosers({
  segment: "NSEEQ",
  topn: 5,
});
Success response (same shape for both)
{
  "status": "Success",
  "records": [
    ["Symbol","SymbolID","Timestamp","Open","High","Low","Close","Volume",
     "Turnover","PrevClose","Change","ChangePer","Series","Exchange"],
    ["INFY", 100000717, "2026-06-19T00:00:00", 1062.3, 1066, 1030, 1042.2,
     26840317, 673013760, 1127.5, -85.3, -7.57, "EQ", "NSE"]
  ]
}

6. getTopNVolumeGainers

warning Only "NSEEQ" segment is available for this call.
const data = await TD.Historical.getTopNVolumeGainers({
  segment: "NSEEQ",
  topn: 5,
});
// Response and error shapes are the same as getTopNGainers
Truedata Icon Sheets by Truedata

Empowering traders and analysts with high-performance real-time market data directly within their spreadsheets.

© 2026 TrueData Market Data Services LLP. All rights reserved.