Skip to main content

Documentation 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.

CBExchangeClient targets the Coinbase Exchange API — the professional trading platform (formerly Coinbase Pro). It exposes deep order book access, profile-based account management, full order lifecycle control, fiat and crypto transfers, currency conversions, and reporting.
Coinbase Exchange uses API key + secret + passphrase authentication — not JWT. You must supply all three credentials when constructing the client.

Installation

npm install coinbase-api

Instantiation

import { CBExchangeClient } from 'coinbase-api';

const client = new CBExchangeClient({
  apiKey: 'your_api_key',
  apiSecret: 'your_api_secret',
  apiPassphrase: 'your_api_passphrase',
});

// Connect to the sandbox environment instead:
const sandboxClient = new CBExchangeClient({
  apiKey: 'sandbox_key',
  apiSecret: 'sandbox_secret',
  apiPassphrase: 'sandbox_passphrase',
  useSandbox: true,
});
Set useSandbox: true to use the Exchange sandbox at https://api-public.sandbox.exchange.coinbase.com. This is ideal for testing order flows without real funds.

Accounts

Trading accounts are separate from your Coinbase.com wallet accounts. Each account holds a single currency balance.
MethodDescription
getAccounts()List all trading accounts for the current profile
getAccount(params)Get a single account by ID
getAccountHolds(params)List holds on an account (open orders, withdrawals)
getAccountLedger(params)Get ledger entries — trades, fees, transfers, conversions
getAccountTransfers(params)List past deposits and withdrawals for an account
// All accounts for the authenticated profile
const accounts = await client.getAccounts();

// Holds on the BTC account
const holds = await client.getAccountHolds({
  account_id: 'btc-account-id',
  limit: 100,
});

// Ledger entries for the past day (default) or a custom range
const ledger = await client.getAccountLedger({
  account_id: 'usd-account-id',
  start_date: '2024-01-01T00:00:00Z',
  end_date: '2024-01-31T23:59:59Z',
});

Address Book

Manage trusted external withdrawal addresses.
MethodDescription
getAddressBook()Get all stored trusted addresses
addAddresses(params)Add new addresses to the address book
deleteAddress(params)Remove an address by ID
const book = await client.getAddressBook();

await client.addAddresses({
  addresses: [{ address: '0xYourEthAddress', currency: 'ETH', label: 'Hot wallet' }],
});

Coinbase Wallets

Link your Coinbase.com wallets for easy fund deposits into your Exchange trading accounts.
MethodDescription
getCoinbaseWallets()List all linked Coinbase.com wallets
createNewCryptoAddress(params)Generate a one-time deposit address
const wallets = await client.getCoinbaseWallets();

const address = await client.createNewCryptoAddress({
  account_id: 'coinbase-wallet-id',
});

Currency Conversion

Convert between currencies within a profile (e.g. USD ↔ USDC).
MethodDescription
convertCurrency(params)Convert funds between currencies
getConversionFeeRates()Get current fee rates and 30-day volumes
getConversion(params)Get details for a specific conversion
getAllConversions(params)List all conversions for a profile
const conversion = await client.convertCurrency({
  from: 'USD',
  to: 'USDC',
  amount: '100',
  profile_id: 'your-profile-id',
});

const fees = await client.getConversionFeeRates();

Orders

submitOrder() automatically validates and assigns a unique client_oid if not provided. The cancelAllOrders() method is best-effort — you may need to call it multiple times to cancel all open orders.
MethodDescription
getOrders(params?)List open (or filtered) orders
submitOrder(params)Place a new limit or market order
cancelAllOrders(params?)Cancel all open orders (best effort)
cancelOrder(params)Cancel a single order by ID
getFills(params?)List recent fills
getOrder(params)Get a single order by ID
const order = await client.submitOrder({
  product_id: 'BTC-USD',
  side: 'buy',
  type: 'limit',
  price: '30000',
  size: '0.001',
});

Products & Market Data

Product endpoints are public — no authentication required.
MethodDescription
getAllTradingPairs(params?)List all currency pairs
getAllProductVolume()Get 30-day and 24-hour volume for all products
getProduct(params)Get a single product
getProductBook(params)Get the order book (level 1, 2, or 3)
getProductCandles(params)Get OHLCV candlestick data
getProductStats(params)Get 30-day and 24-hour stats
getProductTicker(params)Get best bid/ask and 24h volume snapshot
getProductTrades(params)Get the latest trades
// No auth needed for product endpoints
const products = await client.getAllTradingPairs();

const book = await client.getProductBook({
  product_id: 'BTC-USD',
  level: 2,
});

const candles = await client.getProductCandles({
  product_id: 'BTC-USD',
  granularity: 3600,
  start: '2024-01-01T00:00:00Z',
  end: '2024-01-02T00:00:00Z',
});

const ticker = await client.getProductTicker({ product_id: 'ETH-USD' });

Profiles

Profiles are isolated sub-accounts within your Exchange account — each with its own balances and order history.
MethodDescription
getProfiles(params?)List all profiles
createProfile(params)Create a new profile
transferFundsBetweenProfiles(params)Move funds between profiles
getProfileById(params)Get a profile by ID
renameProfile(params)Rename a profile
deleteProfile(params)Delete a profile (transfers all funds to target)
const profiles = await client.getProfiles({ active: true });

await client.transferFundsBetweenProfiles({
  from: 'source-profile-id',
  to: 'target-profile-id',
  currency: 'USD',
  amount: '500',
});

