Coinbase JavaScript SDK
Use coinbase-api to read Coinbase market data, manage orders, and consume streams from Node.js. JavaScript and TypeScript use the same clients; request and response types are included.
Choose a client
- CBAdvancedTradeClient
- Advanced Trade products, accounts, orders, portfolios, derivatives, conversions, fees, and payment methods
- WebsocketClient
- Advanced Trade, Exchange, International, and Prime WebSocket subscriptions
- CBAppClient
- Coinbase App accounts, addresses, transactions, deposits, withdrawals, and public prices
- CBExchangeClient
- Institutional Exchange market data, accounts, orders, profiles, reports, loans, and transfers
- CBInternationalClient
- International instruments, portfolios, orders, positions, loans, and transfers
- CBPrimeClient
- Prime portfolios, balances, orders, activities, allocations, wallets, and transactions
- CBCommerceClient
- Legacy Commerce charges, checkouts, and events
Make a first public request
In a Node.js project, install the package once. The REST and WebSocket API examples below use .mjs files so Node.js can run their imports directly.
npm install coinbase-api
WebSocket API is not currently available for Coinbase.
REST walkthrough
Read public BTC-USD market data with CBAdvancedTradeClient. These public requests require no credentials.
Save the code as rest-public.mjs and run:
node rest-public.mjs
import { CBAdvancedTradeClient } from 'coinbase-api'; const client = new CBAdvancedTradeClient(); async function main() { try { const serverTime = await client.getServerTime(); console.log('Server time:', serverTime.iso); } catch (error) { console.error('Server time request failed:', error); } try { const product = await client.getPublicProduct({ product_id: 'BTC-USD', }); console.log('BTC-USD price:', product.price); console.log('Base increment:', product.base_increment); console.log('Price increment:', product.price_increment); } catch (error) { console.error('Product request failed:', error); } try { const orderBook = await client.getPublicProductBook({ product_id: 'BTC-USD', limit: 5, }); console.log('Best bid:', orderBook.pricebook.bids[0]); console.log('Best ask:', orderBook.pricebook.asks[0]); } catch (error) { console.error('Order book request failed:', error); } const end = Math.floor(Date.now() / 1000); const start = end - 60 * 60; try { const candles = await client.getPublicProductCandles({ product_id: 'BTC-USD', start: String(start), end: String(end), granularity: 'FIVE_MINUTE', limit: 12, }); console.log('Latest candle:', candles.candles[0]); } catch (error) { console.error('Candles request failed:', error); } try { const marketTrades = await client.getPublicMarketTrades({ product_id: 'BTC-USD', limit: 10, }); console.log('Latest trade:', marketTrades.trades[0]); console.log('Best bid:', marketTrades.best_bid); console.log('Best ask:', marketTrades.best_ask); } catch (error) { console.error('Market trades request failed:', error); }} main();Expected response
Market values change on each run. These are the fields to check in the logged output.
| Field | Expected result |
|---|---|
| Server time / BTC-USD price | An ISO time string and a decimal-string price. |
| Base increment / Price increment | Decimal strings defining quantity and price steps. |
| Best bid / Best ask / Latest candle | Book levels with price and size; a candle object with start, OHLC prices, and volume. |
WebSocket walkthrough
Connecting to Coinbase Advanced Trade private WebSocket streams is straightforward with the WebsocketClient.
- Install the Coinbase JavaScript SDK via NPM:
npm install coinbase-api. - Import the WebsocketClient and create an authenticated instance with your API credentials.
- Configure event handlers for key events such as
open,update,response,reconnect,reconnected,close, andexception. - Subscribe to private Advanced Trade user-data topics on the
advTradeUserDataconnection key.
In this example, we:
- Subscribe to
futures_balance_summary. - Subscribe to the
userchannel for account-level private updates. - Demonstrate topic subscription using both simple strings and a structured
WsTopicRequestobject.
This example focuses on the Advanced Trade private group (advTradeUserData). The same WebsocketClient also supports:
- Advanced Trade public market data via
advTradeMarketData(for topics such as heartbeats, ticker, level2, candles, and trades). - Other Coinbase websocket groups used by the SDK (including institutional websocket examples in this repository).
WS_KEY_MAPas a helper enum for choosing valid websocket connection keys.
Built-in websocket behavior includes automatic connection management per wsKey, reconnect handling, and automatic resubscribe of tracked topics after reconnect.
Any subscriptions sent on advTradeUserData are automatically authenticated when API credentials are available, making it easy to receive real-time private account updates.
import { // DefaultLogger, WebsocketClient, // WS_KEY_MAP, WsTopicRequest,} from 'coinbase-api'; async function start() { // key name & private key, as returned by coinbase when creating your API keys. // Note: the below example is a dummy key and won't actually work // Optional: fully customise the logging experience by injecting a custom logger // const logger: typeof DefaultLogger = { // ...DefaultLogger, // trace: (...params) => { // if ( // [ // 'Sending ping', // 'Sending upstream ws message: ', // 'Received pong, clearing pong timer', // 'Received ping, sending pong frame', // ].includes(params[0]) // ) { // return; // } // console.log('trace', params); // }, // }; const client = new WebsocketClient( { // Either pass the full JSON object that can be downloaded when creating your API keys // cdpApiKey: advancedTradeCdpAPIKey, // initialise the client /** * * You can add both ED25519 and ECDSA keys, client will recognize both types of keys * * ECDSA: * * { * apiKey: 'organizations/your_org_id/apiKeys/your_api_key_id', * apiSecret: * '-----BEGIN EC PRIVATE KEY-----\nMHcCAQEEIPT/TTZPxw0kDGvpuCENJp9A4/2INAt9/QKKfyidTWM8oAoGCCqGSM49\nAwEHoUQDQgAEd+cnxrKl536ly5eYBi+8dvXt1MJXYRo+/v38h9HrFKVGBRndU9DY\npV357xIfqeJEzb/MBuk3EW8cG9RTrYBwjg==\n-----END EC PRIVATE KEY-----\n', * } * * ED25519: * { * apiKey: 'your-api-key-id', * apiSecret: 'yourExampleApiSecretEd25519Version==', * } * * */ apiKey: process.env.API_KEY_NAME || 'insert_api_key_here', apiSecret: process.env.API_PRIVATE_KEY || 'insert_api_secret_here', }, // logger, ); client.on('open', (data) => { console.log('open: ', data?.wsKey); }); // Data received client.on('update', (data) => { console.info(new Date(), 'data received: ', JSON.stringify(data)); }); // Something happened, attempting to reconnect client.on('reconnect', (data) => { console.log('reconnect: ', data); }); // Reconnect successful client.on('reconnected', (data) => { console.log('reconnected: ', data); }); // Connection closed. If unexpected, expect reconnect -> reconnected. client.on('close', (data) => { console.error('close: ', data); }); // Reply to a request, e.g. "subscribe"/"unsubscribe"/"authenticate" client.on('response', (data) => { console.info('response: ', JSON.stringify(data, null, 2)); // throw new Error('res?'); }); client.on('exception', (data) => { console.error('exception: ', data); }); try { /** * Use the client subscribe(topic, market) pattern to subscribe to any websocket topic. * * You can subscribe to topics one at a time or many in one request. * * Topics can be sent as simple strings, if no parameters are required. * * Any subscribe requests on the "advTradeUserData" market are automatically authenticated with the available credentials */ // client.subscribe('heartbeats', 'advTradeUserData'); client.subscribe('futures_balance_summary', 'advTradeUserData'); // This is the same as above, but uses WS_KEY_MAP as an enum (do this if you're not sure what value to put) // client.subscribe('futures_balance_summary', WS_KEY_MAP.advTradeUserData); // Subscribe to the user feed for the advanced trade websocket client.subscribe('user', 'advTradeUserData'); // /** // * Or, as an array of simple strings. // * // * Any requests sent to the "advTradeUserData" wsKey are // * automatically authenticated, if API keys are available: // */ // client.subscribe( // ['futures_balance_summary', 'user'], // 'advTradeUserData', // ); /** * Or send a more structured object with parameters, e.g. if parameters are required */ // eslint-disable-next-line @typescript-eslint/no-unused-vars const tickerSubscribeRequest: WsTopicRequest = { topic: 'futures_balance_summary', /** * Anything in the payload will be merged into the subscribe "request", * allowing you to send misc parameters supported by the exchange (such as `product_ids: string[]`) */ payload: { // In this case, the "futures_balance_summary" channel doesn't support any parameters // product_ids: ['ETH-USD', 'BTC-USD'], }, }; client.subscribe(tickerSubscribeRequest, 'advTradeUserData'); } catch (e) { console.error('Subscribe exception: ', e); }} start();Coinbase API JavaScript Tutorial
A practical JavaScript guide to using coinbase-api across Coinbase Advanced Trade REST API calls, public and private WebSocket streams, safe order previews, sandboxes, proxies, and reconnect recovery.
Your app / service
bot, dashboard, worker
coinbase-api
CBAdvancedTradeClient, WebsocketClient, and specialized Coinbase REST API clients
Coinbase APIs
Advanced Trade, Coinbase App, Exchange, International Exchange, Prime, Commerce, and WebSocket streams
Common Coinbase implementation tasks
Start from the behavior you need, not just from REST or WebSocket as a transport. Market-data driven systems should be event driven. Backfill via the REST API once and let WebSockets passively stream new data to you, as it becomes available.
REST API hydration or backfill
Start from the REST API quickstart and endpoint reference, then normalize exchange-specific IDs, timestamps, symbols, and product scope.
Open endpoint referenceWebSocket consumer
Start from the WebSocket quickstart that matches the task boundary, verify subscription acknowledgement semantics, and keep reconnect handling explicit.
Open WebSocket quickstartAgent prompt recipe
Use the AI prompt generator when the task combines REST API hydration, live streams, in-memory state, operational outputs, or strategy code.
Build an agent promptFor coding agents
Give these files to an agent before implementation so it can find the package, examples, task guidance, and safety rules from the normal SDK-page flow.
AI prompt framework
Prompt generator and task recipes for exchange API projects.
llms.txt
Compact discovery file for agents choosing where to start.
llms-full.txt
Full route and implementation guidance index for machine readers.
SDK catalog
Machine-readable package, docs, examples, and task guidance.
Agent skill
Reusable workflow rules for coding agents using exchange APIs.
Endpoint Function Reference
Endpoint maps
Each REST client is a JavaScript class, which provides functions individually mapped to each endpoint available in the exchange's API offering.
The following table shows all methods available in each REST client, whether the method requires authentication (automatically handled if API keys are provided), as well as the exact endpoint each method is connected to.
This can be used to easily find which method to call, once you have found which endpoint you're looking to use.
All REST clients are in the src folder. For usage examples, make sure to check the examples folder.
List of clients:
- CBAdvancedTradeClient
- CBAppClient
- CBExchangeClient
- CBInternationalClient
- CBPrimeClient
- CBCommerceClient
If anything is missing or wrong, please open an issue or let us know in our Node.js Traders telegram group!
How to use table
Table consists of 4 parts:
- Function name
- AUTH
- HTTP Method
- Endpoint
Function name is the name of the function that can be called through the SDK. Check examples folder in the repo for more help on how to use them!
AUTH is a boolean value that indicates if the function requires authentication - which means you need to pass your API key and secret to the SDK.
HTTP Method shows HTTP method that the function uses to call the endpoint. Sometimes endpoints can have same URL, but different HTTP method so you can use this column to differentiate between them.
Endpoint is the URL that the function uses to call the endpoint. Best way to find exact function you need for the endpoint is to search for URL in this table and find corresponding function name.
CBAdvancedTradeClient.ts
This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in CBAdvancedTradeClient.ts.
| Function | AUTH | HTTP Method | Endpoint |
|---|---|---|---|
| getAccounts() | 🔐 | GET | /api/v3/brokerage/accounts |
| getAccount() | 🔐 | GET | /api/v3/brokerage/accounts/{account_id} |
| getBestBidAsk() | 🔐 | GET | /api/v3/brokerage/best_bid_ask |
| getProductBook() | 🔐 | GET | /api/v3/brokerage/product_book |
| getProducts() | 🔐 | GET | /api/v3/brokerage/products |
| getProduct() | 🔐 | GET | /api/v3/brokerage/products/{product_id} |
| getProductCandles() | 🔐 | GET | /api/v3/brokerage/products/{product_id}/candles |
| getMarketTrades() | 🔐 | GET | /api/v3/brokerage/products/{product_id}/ticker |
| submitOrder() | 🔐 | POST | /api/v3/brokerage/orders |
| cancelOrders() | 🔐 | POST | /api/v3/brokerage/orders/batch_cancel |
| updateOrder() | 🔐 | POST | /api/v3/brokerage/orders/edit |
| updateOrderPreview() | 🔐 | POST | /api/v3/brokerage/orders/edit_preview |
| getOrders() | 🔐 | GET | /api/v3/brokerage/orders/historical/batch |
| getFills() | 🔐 | GET | /api/v3/brokerage/orders/historical/fills |
| getOrder() | 🔐 | GET | /api/v3/brokerage/orders/historical/{order_id} |
| previewOrder() | 🔐 | POST | /api/v3/brokerage/orders/preview |
| closePosition() | 🔐 | POST | /api/v3/brokerage/orders/close_position |
| getPortfolios() | 🔐 | GET | /api/v3/brokerage/portfolios |
| createPortfolio() | 🔐 | POST | /api/v3/brokerage/portfolios |
| movePortfolioFunds() | 🔐 | POST | /api/v3/brokerage/portfolios/move_funds |
| getPortfolioBreakdown() | 🔐 | GET | /api/v3/brokerage/portfolios/{portfolio_uuid} |
| deletePortfolio() | 🔐 | DELETE | /api/v3/brokerage/portfolios/{portfolio_uuid} |
| updatePortfolio() | 🔐 | PUT | /api/v3/brokerage/portfolios/{portfolio_uuid} |
| getFuturesBalanceSummary() | 🔐 | GET | /api/v3/brokerage/cfm/balance_summary |
| getIntradayMarginSetting() | 🔐 | GET | /api/v3/brokerage/cfm/intraday/margin_setting |
| setIntradayMarginSetting() | 🔐 | POST | /api/v3/brokerage/cfm/intraday/margin_setting |
| getCurrentMarginWindow() | 🔐 | GET | /api/v3/brokerage/cfm/intraday/current_margin_window |
| getFuturesPositions() | 🔐 | GET | /api/v3/brokerage/cfm/positions |
| getFuturesPosition() | 🔐 | GET | /api/v3/brokerage/cfm/positions/{product_id} |
| scheduleFuturesSweep() | 🔐 | POST | /api/v3/brokerage/cfm/sweeps/schedule |
| getFuturesSweeps() | 🔐 | GET | /api/v3/brokerage/cfm/sweeps |
| cancelPendingFuturesSweep() | 🔐 | DELETE | /api/v3/brokerage/cfm/sweeps |
| allocatePortfolio() | 🔐 | POST | /api/v3/brokerage/intx/allocate |
| getPerpetualsPortfolioSummary() | 🔐 | GET | /api/v3/brokerage/intx/portfolio/{portfolio_uuid} |
| getPerpetualsPositions() | 🔐 | GET | /api/v3/brokerage/intx/positions/{portfolio_uuid} |
| getPerpetualsPosition() | 🔐 | GET | /api/v3/brokerage/intx/positions/{portfolio_uuid}/{symbol} |
| getPortfoliosBalances() | 🔐 | GET | /api/v3/brokerage/intx/balances/{portfolio_uuid} |
| updateMultiAssetCollateral() | 🔐 | POST | /api/v3/brokerage/intx/multi_asset_collateral |
| getTransactionSummary() | 🔐 | GET | /api/v3/brokerage/transaction_summary |
| submitConvertQuote() | 🔐 | POST | /api/v3/brokerage/convert/quote |
| getConvertTrade() | 🔐 | GET | /api/v3/brokerage/convert/trade/{trade_id} |
| commitConvertTrade() | 🔐 | POST | /api/v3/brokerage/convert/trade/{trade_id} |
| getPublicProductBook() | GET | /api/v3/brokerage/market/product_book | |
| getPublicProducts() | GET | /api/v3/brokerage/market/products | |
| getPublicProduct() | GET | /api/v3/brokerage/market/products/{product_id} | |
| getPublicProductCandles() | GET | /api/v3/brokerage/market/products/{product_id}/candles | |
| getPublicMarketTrades() | GET | /api/v3/brokerage/market/products/{product_id}/ticker | |
| getPaymentMethods() | 🔐 | GET | /api/v3/brokerage/payment_methods |
| getPaymentMethod() | 🔐 | GET | /api/v3/brokerage/payment_methods/{payment_method_id} |
| getApiKeyPermissions() | 🔐 | GET | /api/v3/brokerage/key_permissions |
CBAppClient.ts
This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in CBAppClient.ts.
| Function | AUTH | HTTP Method | Endpoint |
|---|---|---|---|
| getAccounts() | 🔐 | GET | /v2/accounts |
| getAccount() | 🔐 | GET | /v2/accounts/{account_id} |
| createAddress() | 🔐 | POST | /v2/accounts/{account_id}/addresses |
| getAddresses() | 🔐 | GET | /v2/accounts/{account_id}/addresses |
| getAddress() | 🔐 | GET | /v2/accounts/{account_id}/addresses/{addressId} |
| getAddressTransactions() | 🔐 | GET | /v2/accounts/{account_id}/addresses/{addressId}/transactions |
| sendMoney() | 🔐 | POST | /v2/accounts/{account_id}/transactions |
| transferMoney() | 🔐 | POST | /v2/accounts/{account_id}/transactions |
| getTransactions() | 🔐 | GET | /v2/accounts/{account_id}/transactions |
| getTransaction() | 🔐 | GET | /v2/accounts/{account_id}/transactions/{transactionId} |
| depositFunds() | 🔐 | POST | /v2/accounts/{account_id}/deposits |
| commitDeposit() | 🔐 | POST | /v2/accounts/{account_id}/deposits/{deposit_id}/commit |
| getDeposits() | 🔐 | GET | /v2/accounts/{account_id}/deposits |
| getDeposit() | 🔐 | GET | /v2/accounts/{account_id}/deposits/{deposit_id} |
| withdrawFunds() | 🔐 | POST | /v2/accounts/{account_id}/withdrawals |
| commitWithdrawal() | 🔐 | POST | /v2/accounts/{account_id}/withdrawals/{withdrawal_id}/commit |
| getWithdrawals() | 🔐 | GET | /v2/accounts/{account_id}/withdrawals |
| getWithdrawal() | 🔐 | GET | /v2/accounts/{account_id}/withdrawals/{withdrawal_id} |
| getCoinbaseOneSubscription() | 🔐 | GET | /v2/subscriptions/coinbase-one |
| getFiatCurrencies() | GET | /v2/currencies | |
| getCryptocurrencies() | GET | /v2/currencies/crypto | |
| getExchangeRates() | GET | /v2/exchange-rates | |
| getBuyPrice() | GET | /v2/prices/{currencyPair}/buy | |
| getSellPrice() | GET | /v2/prices/{currencyPair}/sell | |
| getSpotPrice() | GET | /v2/prices/{currencyPair}/spot | |
| getCurrentTime() | GET | /v2/time |
CBExchangeClient.ts
This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in CBExchangeClient.ts.
| Function | AUTH | HTTP Method | Endpoint |
|---|---|---|---|
| getAccounts() | 🔐 | GET | /accounts |
| getAccount() | 🔐 | GET | /accounts/{account_id} |
| getAccountHolds() | 🔐 | GET | /accounts/{account_id}/holds |
| getAccountLedger() | 🔐 | GET | /accounts/{account_id}/ledger |
| getAccountTransfers() | 🔐 | GET | /accounts/{account_id}/transfers |
| getAddressBook() | 🔐 | GET | /address-book |
| addAddresses() | 🔐 | POST | /address-book |
| deleteAddress() | 🔐 | DELETE | /address-book/{id} |
| getCounterpartyAddressBook() | 🔐 | GET | /address-book/counterparty |
| updateAddressBookEntry() | 🔐 | PUT | /address-book/{id} |
| getCoinbaseWallets() | 🔐 | GET | /coinbase-accounts |
| createNewCryptoAddress() | 🔐 | POST | /coinbase-accounts/{account_id}/addresses |
| convertCurrency() | 🔐 | POST | /conversions |
| getConversionFeeRates() | 🔐 | GET | /conversions/fees |
| getConversion() | 🔐 | GET | /conversions/{conversion_id} |
| getAllConversions() | 🔐 | GET | /conversions |
| getCurrencies() | GET | /currencies | |
| getCurrency() | GET | /currencies/{currency_id} | |
| depositFromCoinbaseAccount() | 🔐 | POST | /deposits/coinbase-account |
| depositFromPaymentMethod() | 🔐 | POST | /deposits/payment-method |
| getPaymentMethods() | 🔐 | GET | /payment-methods |
| getTransfers() | 🔐 | GET | /transfers |
| getTransfer() | 🔐 | GET | /transfers/{transfer_id} |
| submitTravelInformation() | 🔐 | POST | /transfers/{transfer_id}/travel-rules |
| withdrawToCoinbaseAccount() | 🔐 | POST | /withdrawals/coinbase-account |
| withdrawToCryptoAddress() | 🔐 | POST | /withdrawals/crypto |
| getCryptoWithdrawalFeeEstimate() | 🔐 | GET | /withdrawals/fee-estimate |
| withdrawToPaymentMethod() | 🔐 | POST | /withdrawals/payment-method |
| getFees() | 🔐 | GET | /fees |
| getFills() | 🔐 | GET | /fills |
| getOrders() | 🔐 | GET | /orders |
| cancelAllOrders() | 🔐 | DELETE | /orders |
| submitOrder() | 🔐 | POST | /orders |
| getOrder() | 🔐 | GET | /orders/{order_id} |
| cancelOrder() | 🔐 | DELETE | /orders/{order_id} |
| getLoans() | 🔐 | GET | /loans |
| getLoanAssets() | 🔐 | GET | /loans/assets |
| getInterestSummaries() | 🔐 | GET | /loans/interest |
| getInterestRateHistory() | 🔐 | GET | /loans/interest/history/{loan_id} |
| getInterestCharges() | 🔐 | GET | /loans/interest/{loan_id} |
| getLendingOverview() | 🔐 | GET | /loans/lending-overview |
| getNewLoanPreview() | 🔐 | GET | /loans/loan-preview |
| submitNewLoan() | 🔐 | POST | /loans/open |
| getNewLoanOptions() | 🔐 | GET | /loans/options |
| repayLoanInterest() | 🔐 | POST | /loans/repay-interest |
| repayLoanPrincipal() | 🔐 | POST | /loans/repay-principal |
| getPrincipalRepaymentPreview() | 🔐 | GET | /loans/repayment-preview |
| getSignedPrices() | 🔐 | GET | /oracle |
| getAllTradingPairs() | GET | /products | |
| getAllProductVolume() | GET | /products/volume-summary | |
| getProduct() | GET | /products/{product_id} | |
| getProductBook() | GET | /products/{product_id}/book | |
| getProductCandles() | GET | /products/{product_id}/candles | |
| getProductStats() | GET | /products/{product_id}/stats | |
| getProductTicker() | GET | /products/{product_id}/ticker | |
| getProductTrades() | GET | /products/{product_id}/trades | |
| getProfiles() | 🔐 | GET | /profiles |
| createProfile() | 🔐 | POST | /profiles |
| transferFundsBetweenProfiles() | 🔐 | POST | /profiles/transfer |
| getProfileById() | 🔐 | GET | /profiles/{profile_id} |
| renameProfile() | 🔐 | PUT | /profiles/{profile_id} |
| deleteProfile() | 🔐 | PUT | /profiles/{profile_id}/deactivate |
| getAllReports() | 🔐 | GET | /reports |
| createReport() | 🔐 | POST | /reports |
| getReport() | 🔐 | GET | /reports/{report_id} |
| getTravelRuleInformation() | 🔐 | GET | /travel-rules |
| createTravelRuleEntry() | 🔐 | POST | /travel-rules |
| deleteTravelRuleEntry() | 🔐 | DELETE | /travel-rules/{id} |
| getUserExchangeLimits() | 🔐 | GET | /users/{user_id}/exchange-limits |
| updateSettlementPreference() | 🔐 | POST | /users/{user_id}/settlement-preferences |
| getUserTradingVolume() | 🔐 | GET | /users/{user_id}/trading-volumes |
| getAllWrappedAssets() | GET | /wrapped-assets | |
| getAllStakeWraps() | 🔐 | GET | /wrapped-assets/stake-wrap |
| createStakeWrap() | 🔐 | POST | /wrapped-assets/stake-wrap |
| getStakeWrap() | 🔐 | GET | /wrapped-assets/stake-wrap/{stake_wrap_id} |
| getWrappedAssetDetails() | 🔐 | GET | /wrapped-assets/{wrapped_asset_id} |
| getWrappedAssetConversionRate() | 🔐 | GET | /wrapped-assets/{wrapped_asset_id}/conversion-rate |
CBInternationalClient.ts
This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in CBInternationalClient.ts.
| Function | AUTH | HTTP Method | Endpoint |
|---|---|---|---|
| getAssets() | GET | /api/v1/assets | |
| getAssetDetails() | GET | /api/v1/assets/{asset} | |
| getSupportedNetworksPerAsset() | GET | /api/v1/assets/{asset}/networks | |
| getIndexComposition() | GET | /api/v1/index/{index}/composition | |
| getIndexCompositionHistory() | GET | /api/v1/index/{index}/composition-history | |
| getIndexPrice() | GET | /api/v1/index/{index}/price | |
| getIndexCandles() | GET | /api/v1/index/{index}/candles | |
| getInstruments() | GET | /api/v1/instruments | |
| getInstrumentDetails() | GET | /api/v1/instruments/{instrument} | |
| getQuotePerInstrument() | GET | /api/v1/instruments/{instrument}/quote | |
| getDailyTradingVolumes() | GET | /api/v1/instruments/volumes/daily | |
| getAggregatedCandlesData() | GET | /api/v1/instruments/{instrument}/candles | |
| getHistoricalFundingRates() | GET | /api/v1/instruments/{instrument}/funding | |
| getPositionOffsets() | GET | /api/v1/position-offsets | |
| submitOrder() | 🔐 | POST | /api/v1/orders |
| getOpenOrders() | 🔐 | GET | /api/v1/orders |
| cancelOrders() | 🔐 | DELETE | /api/v1/orders |
| updateOpenOrder() | 🔐 | PUT | /api/v1/orders/{id} |
| getOrderDetails() | 🔐 | GET | /api/v1/orders/{id} |
| cancelOrder() | 🔐 | DELETE | /api/v1/orders/{id} |
| getUserPortfolios() | 🔐 | GET | /api/v1/portfolios |
| createPortfolio() | 🔐 | POST | /api/v1/portfolios |
| updatePortfolioParameters() | 🔐 | PATCH | /api/v1/portfolios |
| getUserPortfolio() | 🔐 | GET | /api/v1/portfolios/{portfolio} |
| updatePortfolio() | 🔐 | PUT | /api/v1/portfolios/{portfolio} |
| getPortfolioDetails() | 🔐 | GET | /api/v1/portfolios/{portfolio}/detail |
| getPortfolioSummary() | 🔐 | GET | /api/v1/portfolios/{portfolio}/summary |
| getPortfolioBalances() | 🔐 | GET | /api/v1/portfolios/{portfolio}/balances |
| getBalanceForPortfolioAsset() | 🔐 | GET | /api/v1/portfolios/{portfolio}/balances/{asset} |
| getActiveLoansForPortfolio() | 🔐 | GET | /api/v1/portfolios/{portfolio}/loans |
| getLoanInfoForPortfolioAsset() | 🔐 | GET | /api/v1/portfolios/{portfolio}/loans/{asset} |
| acquireOrRepayLoan() | 🔐 | POST | /api/v1/portfolios/{portfolio}/loans/{asset} |
| previewLoanUpdate() | 🔐 | POST | /api/v1/portfolios/{portfolio}/loans/{asset}/preview |
| getMaxLoanAvailability() | 🔐 | GET | /api/v1/portfolios/{portfolio}/loans/{asset}/availability |
| getPortfolioPositions() | 🔐 | GET | /api/v1/portfolios/{portfolio}/positions |
| getPositionForPortfolioInstrument() | 🔐 | GET | /api/v1/portfolios/{portfolio}/positions/{instrument} |
| getTotalOpenPositionLimit() | 🔐 | GET | /api/v1/portfolios/{portfolio}/position-limits |
| getOpenPositionLimitsForAllInstruments() | 🔐 | GET | /api/v1/portfolios/{portfolio}/position-limits/positions |
| getOpenPositionLimitsForInstrument() | 🔐 | GET | /api/v1/portfolios/{portfolio}/position-limits/positions/{instrument} |
| getFillsByPortfolios() | 🔐 | GET | /api/v1/portfolios/fills |
| getPortfolioFills() | 🔐 | GET | /api/v1/portfolios/{portfolio}/fills |
| setCrossCollateral() | 🔐 | POST | /api/v1/portfolios/{portfolio}/cross-collateral-enabled |
| setAutoMargin() | 🔐 | POST | /api/v1/portfolios/{portfolio}/auto-margin-enabled |
| setPortfolioMarginOverride() | 🔐 | POST | /api/v1/portfolios/margin |
| getFundTransferLimit() | 🔐 | GET | /api/v1/portfolios/transfer/{portfolio}/{asset}/transfer-limit |
| transferFundsBetweenPortfolios() | 🔐 | POST | /api/v1/portfolios/transfer |
| transferPositionsBetweenPortfolios() | 🔐 | POST | /api/v1/portfolios/transfer-position |
| getPortfolioFeeRates() | 🔐 | GET | /api/v1/portfolios/fee-rates |
| getRankings() | 🔐 | GET | /api/v1/rankings/statistics |
| getMatchingTransfers() | 🔐 | GET | /api/v1/transfers |
| getTransfer() | 🔐 | GET | /api/v1/transfers/{transfer_uuid} |
| withdrawToCryptoAddress() | 🔐 | POST | /api/v1/transfers/withdraw |
| createCryptoAddress() | 🔐 | POST | /api/v1/transfers/address |
| createCounterpartyId() | 🔐 | POST | /api/v1/transfers/create-counterparty-id |
| validateCounterpartyId() | 🔐 | POST | /api/v1/transfers/validate-counterparty-id |
| getCounterpartyWithdrawalLimit() | 🔐 | GET | /api/v1/transfers/withdraw/{portfolio}/{asset}/counterparty-withdrawal-limit |
| withdrawToCounterpartyId() | 🔐 | POST | /api/v1/transfers/withdraw/counterparty |
| getFeeRateTiers() | 🔐 | GET | /api/v1/fee-rate-tiers |
CBPrimeClient.ts
This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in CBPrimeClient.ts.
| Function | AUTH | HTTP Method | Endpoint |
|---|---|---|---|
| getActivities() | 🔐 | GET | /v1/portfolios/{portfolio_id}/activities |
| getActivityById() | 🔐 | GET | /v1/activities/{activity_id} |
| getEntityActivities() | 🔐 | GET | /v1/entities/{entity_id}/activities |
| getPortfolioActivityById() | 🔐 | GET | /v1/portfolios/{portfolio_id}/activities/{activity_id} |
| createPortfolioAllocations() | 🔐 | POST | /v1/allocations |
| createPortfolioNetAllocations() | 🔐 | POST | /v1/allocations/net |
| getPortfolioAllocations() | 🔐 | GET | /v1/portfolios/{portfolio_id}/allocations |
| getAllocationById() | 🔐 | GET | /v1/portfolios/{portfolio_id}/allocations/{allocation_id} |
| getNetAllocationsByNettingId() | 🔐 | GET | /v1/portfolios/{portfolio_id}/allocations/net/{netting_id} |
| getEntityAccruals() | 🔐 | GET | /v1/entities/{entity_id}/accruals |
| getEntityLocateAvailabilities() | 🔐 | GET | /v1/entities/{entity_id}/locates_availability |
| getEntityMargin() | 🔐 | GET | /v1/entities/{entity_id}/margin |
| getEntityMarginSummaries() | 🔐 | GET | /v1/entities/{entity_id}/margin_summaries |
| getEntityTFTieredFees() | 🔐 | GET | /v1/entities/{entity_id}/tf_tiered_fees |
| getPortfolioAccruals() | 🔐 | GET | /v1/portfolios/{portfolio_id}/accruals |
| getPortfolioBuyingPower() | 🔐 | GET | /v1/portfolios/{portfolio_id}/buying_power |
| getPortfolioLocates() | 🔐 | GET | /v1/portfolios/{portfolio_id}/locates |
| getPortfolioMarginConversions() | 🔐 | GET | /v1/portfolios/{portfolio_id}/margin_conversions |
| getPortfolioWithdrawalPower() | 🔐 | GET | /v1/portfolios/{portfolio_id}/withdrawal_power |
| getConversionFees() | 🔐 | GET | /v1/conversion/fees |
| getInvoices() | 🔐 | GET | /v1/entities/{entity_id}/invoices |
| getEntityAggregatePositions() | 🔐 | GET | /v1/entities/{entity_id}/aggregate_positions |
| getEntityPositions() | 🔐 | GET | /v1/entities/{entity_id}/positions |
| getPortfolioDerivativePositions() | 🔐 | GET | /v1/portfolios/{portfolio_id}/derivatives/positions |
| getPortfolioDerivativesCurrencySummary() | 🔐 | GET | /v1/portfolios/{portfolio_id}/derivatives/currency_summary |
| getAssets() | 🔐 | GET | /v1/entities/{entity_id}/assets |
| getEntityPaymentMethods() | 🔐 | GET | /v1/entities/{entity_id}/payment-methods |
| getEntityPaymentMethod() | 🔐 | GET | /v1/entities/{entity_id}/payment-methods/{payment_method_id} |
| getUsers() | 🔐 | GET | /v1/entities/{entity_id}/users |
| getPortfolioUsers() | 🔐 | GET | /v1/portfolios/{portfolio_id}/users |
| getPortfolios() | 🔐 | GET | /v1/portfolios |
| getPortfolioById() | 🔐 | GET | /v1/portfolios/{portfolio_id} |
| getPortfolioCreditInformation() | 🔐 | GET | /v1/portfolios/{portfolio_id}/credit |
| getAddressBook() | 🔐 | GET | /v1/portfolios/{portfolio_id}/address_book |
| createAddressBookEntry() | 🔐 | POST | /v1/portfolios/{portfolio_id}/address_book |
| getPortfolioBalances() | 🔐 | GET | /v1/portfolios/{portfolio_id}/balances |
| getWalletBalance() | 🔐 | GET | /v1/portfolios/{portfolio_id}/wallets/{wallet_id}/balance |
| getWeb3WalletBalances() | 🔐 | GET | /v1/portfolios/{portfolio_id}/wallets/{wallet_id}/web3_balances |
| getPortfolioCommission() | 🔐 | GET | /v1/portfolios/{portfolio_id}/commission |
| getPortfolioFills() | 🔐 | GET | /v1/portfolios/{portfolio_id}/fills |
| getOpenOrders() | 🔐 | GET | /v1/portfolios/{portfolio_id}/open_orders |
| submitOrder() | 🔐 | POST | /v1/portfolios/{portfolio_id}/order |
| getOrderPreview() | 🔐 | POST | /v1/portfolios/{portfolio_id}/order_preview |
| getPortfolioOrders() | 🔐 | GET | /v1/portfolios/{portfolio_id}/orders |
| getOrderById() | 🔐 | GET | /v1/portfolios/{portfolio_id}/orders/{order_id} |
| cancelOrder() | 🔐 | POST | /v1/portfolios/{portfolio_id}/orders/{order_id}/cancel |
| getOrderFills() | 🔐 | GET | /v1/portfolios/{portfolio_id}/orders/{order_id}/fills |
| editOrder() | 🔐 | PUT | /v1/portfolios/{portfolio_id}/orders/{order_id}/edit |
| rotateApiKey() | 🔐 | POST | /v1/api-keys/rotate |
| getPortfolioProducts() | 🔐 | GET | /v1/portfolios/{portfolio_id}/products |
| getPortfolioTransactions() | 🔐 | GET | /v1/portfolios/{portfolio_id}/transactions |
| getTransactionById() | 🔐 | GET | /v1/portfolios/{portfolio_id}/transactions/{transaction_id} |
| getTransactionTravelRuleData() | 🔐 | GET | /v1/portfolios/{portfolio_id}/transactions/{transaction_id}/travel_rule |
| createConversion() | 🔐 | POST | /v1/portfolios/{portfolio_id}/wallets/{wallet_id}/conversion |
| getWalletTransactions() | 🔐 | GET | /v1/portfolios/{portfolio_id}/wallets/{wallet_id}/transactions |
| createTransfer() | 🔐 | POST | /v1/portfolios/{portfolio_id}/wallets/{wallet_id}/transfers |
| createWithdrawal() | 🔐 | POST | /v1/portfolios/{portfolio_id}/wallets/{wallet_id}/withdrawals |
| getPortfolioWallets() | 🔐 | GET | /v1/portfolios/{portfolio_id}/wallets |
| createWallet() | 🔐 | POST | /v1/portfolios/{portfolio_id}/wallets |
| getWalletById() | 🔐 | GET | /v1/portfolios/{portfolio_id}/wallets/{wallet_id} |
| getWalletDepositInstructions() | 🔐 | GET | /v1/portfolios/{portfolio_id}/wallets/{wallet_id}/deposit_instructions |
CBCommerceClient.ts
This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in CBCommerceClient.ts.
| Function | AUTH | HTTP Method | Endpoint |
|---|---|---|---|
| createCharge() | 🔐 | POST | /charges |
| getAllCharges() | 🔐 | GET | /charges |
| getCharge() | 🔐 | GET | /charges/{charge_code_or_charge_id} |
| createCheckout() | 🔐 | POST | /checkouts |
| getAllCheckouts() | 🔐 | GET | /checkouts |
| getCheckout() | 🔐 | GET | /checkouts/{checkout_id} |
| listEvents() | 🔐 | GET | /events |
| showEvent() | 🔐 | GET | /events/{event_id} |
Coinbase JavaScript FAQ
What does the Coinbase JavaScript SDK cover?
Coinbase supports Coinbase Advanced Trade API, Coinbase App API, Coinbase Exchange API, Coinbase International Exchange API, Coinbase Prime API, Coinbase Commerce API, Spot, Futures, and WebSockets workflows. The JavaScript guide covers the main REST and WebSocket integration patterns.
How do I authenticate private Coinbase API calls in JavaScript?
The public REST example above needs no credentials. For private calls, follow the authentication setup for coinbase-api in the full tutorial, including the credentials or signer required by your exchange.
Coinbase authentication and setupDoes the Coinbase JavaScript SDK help with WebSocket connection management?
Yes. Use the SDK WebSocket client for subscriptions, reconnect handling, and stream lifecycle management instead of building raw socket flows yourself.
Where should I start on the Coinbase JavaScript page: REST or WebSocket?
Start with the REST quick start for installation, authentication, and request and response flows. Move to the WebSocket example when you need streaming market or account updates.
Direct Example Files
Open the example files below for JavaScript and TypeScript-compatible request, authentication, WebSocket, and Node.js service patterns.