WebSocket

WebSocket

Live streams for prices, trades, order books, accounts and more.

Connect

Base URLwss://api.xrpl.to/ws/
API keyOptional. Add ?apiKey=xrpl_… to the URL, or send an auth message where a stream lists one.
HeartbeatSend { type: "ping" } to receive { type: "pong", time }
CompressionAll endpoints support permessage-deflate
ReconnectingImplement exponential backoff
Close codes4010 rate limit, 4011 max connections/subscriptions, 4012 message size, 4020-4025 invalid params, 4029 connection limit reached ({ error } sent before close)

A session

YouServer
  1. Connectyou sendwss://api.xrpl.to/ws/sync?apiKey=xrpl_…
  2. Subscribeyou send{ "type": "subscribe", "tokens": ["<md5>", …] }
  3. Confirm and snapshotthe server sends{ "type": "subscribed" }, then the current state of those tokens
  4. Updatesthe server sendsa message each time one of them changes
  5. Ping (optional)you send{ "type": "ping" } → { "type": "pong", "time" }
The server checks every connection every 30 seconds; your WebSocket library answers that on its own. If the connection drops, reconnect with backoff and subscribe again.

Streams

Example

JavaScript
// One token
const ws = new WebSocket('wss://api.xrpl.to/ws/token/0413ca7cfc258dfaf698c02fe304e607');
ws.onmessage = (e) => console.log(JSON.parse(e.data));

// Many tokens over one socket
const sync = new WebSocket('wss://api.xrpl.to/ws/sync');
sync.onopen = () => sync.send(JSON.stringify({ type: 'subscribe', tokens: ['<md5>', '<md5>'] }));
setInterval(() => sync.send(JSON.stringify({ type: 'ping' })), 30000);