WebSocket APITopics
Wallet events
Subscribe with predictWalletEvents/{jwt}, where jwt is a wallet JWT from the REST API's
POST /auth. A revoked, invalid or expired JWT is refused with invalid_credentials.
Nothing 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": "predictWalletEvents/eyJhbGciOi...", "data": { "type": "orderAccepted", "orderId": "123456789", "orderHash": "0x3f1c...9a2b", "walletAddress": "0x8ba1f109551bD432803012645Ac136ddd64DBA72", "timestamp": 1736696400000, "details": { "marketId": 123, "outcomeIndex": 1, "marketQuestion": "Will X happen?", "outcome": "YES", "outcomeName": "Yes", "quoteType": "BID", "quantity": "100.000", "quantityFilled": "0.000", "price": "0.620", "value": "62.00", "valueFilled": "0.00", "strategyType": "LIMIT", "categorySlug": "politics" } }}Category changed
Subscribe with predictCategoryChanged/{categoryId}. Refetch the category, or apply patch when the message carries one. Nothing is sent on subscribe.
Heartbeat
Every 15 seconds the server sends a heartbeat carrying the current time. The first one arrives about 15 seconds after the connection opens. Echo its data back before the next one. A missing, late or different value closes the connection with code 1000 at the next heartbeat. The server does not respond to the echo.