SDK guide
JavaScript
REST API + WebSocket

Bitget JavaScript SDK

Build with the Bitget REST API & WebSockets with our JavaScript SDK, TypeScript-first package declarations, and Node.js-compatible runtime patterns. Discover installation, common examples, a detailed endpoint-to-function map, and the REST API/WebSocket patterns shared across our Siebly SDK family.

Use the same TypeScript-first REST API and WebSocket clients from plain JavaScript or TypeScript in Node.js-compatible runtimes.

Package surfaces

Explore the following API capabilities are covered by our Bitget SDK:

  • Spot
  • Copy
  • Futures
  • WebSockets
  • WebSocket clients with:
    • Built-in heartbeats.
    • Automatic reconnection.
    • Automatic reauthentication and resubscribe where the exchange supports it.
  • Typed requests and responses for Node.js, JavaScript, and TypeScript IDEs.
  • Framework-neutral JavaScript snippets that stay approachable in Node.js-compatible runtimes.
  • TypeScript-first package declarations for stricter services, shared libraries, and editor-assisted integrations.

Install Bitget SDK

# Via your favourite package manager, e.g. npm:
npm install bitget-api
# or pnpm:
pnpm install bitget-api
# or yarn:
yarn add bitget-api

Quickstart Examples with the Bitget JavaScript SDK

Get started with just a few lines of JavaScript. TypeScript, while not required, is absolutely recommended. TypeScript declarations are included with all our SDKs and provide convenient definitions on request & response fields, WebSocket payloads, and generally safer integrations.

REST walkthrough

