Step-by-Step Guide to Subscribing to FYERS Data WebSocket

How can I subscribe to the Data Websocket provided by FYERS?

Subscribing to FYERS' Data WebSocket allows you to receive live stock market updates directly in your application. With a few simple steps, you can establish a connection, authenticate, and begin streaming live tick data for selected symbols.

Steps to subscribe to the Data WebSocket

  • Create an instance of the WebSocket class
    Use the WebSocket utility provided in FYERS' SDK or your own implementation.
  • Connect to the WebSocket server
    Use the FYERS WebSocket endpoint:
    wss://api.fyers.in/socket/v2/data/
  • Authenticate your session
    Pass your valid access token in the required format to authorize the connection.
  • Subscribe to symbols
    Send a JSON message specifying the symbols and update type (e.g., lite or symbolUpdate). Example:
    {
      "symbol": ["NSE:TCS-EQ", "NSE:INFY-EQ"],
      "type": "symbolUpdate"
    }
  • Listen for incoming data
    Handle incoming WebSocket messages to process price ticks, volume, or OHLCV updates.
Use heartbeat or ping checks to monitor connection health, and set up auto-reconnect logic for better reliability.

What if...

ScenarioOutcome
Your access token is invalidThe server will reject the authentication request
You subscribe before authenticationThe request will fail—authenticate first
You want to change symbols mid-sessionUnsubscribe and then subscribe to the new ones without reconnecting

Last updated: 30 Jun 2025