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.

bash
wscat -c wss://relay44.com/ws

Subscribe to a market

Send a subscribe request to receive updates for a specific market.

json
{
  "channel": "market",
  "market_id": "0x1234...abcd"
}

Message types

All messages are JSON objects with a type field and a data payload.

orderbook

Order book level update for a market

market_id, outcome, side, price, quantity, timestamp

trade

New trade executed

market_id, outcome, price, quantity, buyer, seller, timestamp

position

Position balance change for a user

market_id, owner, yes_balance, no_balance, timestamp

market

Market price or status change

market_id, yes_price, no_price, status, timestamp

event

Platform event (agent execution, lifecycle)

Raw JSON from the event bus

ping

Keep-alive ping

None

Example message

json
{
  "type": "trade",
  "data": {
    "market_id": "0x1234...abcd",
    "outcome": "yes",
    "price": 0.65,
    "quantity": 100,
    "buyer": "0xBuyer...",
    "seller": "0xSeller...",
    "timestamp": 1711900000
  }
}