Gate TypeScript SDK example: getTickers.ts

Gate TypeScript SDK REST Spot example for Gate/Rest/spot/getTickers.ts. Source code reference for exchange REST, WebSocket, and API integration patterns with links to matching Siebly SDK documentation.

Example Path

Gate/Rest/spot/getTickers.ts

Source Link

Repository source: https://github.com/sieblyio/crypto-api-examples/blob/master/examples/Gate/Rest/spot/getTickers.ts

Related SDK Docs

Example Source

import { RestClient } from 'gateio-api';

// Define the account object with API key and secret
const 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 credentials
const gateRestClient = new RestClient({
  apiKey: account.key,
  apiSecret: account.secret,
});

async function getSpotTicker() {
  try {
    console.log('Using API keys:', account);

    // Fetch the ticker for a specific currency pair (BTC_USDT)
    const ticker = await gateRestClient.getSpotTicker({
      currency_pair: 'BTC_USDT', // Specify the currency pair
    });
    console.log('Response: ', ticker); // Log the response to the console

    // Fetch all tickers
    const allTickers = await gateRestClient.getSpotTicker();
    console.log('Response: ', allTickers); // 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 tickers
getSpotTicker();