Coinbase Institutional CBExchange REST JavaScript SDK example: cb-exchange-public.ts

Coinbase Institutional CBExchange REST cb exchange public JavaScript example for the Siebly Coinbase SDK, covering exchange REST API and WebSocket integration, setup, and production SDK docs.

We use environment variables in our examples for API keys. It is your responsibility to manage and secure your keys appropriately.

examples/Coinbase/Institutional/CBExchange/Rest/cb-exchange-public.ts

What this example covers

  • Coinbase REST API JavaScript example.
  • Uses the Siebly Coinbase SDK package coinbase-api instead of hand-written HTTP request plumbing.
  • Source path: Coinbase/Institutional/CBExchange/Rest/cb-exchange-public.ts.
  • Example category: Institutional CBExchange REST.
  • Imports SDK symbols including CBExchangeClient.
  • Calls SDK methods such as getCurrencies(), getCurrency(), getAllTradingPairs(), getAllProductVolume(), getAllWrappedAssets().

How to use this example

  • Start here for the specific request or stream pattern, then check the matching SDK guide for install, credentials, and operational notes.
  • Open the repository source when you need the latest committed version: GitHub source file.
import { CBExchangeClient } from 'coinbase-api'; // Initialize the client, you can pass in api keys here if you have them but they are not required for public endpointsconst client = new CBExchangeClient(); async function publicExchangeCalls() {  try {    // Get all known currencies    const currencies = await client.getCurrencies();    console.log('Currencies: ', currencies);     // Get a single currency by id    const currency = await client.getCurrency('BTC');    console.log('Currency (BTC): ', currency);     // Get all known trading pairs    const tradingPairs = await client.getAllTradingPairs();    console.log('Trading Pairs: ', tradingPairs);     // Get all product volume    const productVolume = await client.getAllProductVolume();    console.log('Product Volume: ', productVolume);     // Get all wrapped assets    const wrappedAssets = await client.getAllWrappedAssets();    console.log('Wrapped Assets: ', wrappedAssets);  } catch (e) {    console.error('Error: ', e);  }} publicExchangeCalls(); 

Subscribe on Substack

Complete the Substack form below to join our newsletter. Substack handles all subscriber data directly.