CBAdvancedTradeClient provides full access to Coinbase’s Advanced Trade API — retail and institutional trading, futures, perpetuals, and payment methods.
Use this file to discover all available pages before exploring further.
CBAdvancedTradeClient is the primary REST client for Coinbase’s Advanced Trade API. It covers everything from live order management and portfolio tracking to futures, perpetual swaps, asset conversions, and payment methods — all authenticated with JWT-based CDP API keys.
Advanced Trade uses JWT authentication (ECDSA or ED25519 keys). You do not need an apiPassphrase — only the key name and private key are required.
import { CBAdvancedTradeClient } from 'coinbase-api';// Option 1: pass key name + private key directlyconst client = new CBAdvancedTradeClient({ apiKey: 'organizations/YOUR_ORG_ID/apiKeys/YOUR_KEY_ID', apiSecret: '-----BEGIN EC PRIVATE KEY-----\nYOUR_PRIVATE_KEY\n-----END EC PRIVATE KEY-----\n',});// Option 2: pass the full CDP JSON object (downloaded from Coinbase)const client2 = new CBAdvancedTradeClient({ cdpApiKey: { name: 'organizations/YOUR_ORG_ID/apiKeys/YOUR_KEY_ID', privateKey: '-----BEGIN EC PRIVATE KEY-----\nYOUR_PRIVATE_KEY\n-----END EC PRIVATE KEY-----\n', },});
const { CBAdvancedTradeClient } = require('coinbase-api');// Option 1: pass key name + private key directlyconst client = new CBAdvancedTradeClient({ apiKey: 'organizations/YOUR_ORG_ID/apiKeys/YOUR_KEY_ID', apiSecret: '-----BEGIN EC PRIVATE KEY-----\nYOUR_PRIVATE_KEY\n-----END EC PRIVATE KEY-----\n',});// Option 2: pass the full CDP JSON object (downloaded from Coinbase)const client2 = new CBAdvancedTradeClient({ cdpApiKey: { name: 'organizations/YOUR_ORG_ID/apiKeys/YOUR_KEY_ID', privateKey: '-----BEGIN EC PRIVATE KEY-----\nYOUR_PRIVATE_KEY\n-----END EC PRIVATE KEY-----\n', },});
Both ECDSA and ED25519 key formats are supported — the client detects the key type automatically. For ED25519, the privateKey value is a Base64 string rather than a PEM block.
submitOrder() and closePosition() automatically validate and set a unique client_order_id if one is not supplied. All cancel operations accept an array of up to 100 order IDs per request.
// List all linked payment methodsconst methods = await client.getPaymentMethods();// Get details for a specific payment methodconst method = await client.getPaymentMethod({ payment_method_id: 'pm-uuid-here',});
fetchLatencySummary() is a built-in SDK helper (not an official Coinbase API endpoint) that measures round-trip latency and estimates clock drift between your system and the Coinbase server.
If timeDifference exceeds 500 ms, the SDK will log a warning. Large clock skew can cause request authentication failures. Sync your system clock with an NTP server to resolve this.