Bitget V2 Classic REST public futures JavaScript example for the Siebly Bitget 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.
bitget-api instead of hand-written HTTP request plumbing.Bitget/V2 - Classic/Rest/rest-public-futures.ts.RestClientV2.getFuturesCandles().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); }})(); 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.