Skip to Content
Getting StartedAPI GuidesStream Live Market Data

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

  1. 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.

  2. Open a connection

    Create the Data Socket connection and register handlers for connection, message, error and close events.

  3. 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.

  4. 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.

  5. 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.

  6. Reconnect safely after interruption

    Reconnect with controlled backoff, restore only the required subscriptions and avoid opening multiple active connections for the same workflow.

  7. 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
ECONNRESET
View WebSocket Overview →

Continue with AI

Last updated on