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:cnfor connection,subfor subscribe,sffor equity and option data,iffor index data anddpfor 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-EQfor a stock orNSE:NIFTY50-INDEXfor an index. In Python,data_typeisSymbolUpdatefor prices and indices, orDepthUpdatefor market depth. - Each message has a
type:cnconnection,subsubscribe,sfequity and option data,ifindex data,dpmarket depth. - To receive only the last traded price, set
litemode=Truewhen you create the socket in Python, or callmode(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
unsubscribewith the symbols and the samedata_typeyou used to subscribe, for exampleSymbolUpdate. - A successful unsubscribe returns
typeunsub,code200 andsok. Themessagetext 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=Trueso a dropped connection recovers on its own.reconnect_retrysets 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_errorandon_close. - Enable automatic reconnection with
reconnect=Truewhen you create the socket. Set the retry count withreconnect_retry(up to 50). In Node, usefyersdata.autoreconnect(trycount). - Set
write_to_file=Trueto 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
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.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)
- 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.
Use 1-10ms when you need rapid queue processing, and 100-500ms for general market data streaming.
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
| Endpoint | Method | Description |
|---|---|---|
| Connect and Subscribe | WSS | This WebSocket allows you to connect to the Data Socket and subscribe to live updates for your symbols. |
| Unsubscribe and Connection Management | WSS | This WebSocket allows you to unsubscribe from symbols and manage your Data Socket connection. |
| Advanced Configuration | WSS | This setting lets you control how often the Node SDK processes queued Data Socket messages. |
| Symbol Update | WSS | This WebSocket allows you to stream live price updates for equity and option symbols. |
| Indices Update | WSS | This WebSocket allows you to stream live index values such as NIFTY 50 and NIFTY Bank. |
| Market Depth Update | WSS | This WebSocket allows you to stream live five-level market depth for a symbol. |
| Lite Mode | WSS | This WebSocket allows you to receive only the last traded price of a symbol. |