WebSocket APIRequests
Unsubscribe
Unsubscribes from the topic in params[0]. It succeeds whether or not the connection was
subscribed, and fails with invalid_topic only when the topic is malformed.
x-api-key<api-key>The API key in the handshake's x-api-key header. Use this where you can.
const payload = { "method": "unsubscribe", "requestId": 2, "params": [ "predictOrderbook/123" ]};const socket = new WebSocket("wss://ws.predict.fun/ws?apiKey=YOUR_API_KEY");socket.addEventListener("open", () => { socket.send(JSON.stringify(payload));});- payload
method*stringrequestId*RequestIdA number you choose, echoed on the response so you can match the two. Use a
non-negative one: the server answers a frame it cannot read with -1.
int64params*array<>The topic to unsubscribe from. Only the first entry is read.
{ "method": "unsubscribe", "requestId": 2, "params": [ "predictOrderbook/123" ]}Reply
Sent back on the same channel.
- payload
The answer to a subscribe, unsubscribe or setLanguage request. A frame the server cannot
read (invalid JSON, an unknown method, or a missing requestId or params) is
answered with requestId -1 and the error invalid_json. A frame over 8 KiB closes
the connection.
type*stringrequestId*RequestIdA number you choose, echoed on the response so you can match the two. Use a
non-negative one: the server answers a frame it cannot read with -1.
int64success*booleanerror?Present only when success is false.
{ "type": "R", "requestId": 1, "success": true}Subscribe
Subscribes to the topic in params[0]. The server answers with a response carrying the same requestId. For topics that keep a latest value, that value follows right after the response as a normal message, then live updates. Treat it as best effort: it is absent when nothing has been cached yet. Subscribing again to a topic the connection already holds re-acknowledges it. Subscriptions do not carry over to a new connection, so subscribe again after reconnecting.
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.