Subscribe Feed
This document details how to subscribe to the market feed on the Firstock Websockets.
Overview
The Subscribe Feed API enables you to initiate a persistent WebSocket connection to Firstock’s real-time market data stream. Through this connection, you can subscribe to price feeds (LTP, and more) for multiple instruments simultaneously, receiving bundled updates in a single message
Body
Field | Type | Mandatory | Description | Example |
---|---|---|---|---|
action | string |
Yes |
Type of request; |
"t" |
tokens | string |
Yes |
Subscription parameter |
"BSE:500470|NSE:26000|NSE:2885" |
Request
Multiple Token
{"action":"subscribe","tokens":"BSE:500470|NSE:26000"}
action
= Type of request; subscribe
indicates a live subscription to market data
tokens
= Parameters for subscription. In Multiple Token, we can send multiple tokens in single request.
Single Token
{"action":"subscribe","tokens":"NSE:2885"}
action
= Type of request; subscribe
indicates a live subscription to market data
tokens
= Parameters for subscription. In Single Token, we can send only one tokens in single request.
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 |
---|---|
best_buy |
Array of top 5 buy orders with price, quantity, and number of orders. |
best_sell |
Array of top 5 sell orders with price, quantity, and number of orders. |
c_exch_feed_time |
Exchange feed time in human-readable format (e.g., 24-Apr-2025 13:45:24). |
c_exch_seg |
Exchange segment, such as NSE or BSE. |
c_net_change_indicator |
Indicator showing the direction or amount of net price change. |
c_symbol |
Scrip token symbol representing the instrument. |
i_buy_depth_size |
Depth size of buy orders (number of levels). |
i_sell_depth_size |
Depth size of sell orders (number of levels). |
i_feed_time |
Feed timestamp in milliseconds since Unix epoch. |
i_last_trade_time |
Time of the last trade in system timestamp format. |
i_last_traded_price |
Last traded price (usually in paise). |
i_open_interest |
Current open interest value for the contract. |
i_total_open_interest |
Total open interest for the underlying instrument. |
i_total_buy_quantity |
Sum of all buy quantities across order book. |
i_total_sell_quantity |
Sum of all sell quantities across order book. |
i_total_tradevalue |
Total traded value of the instrument today (in paise). |
i_volume_traded_today |
Total number of units traded today. |
i_seconds_since_boe |
Microsecond-precision time since beginning of exchange day. |
i_usecs |
Microseconds part of the timestamp for precise timing. |
Response:
{
"best_buy": [
{
"price": 9223372036854775808,
"quantity": 9223372036854775808,
"orders": 9223372036854775808
},
{
"price": 9223372036854775808,
"quantity": 9223372036854775808,
"orders": 9223372036854775808
},
{
"price": 9223372036854775808,
"quantity": 9223372036854775808,
"orders": 9223372036854775808
},
{
"price": 9223372036854775808,
"quantity": 9223372036854775808,
"orders": 9223372036854775808
},
{
"price": 9223372036854775808,
"quantity": 9223372036854775808,
"orders": 9223372036854775808
}
],
"best_sell": [
{
"price": 9223372036854775808,
"quantity": 9223372036854775808,
"orders": 9223372036854775808
},
{
"price": 9223372036854775808,
"quantity": 9223372036854775808,
"orders": 9223372036854775808
},
{
"price": 9223372036854775808,
"quantity": 9223372036854775808,
"orders": 9223372036854775808
},
{
"price": 9223372036854775808,
"quantity": 9223372036854775808,
"orders": 9223372036854775808
},
{
"price": 9223372036854775808,
"quantity": 9223372036854775808,
"orders": 9223372036854775808
}
],
"c_exch_feed_time": "24-Apr-2025 13:45:24",
"c_exch_seg": "NSE",
"c_net_change_indicator": 43,
"c_symbol": "26074",
"i_buy_depth_size": 5,
"i_feed_time": 1745482524000,
"i_last_trade_time": 9223372036854775808,
"i_last_traded_price": 1228855,
"i_open_interest": 9223372036854775808,
"i_seconds_since_boe": 1745482524462990160,
"i_sell_depth_size": 5,
"i_total_buy_quantity": 9223372036854775808,
"i_total_open_interest": 9223372036854775808,
"i_total_sell_quantity": 9223372036854775808,
"i_total_tradevalue": 9223372036854775808,
"i_usecs": 462990160,
"i_volume_traded_today": 9223372036854775808
}
- Updates Response
Body
Parameter | Description |
---|---|
best_buy |
Array of top 5 buy orders containing price, quantity, and number of orders at each level. |
best_sell |
Array of top 5 sell orders containing price, quantity, and number of orders at each level. |
c_exch_feed_time |
Exchange feed time in readable format (e.g., 24-Apr-2025 13:45:24). |
c_exch_seg |
Exchange segment identifier (e.g., NSE). |
c_net_change_indicator |
Indicates net price change direction. |
c_symbol |
Internal symbol code used for identifying the security. |
i_buy_depth_size |
Number of levels in the buy order book. |
i_sell_depth_size |
Number of levels in the sell order book. |
i_feed_time |
Feed time in milliseconds since epoch. |
i_last_trade_time |
Timestamp of the last trade (if available). |
i_last_traded_price |
Last traded price (multiplied by 100). |
i_open_interest |
Current open interest on the contract. |
i_total_open_interest |
Total open interest across all contracts for the underlying. |
i_total_buy_quantity |
Sum of all buy quantities across order book levels. |
i_total_sell_quantity |
Sum of all sell quantities across order book levels. |
i_total_tradevalue |
Total value of trades executed today (in paise). |
i_volume_traded_today |
Total number of contracts traded today. |
i_seconds_since_boe |
Nanoseconds since beginning of exchange (BOE) day. |
i_usecs |
Microsecond part of the feed timestamp. |
Response:
{
"best_buy": [
{
"price": 9223372036854775808,
"quantity": 9223372036854775808,
"orders": 9223372036854775808
},
{
"price": 9223372036854775808,
"quantity": 9223372036854775808,
"orders": 9223372036854775808
},
{
"price": 9223372036854775808,
"quantity": 9223372036854775808,
"orders": 9223372036854775808
},
{
"price": 9223372036854775808,
"quantity": 9223372036854775808,
"orders": 9223372036854775808
},
{
"price": 9223372036854775808,
"quantity": 9223372036854775808,
"orders": 9223372036854775808
}
],
"best_sell": [
{
"price": 9223372036854775808,
"quantity": 9223372036854775808,
"orders": 9223372036854775808
},
{
"price": 9223372036854775808,
"quantity": 9223372036854775808,
"orders": 9223372036854775808
},
{
"price": 9223372036854775808,
"quantity": 9223372036854775808,
"orders": 9223372036854775808
},
{
"price": 9223372036854775808,
"quantity": 9223372036854775808,
"orders": 9223372036854775808
},
{
"price": 9223372036854775808,
"quantity": 9223372036854775808,
"orders": 9223372036854775808
}
],
"c_exch_feed_time": "24-Apr-2025 13:45:24",
"c_exch_seg": "NSE",
"c_net_change_indicator": 43,
"c_symbol": "26074",
"i_buy_depth_size": 5,
"i_feed_time": 1745482524000,
"i_last_trade_time": 9223372036854775808,
"i_last_traded_price": 1228855,
"i_open_interest": 9223372036854775808,
"i_seconds_since_boe": 1745482524462990160,
"i_sell_depth_size": 5,
"i_total_buy_quantity": 9223372036854775808,
"i_total_open_interest": 9223372036854775808,
"i_total_sell_quantity": 9223372036854775808,
"i_total_tradevalue": 9223372036854775808,
"i_usecs": 462990160,
"i_volume_traded_today": 9223372036854775808
}
Unsubscribe Feed
Body
Below is the general JSON body for the Unsubscribe Feed API request. All fields marked as Mandatory must be included.
Field | Type | Mandatory | Description | Example |
---|---|---|---|---|
action | string |
Yes |
Type of request; |
"t" |
tokens | string |
Yes |
UnSubscription parameter |
"BSE:500470|NSE:26000|NSE:2885" |
Request
Multiple Token
{"action":"unsubscribe","tokens":"BSE:500470|NSE:26000"}
action
= Type of request; unsubscribe
indicates you want to stop receiving live market data for the specified tokens.
tokens
= Parameters for unsubscription. In Multi Token, we can multiple tokens in single request.
Single Token
{"action":"unsubscribe","tokens":"NSE:2885"}
action
= Type of request; unsubscribe
indicates you want to stop receiving live market data for the specified tokens.
tokens
= Parameters for unsubscription. In Single Token, we can send only one tokens in single request.