# Importing Node.js & Typescript Bitget API SDK

**URL:** https://discourse.nodered.org/t/importing-node-js-typescript-bitget-api-sdk/78402
**Category:** General
**Created:** [13 May 2023 16:47 UTC](https://discourse.nodered.org/t/importing-node-js-typescript-bitget-api-sdk/78402 "2023-05-13T16:47:23Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Samokomo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/samokomo/32/63918_2.png) [@Samokomo](https://discourse.nodered.org/u/Samokomo)
#### Post date: [13 May 2023 16:47 UTC](https://discourse.nodered.org/t/importing-node-js-typescript-bitget-api-sdk/78402/1 "2023-05-13T16:47:23Z")

</div>

Hello Node-RED community,

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

> **[bitget-api](https://www.npmjs.com/package/bitget-api)**
>
> Node.js connector for Bitget REST APIs and WebSockets, with TypeScript & end-to-end tests.. Latest version: 1.1.1, last published: 17 days ago. Start using bitget-api in your project by running \`npm i bitget-api\`. There are 2 other projects in...

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.

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [13 May 2023 22:02 UTC](https://discourse.nodered.org/t/importing-node-js-typescript-bitget-api-sdk/78402/2 "2023-05-13T22:02:54Z")

</div>

> [@Samokomo](#):
>
> Obviously it is not available as Node-RED pallete install

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...

```javascript
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);
  });

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [12 July 2023 22:03 UTC](https://discourse.nodered.org/t/importing-node-js-typescript-bitget-api-sdk/78402/3 "2023-07-12T22:03:55Z")

</div>

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