Importing Node.js & Typescript Bitget API SDK

Hello Node-RED community,

I am stumbled upon this API SDK I would love to try out:

Obviously it is not available as Node-RED pallete install. I am running on AWS - not advanced in Ubuntu, but willing to learn. Can someone provide me approximate instructions how to run it? I would really appreciate it.

No, but you can add regular node js libs to the setup tab of a function node.

In this case, you wou add bitget-api to the setup tab then in the function node you can do the following...

const {
  SpotClient,
  FuturesClient,
  BrokerClient,
} = bitgetApi

const API_KEY = 'xxx';
const API_SECRET = 'yyy';
const API_PASS = 'zzz';

const client = new SpotClient({
    apiKey: API_KEY,
    apiSecret: API_SECRET,
    apiPass: API_PASS,
},
  // requestLibraryOptions
);

// For public-only API calls, simply don't provide a key & secret or set them to undefined
// const client = new SpotClient();


client.getApiKeyInfo()
  .then(result => {
    node.send({payload: result});
  })
  .catch(err => {
    node.error(err, msg);
  });

const symbol = 'BTCUSDT_SPBL';
client.getCandles(symbol, '1min');
  .then(result => {
    node.send({payload: result});
  })
  .catch(err => {
    node.error(err, msg);
  });
1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.