WebSockets
IMC exposes a WebSocket proxy for real-time market data.
ws://127.0.0.1:8765
For public deployments, place the proxy behind TLS and use wss://.
Authentication
Every WebSocket session must authenticate first:
{
"action": "authenticate",
"api_key": "YOUR_IMC_API_KEY"
}
Modes
| Mode | Stream | Description |
|---|---|---|
1 | LTP | Last traded price and timestamp. |
2 | Quote | OHLC, LTP, volume, change, and related quote fields. |
3 | Depth | Buy/sell depth, subject to broker support. |
Subscribe
Single-symbol form:
{
"action": "subscribe",
"symbol": "RELIANCE",
"exchange": "NSE",
"mode": 1
}
Bulk form:
{
"action": "subscribe",
"symbols": [
{"symbol": "RELIANCE", "exchange": "NSE"},
{"symbol": "SBIN", "exchange": "NSE"}
],
"mode": 1,
"depth": 5
}
Unsubscribe
{
"action": "unsubscribe",
"symbols": [
{"symbol": "RELIANCE", "exchange": "NSE", "mode": 1}
]
}
SDK Reconnect Behavior
The Python SDK stores active subscriptions by mode. If the WebSocket disconnects unexpectedly and auto_reconnect=True, the SDK reconnects, re-authenticates, and replays the active subscriptions.
Calling disconnect() is treated as intentional shutdown and does not trigger reconnect.