On this page
The everyday price feed. For each instrument you get the last traded price, the day's open, high, low and close, volume, and the single best buy and sell price. This is what you drive a watchlist or a ticker from.
wss://api.infinn.in/NorenWSTP/What it does
Streams the top-of-book snapshot for one or more instruments.
The acknowledgement (tk) gives you a complete snapshot. Every update after that (tf) contains only the fields that changed. If you replace your stored object with each update instead of merging into it, the price will survive and everything else will vanish. Seed your state from tk, then patch it with each tf.
Subscribing to three instruments in a single k produces three separate tk messages, not one containing three entries.
The documentation does not publish a maximum subscription count. In practice, feeds of this family stop adding instruments beyond an undocumented ceiling without returning an error -- you simply never receive data for the surplus. Subscribe to what you are actually displaying, and verify you received a tk for every token you asked for.
The general guidelines state that an at-the-open price is sent as 42949672.95. That is 232−1 divided by 100 -- an unsigned 32-bit maximum reused as a sentinel. Treat it as "no price", not as a price.
Messages you send
Subscribe t: "t"
Client → server
Subscribes to touchline updates.
{ "t": "t", "k": "NSE|2885#NSE|3045#NSE|26000" }| Field | Type | Description |
|---|---|---|
| t | string | Always the literal 't'. |
| k | string | One or more instruments, each written as exchange|token and joined with #. For example NSE|22#BSE|508123#NSE|NIFTY. |
Unsubscribe t: "u"
Client → server
Stops touchline updates for the listed instruments.
{ "t": "u", "k": "NSE|2885#NSE|3045" }| Field | Type | Description |
|---|---|---|
| t | string | Always the literal 'u'. |
| k | string | The instruments to unsubscribe, as exchange|token joined with #. |
Messages you receive
Subscribe acknowledgement (full snapshot) t: "tk"
Server → client
One acknowledgement arrives per instrument in k, each carrying a complete snapshot of that instrument's current state.
| Field | Type | Description |
|---|---|---|
| t | string | Always 'tk'. |
| e | string | Exchange name, for example NSE, BSE or NFO. |
| tk | string | Scrip token, for example 22. |
| pp | string | Price precision. 2 for NSE and BSE; 4 for CDS USDINR. |
| ts | string | Trading symbol. |
| ti | string | Tick size. |
| ls | string | Lot size. |
| lp | string | Last traded price. The price of the most recent trade. |
| pc | string | Percentage change. |
| v | string | Volume. |
| o | string | Open price. |
| h | string | High price. |
| l | string | Low price. |
| c | string | Close price. |
| ap | string | Average trade price. |
| oi | string | Open interest. |
| poi | string | Previous day's closing open interest. |
| toi | string | Total open interest for the underlying. |
| bq1 | string | Best buy quantity, level 1. |
| bp1 | string | Best buy price, level 1. |
| sq1 | string | Best sell quantity, level 1. |
| sp1 | string | Best sell price, level 1. |
| ft | string | Feed time. |
| ord_msg | string | Order message. |
Touchline update (changed fields only) t: "tf"
Server → client
Sent whenever something changes. Only t, e and tk are guaranteed -- every other field may or may not be present.
| Field | Type | Description |
|---|---|---|
| t | string | Always 'tf'. |
| e | string | Exchange name. Always present. |
| tk | string | Scrip token. Always present. |
| lp | string | Last traded price. |
| pc | string | Percentage change. |
| v | string | Volume. |
| o | string | Open price. |
| h | string | High price. |
| l | string | Low price. |
| c | string | Close price. |
| ap | string | Average trade price. |
| oi | string | Open interest. |
| poi | string | Previous day's closing open interest. |
| toi | string | Total open interest for the underlying. |
| bq1 | string | Best buy quantity, level 1. |
| bp1 | string | Best buy price, level 1. |
| sq1 | string | Best sell quantity, level 1. |
| sp1 | string | Best sell price, level 1. |
| ft | string | Feed time. |
Unsubscribe acknowledgement t: "uk"
Server → client
| Field | Type | Description |
|---|---|---|
| t | string | Always 'uk'. |
| k | string | The instruments that were unsubscribed. |
Working example
A complete Python client for this feed. It needs only the websocket-client package (pip install websocket-client).
"""Infinn WebSocket client -- Touchline feed.
Requires: pip install websocket-client
"""
import json
import threading
import time
import websocket # websocket-client
ACCESS_TOKEN = "YOUR_ACCESS_TOKEN"
UID = "IN001"
# Merged state per token. The acknowledgement carries a full snapshot and
# every later update carries only what changed, so updates must be MERGED
# into this, never used to replace an entry.
state = {}
def on_open(ws):
# Step 1: authenticate. Nothing else is honoured until "ak" arrives.
ws.send(json.dumps({
"t": "a",
"uid": UID,
"actid": UID,
"source": "API",
"accesstoken": ACCESS_TOKEN,
}))
def on_message(ws, raw):
msg = json.loads(raw)
kind = msg.get("t")
if kind == "ak":
# The documentation says "Ok or Not_Ok"; the live feed sends "NOT_OK".
# Compare case-insensitively.
if str(msg.get("s", "")).lower() != "ok":
print("Authentication refused:", msg)
ws.close()
return
print("Authenticated. Subscribing.")
ws.send(json.dumps({"t": "t", "k": "NSE|2885#NSE|3045"}))
threading.Thread(target=heartbeat, args=(ws,), daemon=True).start()
return
# Acknowledgements carry a full snapshot; feeds carry deltas.
if kind in ("tk", "dk", "lk"):
state[msg["tk"]] = dict(msg)
elif kind in ("tf", "df", "lf"):
state.setdefault(msg["tk"], {}).update(msg)
elif kind == "hk":
return # heartbeat acknowledged
else:
print(kind, msg)
return
row = state[msg["tk"]]
print(f'{row.get("ts", row["tk"]):<16} {row.get("lp", "-"):>10}')
def heartbeat(ws):
# No interval is published. 30s is comfortably inside any plausible
# idle timeout for a feed of this kind.
while ws.keep_running:
time.sleep(30)
try:
ws.send(json.dumps({"t": "h"}))
except Exception:
return
def on_error(ws, err):
print("error:", err)
def on_close(ws, code, reason):
# 1008 (PolicyViolation) is what the server sends when it rejects
# your credentials.
print(f"closed: {code} {reason}")
if __name__ == "__main__":
websocket.WebSocketApp(
"wss://api.infinn.in/NorenWSTP/",
on_open=on_open,
on_message=on_message,
on_error=on_error,
on_close=on_close,
).run_forever()// Infinn WebSocket client -- Touchline feed
// Node: npm install ws | Browser: use the built-in WebSocket.
const WebSocket = require('ws');
const ACCESS_TOKEN = 'YOUR_ACCESS_TOKEN';
const UID = 'IN001';
// Merged state per token: acknowledgements are snapshots, feeds are deltas.
const state = new Map();
const ws = new WebSocket('wss://api.infinn.in/NorenWSTP/');
ws.on('open', () => {
ws.send(JSON.stringify({
t: 'a',
uid: UID,
actid: UID,
source: 'API',
accesstoken: ACCESS_TOKEN,
}));
});
ws.on('message', (raw) => {
const msg = JSON.parse(raw);
if (msg.t === 'ak') {
// Documented as "Ok or Not_Ok"; the live feed sends "NOT_OK".
if (String(msg.s).toLowerCase() !== 'ok') {
console.error('Authentication refused:', msg);
ws.close();
return;
}
console.log('Authenticated. Subscribing.');
ws.send(JSON.stringify({ t: 't', k: 'NSE|2885#NSE|3045' }));
setInterval(() => ws.send(JSON.stringify({ t: 'h' })), 30000);
return;
}
if (['tk', 'dk', 'lk'].includes(msg.t)) {
state.set(msg.tk, { ...msg }); // snapshot: replace
} else if (['tf', 'df', 'lf'].includes(msg.t)) {
state.set(msg.tk, { ...state.get(msg.tk), ...msg }); // delta: merge
} else {
return;
}
const row = state.get(msg.tk);
console.log((row.ts || row.tk).padEnd(16), String(row.lp ?? '-').padStart(10));
});
// 1008 PolicyViolation is sent when the credentials are rejected.
ws.on('close', (code, reason) => console.log('closed:', code, String(reason)));
ws.on('error', (err) => console.error('error:', err.message));