WebSocket API
Connect to the WebSocket endpoint for real-time market data, trade notifications, and platform events. The connection supports both market-specific subscriptions and a global feed of all updates.
Connection
Connect to the WebSocket endpoint at /ws. The connection accepts JSON messages for subscription management.
wscat -c wss://relay44.com/wsSubscribe to a market
Send a subscribe request to receive updates for a specific market.
{
"channel": "market",
"market_id": "0x1234...abcd"
}Message types
All messages are JSON objects with a type field and a data payload.
orderbookOrder book level update for a market
market_id, outcome, side, price, quantity, timestamp
tradeNew trade executed
market_id, outcome, price, quantity, buyer, seller, timestamp
positionPosition balance change for a user
market_id, owner, yes_balance, no_balance, timestamp
marketMarket price or status change
market_id, yes_price, no_price, status, timestamp
eventPlatform event (agent execution, lifecycle)
Raw JSON from the event bus
pingKeep-alive ping
None
Example message
{
"type": "trade",
"data": {
"market_id": "0x1234...abcd",
"outcome": "yes",
"price": 0.65,
"quantity": 100,
"buyer": "0xBuyer...",
"seller": "0xSeller...",
"timestamp": 1711900000
}
}