Coinbase API SDK
coinbase-api provides typed JavaScript and TypeScript clients for Coinbase REST APIs and WebSockets. Start with Advanced Trade market data, then add account access and order management.
JavaScript & TypeScript · v1.3.1 · MIT license
Installation
TypeScript definitions are included.
Install the npm package with your preferred tool:
npm install coinbase-apipnpm add coinbase-apiyarn add coinbase-apibun add coinbase-apideno add npm:coinbase-apiPackage: coinbase-api
npm: https://www.npmjs.com/package/coinbase-apiFor other npm-compatible tools, use the same package from npm. Runtime-specific setup is covered below.
Choose your setup
Follow the guide for your runtime or framework. Each includes a complete project with commands to install dependencies and run it.
| Setup | Guides |
|---|---|
| Node.js | JavaScript or TypeScript |
| Alternative runtimes | Bun or Deno |
| Browser apps | React with Vite or Vite with plain JavaScript |
| Next.js | Node.js server Route Handler |
| Cloudflare Workers | Public prices and authenticated orders |
| Mobile apps | React Native / Expo for iOS and Android |
Browser and Expo guides include SDK-specific bundler configuration and polyfills where needed. See Runtime setup for project recipes and required configuration.
First request
The Node.js quickstart reads a public Bitcoin price without credentials.
Choose a client
| Client | Purpose |
|---|---|
CBAdvancedTradeClient | Advanced Trade spot and US futures (CFM): market data, accounts and orders. Advanced Trade guide. |
CBAdvancedTradeGlobalClient | Advanced Trade international derivatives on the Deribit-powered Starbase gateway. Global derivatives guide. |
CBAppClient | Coinbase App wallet accounts and transactions. App guide. |
CBExchangeClient | Coinbase Exchange REST market data, accounts and orders. Exchange guide. |
CBInternationalClient | Retained legacy INTX methods. Migration and historical records. |
CBPrimeClient | Prime institutional trading, portfolios and custody. Prime guide. |
CBCommerceClient | Legacy Commerce charges and checkouts. Migration and retained methods. |
WebsocketClient | Shared public and private subscriptions across supported Coinbase platforms, selected with WS_KEY_MAP. Stream selection. |
WebsocketAPIClient | Awaitable Global derivatives JSON-RPC requests over WebSocket. Global WebSocket API. |
Coinbase's API families have different accounts, credentials and protocols. The main walkthroughs use Advanced Trade spot. For international derivatives, use the Global client and guides; US futures (CFM) remain on CBAdvancedTradeClient.