On this page

One connection, held open, over which Infinn pushes everything that changes: prices, order updates, position updates, alerts and market status. It replaces every polling loop you would otherwise write.

The endpoint
wss://api.infinn.in/NorenWSTP/
The difference from a normal request

A normal request is a phone call: you dial, ask one question, get one answer, hang up. To ask again you dial again.

A WebSocket is leaving the line open. You say who you are once, say what you are interested in, and then simply listen. When the price changes, Infinn speaks. You did not have to ask.

For anything that changes constantly, the second is not just faster - it is the only approach that fits inside the rate limit.

Endpoints

WebSocket URL (LIVE): wss://api.infinn.in/NorenWSTP/

Use the connect message with your access token. Orders placed on live are real. Practise first on Sandbox (UAT / Test — NOT live): https://uat.infinn.in. Then use live.

Why it matters here

Polling — what not to doYour appAPIGetQuotesGetQuotesGetQuotesGetQuotes4 requests to learn the price changed onceStreaming — what to doYour appFeedsubscribe oncepushed only when it changes1 request, then updates arrive by themselves
Figure 1. The same information, two costs. Thirty instruments polled once a second is 30 requests every second, three times the 10-per-second budget. The same thirty on the stream cost one subscription message.

The sequence

Your clientwss://api.infinn.in/NorenWSTP/open the socket{"t":"a", ... "accesstoken": "..."}{"t":"ak","s":"Ok"}authenticated — now you may subscribe{"t":"t","k":"NSE|2885#NSE|3045"}{"t":"tk", ...} × one per tokenfull snapshot{"t":"tf","tk":"2885","lp":"1402.30"}delta — merge it, do not replace{"t":"h"} every ~30s{"t":"hk","ft":"..."}
Figure 2. The full exchange, from opening the socket to receiving updates. Nothing is honoured until the ak acknowledgement arrives.
  1. Open the socketConnect to wss://api.infinn.in/NorenWSTP/. The handshake succeeds regardless of your credentials - which is worth knowing, because it means a successful connection tells you nothing about whether you are authenticated.
  2. Send the connect taskA single message with t: "a" carrying your user ID, account ID, source and access token. Fields
  3. Wait for the acknowledgement{"t":"ak","s":"Ok"} means you are in. Anything else means you are not - and the server will close the connection shortly afterwards.
  4. SubscribeSend a subscription for the feed you want. Each instrument in the subscription produces one acknowledgement carrying a full snapshot.
  5. Merge the updatesUpdates that follow carry only the fields that changed. Merge them into the snapshot; do not replace it.
  6. Keep it aliveSend {"t":"h"} periodically. Without it an idle connection will be dropped by something between you and Infinn, and a dead feed looks exactly like a quiet market.

What is available

FeedWhat it carriesMessage types
Connect & authenticateOpens the stream and authenticates the session.a, ak
HeartbeatKeeps the connection alive.h, hk
Touchline feedStreams the top-of-book snapshot for one or more instruments.t, tk, tf, u, uk
Market depth feedStreams five levels of the order book for one or more instruments.d, dk, df, ud, udk
LTP feedStreams only the last traded price -- the lightest feed.l, lk, lf, ul, ulk
Order updatesPushes every change to your orders as it happens.om, uo, uok
Position updatesPushes changes to your open positions.p, pk, pm, up, upk
Alert updatesPushes notifications when a price alert or GTT triggers.am
Admin messagesPushes administrative messages from the broker.rm
Market status updatesPushes changes to each exchange segment's trading status.ms

Message types at a glance

Every message carries a t field, and both sides dispatch on it. The naming is consistent once you see it: a bare letter is a request, k appended is its acknowledgement, f appended is a feed update, and u prefixed is an unsubscribe.

tDirectionMessageDocumented on
aClient → serverConnect taskConnect & authenticate
akServer → clientConnect acknowledgementConnect & authenticate
hClient → serverHeartbeatHeartbeat
hkServer → clientHeartbeat acknowledgementHeartbeat
tClient → serverSubscribeTouchline feed
tkServer → clientSubscribe acknowledgement (full snapshot)Touchline feed
tfServer → clientTouchline update (changed fields only)Touchline feed
uClient → serverUnsubscribeTouchline feed
ukServer → clientUnsubscribe acknowledgementTouchline feed
dClient → serverSubscribeMarket depth feed
dkServer → clientSubscribe acknowledgement (full snapshot)Market depth feed
dfServer → clientDepth update (changed fields only)Market depth feed
udClient → serverUnsubscribeMarket depth feed
udkServer → clientUnsubscribe acknowledgementMarket depth feed
lClient → serverSubscribeLTP feed
lkServer → clientSubscribe acknowledgement (full snapshot)LTP feed
lfServer → clientLTP updateLTP feed
ulClient → serverUnsubscribeLTP feed
ulkServer → clientUnsubscribe acknowledgementLTP feed
omServer → clientOrder updateOrder updates
uoClient → serverUnsubscribe from order updatesOrder updates
uokServer → clientUnsubscribe acknowledgementOrder updates
pClient → serverSubscribePosition updates
pkServer → clientSubscribe acknowledgementPosition updates
pmServer → clientPosition updatePosition updates
upClient → serverUnsubscribePosition updates
upkServer → clientUnsubscribe acknowledgementPosition updates
amServer → clientAlert updateAlert updates
rmServer → clientAdmin message updateAdmin messages
msServer → clientMarket status updateMarket status updates

