Gate REST Spot get candles JavaScript example for the Siebly Gate 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.
gateio-api instead of hand-written HTTP request plumbing.Gate/Rest/spot/getCandles.ts.RestClient.import { RestClient } from 'gateio-api'; // Define the account object with API key and secretconst account = { key: process.env.API_KEY || 'yourApiHere', // Replace 'yourApiHere' with your actual API key secret: process.env.API_SECRET || 'yourSecretHere', // Replace 'yourSecretHere' with your actual API secret}; // Initialize the RestClient with the API credentialsconst gateRestClient = new RestClient({ apiKey: account.key, apiSecret: account.secret,}); async function getSpotCandles() { try { console.log('Using API keys:', account); // Fetch the spot account balances const balances = await gateRestClient.getSpotCandles({ currency_pair: 'BTC_USDT', interval: '1m', }); console.log('Response: ', balances); // Log the response to the console } catch (e) { console.error('Error in execution: ', e); // Log any errors that occur }} // Execute the function to get spot balancesgetSpotCandles(); 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.