Coinbase TypeScript SDK example: cb-exchange-public.ts
Coinbase Institutional CBExchange REST cb exchange public example for the Siebly Coinbase SDK, with TypeScript source for exchange REST API and WebSocket integration, setup, and production SDK docs.
What This Example Covers
- Coinbase REST API example in TypeScript.
- Uses the Siebly Coinbase SDK package
coinbase-apiinstead 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.
Example Path
Coinbase/Institutional/CBExchange/Rest/cb-exchange-public.ts
Source Link
Repository source: https://github.com/sieblyio/crypto-api-examples/blob/master/examples/Coinbase/Institutional/CBExchange/Rest/cb-exchange-public.ts
Related SDK Docs
Example Source
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 endpoints
const 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();