Connection
Connect to the Kalshi WebSocket endpoint:| Property | Value |
|---|---|
| Protocol | WebSocket (wss://) |
| Keepalive | Ping every 54 seconds |
| Timeout | 60 seconds without pong |
| Max Message Size | 512 KB |
Subscribing to markets
Once connected, send a JSON message to subscribe usingklsi_id:
| Field | Type | Required | Description |
|---|---|---|---|
action | string | Yes | subscribe or unsubscribe |
klsi_ids | array | Yes | Array of Kalshi market identifiers |
message_types | array | No | ["prices"], ["orderbook"], ["trades"], or any combination. Defaults to prices and orderbook if omitted |
Unsubscribing
Message types
Price messages
Real-time price updates for subscribed markets:Orderbook messages
Real-time orderbook snapshots for subscribed markets:Trade messages
Real-time trade executions for subscribed markets:Full example
Important notes
- No authentication required for WebSocket connections
- Use
klsi_id(Kalshi market identifier) to subscribe - Messages are only sent for markets you have explicitly subscribed to
- Multiple markets can be subscribed in a single message
- Trades must be explicitly requested (not included in the default subscription)

