On this page
In plain English

The cheapest feed there is: after the opening snapshot, each update carries just the new price. Use it when you need prices for many instruments and nothing else, such as valuing a large portfolio.

WSwss://api.infinn.in/NorenWSTP/

What it does

Streams only the last traded price -- the lightest feed.

The acknowledgement is your only snapshot

lk carries open, high, low, close, volume and the top of book. The lf updates that follow carry none of it. If you need the day's range as well as the live price, capture it from lk and keep it.

The documentation labels the lf table "TouchLine Subscription Updates"

On the Subscribe LTP page, the update table is headed "TouchLine Subscription Updates" -- a copy-paste from the touchline page. The field list beneath it (t, e, tk, lp) is the LTP one and is correct.

Messages you send

Subscribe t: "l"

Client → server

Subscribes to LTP updates.

Example message
{ "t": "l", "k": "NSE|2885#NSE|3045#NSE|1594" }
Subscribe fields
FieldTypeDescription
tstring

Always the literal 'l'.

kstring

One or more instruments as exchange|token joined with #, for example NSE|22#BSE|508123#NSE|NIFTY.

Unsubscribe t: "ul"

Client → server

Example message
{ "t": "ul", "k": "NSE|2885" }
Unsubscribe fields
FieldTypeDescription
tstring

Always the literal 'ul'.

kstring

The instruments to unsubscribe.

Messages you receive

Subscribe acknowledgement (full snapshot) t: "lk"

Server → client

One per instrument, carrying the same full snapshot the touchline acknowledgement does.

Subscribe acknowledgement (full snapshot) fields
FieldTypeDescription
tstring

Always 'lk'.

estring

Exchange name, for example NSE, BSE or NFO.

tkstring

Scrip token, for example 22.

ppstring

Price precision. 2 for NSE and BSE; 4 for CDS USDINR.

tsstring

Trading symbol.

tistring

Tick size.

lsstring

Lot size.

lpstring

Last traded price.

The price of the most recent trade.

pcstring

Percentage change.

vstring

Volume.

ostring

Open price.

hstring

High price.

lstring

Low price.

cstring

Close price.

apstring

Average trade price.

oistring

Open interest.

poistring

Previous day's closing open interest.

toistring

Total open interest for the underlying.

bq1string

Best buy quantity, level 1.

bp1string

Best buy price, level 1.

sq1string

Best sell quantity, level 1.

sp1string

Best sell price, level 1.

ftstring

Feed time.

ord_msgstring

Order message.

LTP update t: "lf"

Server → client

The minimal update: an identifier and a price.

Example message
{ "t": "lf", "e": "NSE", "tk": "2885", "lp": "1402.30" }
LTP update fields
FieldTypeDescription
tstring

Always 'lf'.

estring

Exchange name.

tkstring

Scrip token.

lpstring

Last traded price.

Unsubscribe acknowledgement t: "ulk"

Server → client

Unsubscribe acknowledgement fields
FieldTypeDescription
tstring

Always 'ulk'.

kstring

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).

Python
"""Infinn WebSocket client -- LTP 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": "l", "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()
Esc
↑↓ navigate↵ openEsc close/ to search