Skip to Main Content
WSt: 't' (subscribe) / 'u' (unsubscribe)

Subscribe to Market Feed

Subscribe to live touchline ticks for one or more instruments over the WebSocket connection established in WebSocket Overview.

Overview

After connecting and receiving s: "Ok" per WebSocket Overview, send a subscribe frame listing the instruments (as EXCHANGE|TOKEN pairs) you want ticks for. The gateway sends one full-snapshot acknowledgment per subscribed instrument — the number of tk acks you receive equals the number of scrips in your k field — then streams incremental updates as fields change.

Subscribe frame (t: 't')

json
{ "t": "t", "k": "NSE|22#BSE|508123#NSE|NIFTY" }
FieldPossible valueDescription
ttRepresents the touchline subscribe task.
kOne or more #-delimited EXCHANGE|TOKEN pairs, e.g. NSE|22#BSE|508123#NSE|NIFTY.

Acknowledgment (t: 'tk')

Sent once per subscribed instrument, carrying every field currently known. Aside from t, e, and tk, any other field may or may not be present depending on instrument type:

json
{
  "t": "tk", "e": "NSE", "tk": "22", "ts": "ACC-EQ",
  "pp": "2", "ti": "0.05", "ls": "1",
  "lp": "1287.30", "pc": "0.45",
  "o": "1280.00", "h": "1291.80", "l": "1278.50", "c": "1275.20",
  "ap": "1286.10", "v": "980515",
  "oi": "0", "poi": "0", "toi": "0",
  "bq1": "26", "bp1": "1287.25", "sq1": "6325", "sp1": "1287.35",
  "ft": "1670231374"
}
FieldDescription
ttk — represents the touchline acknowledgment.
eExchange name (NSE, BSE, NFO, etc.).
tkScrip token.
ppPrice precision — 2 for NSE/BSE, 4 for CDS USDINR.
tsTrading symbol.
tiTick size.
lsLot size.
lpLast traded price.
pcPercentage change.
vVolume.
o / h / l / cOpen / high / low / close price.
apAverage trade price.
oi / poi / toiOpen interest, previous day closing OI, total OI for the underlying.
bq1 / bp1Best buy quantity / price (level 1).
sq1 / sp1Best sell quantity / price (level 1).
ftFeed time.
ord_msgOrder message (present in some feed variants).

Incremental updates (t: 'tf')

Except for t, e, and tk, other fields are only sent when they change since the last message — everything else is implicitly unchanged from the state you've already built up client-side:

json
// t:'tk' — full snapshot on subscribe
{"t":"tk","e":"NSE","tk":"11630","ts":"NTPC-EQ","pp":"2","ls":"1","ti":"0.05","lp":"118.55","pc":"0.12","h":"118.65","l":"118.10","ap":"118.39","v":"162220","bp1":"118.45","sp1":"118.50","bq1":"26","sq1":"6325","ft":"1670231200"}

// t:'tf' — only lp, pc, ap, v, sp1, bq1, sq1, ft changed
{"t":"tf","e":"NSE","tk":"11630","lp":"118.45","pc":"0.08","ap":"118.40","v":"166637","sp1":"118.55","bq1":"3135","sq1":"30","ft":"1670231245"}

// t:'tf' — only lp and ft changed this time
{"t":"tf","e":"NSE","tk":"11630","lp":"118.60","ft":"1670231260"}
You must maintain state client-sideThe feed is a diff stream after the initial tk. Maintain a local dictionary keyed by token and merge each tf message into it — don't treat any single message after subscription as a complete quote.

Unsubscribe (t: 'u')

Request:

json
{ "t": "u", "k": "NSE|22#BSE|508123" }

Acknowledgment:

json
{ "t": "uk", "k": "NSE|22#BSE|508123" }
FieldPossible valueDescription
tu (request) / uk (ack)Unsubscribe touchline / unsubscribe acknowledgment.
kSame #-delimited scrip list that was unsubscribed.

Best practices

  • Subscribe to everything you need over the single connection from WebSocket Overview — don't open a second socket per instrument group.
  • Re-send all subscriptions after every reconnect; the gateway does not persist them across a dropped connection.
  • This feed's bp1/sp1 pair is touchline (level-1) only.

Notes

Field presence varies by instrument type — index tokens won't carry bp1/sp1, and equity tokens won't carry oi/poi/toi. Check for field presence rather than assuming a fixed shape.