Bitget TypeScript SDK example: rest-public-futures.ts

Bitget V2 Classic REST REST public futures example for the Siebly Bitget SDK, with TypeScript source for exchange REST API and WebSocket integration, setup, and production SDK docs.

What This Example Covers

  • Bitget REST API example in TypeScript.
  • Uses the Siebly Bitget SDK package bitget-api instead of hand-written HTTP request plumbing.
  • Source path: Bitget/V2 - Classic/Rest/rest-public-futures.ts.
  • Example category: V2 Classic REST.
  • Imports SDK symbols including RestClientV2.
  • Calls SDK methods such as getFuturesCandles().

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

Bitget/V2 - Classic/Rest/rest-public-futures.ts

Source Link

Repository source: https://github.com/sieblyio/crypto-api-examples/blob/master/examples/Bitget/V2 - Classic/Rest/rest-public-futures.ts

Related SDK Docs

Example Source

import { RestClientV2 } from 'bitget-api';

const restClient = new RestClientV2();

const symbol = 'BTCUSDT';

(async () => {
  try {
    // Fetch the last 1000 1min candles for a symbol
    const timestampNow = Date.now();
    const msPerCandle = 60 * 1000; // 60 seconds x 1000
    const candlesToFetch = 1000;
    const msFor1kCandles = candlesToFetch * msPerCandle;
    const startTime = timestampNow - msFor1kCandles;

    const response = await restClient.getFuturesCandles({
      symbol,
      productType: 'USDT-FUTURES',
      granularity: '1m',
      startTime: startTime.toString(),
      endTime: timestampNow.toString(),
      limit: candlesToFetch.toString(),
    });

    console.table(response.data);

    console.log('getCandles returned ' + response.data.length + ' candles');
  } catch (e) {
    console.error('request failed: ', e);
  }
})();