WebSocket API v2.0.0#
Real-time streams for orders, child orders, trades, positions, position risk, balances and market data. Read-only — orders are placed and cancelled through the REST API.
Download AsyncAPI spec · OpenAPI (REST) spec
Endpoints#
| Environment | URL |
|---|---|
| Production | wss://api.pro.anboto.xyz/api/v2/ws |
| Testnet | wss://api.testnet.anboto.xyz/api/v2/ws |
Authentication#
- Call
GET /api/v2/trading/listenKey(guide) — signed like any REST request. The response body is a listenKey (JWT, valid 1 hour). - Connect to
wss://<host>/api/v2/ws?listenKey=<listenKey>, or sendAuthorization: Bearer <listenKey>as a handshake header (keeps the token out of proxy logs).
Invalid or expired listenKey → handshake rejected with HTTP 401. Checked at handshake only; open connections are not dropped on expiry, but every reconnect needs a fresh key. A read-only API key is sufficient. Details: WebSocket guide.
Keep-alive#
Server sends {"topic":"ping"} every 60 s — reply {"topic":"pong"}. No client message for 5 min → close 1001. Subscriptions are per connection: re-subscribe after every reconnect. See Keep-alive.
Subscribing#
All messages are JSON text frames. One subscription per (topic, exchange) pair per connection.
{"topic": "order", "exchange": "binance", "method": "subscribe"}
| Field | Description | |
|---|---|---|
topic |
required | one of the topics below |
exchange |
required | any trading exchange, case-insensitive |
method |
required | subscribe / unsubscribe |
Every request gets {code, message} back — 0 = ack; non-zero codes in Errors.
Topics#
| Topic | Description | |
|---|---|---|
| WS | position | Channel for subscribing to account position updates for a specific exchange |
| WS | balance | Channel for subscribing to asset balance updates for a specific exchange |
| WS | order | Channel for subscribing to order updates for a specific exchange |
| WS | trade | Channel for subscribing to trade (fill) updates for a specific exchange |
| WS | child_order | Channel for subscribing to child-order (slice) updates; subscribe with |
| WS | position_risk | Channel for subscribing to position risk telemetry; subscribe with |
| WS | ticker | Best bid/offer stream per symbol; subscribe with {"topic":"ticker","exchange":...,"symbol":"BTC/USDT","method":"subscribe"}. Market data subscriptions are capped per connection and may be disabled per environment. |
| WS | ohlcv | Candlestick stream per symbol; subscribe with |
| WS | open_interest | Open interest stream per symbol; subscribe with {"topic":"open_interest","exchange":...,"symbol":"BTC/USDT","method":"subscribe"}. Market data subscriptions are capped per connection and may be disabled per environment. |
| WS | Keep-alive (ping/pong) | Keep-alive channel for maintaining WebSocket connection |
Limits: Rate limits.