Coinbase cbapp public REST all 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.
coinbase-api instead of hand-written HTTP request plumbing.Coinbase/CoinbaseApp/Public/cbapp-public-rest-all.ts.CBAppClient.getFiatCurrencies(), getCryptocurrencies(), getExchangeRates(), getBuyPrice(), getSellPrice(), getSpotPrice(), getCurrentTime().import { CBAppClient } 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 CBAppClient(); async function publicCalls() { try { // Get fiat currencies const fiatCurrencies = await client.getFiatCurrencies(); console.log('Fiat Currencies: ', fiatCurrencies); // Get cryptocurrencies const cryptocurrencies = await client.getCryptocurrencies(); console.log('Cryptocurrencies: ', cryptocurrencies); // Get exchange rates const exchangeRates = await client.getExchangeRates({ currency: 'USD' }); console.log('Exchange Rates: ', exchangeRates); // Get buy price const buyPrice = await client.getBuyPrice({ currencyPair: 'BTC-USD' }); console.log('Buy Price: ', buyPrice); // Get sell price const sellPrice = await client.getSellPrice({ currencyPair: 'BTC-USD' }); console.log('Sell Price: ', sellPrice); // Get spot price const spotPrice = await client.getSpotPrice({ currencyPair: 'BTC-USD' }); console.log('Spot Price: ', spotPrice); // Get current time const currentTime = await client.getCurrentTime(); console.log('Current Time: ', currentTime); } catch (e) { console.error('Error: ', e); }} publicCalls(); We use essential cookies and optional analytics. Read the Privacy Policy.
Essential cookies stay on. Toggle analytics if you want to share anonymous usage insights. You can revisit this anytime via Cookie Settings in the footer.