Example: rest-spot-public.ts

Static snapshot for Binance/Rest/Spot/rest-spot-public.ts.

Example Path

Binance/Rest/Spot/rest-spot-public.ts

Source Link

Repository source: https://github.com/sieblyio/crypto-api-examples/blob/master/examples/Binance/Rest/Spot/rest-spot-public.ts

Code Snapshot

import { MainClient } from 'binance';

const client = new MainClient({
  // Optional (default: false) - when true, response strings are parsed to floats (only for known keys).
  // beautifyResponses: true,
});

(async () => {
  try {
    // console.log(
    //   'getAvgPrice: ',
    //   await client.getAvgPrice({ symbol: 'BTCUSDT' }),
    // );
    // console.log(
    //   'getExchangeInfo: ',
    //   JSON.stringify(await client.getExchangeInfo(), null, 2),
    // );

    const oneTicker = await client.get24hrChangeStatistics({
      symbol: 'BTCUSDT',
    });
    console.log('getTickers', oneTicker);

    const manyTickers = await client.get24hrChangeStatistics({
      symbols: ['BTCUSDT', 'ETHUSDT'],
    });
    console.log('getTickers many', manyTickers);
    const allTickers = await client.get24hrChangeStatistics();
    console.log('getTickers all', allTickers);
  } catch (e) {
    console.error('request failed: ', e);
  }
})();

This is a static, crawlable snapshot. The interactive app loads after JavaScript starts and can refresh live data.