Stream live market data
Use Data Socket when your application needs continuous market updates rather than repeated REST requests.
Plan check Data Socket symbol limits are per user, across all connections: Standard supports 100 symbols and Prime supports 5,000. See Plans & rate limits.
Before you begin
Step-by-step workflow
Authenticate the socket connection
Prepare the verified socket authentication value using the active FYERS API session. Do not place credentials directly in logs or client-visible output.
Open a connection
Create the Data Socket connection and register handlers for connection, message, error and close events.
Subscribe to symbols
Subscribe only to the symbols and data type required by the workflow. Keep the subscription count within the applicable Standard or Prime limit.
Process incoming updates
Validate each message type before reading its fields. Update the application state using the latest event rather than assuming every message has the same structure.
Change or remove subscriptions
Unsubscribe from symbols that are no longer required and update the local subscription list so the application and socket stay aligned.
Reconnect safely after interruption
Reconnect with controlled backoff, restore only the required subscriptions and avoid opening multiple active connections for the same workflow.
Verify the result
Check the relevant API response and account or market-data state to confirm that the workflow completed successfully. If the result is partial or unsuccessful, review the returned status and message before deciding whether to retry or take another action.
Common issues
Authentication or permission failure401 Unauthorized
The access token is missing, expired, or the app does not have the required permission. Generate a fresh token and retry the request.
HTTP/1.1 401 Unauthorized
{"s":"error","code":-8,"message":"Could not authenticate the user"}View Authentication →Incorrect request inputs400 Bad Request
A required field is missing or invalid (symbol, quantity, side, or product type). Read the response message, correct the payload, then retry.
HTTP/1.1 400 Bad Request
{"s":"error","code":-50,"message":"Please provide valid order parameters"}View Error Code Reference →Plan or rate-limit restriction429 Too Many Requests
The request exceeded the plan’s rate limit or an entitlement. Back off before retrying and confirm the Standard vs Prime limits for the API you are calling.
HTTP/1.1 429 Too Many Requests
Retry-After: 1
{"s":"error","message":"Rate limit exceeded"}Learn exponential backoff →Temporary network or socket interruptionTimeout
The connection dropped before a response arrived. Check the latest order, position, or socket state before sending the same request again.
Error: socket hang up
ECONNRESETView WebSocket Overview →Related API reference
WebSocket services overview
View API →Subscribe to live symbols
View API →Process symbol updates
View API →Process depth updates
View API →Manage subscriptions and connections
View API →Tune the queue processing interval
View API →