Connection
Connect to the PredictIt WebSocket endpoint:| Property | Value |
|---|---|
| Protocol | WebSocket (wss://) |
| Authentication | api_key query parameter |
| Keepalive | Ping every 54 seconds |
| Timeout | 60 seconds without pong |
| Max Message Size | 16 KB |
Subscribing to markets
Once connected, send a JSON message to subscribe usingmarket_id:
| Field | Type | Required | Description |
|---|---|---|---|
action | string | Yes | subscribe or unsubscribe |
market_ids | array | Yes | Array of PredictIt market identifiers (numeric strings) |
message_types | array | No | ["prices"] only. Defaults to prices if omitted. No orderbook or trades available. |
Unsubscribing
Message types
Price messages
Full example
Important notes
- Authentication required via
api_keyquery parameter - Prices only — PredictIt does not provide orderbook depth or individual trade history
- PredictIt data is sourced via REST polling (60-second intervals)
- Only emits updates when market state changes (last trade price, best bid/ask)
- Use
market_id(PredictIt market identifier) to subscribe