Easily start calling Bitget's V2 spot REST APIs in JavaScript.

  • Install the Bitget JavaScript SDK via NPM: npm install bitget-api.
  • Import the RestClientV2 class (REST API wrapper for Bitget's V2 APIs) and WebsocketClientV2.
    • Note: for Bitget's V3 (UTA) APIs, you can use RestClientV3 and WebsocketClientV3 instead. Examples can be found on GitHub.
  • Create client instances with your API credentials (different key types are automatically detected & handled).
  • Call REST API methods as functions and await the promise containing the response.

In this example, we:

  • Open a private WebSocket connection and subscribe to account and order updates for spot.
  • Query account spot balances and find the available BTC balance.
  • Query symbol trading rules for BTCUSDT and select the minimum trade quantity.
  • Submit a market sell order using that quantity and log the response.

This setup demonstrates using REST and private WebSocket streams together, so you can place trades while receiving live account updates at the same time.

For a full map of available REST API methods, check out the endpoint reference below.

import {  RestClientV2,  SpotOrderRequestV2,  WebsocketClientV2,} from 'bitget-api'; // read from environmental variablesconst API_KEY = process.env.API_KEY_COM;const API_SECRET = process.env.API_SECRET_COM;const API_PASS = process.env.API_PASS_COM; // If running from CLI in unix, you can pass env vars as such:// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/rest-trade-spot.ts // note the single quotes, preventing special characters such as $ from being incorrectly passed const client = new RestClientV2({  apiKey: API_KEY,  apiSecret: API_SECRET,  apiPass: API_PASS,  // apiKey: 'apiKeyHere',  // apiSecret: 'apiSecretHere',  // apiPass: 'apiPassHere',}); const wsClient = new WebsocketClientV2({  apiKey: API_KEY,  apiSecret: API_SECRET,  apiPass: API_PASS,}); function logWSEvent(type: string, data: any) {  console.log(new Date(), `WS ${type} event: `, data);} // simple sleep functionfunction promiseSleep(milliseconds: number) {  return new Promise((resolve) => setTimeout(resolve, milliseconds));} /** This is a simple script wrapped in a immediately invoked function expression, designed to check for any available BTC balance and immediately sell the full amount for USDT */(async () => {  try {    // Add event listeners to log websocket events on account    wsClient.on('update', (data) => logWSEvent('update', data));    wsClient.on('open', (data) => logWSEvent('open', data));    wsClient.on('response', (data) => logWSEvent('response', data));    wsClient.on('reconnect', (data) => logWSEvent('reconnect', data));    wsClient.on('reconnected', (data) => logWSEvent('reconnected', data));    wsClient.on('authenticated', (data) => logWSEvent('authenticated', data));    wsClient.on('exception', (data) => logWSEvent('exception', data));     // Subscribe to private account topics    // spot private    // : account updates    wsClient.subscribeTopic('SPOT', 'account');     // : order updates (note: symbol is required)    wsClient.subscribeTopic('SPOT', 'orders', 'BTCUSDT');     // wait briefly for ws to be ready (could also use the response or authenticated events, to make sure topics are subscribed to before starting)    await promiseSleep(2.5 * 1000);     const balanceResult = await client.getSpotAccountAssets();    const allBalances = balanceResult.data;     const balanceBTC = allBalances.find(      (bal) => bal.coin === 'BTC' || bal.coin === 'btc',    );    const btcAmount = balanceBTC ? Number(balanceBTC.available) : 0;    // console.log('balance: ', JSON.stringify(balances, null, 2));    console.log('BTC balance result: ', balanceBTC);     if (!btcAmount) {      console.error('No BTC to trade');      return;    }     console.log(`BTC available: ${btcAmount}`);    const symbol = 'BTCUSDT';     const symbolsResult = await client.getSpotSymbolInfo();    const btcRules = symbolsResult.data.find((rule) => rule.symbol === symbol);    console.log('btc trading rules: ', btcRules);    if (!btcRules) {      return console.log('no rules found for trading ' + symbol);    }     const quantity = btcRules.minTradeAmount;     const order: SpotOrderRequestV2 = {      symbol: symbol,      side: 'sell',      orderType: 'market',      force: 'gtc',      size: quantity,    } as const;     console.log('submitting order: ', order);     const sellResult = await client.spotSubmitOrder(order);     console.log('sell result: ', sellResult);  } catch (e) {    console.error('request failed: ', e);  }})();
Full Bitget course

Bitget API JavaScript Tutorial

A practical JavaScript guide to using bitget-api across Bitget V3/UTA REST, public and private streams, demo trading, WebSocket API commands, and V2/Classic fallback flows.

V3/UTA REST API workflows
Public and private WebSocket streams
Demo trading and WebSocket API commands
Clear V2/Classic boundaries
REST API
WebSocket Streams
WebSocket API
Examples

Your app / service

bot, dashboard, worker

bitget-api

RestClientV3, WebsocketClientV3, WebsocketAPIClient

Bitget APIs

V3/UTA REST, streams, WebSocket API, Classic fallbacks

Common Bitget implementation tasks

Start from the behavior you need, not just from REST or WebSocket as a transport. Market-data driven systems should be event driven. Backfill via the REST API once and let WebSockets passively stream new data to you, as it becomes available.

Endpoint Function Reference

Endpoint maps

Each REST client is a JavaScript class, which provides functions individually mapped to each endpoint available in the exchange's API offering.

The following table shows all methods available in each REST client, whether the method requires authentication (automatically handled if API keys are provided), as well as the exact endpoint each method is connected to.

This can be used to easily find which method to call, once you have found which endpoint you're looking to use.

All REST clients are in the src folder. For usage examples, make sure to check the examples folder.

List of clients:

If anything is missing or wrong, please open an issue or let us know in our Node.js Traders telegram group!

How to use table

Table consists of 4 parts:

  • Function name
  • AUTH
  • HTTP Method
  • Endpoint

Function name is the name of the function that can be called through the SDK. Check examples folder in the repo for more help on how to use them!

AUTH is a boolean value that indicates if the function requires authentication - which means you need to pass your API key and secret to the SDK.

HTTP Method shows HTTP method that the function uses to call the endpoint. Sometimes endpoints can have same URL, but different HTTP method so you can use this column to differentiate between them.

Endpoint is the URL that the function uses to call the endpoint. Best way to find exact function you need for the endpoint is to search for URL in this table and find corresponding function name.

rest-client-v2.ts

This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in rest-client-v2.ts.

FunctionAUTHHTTP MethodEndpoint
getAnnouncements()GET/api/v2/public/annoucements
getServerTime()GET/api/v2/public/time
getTradeRate()🔐GET/api/v2/common/trade-rate
getSpotTransactionRecords()🔐GET/api/v2/tax/spot-record
getFuturesTransactionRecords()🔐GET/api/v2/tax/future-record
getMarginTransactionRecords()🔐GET/api/v2/tax/margin-record
getP2PTransactionRecords()🔐GET/api/v2/tax/p2p-record
getP2PMerchantList()🔐GET/api/v2/p2p/merchantList
getP2PMerchantInfo()🔐GET/api/v2/p2p/merchantInfo
getP2PMerchantOrders()🔐GET/api/v2/p2p/orderList
getP2PMerchantAdvertisementList()🔐GET/api/v2/p2p/advList
getSpotWhaleNetFlowData()🔐GET/api/v2/spot/market/whale-net-flow
getFuturesActiveTakerBuySellVolumeData()GET/api/v2/mix/market/taker-buy-sell
getFuturesActiveLongShortPositionData()GET/api/v2/mix/market/position-long-short
getFuturesLongShortRatio()GET/api/v2/mix/market/long-short-ratio
getMarginLoanGrowthRate()GET/api/v2/mix/market/loan-growth
getIsolatedMarginBorrowingRatio()GET/api/v2/mix/market/isolated-borrow-rate
getFuturesActiveBuySellVolumeData()GET/api/v2/mix/market/long-short
getSpotFundFlow()GET/api/v2/spot/market/fund-flow
getTradeDataSupportSymbols()GET/api/v2/spot/market/support-symbols
getSpotFundNetFlowData()GET/api/v2/spot/market/fund-net-flow
getFuturesActiveLongShortAccountData()GET/api/v2/mix/market/account-long-short
createVirtualSubaccount()🔐POST/api/v2/user/create-virtual-subaccount
modifyVirtualSubaccount()🔐POST/api/v2/user/modify-virtual-subaccount
batchCreateVirtualSubaccountAndAPIKey()🔐POST/api/v2/user/batch-create-subaccount-and-apikey
getVirtualSubaccounts()🔐GET/api/v2/user/virtual-subaccount-list
createVirtualSubaccountAPIKey()🔐POST/api/v2/user/create-virtual-subaccount-apikey
modifyVirtualSubaccountAPIKey()🔐POST/api/v2/user/modify-virtual-subaccount-apikey
getVirtualSubaccountAPIKeys()🔐GET/api/v2/user/virtual-subaccount-apikey-list
createAgentSubaccount()🔐POST/api/v2/user/create-agent-subaccount
getFundingAssets()🔐GET/api/v2/account/funding-assets
getBotAccount()🔐GET/api/v2/account/bot-assets
getBalances()🔐GET/api/v2/account/all-account-balance
getConvertCoins()🔐GET/api/v2/convert/currencies
getConvertQuotedPrice()🔐GET/api/v2/convert/quoted-price
convert()🔐POST/api/v2/convert/trade
getConvertHistory()🔐GET/api/v2/convert/convert-record
getConvertBGBCoins()🔐GET/api/v2/convert/bgb-convert-coin-list
convertBGB()🔐POST/api/v2/convert/bgb-convert
getConvertBGBHistory()🔐GET/api/v2/convert/bgb-convert-records
getSpotCoinInfo()🔐GET/api/v2/spot/public/coins
getSpotSymbolInfo()🔐GET/api/v2/spot/public/symbols
getSpotVIPFeeRate()🔐GET/api/v2/spot/market/vip-fee-rate
getSpotTicker()🔐GET/api/v2/spot/market/tickers
getSpotMergeDepth()🔐GET/api/v2/spot/market/merge-depth
getSpotOrderBookDepth()🔐GET/api/v2/spot/market/orderbook
getSpotCandles()🔐GET/api/v2/spot/market/candles
getSpotHistoricCandles()🔐GET/api/v2/spot/market/history-candles
getSpotRecentTrades()🔐GET/api/v2/spot/market/fills
getSpotHistoricTrades()🔐GET/api/v2/spot/market/fills-history
spotSubmitOrder()🔐POST/api/v2/spot/trade/place-order
spotCancelandSubmitOrder()🔐POST/api/v2/spot/trade/cancel-replace-order
spotBatchCancelandSubmitOrder()🔐POST/api/v2/spot/trade/batch-cancel-replace-order
spotCancelOrder()🔐POST/api/v2/spot/trade/cancel-order
spotBatchSubmitOrders()🔐POST/api/v2/spot/trade/batch-orders
spotBatchCancelOrders()🔐POST/api/v2/spot/trade/batch-cancel-order
spotCancelSymbolOrder()🔐POST/api/v2/spot/trade/cancel-symbol-order
getSpotOrder()🔐GET/api/v2/spot/trade/orderInfo
getSpotOpenOrders()🔐GET/api/v2/spot/trade/unfilled-orders
getSpotHistoricOrders()🔐GET/api/v2/spot/trade/history-orders
getSpotFills()🔐GET/api/v2/spot/trade/fills
spotSubmitPlanOrder()🔐POST/api/v2/spot/trade/place-plan-order
spotModifyPlanOrder()🔐POST/api/v2/spot/trade/modify-plan-order
spotCancelPlanOrder()🔐POST/api/v2/spot/trade/cancel-plan-order
getSpotCurrentPlanOrders()🔐GET/api/v2/spot/trade/current-plan-order
getSpotPlanSubOrder()🔐GET/api/v2/spot/trade/plan-sub-order
getSpotHistoricPlanOrders()🔐GET/api/v2/spot/trade/history-plan-order
spotCancelPlanOrders()🔐POST/api/v2/spot/trade/batch-cancel-plan-order
getSpotAccount()🔐GET/api/v2/spot/account/info
getSpotAccountAssets()🔐GET/api/v2/spot/account/assets
getSpotSubAccountAssets()🔐GET/api/v2/spot/account/subaccount-assets
spotModifyDepositAccount()🔐POST/api/v2/spot/wallet/modify-deposit-account
getSpotAccountBills()🔐GET/api/v2/spot/account/bills
spotTransfer()🔐POST/api/v2/spot/wallet/transfer
getSpotTransferableCoins()🔐GET/api/v2/spot/wallet/transfer-coin-info
spotSubTransfer()🔐POST/api/v2/spot/wallet/subaccount-transfer
spotWithdraw()🔐POST/api/v2/spot/wallet/withdrawal
getSpotMainSubTransferRecord()🔐GET/api/v2/spot/account/sub-main-trans-record
getSpotTransferHistory()🔐GET/api/v2/spot/account/transferRecords
spotSwitchBGBDeduct()🔐POST/api/v2/spot/account/switch-deduct
getSpotDepositAddress()🔐GET/api/v2/spot/wallet/deposit-address
getSpotSubDepositAddress()🔐GET/api/v2/spot/wallet/subaccount-deposit-address
getSpotBGBDeductInfo()🔐GET/api/v2/spot/account/deduct-info
spotCancelWithdrawal()🔐POST/api/v2/spot/wallet/cancel-withdrawal
getSubAccountDepositRecords()🔐GET/api/v2/spot/wallet/subaccount-deposit-records
getSpotWithdrawalHistory()🔐GET/api/v2/spot/wallet/withdrawal-records
getSpotDepositHistory()🔐GET/api/v2/spot/wallet/deposit-records
upgradeToUnifiedAccount()🔐POST/api/v2/spot/account/upgrade
getUnifiedAccountSwitchStatus()🔐GET/api/v2/spot/account/upgrade-status
getFuturesVIPFeeRate()GET/api/v2/mix/market/vip-fee-rate
getFuturesInterestRateHistory()GET/api/v2/mix/market/union-interest-rate-history
getFuturesInterestExchangeRate()GET/api/v2/mix/market/exchange-rate
getFuturesDiscountRate()GET/api/v2/mix/market/discount-rate
getFuturesMergeDepth()GET/api/v2/mix/market/merge-depth
getFuturesTicker()GET/api/v2/mix/market/ticker
getFuturesAllTickers()GET/api/v2/mix/market/tickers
getFuturesRecentTrades()GET/api/v2/mix/market/fills
getFuturesHistoricTrades()GET/api/v2/mix/market/fills-history
getFuturesCandles()GET/api/v2/mix/market/candles
getFuturesHistoricCandles()GET/api/v2/mix/market/history-candles
getFuturesHistoricIndexPriceCandles()GET/api/v2/mix/market/history-index-candles
getFuturesHistoricMarkPriceCandles()GET/api/v2/mix/market/history-mark-candles
getFuturesOpenInterest()GET/api/v2/mix/market/open-interest
getFuturesNextFundingTime()GET/api/v2/mix/market/funding-time
getFuturesSymbolPrice()GET/api/v2/mix/market/symbol-price
getFuturesHistoricFundingRates()GET/api/v2/mix/market/history-fund-rate
getFuturesCurrentFundingRate()GET/api/v2/mix/market/current-fund-rate
getFuturesContractConfig()GET/api/v2/mix/market/contracts
getFuturesAccountAsset()🔐GET/api/v2/mix/account/account
getFuturesAccountAssets()🔐GET/api/v2/mix/account/accounts
getFuturesSubAccountAssets()🔐GET/api/v2/mix/account/sub-account-assets
getFuturesInterestHistory()🔐GET/api/v2/mix/account/interest-history
getFuturesOpenCount()🔐GET/api/v2/mix/account/open-count
setFuturesPositionAutoMargin()🔐POST/api/v2/mix/account/set-auto-margin
setFuturesLeverage()🔐POST/api/v2/mix/account/set-leverage
setFuturesPositionMargin()🔐POST/api/v2/mix/account/set-margin
setFuturesAssetMode()🔐POST/api/v2/mix/account/set-asset-mode
setFuturesMarginMode()🔐POST/api/v2/mix/account/set-margin-mode
setFuturesPositionMode()🔐POST/api/v2/mix/account/set-position-mode
getFuturesAccountBills()🔐GET/api/v2/mix/account/bill
getUnionTransferLimits()🔐GET/api/v2/mix/account/transfer-limits
getUnionConfig()🔐GET/api/v2/mix/account/union-config
getSwitchUnionUsdt()🔐GET/api/v2/mix/account/switch-union-usdt
unionConvert()🔐POST/api/v2/mix/account/union-convert
getFuturesMaxOpenableQuantity()🔐GET/api/v2/mix/account/max-open
getFuturesLiquidationPrice()🔐GET/api/v2/mix/account/liq-price
getFuturesIsolatedSymbols()🔐GET/api/v2/mix/account/isolated-symbols
getFuturesPositionTier()GET/api/v2/mix/market/query-position-lever
getFuturesPosition()🔐GET/api/v2/mix/position/single-position
getFuturesPositions()🔐GET/api/v2/mix/position/all-position
getFuturesHistoricPositions()🔐GET/api/v2/mix/position/history-position
futuresSubmitOrder()🔐POST/api/v2/mix/order/place-order
futuresSubmitReversal()🔐POST/api/v2/mix/order/click-backhand
futuresBatchSubmitOrders()🔐POST/api/v2/mix/order/batch-place-order
futuresModifyOrder()🔐POST/api/v2/mix/order/modify-order
futuresCancelOrder()🔐POST/api/v2/mix/order/cancel-order
futuresBatchCancelOrders()🔐POST/api/v2/mix/order/batch-cancel-orders
futuresFlashClosePositions()🔐POST/api/v2/mix/order/close-positions
getFuturesOrder()🔐GET/api/v2/mix/order/detail
getFuturesFills()🔐GET/api/v2/mix/order/fills
getFuturesHistoricOrderFills()🔐GET/api/v2/mix/order/fill-history
getFuturesOpenOrders()🔐GET/api/v2/mix/order/orders-pending
getFuturesHistoricOrders()🔐GET/api/v2/mix/order/orders-history
futuresCancelAllOrders()🔐POST/api/v2/mix/order/cancel-all-orders
getFuturesTriggerSubOrder()🔐GET/api/v2/mix/order/plan-sub-order
futuresSubmitTPSLOrder()🔐POST/api/v2/mix/order/place-tpsl-order
futuresSubmitPlanOrder()🔐POST/api/v2/mix/order/place-plan-order
futuresModifyTPSLPOrder()🔐POST/api/v2/mix/order/modify-tpsl-order
futuresModifyPlanOrder()🔐POST/api/v2/mix/order/modify-plan-order
getFuturesPlanOrders()🔐GET/api/v2/mix/order/orders-plan-pending
futuresCancelPlanOrder()🔐POST/api/v2/mix/order/cancel-plan-order
getFuturesHistoricPlanOrders()🔐GET/api/v2/mix/order/orders-plan-history
modifySubaccountEmail()🔐POST/api/v2/broker/account/modify-subaccount-email
getBrokerInfo()🔐GET/api/v2/broker/account/info
createSubaccount()🔐POST/api/v2/broker/account/create-subaccount
getSubaccounts()🔐GET/api/v2/broker/account/subaccount-list
modifySubaccount()🔐POST/api/v2/broker/account/modify-subaccount
getSubaccountEmail()🔐GET/api/v2/broker/account/subaccount-email
getSubaccountSpotAssets()🔐GET/api/v2/broker/account/subaccount-spot-assets
getSubaccountFuturesAssets()🔐GET/api/v2/broker/account/subaccount-future-assets
createSubaccountDepositAddress()🔐POST/api/v2/broker/account/subaccount-address
subaccountWithdrawal()🔐POST/api/v2/broker/account/subaccount-withdrawal
subaccountSetAutoTransfer()🔐POST/api/v2/broker/account/set-subaccount-autotransfer
subaccountDepositRecords()🔐GET/api/v2/broker/subaccount-deposit
subaccountWithdrawalRecords()🔐GET/api/v2/broker/subaccount-withdrawal
createSubaccountApiKey()🔐POST/api/v2/broker/manage/create-subaccount-apikey
getSubaccountApiKey()🔐GET/api/v2/broker/manage/subaccount-apikey-list
modifySubaccountApiKey()🔐POST/api/v2/broker/manage/modify-subaccount-apikey
getAllSubDepositWithdrawalRecords()🔐GET/api/v2/broker/all-sub-deposit-withdrawal
getBrokerSubaccounts()🔐GET/api/v2/broker/subaccounts
getBrokerCommissions()🔐GET/api/v2/broker/commissions
getBrokerTradeVolume()🔐GET/api/v2/broker/trade-volume
getBrokerTotalCommission()🔐GET/api/v2/broker/total-commission
getBrokerOrderCommission()🔐GET/api/v2/broker/order-commission
getBrokerRebateInfo()🔐GET/api/v2/broker/rebate-info
getAgentCustomerCommissions()🔐GET/api/v2/broker/customer-commissions
getAgentSubCustomerList()🔐GET/api/v2/broker/sub-customer-list
getAgentCustomerTradeVolume()🔐POST/api/v2/broker/customer-trade-volume
getAgentCustomerList()🔐POST/api/v2/broker/customer-list
getAgentCustomerKycResult()🔐GET/api/v2/broker/customer-kyc-result
getAgentCustomerDeposits()🔐POST/api/v2/broker/customer-deposit
getAgentCustomerAssets()🔐POST/api/v2/broker/customer-asset
getAgentCommissionDetail()🔐GET/api/v2/broker/agent-commission
getMarginCurrencies()GET/api/v2/margin/currencies
getMarginBorrowHistory()🔐GET/api/v2/margin/${marginType}/borrow-history
getMarginRepayHistory()🔐GET/api/v2/margin/${marginType}/repay-history
getMarginInterestHistory()🔐GET/api/v2/margin/${marginType}/interest-history
getMarginLiquidationHistory()🔐GET/api/v2/margin/${marginType}/liquidation-history
getMarginFinancialHistory()🔐GET/api/v2/margin/${marginType}/financial-records
getMarginAccountAssets()🔐GET/api/v2/margin/${marginType}/account/assets
marginBorrow()🔐POST/api/v2/margin/${marginType}/account/borrow
marginRepay()🔐POST/api/v2/margin/${marginType}/account/repay
getMarginRiskRate()🔐GET/api/v2/margin/${marginType}/account/risk-rate
getMarginMaxBorrowable()🔐GET/api/v2/margin/${marginType}/account/max-borrowable-amount
getMarginMaxTransferable()🔐GET/api/v2/margin/${marginType}/account/max-transfer-out-amount
getMarginInterestRateAndMaxBorrowable()🔐GET/api/v2/margin/${marginType}/interest-rate-and-limit
getMarginTierConfiguration()🔐GET/api/v2/margin/${marginType}/tier-data
marginFlashRepay()🔐POST/api/v2/margin/${marginType}/account/flash-repay
getMarginFlashRepayResult()🔐GET/api/v2/margin/${marginType}/account/query-flash-repay-status
marginSubmitOrder()🔐POST/api/v2/margin/${marginType}/place-order
marginBatchSubmitOrders()🔐POST/api/v2/margin/${marginType}/batch-place-order
marginCancelOrder()🔐POST/api/v2/margin/${marginType}/cancel-order
marginBatchCancelOrders()🔐POST/api/v2/margin/${marginType}/batch-cancel-order
getMarginOpenOrders()🔐GET/api/v2/margin/${marginType}/open-orders
getMarginHistoricOrders()🔐GET/api/v2/margin/${marginType}/history-orders
getMarginHistoricOrderFills()🔐GET/api/v2/margin/${marginType}/fills
getMarginLiquidationOrders()🔐GET/api/v2/margin/${marginType}/liquidation-order
getFuturesTraderCurrentOrder()🔐GET/api/v2/copy/mix-trader/order-current-track
getFuturesTraderHistoryOrders()🔐GET/api/v2/copy/mix-trader/order-history-track
modifyFuturesTraderOrderTPSL()🔐POST/api/v2/copy/mix-trader/order-modify-tpsl
getFuturesTraderOrder()🔐GET/api/v2/copy/mix-trader/order-total-detail
getFuturesTraderProfitHistory()🔐GET/api/v2/copy/mix-trader/profit-history-summarys
getFuturesTraderProfitShareHistory()🔐GET/api/v2/copy/mix-trader/profit-history-details
closeFuturesTraderOrder()🔐POST/api/v2/copy/mix-trader/order-close-positions
getFuturesTraderProfitShare()🔐GET/api/v2/copy/mix-trader/profit-details
getFuturesTraderProfitShareGroup()🔐GET/api/v2/copy/mix-trader/profits-group-coin-date
getFuturesTraderSymbolSettings()🔐GET/api/v2/copy/mix-trader/config-query-symbols
updateFuturesTraderSymbolSettings()🔐POST/api/v2/copy/mix-trader/config-setting-symbols
updateFuturesTraderGlobalSettings()🔐POST/api/v2/copy/mix-trader/config-settings-base
getFuturesTraderFollowers()🔐GET/api/v2/copy/mix-trader/config-query-followers
removeFuturesTraderFollower()🔐POST/api/v2/copy/mix-trader/config-remove-follower
getFuturesFollowerCurrentOrders()🔐GET/api/v2/copy/mix-follower/query-current-orders
getFuturesFollowerHistoryOrders()🔐GET/api/v2/copy/mix-follower/query-history-orders
updateFuturesFollowerTPSL()🔐POST/api/v2/copy/mix-follower/setting-tpsl
updateFuturesFollowerSettings()🔐POST/api/v2/copy/mix-follower/settings
getFuturesFollowerSettings()🔐GET/api/v2/copy/mix-follower/query-settings
closeFuturesFollowerPositions()🔐POST/api/v2/copy/mix-follower/close-positions
getFuturesFollowerTraders()🔐GET/api/v2/copy/mix-follower/query-traders
getFuturesFollowerFollowLimit()🔐GET/api/v2/copy/mix-follower/query-quantity-limit
unfollowFuturesTrader()🔐POST/api/v2/copy/mix-follower/cancel-trader
getBrokerTraders()🔐GET/api/v2/copy/mix-broker/query-traders
getBrokerTradersHistoricalOrders()🔐GET/api/v2/copy/mix-broker/query-history-traces
getBrokerTradersPendingOrders()🔐GET/api/v2/copy/mix-broker/query-current-traces
getSpotTraderProfit()🔐GET/api/v2/copy/spot-trader/profit-summarys
getSpotTraderHistoryProfit()🔐GET/api/v2/copy/spot-trader/profit-history-details
getSpotTraderUnrealizedProfit()🔐GET/api/v2/copy/spot-trader/profit-details
getSpotTraderOrder()🔐GET/api/v2/copy/spot-trader/order-total-detail
modifySpotTraderOrderTPSL()🔐POST/api/v2/copy/spot-trader/order-modify-tpsl
getSpotTraderHistoryOrders()🔐GET/api/v2/copy/spot-trader/order-history-track
getSpotTraderCurrentOrders()🔐GET/api/v2/copy/spot-trader/order-current-track
sellSpotTrader()🔐POST/api/v2/copy/spot-trader/order-close-tracking
getSpotTraderSymbolSettings()🔐POST/api/v2/copy/spot-trader/config-setting-symbols
removeSpotTraderFollowers()🔐POST/api/v2/copy/spot-trader/config-remove-follower
getSpotTraderConfiguration()🔐GET/api/v2/copy/spot-trader/config-query-settings
getSpotTraderFollowers()🔐GET/api/v2/copy/spot-trader/config-query-followers
cancelSpotFollowerOrder()🔐POST/api/v2/copy/spot-follower/stop-order
updateSpotFollowerSettings()🔐POST/api/v2/copy/spot-follower/settings
updateSpotFollowerTPSL()🔐POST/api/v2/copy/spot-follower/setting-tpsl
getSpotFollowerTraders()🔐GET/api/v2/copy/spot-follower/query-traders
getSpotFollowerCurrentTraderSymbols()🔐GET/api/v2/copy/spot-follower/query-trader-symbols
getSpotFollowerSettings()🔐GET/api/v2/copy/spot-follower/query-settings
getSpotFollowerHistoryOrders()🔐GET/api/v2/copy/spot-follower/query-history-orders
getSpotFollowerOpenOrders()🔐GET/api/v2/copy/spot-follower/query-current-orders
sellSpotFollower()🔐POST/api/v2/copy/spot-follower/order-close-tracking
unfollowSpotTrader()🔐POST/api/v2/copy/spot-follower/cancel-trader
getEarnSavingsProducts()🔐GET/api/v2/earn/savings/product
getEarnSavingsAccount()🔐GET/api/v2/earn/savings/account
getEarnSavingsAssets()🔐GET/api/v2/earn/savings/assets
getEarnSavingsRecords()🔐GET/api/v2/earn/savings/records
getEarnSavingsSubscription()🔐GET/api/v2/earn/savings/subscribe-info
earnSubscribeSavings()🔐POST/api/v2/earn/savings/subscribe
getEarnSavingsSubscriptionResult()🔐GET/api/v2/earn/savings/subscribe-result
earnRedeemSavings()🔐POST/api/v2/earn/savings/redeem
getEarnSavingsRedemptionResult()🔐GET/api/v2/earn/savings/redeem-result
getEarnAccount()🔐GET/api/v2/earn/account/assets
getEarnEliteProducts()🔐GET/api/v2/earn/elite/product
getEarnEliteAssets()🔐GET/api/v2/earn/elite/assets
getEarnEliteRecords()🔐GET/api/v2/earn/elite/records
getEarnEliteSubscribeInfo()🔐GET/api/v2/earn/elite/subscribe-info
subscribeEarnElite()🔐POST/api/v2/earn/elite/subscribe
getEarnEliteSubscribeResult()🔐GET/api/v2/earn/elite/subscribe-result
getEarnEliteRedeemInfo()🔐GET/api/v2/earn/elite/redeem-info
redeemEarnElite()🔐POST/api/v2/earn/elite/redeem
getSharkfinProducts()🔐GET/api/v2/earn/sharkfin/product
getSharkfinAccount()🔐GET/api/v2/earn/sharkfin/account
getSharkfinAssets()🔐GET/api/v2/earn/sharkfin/assets
getSharkfinRecords()🔐GET/api/v2/earn/sharkfin/records
getSharkfinSubscription()🔐GET/api/v2/earn/sharkfin/subscribe-info
subscribeSharkfin()🔐POST/api/v2/earn/sharkfin/subscribe
getSharkfinSubscriptionResult()🔐GET/api/v2/earn/sharkfin/subscribe-result
getLoanCurrencies()GET/api/v2/earn/loan/public/coinInfos
getLoanEstInterestAndBorrowable()GET/api/v2/earn/loan/public/hour-interest
borrowLoan()🔐POST/api/v2/earn/loan/borrow
getOngoingLoanOrders()🔐GET/api/v2/earn/loan/ongoing-orders
repayLoan()🔐POST/api/v2/earn/loan/repay
getRepayHistory()🔐GET/api/v2/earn/loan/repay-history
updateLoanPledgeRate()🔐POST/api/v2/earn/loan/revise-pledge
getLoanPledgeRateHistory()🔐GET/api/v2/earn/loan/revise-history
getLoanHistory()🔐GET/api/v2/earn/loan/borrow-history
getLoanDebts()🔐GET/api/v2/earn/loan/debts
getLoanLiquidationRecords()🔐GET/api/v2/earn/loan/reduces

rest-client-v3.ts

This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in rest-client-v3.ts.

FunctionAUTHHTTP MethodEndpoint
getServerTime()GET/api/v3/public/time
getInstruments()GET/api/v3/market/instruments
getMarketFeeGroup()GET/api/v3/market/fee-group
getLiquidations()GET/api/v3/market/liquidations
getRpiSymbols()GET/api/v3/market/rpi-symbols
getRpiOrderBook()GET/api/v3/market/rpi-orderbook
getCashDividendRecords()GET/api/v3/market/cash-dividend-records
getSpotWhaleFlow()GET/api/v3/market/spot-whale-flow
getSpotFundFlow()GET/api/v3/market/spot-fund-flow
getSpotNetFlow()GET/api/v3/market/spot-net-flow
getMarginLongShort()GET/api/v3/market/margin-long-short
getMarginLoanGrowth()GET/api/v3/market/margin-loan-growth
getMarginIsolatedBorrow()GET/api/v3/market/margin-isolated-borrow
getFuturesActiveBuySell()GET/api/v3/market/futures-active-buy-sell
getFuturesLongShort()GET/api/v3/market/futures-long-short
getFuturesPositionLongShort()GET/api/v3/market/futures-position-long-short
getFuturesAccountLongShort()GET/api/v3/market/futures-account-long-short
getMarketScoreWeights()GET/api/v3/market/score-weights
getTickers()GET/api/v3/market/tickers
getOrderBook()GET/api/v3/market/orderbook
getFills()GET/api/v3/market/fills
getProofOfReserves()GET/api/v3/market/proof-of-reserves
getOpenInterest()GET/api/v3/market/open-interest
getCandles()GET/api/v3/market/candles
getHistoryCandles()GET/api/v3/market/history-candles
getCurrentFundingRate()GET/api/v3/market/current-fund-rate
getHistoryFundingRate()GET/api/v3/market/history-fund-rate
getRiskReserve()GET/api/v3/market/risk-reserve
getRiskReserveHour()GET/api/v3/market/risk-reserve-hour
getRiskReserveAll()GET/api/v3/market/risk-reserve-all
getDiscountRate()GET/api/v3/market/discount-rate
getMarginLoans()GET/api/v3/market/margin-loans
getPositionTier()GET/api/v3/market/position-tier
getContractsOi()GET/api/v3/market/oi-limit
getIndexComponents()GET/api/v3/market/index-components
getCopyFuturesTradingPairs()🔐GET/api/v3/copy/futures/trading-pairs
getCopyFuturesPositionSummary()🔐GET/api/v3/copy/futures/position-summary
getCopyFuturesMaxTransferable()🔐GET/api/v3/copy/futures/max-transferable
copyFuturesTransfer()🔐POST/api/v3/copy/futures/transfer
getCopyFuturesTransferRecords()🔐GET/api/v3/copy/futures/transfer-record
getBalances()🔐GET/api/v3/account/assets
getFundingAssets()🔐GET/api/v3/account/funding-assets
getAccountInfo()🔐GET/api/v3/account/info
getAccountSettings()🔐GET/api/v3/account/settings
adjustAccountMode()🔐POST/api/v3/account/adjust-account-mode
getDeltaInfo()🔐GET/api/v3/account/delta-info
setLeverage()🔐POST/api/v3/account/set-leverage
setHoldMode()🔐POST/api/v3/account/set-hold-mode
getCollateralType()🔐GET/api/v3/account/collateral-type
setCollateralType()🔐POST/api/v3/account/set-collateral-type
getCustomCollateralCoins()GET/api/v3/account/custom-collateral-coins
preSetLeverage()🔐GET/api/v3/account/pre-set-leverage
setMargin()🔐POST/api/v3/account/set-margin
getMaxWithdrawal()🔐GET/api/v3/account/max-withdrawal
getFinancialRecords()🔐GET/api/v3/account/financial-records
getRepayableCoins()🔐GET/api/v3/account/repayable-coins
getPaymentCoins()🔐GET/api/v3/account/payment-coins
submitRepay()🔐POST/api/v3/account/repay
getConvertRecords()🔐GET/api/v3/account/convert-records
setDepositAccount()🔐POST/api/v3/account/deposit-account
switchDeduct()🔐POST/api/v3/account/switch-deduct
getDeductInfo()🔐GET/api/v3/account/deduct-info
getFeeRate()🔐GET/api/v3/account/fee-rate
getAllFeeRates()🔐GET/api/v3/account/all-fee-rate
getMaxTransferable()🔐GET/api/v3/account/max-transferable
getOpenInterestLimit()🔐GET/api/v3/account/open-interest-limit
downgradeAccountToClassic()🔐POST/api/v3/account/switch
getUnifiedAccountSwitchStatus()🔐GET/api/v3/account/switch-status
getTaxRecords()🔐GET/api/v3/tax/records
createSubAccount()🔐POST/api/v3/user/create-sub
freezeSubAccount()🔐POST/api/v3/user/freeze-sub
getSubUnifiedAssets()🔐GET/api/v3/account/sub-unified-assets
getSubAccountList()🔐GET/api/v3/user/sub-list
createSubAccountApiKey()🔐POST/api/v3/user/create-sub-api
updateSubAccountApiKey()🔐POST/api/v3/user/update-sub-api
deleteSubAccountApiKey()🔐POST/api/v3/user/delete-sub-api
getSubAccountApiKeys()🔐GET/api/v3/user/sub-api-list
getTransferableCoins()🔐GET/api/v3/account/transferable-coins
submitTransfer()🔐POST/api/v3/account/transfer
subAccountTransfer()🔐POST/api/v3/account/sub-transfer
getSubTransferRecords()🔐GET/api/v3/account/sub-transfer-record
getDepositAddress()🔐GET/api/v3/account/deposit-address
getSubDepositAddress()🔐GET/api/v3/account/sub-deposit-address
getDepositRecords()🔐GET/api/v3/account/deposit-records
getSubDepositRecords()🔐POST/api/v3/account/sub-deposit-records
submitWithdraw()🔐POST/api/v3/account/withdraw
getWithdrawRecords()🔐GET/api/v3/account/withdrawal-records
getWithdrawAddressBook()🔐GET/api/v3/account/withdraw-address
cancelWithdrawal()🔐POST/api/v3/account/cancel-withdrawal
submitNewOrder()🔐POST/api/v3/trade/place-order
modifyOrder()🔐POST/api/v3/trade/modify-order
placeRealityOrder()🔐POST/api/v3/trade/place-reality-order
cancelRealityOrder()🔐POST/api/v3/trade/cancel-reality-order
getLoanData()🔐GET/api/v3/trade/loan-data
cancelOrder()🔐POST/api/v3/trade/cancel-order
placeBatchOrders()🔐POST/api/v3/trade/place-batch
batchModifyOrders()🔐POST/api/v3/trade/batch-modify-order
cancelBatchOrders()🔐POST/api/v3/trade/cancel-batch
cancelAllOrders()🔐POST/api/v3/trade/cancel-symbol-order
closeAllPositions()🔐POST/api/v3/trade/close-positions
getOrderInfo()🔐GET/api/v3/trade/order-info
getUnfilledOrders()🔐GET/api/v3/trade/unfilled-orders
getHistoryOrders()🔐GET/api/v3/trade/history-orders
getTradeFills()🔐GET/api/v3/trade/fills
getCurrentPosition()🔐GET/api/v3/position/current-position
getPositionHistory()🔐GET/api/v3/position/history-position
getMaxOpenAvailable()🔐POST/api/v3/account/max-open-available
getPositionAdlRank()🔐GET/api/v3/position/adlRank
countdownCancelAll()🔐POST/api/v3/trade/countdown-cancel-all
getLoanTransfered()🔐GET/api/v3/ins-loan/transfered
getLoanSymbols()🔐GET/api/v3/ins-loan/symbols
getLoanRiskUnit()🔐GET/api/v3/ins-loan/risk-unit
getLoanRepaidHistory()🔐GET/api/v3/ins-loan/repaid-history
getLoanProductInfo()🔐GET/api/v3/ins-loan/product-infos
getLoanOrder()🔐GET/api/v3/ins-loan/loan-order
getLoanLTVConvert()🔐GET/api/v3/ins-loan/ltv-convert
getLoanMarginCoinInfo()🔐GET/api/v3/ins-loan/ensure-coins-convert
bindLoanUid()🔐POST/api/v3/ins-loan/bind-uid
getLoanCoins()🔐GET/api/v3/loan/coins
getLoanInterest()🔐GET/api/v3/loan/interest
loanBorrow()🔐POST/api/v3/loan/borrow
getLoanBorrowOngoing()🔐GET/api/v3/loan/borrow-ongoing
getLoanBorrowHistory()🔐GET/api/v3/loan/borrow-history
loanRepay()🔐POST/api/v3/loan/repay
getLoanRepayHistory()🔐GET/api/v3/loan/repay-history
loanRevisePledge()🔐POST/api/v3/loan/revise-pledge
getLoanPledgeRateHistory()🔐GET/api/v3/loan/pledge-rate-history
getLoanDebts()🔐GET/api/v3/loan/debts
getLoanReduces()🔐GET/api/v3/loan/reduces
submitStrategyOrder()🔐POST/api/v3/trade/place-strategy-order
modifyStrategyOrder()🔐POST/api/v3/trade/modify-strategy-order
cancelStrategyOrder()🔐POST/api/v3/trade/cancel-strategy-order
getUnfilledStrategyOrders()🔐GET/api/v3/trade/unfilled-strategy-orders
getHistoryStrategyOrders()🔐GET/api/v3/trade/history-strategy-orders
createBrokerSubAccount()🔐POST/api/v3/broker/create-sub
getBrokerSubAccountList()🔐GET/api/v3/broker/sub-list
modifyBrokerSubAccount()🔐POST/api/v3/broker/modify-sub
brokerSubWithdrawal()🔐POST/api/v3/broker/sub-withdrawal
getBrokerSubDepositAddress()🔐POST/api/v3/broker/sub-deposit-address
getBrokerAllSubDepositWithdrawal()🔐GET/api/v3/broker/all-sub-deposit-withdrawal
getBrokerCommission()🔐GET/api/v3/broker/commission
createBrokerSubApiKey()🔐POST/api/v3/broker/create-sub-apikey
modifyBrokerSubApiKey()🔐POST/api/v3/broker/modify-sub-apikey
deleteBrokerSubApiKey()🔐POST/api/v3/broker/delete-sub-apikey
getBrokerSubApiKey()🔐GET/api/v3/broker/query-sub-apikey
getP2pAdList()🔐GET/api/v3/p2p/ad-list
getP2pExchangeRate()🔐GET/api/v3/p2p/exchange-rate
simulateP2pFee()🔐POST/api/v3/p2p/fee-simulate
getP2pAdLimit()🔐GET/api/v3/p2p/ad-limit
createP2pAd()🔐POST/api/v3/p2p/ad-create
updateP2pAd()🔐POST/api/v3/p2p/ad-update
operateP2pAd()🔐POST/api/v3/p2p/ad-operate
getP2pAdInfo()🔐GET/api/v3/p2p/ad-info
getP2pMyAds()🔐GET/api/v3/p2p/my-ads
getP2pPendingOrders()🔐GET/api/v3/p2p/pending-orders
getP2pAllOrders()🔐GET/api/v3/p2p/all-orders
getP2pOrderInfo()🔐GET/api/v3/p2p/order-info
confirmP2pOrderPayment()🔐POST/api/v3/p2p/order-pay
releaseP2pOrderAsset()🔐POST/api/v3/p2p/order-release
getP2pUserInfo()🔐GET/api/v3/p2p/user-info
getP2pCurrencies()🔐GET/api/v3/p2p/currencies
getP2pPayMethods()🔐GET/api/v3/p2p/pay-method
getP2pBalance()🔐GET/api/v3/p2p/balance
getEarnEliteProducts()🔐GET/api/v3/earn/elite-product
getEarnEliteAssets()🔐GET/api/v3/earn/elite-assets
getEarnEliteRecords()🔐GET/api/v3/earn/elite-records
getEarnEliteSubscribeInfo()🔐GET/api/v3/earn/elite-subscribe-info
subscribeEarnElite()🔐POST/api/v3/earn/elite-subscribe
getEarnEliteSubscribeResult()🔐GET/api/v3/earn/elite-subscribe-result
getEarnEliteRedeemInfo()🔐GET/api/v3/earn/elite-redeem-info
redeemEarnElite()🔐POST/api/v3/earn/elite-redeem

websocket-api-client.ts

This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in websocket-api-client.ts.

This client provides WebSocket API endpoints which allow for faster interactions with the Bitget API via a WebSocket connection.

FunctionAUTHHTTP MethodEndpoint
submitNewOrder()WSplace-order
placeBatchOrders()WSbatch-place
cancelOrder()WScancel-order
cancelBatchOrders()WSbatch-cancel
View endpoint map sourceShowing the available endpoint reference map.

Bitget JavaScript FAQ

What does the Bitget JavaScript SDK cover?

Bitget supports Spot, Copy, Futures, and WebSockets workflows. The JavaScript guide covers the main REST and WebSocket integration patterns.

How do I authenticate private Bitget API calls in JavaScript?

Install bitget-api from npm & pass API credentials into the SDK client options, as shown in the Bitget JavaScript examples above. The SDK handles the exchange-specific signing requirements for private requests.

Does the Bitget JavaScript SDK help with WebSocket connection management?

Yes. Use the SDK WebSocket client for subscriptions, reconnect handling, and stream lifecycle management instead of building raw socket flows yourself.

Where should I start on the Bitget JavaScript page: REST or WebSocket?

Start with the REST quick start for installation, authentication, and request and response flows. Move to the WebSocket example when you need streaming market or account updates.

Direct Example Files

Continue with implementation resources

Subscribe on Substack

Complete the Substack form below to join our newsletter. Substack handles all subscriber data directly.