Three things that catch people out

1. Updates are deltas, not snapshots

The acknowledgement gives you a complete picture. Every update after it contains only what changed - often just a token and a price.

Replace your stored object with an update and you lose the symbol, the day's range and everything else. Merge, always.

1. Snapshot (tk)tk: "2885"lp: "1400.00"o: "1395.00"h: "1410.00"v: "500000"+2. Delta (tf)tk: "2885"lp: "1402.30"v: "500180"o and h are absent=3. Merged statetk: "2885"lp: "1402.30"o: "1395.00"h: "1410.00"v: "500180"Merge the delta into your stored objectReplacing the object instead would leave you with a price and nothing else.
Figure 3. A snapshot, a delta and the correct result. The delta carries no open or high; those must survive from the snapshot.
2. The handshake succeeding does not mean you are authenticated

Verified against the live endpoint on 2026-10-08: connecting with an invalid token succeeds at the TLS and WebSocket level, returns {"t":"ak","s":"NOT_OK"}, and the server then closes with code 1008 (PolicyViolation).

Note also that the live value is NOT_OK in upper case, while the documentation says Not_Ok. Compare case-insensitively.

3. There is no replay

Nothing that happens while you are disconnected is redelivered. An order that fills during a reconnect simply never produces a message you will see.

So every reconnect must be followed by re-reading state over REST - the order book, the positions book - and then resubscribing. The order-tracking guide shows the pattern.

A complete client

Connects, authenticates, subscribes, merges deltas, heartbeats, and reconnects with backoff. Runnable as it stands.

A production-shaped WebSocket client
"""A complete Infinn WebSocket client.

Handles the five things a toy example leaves out: authentication ordering,
delta merging, heartbeats, reconnection with backoff, and resubscription
after a reconnect.

Requires: pip install websocket-client
"""
import json
import logging
import random
import threading
import time

import websocket  # websocket-client

WS_URL = "wss://api.infinn.in/NorenWSTP/"
HEARTBEAT_SECONDS = 30

log = logging.getLogger("infinn.ws")


