WebSocket APITopics
Order book
Subscribe with predictOrderbook/{marketId}. Each message is the whole book. The latest
book is sent on subscribe.
x-api-key<api-key>The API key in the handshake's x-api-key header. Use this where you can.
const socket = new WebSocket("wss://ws.predict.fun/ws?apiKey=YOUR_API_KEY");socket.addEventListener("message", (event) => { console.log(event.data);});- payload
type*stringtopic*stringThe topic string the subscription was made with.
data*{ "type": "M", "topic": "predictOrderbook/123", "data": { "version": 1, "marketId": 123, "updateTimestampMs": 1736696400000, "orderCount": 42, "asks": [ [ 0.62, 1500 ], [ 0.63, 800 ] ], "bids": [ [ 0.61, 2000 ], [ 0.6, 1200 ] ], "lastOrderSettled": { "id": "987654321", "price": "0.62", "kind": "LIMIT", "marketId": 123, "side": "Ask", "outcome": "Yes" }, "settlementsPending": { "asks": [ [ 0.62, 310 ] ], "bids": [] } }}Set language
Sets the language of details.outcomeName in wallet events, from the next event on, including subscriptions that are already running. No other field or topic is translated. Supported codes: ar, de, es, fr, hi, id, it, ja, pl, pt (or pt-br), ru, th, tr, uk, vi, zh-CN (or zh, zh-hans) and zh-Hant (or zh-hk, zh-tw). English and any other code give the original text, and still succeed.
Top of book
Subscribe with predictTopOfBook/{marketId}. Each message holds the best bid, the best ask and the last settled order, taken from the market's order book. A message is sent only when one of them changes, including the quantity at the best price. The latest value is sent on subscribe.