Skip to content

Node.js quickstart with JavaScript ​

Read a live BTCUSDT Spot price using Bitget's Unified Trading Account (UTA) V3 API. No API key, secret or passphrase is required.

Installation ​

TypeScript definitions are included.

Install the npm package with your preferred tool:

sh
npm install bitget-api
sh
pnpm add bitget-api
sh
yarn add bitget-api
sh
bun add bitget-api
sh
deno add npm:bitget-api
text
Package: bitget-api
npm: https://www.npmjs.com/package/bitget-api

For other npm-compatible tools, use the same package from npm. Runtime-specific setup is covered below.

Choose your setup ​

Follow the guide for your runtime or framework. Each includes a complete project with commands to install dependencies and run it.

SetupGuides
Node.jsJavaScript or TypeScript
Alternative runtimesBun or Deno
Browser appsReact with Vite or Vite with plain JavaScript
Next.jsNode.js server Route Handler
Cloudflare WorkersPublic prices and authenticated orders
Mobile appsReact Native / Expo for iOS and Android

Browser and Expo guides include SDK-specific bundler configuration and polyfills where needed. See Runtime setup for project recipes and required configuration.

Use Node.js 24 for this quickstart. For other runtimes and required polyfills, see Runtime compatibility.

Make a request ​

Save this as prices.mjs:

js
import { RestClientV3 } from 'bitget-api';

const client = new RestClientV3();

async function main() {
  const response = await client.getTickers({
    category: 'SPOT',
    symbol: 'BTCUSDT',
  });
  console.log('BTCUSDT last price:', response.data[0]?.lastPrice);
}

main().catch((error) => {
  console.error('Public request failed:', error);
  process.exitCode = 1;
});
sh
node prices.mjs

Example output ​

text
BTCUSDT last price: 65000.1

Your price will differ. getTickers() returns tickers in data. The example reads data[0]?.lastPrice, a decimal string, or undefined if no ticker is returned.

Module formats ​

The .mjs extension selects ES modules. For CommonJS, save a .cjs file and replace the import with const { RestClientV3 } = require('bitget-api'), retaining the async function. TypeScript uses the same import with the SDK's included types.

Market data · Streaming · Choose UTA or Classic · Runtime setup

TypeScript integrations ​

The SDK works with both JavaScript and TypeScript. TypeScript is optional, but we strongly recommend it for SDK integrations: the included types help catch invalid method names, parameter shapes and response assumptions at build time, before requests reach the exchange. If you choose TypeScript, follow the TypeScript setup and run npx tsc --noEmit during development and CI. Type checking does not replace runtime validation or exchange-side checks.

Some runtimes can execute TypeScript directly. For example, Node.js type stripping supports erasable TypeScript syntax without a separate compiler, but does not check types. If your runtime cannot execute the syntax used by a TypeScript example, compile that example to JavaScript or use a compatible TypeScript runner. Examples with local .js imports that refer to TypeScript source files can use the compiler-based setup above. Plain JavaScript usage does not need any TypeScript tooling.

See Demo trading for setup, credentials and limitations.

Built by Siebly. Open source SDKs for exchange APIs.