WebSocket
Real-time market data. No authentication required.
Connection
wss://oracle-api.parti.com/v1/ws # production
wss://oracle-gateway.pbcapps.dev/v1/ws # staging
Subscribe
The message field is type (not action). Only book: and trades: are
served by the gateway relay today (user: is reserved for the per-market DO
feed and returns unknown_channel_kind):
{"type": "subscribe", "channel": "book:abc123def456..."}
{"type": "subscribe", "channel": "trades:abc123def456..."}
Heartbeat: {"type":"ping"} → {"type":"pong"}. Ack: {"type":"subscribed","channel":"..."}.
Events
BookUpdate
Sent on every order book change. Includes full snapshot + live prices.
{
"type": "book_update",
"market_id": "abc123...",
"snapshot": {
"yes_bids": [{"price": 6200, "size": 500, "order_count": 3}],
"yes_asks": [{"price": 6300, "size": 200, "order_count": 1}],
"yes_price": 6250,
"no_price": 3750,
"spread": 100,
"sequence": 42
}
}
Trade
Sent on every fill.
{
"type": "trade",
"market_id": "abc123...",
"trade": {
"price": 6200,
"quantity": 100,
"taker_side": "buy",
"outcome": "yes",
"taker_fee": 15,
"builder_fee": 62,
"timestamp": 1700000000
}
}
MarketUpdate
Sent when a market is resolved or status changes.
Channels
| Channel | Events |
|---|---|
book:{market_id} |
BookUpdate |
trades:{market_id} |
Trade |
markets |
MarketUpdate (all markets) |
user:{0x_address} |
Trades involving this user |
Example
const ws = new WebSocket('wss://oracle-api.parti.com/v1/ws');
ws.onopen = () => {
ws.send(JSON.stringify({ type: 'subscribe', channel: `book:${marketId}` }));
ws.send(JSON.stringify({ type: 'subscribe', channel: `trades:${marketId}` }));
};
ws.onmessage = (e) => {
const msg = JSON.parse(e.data);
if (msg.type === 'book_update') {
updatePrices(msg.snapshot.yes_price, msg.snapshot.no_price);
updateOrderBook(msg.snapshot);
}
if (msg.type === 'trade') {
addTrade(msg.trade);
}
};
Backpressure
If your client falls behind (4096 message buffer), you'll get:
{"type": "error", "code": "lagged", "message": "Dropped N messages"}
Re-fetch state via REST when this happens.