Coinbase TypeScript SDK example: cb-intx-public.ts
Coinbase Institutional CBInternational Exchange cb intx 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 exchange API example in TypeScript.
- Uses the Siebly Coinbase SDK package
coinbase-apiinstead of hand-written HTTP request plumbing. - Source path:
Coinbase/Institutional/CBInternationalExchange/cb-intx-public.ts. - Example category: Institutional CBInternational Exchange.
- Imports SDK symbols including
CBInternationalClient. - Calls SDK methods such as
getAssets(),getAssetDetails(),getSupportedNetworksPerAsset(),getInstruments(),getInstrumentDetails(),getQuotePerInstrument(),getDailyTradingVolumes(),getAggregatedCandlesData(),getHistoricalFundingRates(),getPositionOffsets().
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/CBInternationalExchange/cb-intx-public.ts
Source Link
Repository source: https://github.com/sieblyio/crypto-api-examples/blob/master/examples/Coinbase/Institutional/CBInternationalExchange/cb-intx-public.ts
Related SDK Docs
Example Source
import { CBInternationalClient } 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 CBInternationalClient();
async function publicInternationalCalls() {
try {
// List assets
const assets = await client.getAssets();
console.log('Assets: ', assets);
// Get asset details
const assetDetails = await client.getAssetDetails({ asset: 'BTC' });
console.log('Asset Details (BTC): ', assetDetails);
// Get supported networks per asset
const supportedNetworks = await client.getSupportedNetworksPerAsset({
asset: 'BTC',
});
console.log('Supported Networks (BTC): ', supportedNetworks);
// List instruments
const instruments = await client.getInstruments();
console.log('Instruments: ', instruments);
// Get instrument details
const instrumentDetails = await client.getInstrumentDetails({
instrument: 'BTC-PERP',
});
console.log('Instrument Details (BTC-PERP): ', instrumentDetails);
// Get quote per instrument
const quote = await client.getQuotePerInstrument({
instrument: 'BTC-PERP',
});
console.log('Quote (BTC-PERP): ', quote);
// Get daily trading volumes
const dailyVolumes = await client.getDailyTradingVolumes({
instruments: 'BTC-PERP',
});
console.log('Daily Trading Volumes (BTC-PERP): ', dailyVolumes);
// Get aggregated candles data per instrument
const candlesData = await client.getAggregatedCandlesData({
instrument: 'BTC-PERP',
granularity: 'ONE_HOUR',
start: '2023-01-01T00:00:00Z',
end: '2023-01-02T00:00:00Z',
});
console.log('Aggregated Candles Data (BTC-PERP): ', candlesData);
// Get historical funding rates
const fundingRates = await client.getHistoricalFundingRates({
instrument: 'BTC-PERP',
});
console.log('Historical Funding Rates (BTC-PERP): ', fundingRates);
// List position offsets
const positionOffsets = await client.getPositionOffsets();
console.log('Position Offsets: ', positionOffsets);
} catch (e) {
console.error('Error: ', e);
}
}
publicInternationalCalls();