Integrate Coinbase Advanced Trade API for real-time L2 orderbook data, market trades, and websocket feeds with secure credential management.
This skill enables integration with Coinbase's Advanced Trade API to access granular Level 2 (L2) orderbook data, real-time market trades, and websocket feeds for cryptocurrency trading applications.
Provides secure access to Coinbase Advanced Trade API with real-time orderbook construction, trade data streaming, and proper credential management. Ideal for building trading dashboards, market analysis tools, or automated trading systems.
**CRITICAL**: Never expose or log API credentials directly.
**Endpoint**: `wss://advanced-trade-ws.coinbase.com`
When establishing websocket connections:
1. Create secure websocket client with authentication headers using env credentials
2. Implement reconnection logic with exponential backoff for network resilience
3. Subscribe to relevant channels immediately after connection established
4. Handle connection errors gracefully without exposing credentials in error messages
**`level2` Channel** - Full Orderbook Updates:
**`market_trades` Channel** - Real-time Time & Sales:
Implement orderbook maintenance following these steps:
**Step 1: Initialize with Snapshot**
**Step 2: Apply Incremental Updates**
**Step 3: Implement Pruning Strategy**
```
1. Load credentials from environment (never hardcode)
2. Establish authenticated websocket connection
3. Subscribe to level2 and/or market_trades channels
4. Receive snapshot and initialize orderbook state
5. Process updates in real-time, maintaining full book backend
6. Transmit pruned top_20 data to frontend via optimized transport
7. Implement error handling and reconnection logic
```
**Scenario**: Build a real-time orderbook visualization dashboard
1. Backend establishes websocket connection using env credentials
2. Subscribes to `level2` channel for BTC-USD product
3. Receives snapshot and constructs initial orderbook
4. Processes continuous `l2update` messages
5. Maintains full orderbook internally for analysis
6. Sends top 20 bid/ask levels to frontend every 100ms
7. Frontend renders dynamic orderbook ladder with price levels
**Scenario**: Market trade flow analyzer
1. Connect to `market_trades` channel for multiple products
2. Stream trade data into time-series database
3. Calculate rolling metrics (volume, VWAP, trade size distribution)
4. Trigger alerts on unusual trade patterns
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-04hfw4/raw