Integrate with Coinbase Advanced Trade API to access granular L2 orderbook data, real-time market trades, and websocket feeds for cryptocurrency trading applications.
This skill enables integration with Coinbase's Advanced Trade API to access real-time cryptocurrency market data, including L2 orderbook snapshots and updates.
The Coinbase Advanced Trade API provides granular market data through REST endpoints and WebSocket feeds. This skill guides you through implementing orderbook tracking, real-time trade monitoring, and efficient data management for trading applications.
**Access Keys via Environment Variables:**
**Primary Endpoint:** `wss://advanced-trade-ws.coinbase.com`
1. **`level2` Channel**: Full orderbook updates
- Subscribe to receive initial snapshot and incremental updates
- Provides price levels and quantities for bids and asks
2. **`market_trades` Channel**: Real-time Time & Sales
- Live trade executions as they occur
- Includes price, size, side, and timestamp
Implement the following workflow to maintain an accurate orderbook:
1. **Connection Management**
- Implement reconnection logic with exponential backoff
- Handle WebSocket disconnect/error events gracefully
- Maintain subscription state across reconnections
2. **Data Integrity**
- Validate sequence numbers if provided
- Detect and recover from missed updates
- Request fresh snapshot if orderbook state becomes inconsistent
3. **Performance Optimization**
- Use efficient data structures (e.g., sorted maps) for orderbook storage
- Batch updates when possible to reduce processing overhead
- Implement throttling for frontend updates (e.g., 100ms intervals)
4. **Error Handling**
- Log authentication failures without exposing credentials
- Handle malformed messages without crashing
- Implement circuit breakers for repeated failures
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/coinbase-advanced-trade-api-y4ahm3/raw