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.
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
- 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.
Parameter | Description |
---|---|
t |
‘dk’ represents depth acknowledgemen |
e | Exchange name |
tk | Scrip Token |
lp | LTP |
pc | Percentage change |
v | volume |
o | Open price |
h | High price |
l | Low price |
c | Close price |
ap | Average trade price |
ltt | Last trade time |
ltq | Last trade quantity |
tbq | Total Buy Quantity |
tsq | Total Sell Quantity |
bq1...bq5 | Best Buy Quantity |
bp1...bp5 | Best Buy Price |
bo1...bo5 | Best Buy Orders |
sq1...sq5 | Best Sell Quantity |
sp1...sp5 | Best Sell Price |
so1...so5 | Best Sell Orders |
lc | Lower Circuit Limit |
uc | Upper Circuit Limit |
52h | 52 week high low in other exchanges, Life time high low in mcx |
52l | 52 week high low in other exchanges, Life time high low in mcx |
oi | Open interest |
poi | Previous day closing Open Interest |
toi | Total open interest for underlying |
ft | Feed 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"
}
- Updates Response
Body
The response in "Depth Subscription Updates" will display only the modified fields.
Parameter | Description |
---|---|
t | ‘df’ represents depth feed |
e | Exchange name |
tk | Scrip Token |
lp | LTP |
pc | Percentage change |
v | volume |
o | Open price |
h | High price |
l | Low price |
c | Close price |
ap | Average trade price |
ltt | Last trade time |
ltq | Last trade quantity |
tbq | Total Buy Quantity |
tsq | Total Sell Quantity |
bq1...bq5 | Best Buy Quantity |
bp1...bp5 | Best Buy Price |
bo1...b05 | Best Buy Orders |
sq1...sq5 | Best Sell Quantity |
sp1...sp5 | Best Sell Price |
so1...so5 | Best Sell Orders |
lc | Lower Circuit Limit |
uc | Upper Circuit Limit |
52h | 52 week high low in other exchanges, Life time high low in mcx |
52l | 52 week high low in other exchanges, Life time high low in mcx |
oi | Open interest |
poi | Previous day closing Open Interest |
toi | Total open interest for underlying |
ft | Feed time |
ue | Exchange high range |
le | Exchange 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.
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"}