Skip to content

Coinbase App ​

CBAppClient accesses Coinbase App wallet accounts and transactions on api.coinbase.com. It is a wallet API, not an exchange order client.

Setup ​

Install coinbase-api with npm install coinbase-api and use Node.js 24 to run the examples. Public REST examples need no credentials. For authenticated examples, add the variables below to a private .env file excluded from Git and run node --env-file=.env filename.ts, replacing filename.ts with its filename. Keep account output private.

Public prices ​

Save as app-market-data.ts and run node app-market-data.ts:

ts
import { CBAppClient } from 'coinbase-api';

async function main() {
  const client = new CBAppClient();
  const response = await client.getSpotPrice({ currencyPair: 'BTC-USD' });
  console.log(response.data);
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

getSpotPrice() returns a data object. Use getBuyPrice() or getSellPrice() for the corresponding price endpoint, and getExchangeRates() for currency conversion data. A displayed price is not an executable order or a reserved quote.

Authenticate wallet reads ​

Use the CDP key name and private key accepted by the App endpoints you need:

dotenv
COINBASE_APP_API_KEY=organizations/your-organization/apiKeys/your-key
COINBASE_APP_API_SECRET="your-full-PEM-private-key-with-\n-line-breaks"

Retain the complete original private-key header, footer and newlines in your local value. The REST client normalizes escaped newline sequences. Grant only the required account permissions; signing a request does not grant access to every App endpoint.

Save as app-read.ts:

ts
import { CBAppClient } from 'coinbase-api';

function requiredEnvVar(name: string) {
  const value = process.env[name];
  if (!value) {
    throw new Error(`Set ${name}.`);
  }
  return value;
}

async function main() {
  const client = new CBAppClient({
    apiKey: requiredEnvVar('COINBASE_APP_API_KEY'),
    apiSecret: requiredEnvVar('COINBASE_APP_API_SECRET'),
  });
  const response = await client.getAccounts();
  console.log(response);
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

Account balances and pagination ​

The response contains data (accounts) and pagination. Each account has its own ID and balance. Use getAccount({ account_id }) for one account. When loading the whole account list, follow the returned pagination metadata using getAccounts({ paginationURL }) rather than assuming the first page is complete. Use only pagination URLs returned by the trusted Coinbase response.

Inspect transactions ​

Set COINBASE_APP_ACCOUNT_ID to an account ID returned above. Save as app-transactions.ts:

ts
import { CBAppClient } from 'coinbase-api';

function requiredEnvVar(name: string) {
  const value = process.env[name];
  if (!value) {
    throw new Error(`Set ${name}.`);
  }
  return value;
}

async function main() {
  const client = new CBAppClient({
    apiKey: requiredEnvVar('COINBASE_APP_API_KEY'),
    apiSecret: requiredEnvVar('COINBASE_APP_API_SECRET'),
  });
  const account_id = requiredEnvVar('COINBASE_APP_ACCOUNT_ID');
  const response = await client.getTransactions({ account_id });
  console.log(response.data);
  console.log('Pagination:', response.pagination);
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

getTransactions() also returns data and pagination. For a specific unresolved transaction, call getTransaction({ account_id, transactionId }); the parameter is transactionId, not an exchange order_id.

Use transaction status and the account balance together when reconciling wallet activity. Keep original transaction identifiers, and do not assume that a successful HTTP response means a transfer has completed.

Money movement ​

sendMoney() sends supported assets to a recipient, while transferMoney() moves supported assets between the user's eligible accounts. Both change account state. depositFunds() / withdrawFunds() and their commit methods have their own payment-method and confirmation requirements. Do not invoke them just to verify credentials.

Review the recipient or destination account, currency, amount, fees and permissions before sending. If a response is lost, resolve the original transaction with targeted reads before creating another transfer.

Transport and environments ​

There is no mapped App sandbox, App WebSocket feed or App WebSocket request API in this SDK. Read wallet state through REST when your application needs it. If your application receives account events through another authorized integration, update local state from those events and use targeted reads to fill gaps; exchange market streams do not cover App wallet transactions.

App client reference · Choose another API

Built by Siebly. Open source SDKs for exchange APIs.