class InfinnFeed:
  def __init__(self, uid, access_token, on_tick=None, on_order=None):
      self.uid = uid
      self.access_token = access_token
      self.on_tick = on_tick or (lambda row: None)
      self.on_order = on_order or (lambda row: None)

      # Tokens we want, as "NSE|2885". Kept so a reconnect can restore them.
      self.subscriptions = set()
      # Merged state per (exchange, token).
      self.state = {}

      self._ws = None
      self._authenticated = threading.Event()
      self._stop = threading.Event()
      self._lock = threading.Lock()

  # --- public ------------------------------------------------------------

  def subscribe(self, keys):
      """Subscribes to touchline for keys like 'NSE|2885'."""
      with self._lock:
          self.subscriptions.update(keys)
      if self._authenticated.is_set():
          self._send({"t": "t", "k": "#".join(keys)})

  def run_forever(self):
      """Connects, and keeps reconnecting until stop() is called."""
      attempt = 0
      while not self._stop.is_set():
          try:
              self._connect_once()
              attempt = 0            # a clean run resets the backoff
          except Exception as err:
              log.warning("feed error: %s", err)

          if self._stop.is_set():
              return

          # Full jitter, capped. Without jitter, every client of a broker
          # that just restarted reconnects on the same tick.
          delay = min(60, 2 ** min(attempt, 6))
          time.sleep(random.uniform(1, max(2, delay)))
          attempt += 1
          log.info("reconnecting")

  def stop(self):
      self._stop.set()
      if self._ws:
          self._ws.close()

  # --- internals ----------------------------------------------------------

  def _connect_once(self):
      self._authenticated.clear()
      self._ws = websocket.WebSocketApp(
          WS_URL,
          on_open=self._on_open,
          on_message=self._on_message,
          on_error=lambda ws, e: log.warning("socket error: %s", e),
          on_close=self._on_close,
      )
      self._ws.run_forever(ping_interval=0)   # we send our own heartbeat

  def _send(self, message):
      if self._ws:
          self._ws.send(json.dumps(message))

  def _on_open(self, ws):
      log.info("socket open, authenticating")
      # The handshake succeeding proves nothing. Authenticate, then wait.
      self._send({
          "t": "a",
          "uid": self.uid,
          "actid": self.uid,
          "source": "API",
          "accesstoken": self.access_token,
      })

  def _on_close(self, ws, code, reason):
      # 1008 PolicyViolation is what Infinn sends when it rejects the
      # credentials -- distinguishing it stops a pointless reconnect loop.
      if code == 1008:
          log.error("authentication rejected (1008). Check the token and "
                    "that this machine's IP is registered. Not retrying.")
          self._stop.set()
      else:
          log.info("socket closed: %s %s", code, reason)

  def _on_message(self, ws, raw):
      msg = json.loads(raw)
      kind = msg.get("t")

      if kind == "ak":
          # Documented as "Ok or Not_Ok"; the live feed sends "NOT_OK".
          if str(msg.get("s", "")).lower() != "ok":
              log.error("authentication refused: %s", msg)
              ws.close()
              return
          self._authenticated.set()
          log.info("authenticated")
          self._resubscribe()
          threading.Thread(target=self._heartbeat, daemon=True).start()
          return

      if kind == "hk":
          return                                  # heartbeat acknowledged

      # Snapshots replace; feeds merge. Getting this backwards is the most
      # common bug in clients for this feed.
      if kind in ("tk", "dk", "lk"):
          key = (msg.get("e"), msg.get("tk"))
          self.state[key] = dict(msg)
          self.on_tick(self.state[key])
      elif kind in ("tf", "df", "lf"):
          key = (msg.get("e"), msg.get("tk"))
          row = self.state.setdefault(key, {})
          row.update(msg)
          self.on_tick(row)
      elif kind == "om":
          self.on_order(msg)
      elif kind in ("am", "rm", "ms"):
          log.info("%s: %s", kind, msg.get("dmsg") or msg)

  def _resubscribe(self):
      with self._lock:
          keys = sorted(self.subscriptions)
      if keys:
          # One message can carry many instruments.
          self._send({"t": "t", "k": "#".join(keys)})
          log.info("subscribed to %d instruments", len(keys))

  def _heartbeat(self):
      # No interval is published. 30s is well inside any plausible idle
      # timeout and costs nothing.
      while self._authenticated.is_set() and not self._stop.is_set():
          time.sleep(HEARTBEAT_SECONDS)
          try:
              self._send({"t": "h"})
          except Exception:
              return


if __name__ == "__main__":
  logging.basicConfig(level=logging.INFO,
                      format="%(asctime)s %(levelname)s %(message)s")

  feed = InfinnFeed(
      uid="IN001",
      access_token="YOUR_ACCESS_TOKEN",
      on_tick=lambda row: print(
          f'{row.get("ts", row.get("tk")):<18} {row.get("lp", "-"):>10}'),
  )
  # NSE|2885 is RELIANCE-EQ, NSE|3045 is SBIN-EQ, NSE|26000 is Nifty 50.
  feed.subscribe(["NSE|2885", "NSE|3045", "NSE|26000"])

  try:
      feed.run_forever()
  except KeyboardInterrupt:
      feed.stop()

Choosing a feed

NeedFeedPer-update payload
A price, and nothing else, for many instrumentsLTP4 fields
A watchlist or ticker rowTouchlineUp to ~19 fields
A depth ladderDepthUp to ~30 fields
Order statusOrder updatesNo subscription needed
Position changesPosition updatesMay not be enabled on your account
Subscribe to what you are showing, and no more

The documentation publishes no maximum subscription count. In practice feeds of this family stop adding instruments past an undocumented ceiling without returning an error - you simply never receive data for the surplus.

So count your acknowledgements. You should get one per token you asked for; fewer means some were silently dropped. Subscribe to the visible rows, and unsubscribe when they scroll away.

Sentinel values

42949672.95 means "no price"

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 being reused as a marker.

Treat it as absent, not as a price. Rendered literally it will make a chart unreadable and a portfolio total absurd.

Guard the sentinel
ATO_SENTINEL = 42949672.95


def price(value):
  """Returns a usable price, or None when the feed is signalling 'no price'."""
  parsed = num(value)
  if parsed == 0 or abs(parsed - ATO_SENTINEL) < 0.01:
      return None
  return parsed

All the feeds

Next

Esc
↑↓ navigate↵ openEsc close/ to search