On this page
Instead of asking 'has my order filled yet?' over and over, you are told the moment anything happens to it -- accepted, partially filled, filled, rejected or cancelled. This is the correct way to track orders.
wss://api.infinn.in/NorenWSTP/What it does
Pushes every change to your orders as it happens.
Order updates start flowing as soon as the connection is authenticated. The documentation provides uo to turn them off but no matching message to turn them back on, so treat unsubscribing as a one-way decision for the lifetime of that connection.
The same concepts carry different names here: product is pcode on the stream but prd over REST, and the event type is reporttype here but rpt in the order book. If you merge stream and REST data into one model, normalise the names at the boundary.
Combining this feed with a single Order Book call at startup gives you a complete, live picture for the whole session without ever polling. The order tracking guide shows the pattern.
The WebSocket annexure documents many more reporttype values than the REST annexure does, including lifecycle events such as Triggered, lapsed, Frozen and the AMO variants. See the annexure.
Messages you send
Unsubscribe from order updates t: "uo"
Client → server
Stops order updates for this connection.
{ "t": "uo" }| Field | Type | Description |
|---|---|---|
| t | string | Always the literal 'uo'. |
Messages you receive
Order update t: "om"
Server → client
Pushed on every order event. No subscribe message is needed: order updates begin arriving once the connection is authenticated.
| Field | Type | Description |
|---|---|---|
| t | string | Always 'om'. |
| norenordno | string | Infinn order number. |
| uid | string | User ID. |
| actid | string | Account ID. For an individual account it equals |
| exch | string | Exchange. |
| tsym | string | Trading symbol. |
| qty | string | Order quantity. |
| prc | string | Order price. |
| pcode | string | Product. Note the name: this field is pcode on the stream, while the REST endpoints call the same thing prd. |
| status | string | Order status, for example New, Replaced, Complete or Rejected. |
| reporttype | string | The event this message reports, for example Fill, Rejected or Canceled. On the REST endpoints the equivalent field is called rpt. |
| trantype | string | Buy or sell. |
| prctyp | string | Price type: LMT, MKT, SL-LMT or SL-MKT. |
| ret | string | Retention type: DAY, EOS or IOC. |
| fillshares | string | Total quantity filled on this order. |
| avgprc | string | Average fill price. |
| fltm | string | Fill time. PresenceOnly when reporttype is Fill. |
| flid | string | Fill ID. PresenceOnly when reporttype is Fill. |
| flqty | string | Fill quantity. PresenceOnly when reporttype is Fill. |
| flprc | string | Fill price. PresenceOnly when reporttype is Fill. |
| rejreason | string | Rejection reason. PresenceOnly when rejected. |
| exchordid | string | Exchange order ID. |
| cancelqty | string | Cancelled quantity. PresenceOnly when cancelled. |
| remarks | string | The tag you added when placing the order. |
| dscqty | string | Disclosed quantity. |
| trgprc | string | Trigger price, for SL orders. |
| snonum | string | Child-order sequence number for cover and bracket orders. If present, send it when exiting. PresenceCover and bracket child orders. |
| snoordt | string | Whether the child order is the profit or the stop-loss leg. PresenceCover and bracket child orders. |
| blprc | string | Differential stop-loss trigger price. PresenceCover and bracket parent orders. |
| bpprc | string | Differential profit price. PresenceBracket parent orders. |
| trailprc | string | Trailing price, if trailing ticks are enabled. PresenceCover and bracket parent orders. |
| exch_tm | string | Exchange update time, formatted dd-mm-YYYY hh:MM:SS. |
| amo | string | Present with the value "Yes" when the order is an after-market order. |
| tm | string | Timestamp. |
| ntm | string | Nanosecond timestamp. |
| kidid | string | Kid ID. |
| sno_fillid | string | Bracket-order sequence ID. |
| rejby | string | Which system rejected the order. PresenceOnly when rejected. |
| dname | string | Broker-specific contract display name. |
| handlinst | string | Handling instruction: DMA, TOUCH or WO. |
| ordenttm | string | Order entry time. |
| uidc | string | UI device code. |
| os | string | Order source. |
| ai | string | Algo ID. |
Unsubscribe acknowledgement t: "uok"
Server → client
| Field | Type | Description |
|---|---|---|
| t | string | Always 'uok'. |
Working example
A complete Python client for this feed. It needs only the websocket-client package (pip install websocket-client).
"""Infinn WebSocket client -- Order updates.
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.")
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 -- Order updates
// 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.');
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));