测试网LiberX 目前运行在通往主网的深度公开测试网。交易限于白名单队列。
查看状态
WebSocket streams

Real-time feeds

One connection per bearer. MessagePack binary frames. The gateway coalesces book deltas into at most one frame per 8 ms so the client never drowns in renders.

Handshake

GET /ws/v1 HTTP/1.1
Host: api.liberx.xyz
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: ...
Sec-WebSocket-Version: 13
Authorization: Bearer eyJh...

Subscribe

ws.send(JSON.stringify({
  op: 'subscribe',
  streams: [
    'book.BTCUSD',
    'trades.BTCUSD',
    'candles.BTCUSD.1m',
    'preconfirms',
    'positions',
  ],
}));

Decoding frames

Use @msgpack/msgpack or any MessagePack decoder. Frames are small typed envelopes with a t kind tag.

import { decode } from '@msgpack/msgpack';

ws.binaryType = 'arraybuffer';
ws.onmessage = (ev) => {
  const frame = decode(new Uint8Array(ev.data)) as {
    t: 'book' | 'trades' | 'preconfirm' | 'ping';
    s?: string;            // symbol
    d: unknown;            // payload
  };
  if (frame.t === 'ping') return ws.send(new Uint8Array([0x2A])); // pong
  /* dispatch frame.d into your store */
};

Topics

TopicDescription
book.{symbol}Incremental book deltas and periodic snapshots.
trades.{symbol}Public trade tape for the symbol.
candles.{symbol}.{resolution}Live candle updates (1m..1d).
preconfirmsThe caller's preconfirm stream — fills, cancels, acks.
positionsPosition updates for the caller.
bridge.{chain}Attestation events per origin chain.