WebSocket Streaming¶
Our WebSocket API provides a fast, efficient, and low-latency way to receive real-time data, including market quotes and order status updates. This is the preferred method for streaming high-frequency data.
We offer two distinct WebSocket endpoints for different types of real-time data:
- Price Feed WebSocket - For live market data including LTP (Last Traded Price) and real-time quotes
- Order Updates WebSocket - For real-time updates on your order statuses and trade confirmations
Authentication for both endpoints is handled via an Authorization header passed during the initial connection handshake.
Price Feed¶
Use this endpoint to stream live market data for instruments.
Endpoint: wss://ws-prices.indstocks.com/api/v1/ws/prices
Subscription
Once connected, you send JSON messages to subscribe to or unsubscribe from instrument feeds.
Request Structure A subscription message consists of an action, a mode, and an array of instruments.
| Parameter | Type | Description |
|---|---|---|
action | string | The action to perform. Enum: "subscribe", "unsubscribe" |
mode | string | The data mode. Enum: "ltp", "quote" |
instruments | array | An array of instrument tokens to subscribe to. |
Instrument Format Instrument tokens are strings that identify a specific security or index, formatted as SEGMENT:TOKEN.
| Type | Prefix | Example |
|---|---|---|
| NSE Equity | NSE: | "NSE:2885" |
| BSE Equity | BSE: | "BSE:500325" |
| NSE Derivatives (F&O) | NFO: | "NFO:51011" |
| BSE Derivatives (F&O) | BFO: | "BFO:12345" |
| NSE Index | NIDX: | "NIDX:26000" |
| BSE Index | BIDX: | "BIDX:1" |
Subscription Examples
-
To subscribe to LTP mode for an instrument:
-
To subscribe to Quote mode:
Data Response
The data from the server will be a JSON string. You will need to parse this string to get the JSON object.
- LTP Response Format:
Order Updates Feed¶
This endpoint streams all real-time updates for your orders.
Endpoint: wss://ws-order-updates.indstocks.com
Subscription
To start receiving order updates, send a single subscription message after connecting.
- Subscription Message: Once subscribed, all updates for your orders (e.g., placement, execution, cancellation) will be pushed to you automatically.
Order Update Response
The server will push a JSON message for any change in an order's state.
- Example Order Update:
Heartbeats
The server may send periodic heartbeat messages to keep the connection alive. Your client should be configured to handle these, typically by ignoring them.