Skip to main content

Best Practices

Use WebSocket for Real-Time Data

Don’t poll REST endpoints every second. Subscribe via WebSocket and receive events as they happen — lower latency, less bandwidth, no wasted requests.
{"action": "subscribe", "channel": {"type": "trades"}}

Enable Compression

Add ?compress=zlib to your WebSocket URL. Saves ~60% bandwidth with zero latency impact.

Cache Intelligently

  • Market metadata changes rarely — cache for 5+ minutes
  • Orderbook snapshots are refreshed every 10 seconds in our cache
  • Price data from /v1/price is derived from latest trades — cache for 1-2 seconds at most

Handle Reconnections

WebSocket connections will drop. Always implement:
  1. Exponential backoff (1s → 2s → 4s → … → 60s max)
  2. Re-subscribe to all channels on reconnect
  3. Request a snapshot after reconnecting to fill any gaps

Pagination

All list endpoints support limit and offset:
# First page
GET /v1/trades?limit=100&offset=0

# Next page
GET /v1/trades?limit=100&offset=100

Use Appropriate Candle Resolutions

Don’t fetch 1-minute candles for a weekly chart. Match resolution to your use case:
ResolutionUse case
1mLive trading UI
5m / 15mIntraday charts
1hDaily overview
4h / 1dMulti-day analysis

Idempotency

Trades have unique (tx_hash, order_hash) pairs. Use these to deduplicate if you receive the same event twice (e.g., after a WebSocket reconnection).