Skip to main content

Websocket

Sending heartbeat

Sending a heartbeat via WebSocket serves as a mechanism to notify the server of the client's continued activity and its readiness to receive data feeds. This practice allows the server to efficiently manage and prune inactive or closed client connections, contributing to overall improved performance. The request parameters for sending a heartbeat to the server include the essential details needed to maintain this active communication and ensure optimal functioning.

Request

{
"k": "",
"t": "h"
}

k = Send this as empty for heartbeat request
t = Type of request, 'h' stands for Heartbeat

Subscription to market data(LTP, Change, OHLC and Volume)

Request

{"k":"NFO|54957#NSE|26000","t":"t"}

t = Type of request, t for tick data
k = Params for subscription with pipe ‘|’ delimited tokens and exchange. Token and exchange should be separated with #

Acknowledgement Response

{'t': 'tk', 'e': 'NSE', 'tk': '26009', 'ts': 'Nifty Bank', 'pp': '2', 'ls': '1', 'ti': '0.05', 'lp': '50580.45', 'pc': '5.06', 'ft': '1702707042', 'o': '48362.45', 'h': '52708.85', 'l': '47885.10', 'c': '48143.55', 'toi': '13542150'}

Feed Response

{
  't': 'tf',
  'e': 'NSE',
  'tk': '22',
  'ft': '1664340733',
  'v': '2371.20',
  'bp1': '2371.20',
  'sp1': '2371',
  'bq1': '49',
  'sq1': '10'
}
Parameter Description
t Type
tf Tick Feed
tk Tick Acknowledgement
e Exchange
tk Token
pc Percentage Change
cv Change Value
v Volume
o Open
h High
l Low
c Close
ap Average Price
symbol Symbol Name

Un-Subscription to market data(LTP, Change, OHLC and Volume)

Request

{"k":"NFO|54957#NSE|26000","t":"u"}

t = Type of request, u for Un-subscription
k = Params for subscription with pipe ‘|’ delimited tokens and exchange. Token and exchange should be separated with #

Response

No response will be coming for this. Unsubscribed tokens will no longer receive feed

Subscription to Depth Data (LTP, Change, OHLC and Volume)

Request

{"k":"NFO|54957#NSE|26000","t":"d"}

t = Type of request, d for depth data
k = Params for subscription with pipe ‘|’ delimited tokens and exchange. Token and exchange should be separated with #

Acknowledgement Response

{'t': 'dk', 'e': 'NSE', 'tk': '26009', 'ts': 'Nifty Bank', 'pp': '2', 'ls': '1', 'ti': '0.05', 'lp': '50580.45', 'pc': '5.06', 'ft': '1702707042', 'o': '48362.45', 'h': '52708.85', 'l': '47885.10', 'c': '48143.55', '52h': '48219.95', '52l': '38613.15', 'toi': '13542150'}

Feed Response

{
  't': 'df',
  'e': 'NFO',
  'tk': '37516',
  'ft': '1662443826',
  'tbq': '149300',
  'tsq': '134500',
  'bp1': '39888.05',
  'bp2': '39888.00',
  'bp3': '39887.15',
  'sp3': '39894.55',
  'bp4': '39887.10',
  'sp4': '39894.60',
  'bp5': '39886.80',
  'sp5': '39894.95',
  'bq1': '75',
  'sq2': '100',
  'bq3': '100',
  'bq4': '100',
  'sq4': '25',
  'sq5': '100',
  'bo1': '2',
  'so2': '2',
  'so3': '1',
  'so5': '2'
}
Parameter Description
t type
tf tick feed
tk tick acknowledgement
e exchange
tk token
pc percentage change
cv change value
v volume
o open
h high
l low
c close
ap average price
ts Symbol Name
bp1, bp2, bp3, bp4, bp5 Depth buy price
sp1, sp2, sp3, sp4, sp5 Depth sell price
bq1, bq2, bq3, bq4, bq5 Depth buy quantity
sq1, sq2, sq3, sq4, sq5 Depth sell quantity
bo1, bo2, bo3, bo4, bo5 Depth buy order
so1, so2, so3, so4, so5 Depth sell order
oi open interest
ltp last traded qty
ltt last traded time
tbq total buy qty
tsq total sell qty
uc upper circuit
lc lower circuit

Un-Subscription to Depth data(LTP, Change, OHLC and Volume)

Request

{"k":"NFO|54957#NSE|26000","t":"ud"}

t = Type of request, ud for Un-subscription
k = Params for subscription with pipe ‘|’ delimited tokens and exchange. Token and exchange should be separated with #

Response

No response will be coming for this. Unsubscribed tokens will no longer receive feed