Skip to main content

General guide lines

The WebSocket API leverages the WebSocket protocol to establish a persistent, single TCP connection through an HTTP handshake, enabling the reception of real-time streaming quotes. This API offers the most efficient solution for retrieving instrument quotes from all exchanges during live market hours.

In addition to real-time market information, Firstock WebSocket API also provides live alerts and order updates. To access this seamless stream of data, a WebSocket client library compatible with your preferred programming language is required.

Connect to:

wss://norenapi.thefirstock.com/NorenWSTP/
Note
  • As soon as connection is done, a connection request should be sent with User id and login session id.
  • All input and output messages will be in json format.

Multi WebSocket:

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()