Subscribe feed
Websocket Subscribe Feed API will provide multiple instruments available actions and possible values at once.
Request details
| Parameter | Description |
|---|---|
| t | 't' represents touchline task |
| k | One or more scriplist for subscription. Example NSE 22#BSE |
from typing import Any
from thefirstock.firstockModules import firstockWebSockets
from thefirstock.pyClient.websocket import WsClient
from thefirstock.pyClient.websocket.enums import MessageTopic
client = firstockWebSockets.webSocketLogin()
ws = client.ws
@ws.on_connect
def connected(client, message):
if message.get('s') == 'OK':
client.subscribe_feed('NSE|26000#NSE|26009#NSE|22')
@ws.on_message(MessageTopic.SUBSCRIBE_FEED)
def msg_handler(client: WsClient, message: Any):
print(message)
ws.connect(uid="<userId>", actid="<userId>")
ws.run_forever()
const Firstock = require("thefirstock");
const firstock = new Firstock();
const ws = firstock.initializeWebSocket();
ws.on("open", function open() {
firstock.getWebSocketDetails((err, result) => {
if (!err) {
firstock.initialSendWebSocketDetails(ws, result, () => {
ws.send(firstock.subscribeFeed("NSE|26000#NSE|26009"));
});
}
});
});
ws.on("error", function error(error) {
console.log(`WebSocket error: ${error}`);
});
ws.on("message", function message(data) {
const result = firstock.receiveWebSocketDetails(data);
console.log("message: ", result);
});
using thefirstock;
var exitEvent = new ManualResetEvent(false);
using (var client = firstock.initializeWebSocket())
{
client.MessageReceived.Subscribe(msg =>
{
Console.WriteLine("Message received: " + msg);
client.Send(firstock.subscribeTouchline("NSE|26000"));
});
client.Start();
client.Send(firstock.startWebsockets());
exitEvent.WaitOne();
}
TouchLine subscription Updates
| Parameter | Description |
|---|---|
| t | represents feed acknowledgement |
| e | NSE, BSE, NFO ..Exchane name |
| lp | LTP |
| tk | 22 Script token |
| pp | Price precision |
| ts | Trading Symbol |
| ti | Tick size |
| ls | Lot size |
| lp | LTP |
| pc | Percentage change |
| v | volume |
| o | Open price |
| h | High price |
| l | Low price |
| c | Close price |
| ap | Average trade Price |
| oi | Open interest |
| poi | Previous day closing Open Interest |
| toi | Total open interest for underlying |
| bq1 | Best Buy Quantity 1 |
| bp1 | Best Buy Price 1 |
| sq1 | Best Sell Quantity 1 |
| sp1 | Best Sell Price 1 |
| ft | Feed time |
Sample response
- Success response
{
't': 'tf',
'e': 'NSE',
'tk': '22',
'ft': '1664340733',
'v': '2371.20',
'bp1': '2371.20',
'sp1': '2371',
'bq1': '49',
'sq1': '10'
}


