For the complete documentation index, see llms.txt. This page is also available as Markdown.

Connection

Ping / Pong

post
/ws/ping

Send a heartbeat to keep the connection alive.

{ "method": "ping" }
Responses
200

Pong

application/json
post/ws/ping
const ws = new WebSocket("wss://ws.afx.xyz/ws/dex");

ws.onopen = () => {
  // Heartbeat every 30s
  setInterval(() => ws.send(JSON.stringify({ method: "ping" })), 30000);
};

ws.onmessage = (event) => {
  const msg = JSON.parse(event.data);
  if (msg.channel === "pong") return;
  console.log("data:", msg);
};
200

Pong

{
  "channel": "pong"
}

Unsubscribe

post
/ws/unsubscribe

Unsubscribe from a channel. Send the same subscription object used to subscribe.

{ "method": "unsubscribe", "subscription": { "type": "orderBook", "symbol": "BTCUSDC", "depth": 50 } }
Responses
200

Ack

application/json
post/ws/unsubscribe
ws.send(JSON.stringify({
  method: "unsubscribe",
  subscription: { type: "orderBook", symbol: "BTCUSDC", depth: 50 },
}));
200

Ack

{
  "method": "unsubscribe",
  "success": true,
  "subject": "orderBook.BTCUSDC.50"
}

Last updated