Websocket

Depth Feed

This document details how to subscribe to the depth feed on the Firstock Websockets.

Overview

The WebSocket Depth Feed provides real-time market depth (top-5 bid/ask levels) for multiple instruments via a persistent WebSocket connection

Body

Below is the general JSON body for the Depth Feed API request. All fields marked as Mandatory must be included.

Order Placement API Parameters
Field Type Mandatory Description Example
t

string

Yes

‘d’ represents depth subscription

d

k

string

No

One or more scriplist for subscription

NSE|22#BSE|508123

Request

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

Response Structure

  1. Acknowledgement Response

Body

Number of Acknowledgements for a single subscription will be the same as the number of scrips mentioned in the key (k) field.

Depth Acknowledgement API Parameters
Parameter Description

t

‘dk’ represents depth acknowledgemen

eExchange name
tkScrip Token
lpLTP
pcPercentage change
vvolume
oOpen price
hHigh price
lLow price
cClose price
apAverage trade price
lttLast trade time
ltqLast trade quantity
tbqTotal Buy Quantity
tsqTotal Sell Quantity
bq1...bq5Best Buy Quantity
bp1...bp5Best Buy Price
bo1...bo5Best Buy Orders
sq1...sq5Best Sell Quantity
sp1...sp5Best Sell Price
so1...so5Best Sell Orders
lcLower Circuit Limit
ucUpper Circuit Limit
52h52 week high low in other exchanges, Life time high low in mcx
52l52 week high low in other exchanges, Life time high low in mcx
oiOpen interest
poiPrevious day closing Open Interest
toiTotal open interest for underlying
ftFeed time

Response:

{
   "t": "dk",
   "e": "NSE",
   "tk": "26000",
   "ts": "Nifty 50",
   "pp": "2",
   "ls": "1",
   "ti": "0.05",
   "lp": "24865.45",
   "pc": "-0.98",
   "ft": "1750652516",
   "o": "24939.75",
   "h": "24988.10",
   "l": "24834.55",
   "c": "25112.40",
   "52h": "26277.35",
   "52l": "21743.65",
   "toi": "62387700"
}
  1. Updates Response

Body

The response in "Depth Subscription Updates" will display only the modified fields.

Depth Acknowledgement API Parameters
Parameter Description
t‘df’ represents depth feed
eExchange name
tkScrip Token
lpLTP
pcPercentage change
vvolume
oOpen price
hHigh price
lLow price
cClose price
apAverage trade price
lttLast trade time
ltqLast trade quantity
tbqTotal Buy Quantity
tsqTotal Sell Quantity
bq1...bq5Best Buy Quantity
bp1...bp5Best Buy Price
bo1...b05Best Buy Orders
sq1...sq5Best Sell Quantity
sp1...sp5Best Sell Price
so1...so5Best Sell Orders
lcLower Circuit Limit
ucUpper Circuit Limit
52h52 week high low in other exchanges, Life time high low in mcx
52l52 week high low in other exchanges, Life time high low in mcx
oiOpen interest
poiPrevious day closing Open Interest
toiTotal open interest for underlying
ftFeed time
ueExchange high range
leExchange Low range

Response:

{
   "t": "df",
   "e": "NSE",
   "tk": "26000",
   "lp": "24872.10",
   "pc": "-0.96",
   "ft": "1750652527"
}

Unsubscribe Depth

Body

Below is the general JSON body for the Unsubscribe Depth Feed API request. All fields marked as Mandatory must be included.

Order Placement API Parameters
Field Type Mandatory Description Example
t

string

Yes

‘ud’ represents Unsubscribe depth

ud

k

string

No

One or more scriplist for unsubscription.

NSE|22#BSE|508123

Request

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