Skip to Content

Data Socket Overview

This WebSocket allows you to stream live symbol, index and market-depth updates over a single connection.

USE CASE

Stream live prices for a watchlist, chart or strategy without polling the Quotes API.

Data streams

Key points

  • You can create only one Data Socket connection instance at a time.
  • Every message has a type: cn for connection, sub for subscribe, sf for equity and option data, if for index data and dp for market depth.
  • Need 50 levels of depth? Use the Tick-by-Tick (TBT) Socket.

Connect and subscribe

  • The higher symbol limit applies from Python v3.1.0, Node v1.1.1 and Web JS v1.1.0, so use these versions or later. See the Change Log.
  • Pass the access token in the format appid:accesstoken.
  • Subscribe from the on-connect callback so symbols are requested as soon as the connection opens. In Python, call keep_running() afterwards to keep receiving data.
  • Use FYERS symbology, for example NSE:SBIN-EQ for a stock or NSE:NIFTY50-INDEX for an index. In Python, data_type is SymbolUpdate for prices and indices, or DepthUpdate for market depth.
  • Each message has a type: cn connection, sub subscribe, sf equity and option data, if index data, dp market depth.
  • To receive only the last traded price, set litemode=True when you create the socket in Python, or call mode(LiteMode) in Node and Web JS. See Lite Mode.
  • With auto-reconnect on, previous symbols are resubscribed automatically after a reconnect.

Full reference and samples: Data Socket - Connect and Subscribe.

Unsubscribe and connection management

  • In Python, call unsubscribe with the symbols and the same data_type you used to subscribe, for example SymbolUpdate.
  • A successful unsubscribe returns type unsub, code 200 and s ok. The message text differs by SDK (Python: Unsubscribed; Node: successful).
  • You can run the call from the message callback, for example to drop a symbol once your condition is met.
  • For a changed symbol list, unsubscribe from the current list and subscribe again. Do not open a second connection, because only one connection instance is allowed.
  • Set reconnect=True so a dropped connection recovers on its own. reconnect_retry sets the retry count, up to 50.
  • Handle disconnects and errors in the on-close and on-error callbacks.

Full reference and samples: Data Socket - Unsubscribe and Connection Management.

Subscription limits

Symbol limits are counted per user, across all your connections to the Data Socket.

Plan limits

Standard plan

  • Up to 100 symbols, counted per user across all connections

Prime plan

  • Up to 5,000 symbols, counted per user across all connections

For rate limits and all other plan details, see Plans & rate limits.

Best practices

  • The WebSocket runs on a dedicated thread, independent of your main application thread, so primary work is not blocked by socket I/O.
  • To update symbols in an already subscribed socket, unsubscribe from the existing list of symbols and then subscribe again with the updated list.
  • Use the callbacks to define what happens on data updates and errors: on_connect, on_message, on_error and on_close.
  • Enable automatic reconnection with reconnect=True when you create the socket. Set the retry count with reconnect_retry (up to 50). In Node, use fyersdata.autoreconnect(trycount).
  • Set write_to_file=True to save received data to a log file. It works only when callback functions are not used.
  • In Node, pass a logging flag in the constructor to disable logs: new FyersSocket("token", "logpath", true).

Advanced configuration

Details

The WebSocket queue processing interval is an Optional setting that allows you to customize how frequently data in the subscription queue is handled. By default, this interval is set to 1 millisecond, but it can be adjusted to better suit your application's specific needs and performance preferences.
Queue processing interval

You can set the processing interval anywhere between 1ms and 2000ms (2 seconds). Call setQueueProcessInterval before or during an active WebSocket session.

setQueueProcessInterval

Range: 1ms to 2000ms
Default: 1ms
Example: setQueueProcessInterval(200)

Configuration options
  • Customizable Interval: You can set the processing interval anywhere between 1ms to 2000ms (2 seconds), giving you flexibility to optimize performance and responsiveness.
  • Dynamic Adjustment: The interval setting can be changed at any time during an active WebSocket session.
  • Performance Optimization: Shorter intervals (1-10ms) are ideal for high-frequency trading scenarios that benefit from rapid data processing, while slightly longer intervals (100-500ms) work well for general market data streaming.
  • Resource Management: You can tune the interval based on how your application handles incoming data, helping to maintain smooth operation across different environments.
Recommended ranges

Use 1-10ms when you need rapid queue processing, and 100-500ms for general market data streaming.

Availability

Customizing the queue processing interval was added on 09 Jun 2025 (the Change Log lists Node Js fyers-web-sdk-v3 v1.4.2). The sample on this page uses the Node SDK. Check the Change Log for other SDKs.

Full reference and samples: Data Socket - Advanced Configuration.

In this section

EndpointMethodDescription
Connect and SubscribeWSSThis WebSocket allows you to connect to the Data Socket and subscribe to live updates for your symbols.
Unsubscribe and Connection ManagementWSSThis WebSocket allows you to unsubscribe from symbols and manage your Data Socket connection.
Advanced ConfigurationWSSThis setting lets you control how often the Node SDK processes queued Data Socket messages.
Symbol UpdateWSSThis WebSocket allows you to stream live price updates for equity and option symbols.
Indices UpdateWSSThis WebSocket allows you to stream live index values such as NIFTY 50 and NIFTY Bank.
Market Depth UpdateWSSThis WebSocket allows you to stream live five-level market depth for a symbol.
Lite ModeWSSThis WebSocket allows you to receive only the last traded price of a symbol.
Last updated on