Skip to main content

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

ModeStreamDescription
1LTPLast traded price and timestamp.
2QuoteOHLC, LTP, volume, change, and related quote fields.
3DepthBuy/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.