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.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/priceis derived from latest trades — cache for 1-2 seconds at most
Handle Reconnections
WebSocket connections will drop. Always implement:- Exponential backoff (1s → 2s → 4s → … → 60s max)
- Re-subscribe to all channels on reconnect
- Request a snapshot after reconnecting to fill any gaps
Pagination
All list endpoints supportlimit and offset:
Use Appropriate Candle Resolutions
Don’t fetch 1-minute candles for a weekly chart. Match resolution to your use case:| Resolution | Use case |
|---|---|
1m | Live trading UI |
5m / 15m | Intraday charts |
1h | Daily overview |
4h / 1d | Multi-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).