Transfers

Move funds in and out of your Exchange trading accounts via Coinbase wallets or linked payment methods.
MethodDescription
depositFromCoinbaseAccount(params)Deposit from a Coinbase.com wallet
depositFromPaymentMethod(params)Deposit from a linked payment method
withdrawToCoinbaseAccount(params)Withdraw to a Coinbase.com wallet
withdrawToCryptoAddress(params)Withdraw to an external crypto address
withdrawToPaymentMethod(params)Withdraw to a linked payment method
getTransfers(params?)List all transfers
getTransfer(params)Get a single transfer
submitTravelInformation(params)Submit travel rule information for a transfer
getCryptoWithdrawalFeeEstimate(params)Estimate fees for a crypto withdrawal
getPaymentMethods()List all linked payment methods
// Deposit from a linked Coinbase wallet
await client.depositFromCoinbaseAccount({
  amount: '0.1',
  currency: 'BTC',
  coinbase_account_id: 'coinbase-wallet-uuid',
  profile_id: 'trading-profile-id',
});

// Withdraw to an external address
await client.withdrawToCryptoAddress({
  amount: '0.05',
  currency: 'ETH',
  crypto_address: '0xYourEthAddress',
  profile_id: 'trading-profile-id',
});

Fees

// Get your current maker/taker fee rates and 30-day trailing volume
const fees = await client.getFees();

Loans

Manage institutional lending — open loans, track interest, and manage repayments.
MethodDescription
getLoans(params?)List loans (optionally filtered by IDs)
getLoanAssets()List lendable assets and collateral haircut weights
getInterestSummaries()List interest owed summaries by asset
getInterestRateHistory(params)List interest rate history for a loan
getInterestCharges(params)List interest charges for a loan
getLendingOverview()Get overall lending overview (balance, collateral, available to borrow)
getNewLoanPreview(params)Preview the result of opening a new loan
submitNewLoan(params)Open a new loan
getNewLoanOptions()List available currencies and rates for new loans
repayLoanInterest(params)Submit an interest repayment
repayLoanPrincipal(params)Submit a principal repayment
getPrincipalRepaymentPreview(params)Preview the results of a principal repayment
// Get lending overview
const overview = await client.getLendingOverview();

// Preview opening a new loan of 1 BTC
const preview = await client.getNewLoanPreview({
  currency: 'BTC',
  native_amount: '1',
});

// Open the loan
await client.submitNewLoan({ currency: 'BTC', native_amount: '1' });

// Repay interest
await client.repayLoanInterest({ loan_id: 'loan-uuid', amount: '0.01', currency: 'BTC' });

Oracle (Signed Prices)

// Get cryptographically signed prices for Compound's Open Oracle smart contract
const prices = await client.getSignedPrices();

Reports

Generate and retrieve user-created reports (fills, account, and balance snapshots).
MethodDescription
getAllReports(params?)List all user-generated reports
createReport(params)Generate a new report
getReport(params)Get a specific report by ID
const reports = await client.getAllReports();

const report = await client.createReport({
  type: 'fills',
  fills: { product_id: 'BTC-USD', start_date: '2024-01-01', end_date: '2024-01-31' },
  format: 'csv',
  email: 'you@example.com',
});

Travel Rules

// Retrieve all stored travel rule information
const rules = await client.getTravelRuleInformation();

// Create a travel rule entry
await client.createTravelRuleEntry({
  address: '0xYourAddress',
  originator_name: 'Jane Doe',
  originator_country: 'US',
});

// Delete an existing entry
await client.deleteTravelRuleEntry({ id: 'travel-rule-id' });
MethodDescription
getTravelRuleInformation(params?)List all stored travel rule information
createTravelRuleEntry(params)Create a travel rule entry for a sending address
deleteTravelRuleEntry(params)Delete an existing travel rule entry

Users

// Get exchange limits for a user
const limits = await client.getUserExchangeLimits({ user_id: 'user-id' });

// Update settlement preference (hold funds in USD or USDC)
await client.updateSettlementPreference({
  user_id: 'user-id',
  settlement_preference: 'USD',
});

// Get aggregated trading volumes for a user
const volume = await client.getUserTradingVolume({ user_id: 'user-id' });
MethodDescription
getUserExchangeLimits(params)Get exchange limits for a user
updateSettlementPreference(params)Update USD or USDC settlement preference
getUserTradingVolume(params)Get aggregated trading volumes for a user

Wrapped Assets

Manage cbETH and other wrapped/staked assets.
MethodDescription
getAllWrappedAssets()List all supported wrapped assets
getAllStakeWraps(params?)List stake-wraps in the current profile
createStakeWrap(params)Stake and wrap from one currency to another
getStakeWrap(params)Get details for a specific stake-wrap
getWrappedAssetDetails(params)Get circulating supply and conversion rate for a wrapped asset
getWrappedAssetConversionRate(params)Get the conversion rate for a wrapped asset
const wrapped = await client.getAllWrappedAssets();

const details = await client.getWrappedAssetDetails({
  wrapped_asset_id: 'CBETH',
});

await client.createStakeWrap({
  from_currency: 'ETH',
  to_currency: 'CBETH',
  amount: '1',
});

Next Steps

International Client

Institutional cross-border trading and portfolio margin

Advanced Trade Client

Modern retail & institutional trading with JWT auth

Build docs developers (and LLMs) love