WebSocket APIRequests

Unsubscribe

Send
/ws
Server

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.

Authorization

headerx-api-key<api-key>

The API key in the handshake's x-api-key header. Use this where you can.

Code Sample
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));});

Messages

application/json
  1. payload
method*string
requestId*RequestId

A 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.

Formatint64
params*array<>

The topic to unsubscribe from. Only the first entry is read.

orderbook
{  "method": "unsubscribe",  "requestId": 2,  "params": [    "predictOrderbook/123"  ]}

Reply

Receive

Sent back on the same channel.

application/json
  1. 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*string
requestId*RequestId

A 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.

Formatint64
success*boolean
error?

Present only when success is false.

{  "type": "R",  "requestId": 1,  "success": true}