Skip to main content
Every REST read that changes over time has a stream that pushes the same objects. A streamed candle or token has exactly the shape the REST endpoint returns. A streamed trade has the REST trade shape, minus some fields per subscription mode: see spot.trades. A stream costs no request budget after its handshake, so it is the cheaper way to follow anything that changes more than once a minute.

Snapshot, then stream

A stream sends only what happens after you subscribe. To show a complete view, combine the two:
  1. Subscribe first, and buffer the updates that arrive.
  2. Read the snapshot from the REST endpoint.
  3. Apply the buffered updates on top of the snapshot, then apply new updates as they arrive.
Subscribing before you read means nothing that happens between the two calls is lost.

Merging without duplicates

After a reconnect

Subscriptions end when a connection closes. When you reconnect:
  1. Resubscribe, and buffer updates again.
  2. Re-read the REST endpoint to cover the gap: the latest trades, or candles with to left out.
  3. Merge with the rules above.
See Connecting to streams for close codes and a reconnect loop.