Registry / cryptocurrency / bitget-api

bitget-api

JSON →
library3.1.8jsnpmunverified

Complete Node.js & JavaScript SDK for Bitget V2 REST APIs and WebSockets, plus V3/UTA REST APIs and WebSockets. Version 3.1.8 is actively maintained (released weekly, over 100 e2e tests per release). It is an officially listed SDK in Bitget API docs. Supports HMAC and RSA authentication, proxy, browser usage via webpack, and full TypeScript types. Differentiators: robust WebSocket auto-reconnect, promise-driven interface, extensive automated testing, and active community on Telegram.

npm install bitget-api
INSTALL
IMPORT
SIG · BITGET-API
B
bitget-api
cryptocurrencyjavascriptv3.1.8
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BitgetRestClient
import { BitgetRestClient } from 'bitget-api';
const BitgetRestClient = require('bitget-api').BitgetRestClient;
Package is ESM-first; named import is standard. CJS require also works but named import is preferred for tree-shaking.
BitgetWsClient
import { BitgetWsClient } from 'bitget-api';
import BitgetWsClient from 'bitget-api';
BitgetWsClient is a named export, not default. Common mistake: using default import.
USDT_FUTURES_PROD
import { USDT_FUTURES_PROD } from 'bitget-api';
Constant for environment URLs. Available for REST and WebSocket endpoints.

Initializes the Bitget REST client with credentials and fetches account assets. Uses environment variables for keys.

import { BitgetRestClient } from 'bitget-api'; const client = new BitgetRestClient({ apiKey: process.env.API_KEY ?? '', apiSecret: process.env.API_SECRET ?? '', apiPass: process.env.API_PASS ?? '', }); // Example: Get account assets client.getAccountAssets().then(result => { console.log('Account assets:', result); }).catch(err => { console.error('Error:', err); });
Debug
Known issues
gotchaWhen using WebSocket client, the 'open' event fires before authentication completes; wait for 'login' or 'authenticated' event to ensure subscription calls work.
fix
Subscribe in the 'login' callback: client.on('login', () => { client.subscribe(...); });
affects: >=0.0.1
deprecatedV1 API support was removed in v3.0.0. Use V2 or V3 (UTA) endpoints.
fix
Migrate to V2 or V3 endpoints. See migration guide in repo.
affects: >=3.0.0
breakingThe package switched from CJS to ESM in v3.0.0. require() still works but named imports are now required for tree-shaking.
fix
Use import statements instead of require for TypeScript; if using CommonJS, use named destructuring.
affects: >=3.0.0
breakingIn v3.1.0, the default export was removed. All exports are now named.
fix
Change default import to named import, e.g., import { BitgetRestClient } from 'bitget-api';
affects: >=3.1.0
gotchaAPI credentials: apiPass is required for V3 endpoints. For V2, it may be optional depending on account configuration.
fix
Always provide apiPass when using V3 clients; for V2 check Bitget documentation.
affects: >=0.0.1
deprecatedRSA key passphrase is deprecated in favor of direct RSA key without passphrase. Support may be removed in future versions.
fix
Use RSA keys without passphrase.
affects: >=3.0.0
gotchaWebSocket reconnection will re-subscribe automatically, but any pending orders or state may be lost. Implement idempotent logic.
fix
Monitor reconnect event and re-subscribe with idempotent message IDs.
affects: >=0.0.1
Errors
Common errors & fixes
Missing required parameter: apiPass
V3 client instantiated without apiPass in config.
fix
Add apiPass: 'your-passphrase' when creating V3 client.
TypeError: client.getAccountAssets is not a function
Using default import instead of named import, resulting in undefined client.
fix
Use named import: import { BitgetRestClient } from 'bitget-api';
WebSocket connection failed: 401 Unauthorized
WebSocket authentication failed due to incorrect apiKey, apiSecret, or apiPass.
fix
Verify credentials and timestamp. Ensure apiPass is provided for V3 WebSocket.
Cannot find module 'bitget-api'
Package not installed or wrong import path when using TypeScript.
fix
Run: npm install bitget-api
Error: "order placement via websocket" is only available for V3
Trying to place orders via WebSocket on V2 client.
fix
Use V3 WebSocket client for order placement: new BitgetWsClient({ wsUrl: USDT_FUTURES_PROD })
Upgrade
Version history
3.1.8latest on npm
Audit
Dependencies
axiosoptionalUsed internally for HTTP requests; no need to install separately.
wsoptionalUsed internally for WebSocket connections; no need to install separately.
crypto-jsoptionalUsed for HMAC & RSA signature generation.
Agent activity
48 hits · last 30 days
node
44
Perplexity
1
OpenAI (training)
1
Resources
bitget-api — npm install bitget-api · libregistry