How can developers incorporate real-time stock data into their applications?
Adding real-time stock data to your application can significantly enhance its value for users who need live market insights. FYERS provides a dedicated Market Data WebSocket API that allows developers to receive streaming updates for stock prices, trades, and market depth.
What is the Market Data WebSocket API?
The Market Data WebSocket API is a service by FYERS that streams live data such as last traded price (LTP), bid/ask quotes, and volume for subscribed instruments. This is especially useful for trading platforms, analytical tools, and automated systems that require low-latency data feeds.
How to integrate real-time data into your application
- Create an app on FYERS API Dashboard
Visit FYERS API Portal and register your application to generate an App ID and Secret. - Obtain access token
Complete the authentication flow to generate a valid access token. - Connect to the WebSocket endpoint
Use this endpoint:
wss://api.fyers.in/socket/v2/data/
- Send authentication message
Use your access token to authenticate the connection. - Subscribe to stock symbols
Use the subscription message format to specify instruments like NSE:INFY-EQ
or NSE:SBIN-EQ
. - Process incoming tick data
Handle incoming messages and integrate the data into your UI or analytics engine.
Set up reconnection logic and ping checks in your WebSocket client to maintain a stable stream, especially for long sessions.
What if...
Scenario | Outcome |
---|
You send an invalid symbol or format | The subscription may fail silently; verify symbol codes |
You need to switch instruments dynamically | Unsubscribe from old symbols before subscribing to new ones |
The WebSocket disconnects randomly | Check heartbeat/ping settings and implement retry logic |
This API is intended for informational and non-commercial use unless separately licensed. Ensure compliance with FYERS API policies to avoid access restrictions.
Last updated: 30 Jun 2025