Skip to main content
PaperDrill’s public WebSocket streams market updates without authentication. Signed-in users can also receive private portfolio snapshots over the same connection.

Choose channels

Use the exact symbol returned by GET /markets.

Private account updates

Portfolio snapshots are pushed on account:<userId>. The channel is private, so the connection must present a single-use ticket instead of your session cookie.
  1. Call POST /v1/auth/ws-ticket from your signed-in frontend session.
  2. Read ticket from the 201 response. It expires after 60 seconds and works once.
  3. Connect to wss://api.paperdrill.dev/?ticket=TICKET.
The server consumes the ticket, subscribes the socket to your account:<userId> channel, and sends an acknowledgement:
You do not need to send SUBSCRIBE for your own account channel. Asking for a different user’s private channel returns:
Tickets cannot be reused. Mint a new ticket for every connection attempt, including reconnects.

Snapshot shape

Snapshot numbers are raw integers scaled by precision, not decimal strings. Divide money fields by 10 ** quotePrecision and quantity fields by 10 ** qtyPrecision. at, lastBuyAt, and lastSellAt are Unix milliseconds. Snapshots are sent after fills and balance changes with a short debounce, then at most every five minutes while positions are open. Fetch GET /portfolio once for initial state, then apply snapshots as replacements.

Leaderboard updates

The public leaderboard channel announces that live standings changed. Subscribe without a ticket. Messages are lightweight invalidation signals, not full standings:
Refetch GET /leaderboard when a message arrives. The server debounces bursts, so clients should debounce refetches too. Rankings are computed from the same live account snapshots; there is no polling interval to mirror.

Subscribe

Send one SUBSCRIBE message after the connection opens. One message can contain multiple channels.
The server does not send a subscription acknowledgement. Messages begin when the selected market changes. To stop receiving a channel, send the same params with UNSUBSCRIBE.

Interpret messages

Trades

Tickers and candles

Ticker messages use the same shape as the REST ticker. Candle messages contain time, symbol, open, high, low, close, volume, and event: "candle".

Depth

Depth messages contain only changed levels. Follow the snapshot-and-buffer procedure in Maintain a local order book; do not treat one depth message as a complete book.

Reconnect safely

Connections can close during a deployment or network interruption. Reconnect with exponential backoff and jitter, then resubscribe to every desired channel.
Fetch a fresh REST snapshot after reconnecting before trusting a local order book. For the private account channel, mint a new ticket before each reconnect, then refetch GET /portfolio if the gap is long enough that the last snapshot may be stale.