TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/tiagosiebler/coinbase-api/llms.txt
Use this file to discover all available pages before exploring further.
coinbase-api npm package is a professional, production-ready Node.js SDK that provides a unified interface to every Coinbase REST API and WebSocket feed. It is actively maintained, battle-tested in live trading environments, and ships with full TypeScript declarations so your editor can autocomplete every request parameter and response field.
Why coinbase-api?
Coinbase operates six distinct API surfaces — each targeting a different user type and product. Rather than juggling six separate HTTP wrappers,coinbase-api gives you a single, consistent package with dedicated clients for each platform:
- Strongly typed — every request and response is modelled in TypeScript.
- Promise-driven — all REST methods return native Promises;
async/awaitjust works. - Dual module output — ships compiled ESM and CJS, so it works in any Node.js project regardless of
"type"field. - Browser bundle — a webpack build is included for frontend usage.
- Proxy support — powered by
axios, so standard proxy configuration applies without any extra wrapping. - Automatic key detection — pass ECDSA or ED25519 private keys; the SDK detects the format and signs correctly every time.
- Robust WebSocket layer — auto-reconnect, resubscribe on reconnect, configurable heartbeats, and event-driven message dispatch.
Upcoming change: As part of the Siebly.io brand, this SDK will soon be hosted under the Siebly.io GitHub organisation. The migration is seamless and requires no changes from users.
REST Clients
Each Coinbase product group has its own REST client. Import only what you need.CBAdvancedTradeClient
Coinbase’s modern retail and algorithmic trading platform. Supports spot and futures orders, order management, portfolios, and product data.
CBAppClient
Consumer-facing Coinbase mobile and web app APIs. Manage wallets, send/receive funds, and query transaction history programmatically.
CBExchangeClient
The professional Coinbase Exchange (formerly Coinbase Pro) REST API. Full order book access, fills, accounts, and payment methods.
CBInternationalClient
Institutional cross-border trading via the Coinbase International Exchange. Designed for large-volume, multi-currency institutional flows.
CBPrimeClient
Institutional custody and trading through Coinbase Prime. Portfolio management, allocations, and wallet operations for institutions.
CBCommerceClient
Accept cryptocurrency payments via Coinbase Commerce. Create charges, manage invoices, and handle on-chain payment events.
WebSocket Client
A singleWebsocketClient class handles every Coinbase WebSocket feed — public market data and private user data alike. You pass a WsKey string to route subscriptions to the correct upstream connection, and the client manages keep-alive pings, reconnection, and resubscription automatically.
- Auto-reconnect — dropped connections are restored automatically; a
reconnectedevent fires when live again. - Resubscribe on reconnect — all active subscriptions are replayed after reconnection with no extra code.
- Event-driven — listen to
open,update,response,reconnect,reconnected,close, andexceptionevents. - Public & private streams — unauthenticated market data and authenticated user data streams across all platforms.
TypeScript Support
The SDK is written in TypeScript and exports type declarations for the vast majority of API request parameters and response shapes. You get full IntelliSense support in VS Code and other editors without any additional@types package.
Exported Types & Utilities
The package exports the following public symbols fromcoinbase-api. These cover every client class, configuration type, and WebSocket utility you need:
| Export | Kind | Description |
|---|---|---|
CBAdvancedTradeClient | Class | REST client for the Advanced Trade API |
CBAppClient | Class | REST client for the Coinbase App API |
CBExchangeClient | Class | REST client for the Exchange API |
CBInternationalClient | Class | REST client for the International Exchange API |
CBPrimeClient | Class | REST client for the Prime API |
CBCommerceClient | Class | REST client for the Commerce API |
WebsocketClient | Class | Unified WebSocket client for all feeds |
WS_KEY_MAP | Const | Enum-like map of all valid WebSocket key strings (e.g. advTradeMarketData, advTradeUserData, exchangeMarketData) |
WsKey | Type | Union of all valid WsKey string literals derived from WS_KEY_MAP |
WsTopicRequest | Interface | Structured subscribe/unsubscribe request object { topic: string; payload?: any } |
WSConnectedResult | Interface | Result returned when a WebSocket connection is established: { wsKey: string } |
RestClientOptions | Interface | Configuration object accepted by all REST client constructors (credentials, sandbox, keep-alive, etc.) |
DefaultLogger | Const | Default logger object with trace, info, and error methods; spread and override to customise logging |
Authentication
coinbase-api supports two authentication schemes depending on which client you use:
- JWT (ECDSA / ED25519) —
CBAdvancedTradeClientandCBAppClientuse short-lived JWTs signed with your CDP API private key. Both key formats are detected automatically. - API Key + Secret + Passphrase —
CBExchangeClient,CBInternationalClient, andCBPrimeClientuse HMAC-signed requests with an additional passphrase.
Module Formats & Browser Usage
The package ships with both an ESM build (dist/mjs/) and a CommonJS build (dist/cjs/). Node.js will select the right one automatically based on your project’s module system.
npm run build && npm run pack inside a clone of the repository. The resulting webpack bundle is placed in dist/ and can be loaded directly in a browser.
Proxy Support
Because the SDK usesaxios under the hood, you can configure HTTP proxies via the standard axios proxy options or by setting the HTTP_PROXY / HTTPS_PROXY environment variables — no extra configuration needed on the RestClientOptions level.
Next Steps
Quickstart
Install the SDK and make your first API call in under five minutes.
Authentication
Configure credentials for JWT-based and passphrase-based clients.