diff --git a/docs/endpointFunctionList.md b/docs/endpointFunctionList.md index 2505cb1..98ded34 100644 --- a/docs/endpointFunctionList.md +++ b/docs/endpointFunctionList.md @@ -4,8 +4,8 @@

- - SDK Logo + + SDK Logo

@@ -14,7 +14,7 @@ Each REST client is a JavaScript class, which provides functions individually ma 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](https://github.com/tiagosiebler/awesome-crypto-examples/wiki/How-to-find-SDK-functions-that-match-API-docs-endpoint). +This can be used to easily find which method to call, once you have [found which endpoint you're looking to use](https://github.com/sieblyio/awesome-crypto-examples/wiki/How-to-find-SDK-functions-that-match-API-docs-endpoint). All REST clients are in the [src](/src) folder. For usage examples, make sure to check the [examples](/examples) folder. @@ -50,297 +50,310 @@ This table includes all endpoints from the official Exchange API docs and corres | Function | AUTH | HTTP Method | Endpoint | | -------- | :------: | :------: | -------- | -| [getAnnouncements()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L482) | | GET | `/api/v2/public/annoucements` | -| [getServerTime()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L494) | | GET | `/api/v2/public/time` | -| [getTradeRate()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L502) | :closed_lock_with_key: | GET | `/api/v2/common/trade-rate` | -| [getSpotTransactionRecords()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L517) | :closed_lock_with_key: | GET | `/api/v2/tax/spot-record` | -| [getFuturesTransactionRecords()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L523) | :closed_lock_with_key: | GET | `/api/v2/tax/future-record` | -| [getMarginTransactionRecords()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L529) | :closed_lock_with_key: | GET | `/api/v2/tax/margin-record` | -| [getP2PTransactionRecords()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L535) | :closed_lock_with_key: | GET | `/api/v2/tax/p2p-record` | -| [getP2PMerchantList()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L547) | :closed_lock_with_key: | GET | `/api/v2/p2p/merchantList` | -| [getP2PMerchantInfo()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L556) | :closed_lock_with_key: | GET | `/api/v2/p2p/merchantInfo` | -| [getP2PMerchantOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L560) | :closed_lock_with_key: | GET | `/api/v2/p2p/orderList` | -| [getP2PMerchantAdvertisementList()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L569) | :closed_lock_with_key: | GET | `/api/v2/p2p/advList` | -| [getSpotWhaleNetFlowData()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L586) | :closed_lock_with_key: | GET | `/api/v2/spot/market/whale-net-flow` | -| [getFuturesActiveTakerBuySellVolumeData()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L592) | | GET | `/api/v2/mix/market/taker-buy-sell` | -| [getFuturesActiveLongShortPositionData()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L599) | | GET | `/api/v2/mix/market/position-long-short` | -| [getFuturesLongShortRatio()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L606) | | GET | `/api/v2/mix/market/long-short-ratio` | -| [getMarginLoanGrowthRate()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L614) | | GET | `/api/v2/mix/market/loan-growth` | -| [getIsolatedMarginBorrowingRatio()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L622) | | GET | `/api/v2/mix/market/isolated-borrow-rate` | -| [getFuturesActiveBuySellVolumeData()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L629) | | GET | `/api/v2/mix/market/long-short` | -| [getSpotFundFlow()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L636) | | GET | `/api/v2/spot/market/fund-flow` | -| [getTradeDataSupportSymbols()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L643) | | GET | `/api/v2/spot/market/support-symbols` | -| [getSpotFundNetFlowData()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L652) | | GET | `/api/v2/spot/market/fund-net-flow` | -| [getFuturesActiveLongShortAccountData()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L663) | | GET | `/api/v2/mix/market/account-long-short` | -| [createVirtualSubaccount()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L676) | :closed_lock_with_key: | POST | `/api/v2/user/create-virtual-subaccount` | -| [modifyVirtualSubaccount()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L682) | :closed_lock_with_key: | POST | `/api/v2/user/modify-virtual-subaccount` | -| [batchCreateVirtualSubaccountAndAPIKey()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L690) | :closed_lock_with_key: | POST | `/api/v2/user/batch-create-subaccount-and-apikey` | -| [getVirtualSubaccounts()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L699) | :closed_lock_with_key: | GET | `/api/v2/user/virtual-subaccount-list` | -| [createVirtualSubaccountAPIKey()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L712) | :closed_lock_with_key: | POST | `/api/v2/user/create-virtual-subaccount-apikey` | -| [modifyVirtualSubaccountAPIKey()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L721) | :closed_lock_with_key: | POST | `/api/v2/user/modify-virtual-subaccount-apikey` | -| [getVirtualSubaccountAPIKeys()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L730) | :closed_lock_with_key: | GET | `/api/v2/user/virtual-subaccount-apikey-list` | -| [createAgentSubaccount()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L743) | :closed_lock_with_key: | POST | `/api/v2/user/create-agent-subaccount` | -| [getFundingAssets()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L754) | :closed_lock_with_key: | GET | `/api/v2/account/funding-assets` | -| [getBotAccount()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L760) | :closed_lock_with_key: | GET | `/api/v2/account/bot-assets` | -| [getBalances()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L767) | :closed_lock_with_key: | GET | `/api/v2/account/all-account-balance` | -| [getConvertCoins()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L784) | :closed_lock_with_key: | GET | `/api/v2/convert/currencies` | -| [getConvertQuotedPrice()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L788) | :closed_lock_with_key: | GET | `/api/v2/convert/quoted-price` | -| [convert()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L794) | :closed_lock_with_key: | POST | `/api/v2/convert/trade` | -| [getConvertHistory()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L800) | :closed_lock_with_key: | GET | `/api/v2/convert/convert-record` | -| [getConvertBGBCoins()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L815) | :closed_lock_with_key: | GET | `/api/v2/convert/bgb-convert-coin-list` | -| [convertBGB()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L823) | :closed_lock_with_key: | POST | `/api/v2/convert/bgb-convert` | -| [getConvertBGBHistory()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L829) | :closed_lock_with_key: | GET | `/api/v2/convert/bgb-convert-records` | -| [getSpotCoinInfo()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L849) | :closed_lock_with_key: | GET | `/api/v2/spot/public/coins` | -| [getSpotSymbolInfo()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L855) | :closed_lock_with_key: | GET | `/api/v2/spot/public/symbols` | -| [getSpotVIPFeeRate()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L861) | :closed_lock_with_key: | GET | `/api/v2/spot/market/vip-fee-rate` | -| [getSpotTicker()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L865) | :closed_lock_with_key: | GET | `/api/v2/spot/market/tickers` | -| [getSpotMergeDepth()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L871) | :closed_lock_with_key: | GET | `/api/v2/spot/market/merge-depth` | -| [getSpotOrderBookDepth()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L879) | :closed_lock_with_key: | GET | `/api/v2/spot/market/orderbook` | -| [getSpotCandles()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L887) | :closed_lock_with_key: | GET | `/api/v2/spot/market/candles` | -| [getSpotHistoricCandles()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L893) | :closed_lock_with_key: | GET | `/api/v2/spot/market/history-candles` | -| [getSpotRecentTrades()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L899) | :closed_lock_with_key: | GET | `/api/v2/spot/market/fills` | -| [getSpotHistoricTrades()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L906) | :closed_lock_with_key: | GET | `/api/v2/spot/market/fills-history` | -| [spotSubmitOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L918) | :closed_lock_with_key: | POST | `/api/v2/spot/trade/place-order` | -| [spotCancelandSubmitOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L927) | :closed_lock_with_key: | POST | `/api/v2/spot/trade/cancel-replace-order` | -| [spotBatchCancelandSubmitOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L933) | :closed_lock_with_key: | POST | `/api/v2/spot/trade/batch-cancel-replace-order` | -| [spotCancelOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L942) | :closed_lock_with_key: | POST | `/api/v2/spot/trade/cancel-order` | -| [spotBatchSubmitOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L951) | :closed_lock_with_key: | POST | `/api/v2/spot/trade/batch-orders` | -| [spotBatchCancelOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L957) | :closed_lock_with_key: | POST | `/api/v2/spot/trade/batch-cancel-order` | -| [spotCancelSymbolOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L963) | :closed_lock_with_key: | POST | `/api/v2/spot/trade/cancel-symbol-order` | -| [getSpotOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L971) | :closed_lock_with_key: | GET | `/api/v2/spot/trade/orderInfo` | -| [getSpotOpenOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L977) | :closed_lock_with_key: | GET | `/api/v2/spot/trade/unfilled-orders` | -| [getSpotHistoricOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L983) | :closed_lock_with_key: | GET | `/api/v2/spot/trade/history-orders` | -| [getSpotFills()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L989) | :closed_lock_with_key: | GET | `/api/v2/spot/trade/fills` | -| [spotSubmitPlanOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1001) | :closed_lock_with_key: | POST | `/api/v2/spot/trade/place-plan-order` | -| [spotModifyPlanOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1010) | :closed_lock_with_key: | POST | `/api/v2/spot/trade/modify-plan-order` | -| [spotCancelPlanOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1019) | :closed_lock_with_key: | POST | `/api/v2/spot/trade/cancel-plan-order` | -| [getSpotCurrentPlanOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1030) | :closed_lock_with_key: | GET | `/api/v2/spot/trade/current-plan-order` | -| [getSpotPlanSubOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1040) | :closed_lock_with_key: | GET | `/api/v2/spot/trade/plan-sub-order` | -| [getSpotHistoricPlanOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1046) | :closed_lock_with_key: | GET | `/api/v2/spot/trade/history-plan-order` | -| [spotCancelPlanOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1056) | :closed_lock_with_key: | POST | `/api/v2/spot/trade/batch-cancel-plan-order` | -| [getSpotAccount()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1071) | :closed_lock_with_key: | GET | `/api/v2/spot/account/info` | -| [getSpotAccountAssets()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1075) | :closed_lock_with_key: | GET | `/api/v2/spot/account/assets` | -| [getSpotSubAccountAssets()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1082) | :closed_lock_with_key: | GET | `/api/v2/spot/account/subaccount-assets` | -| [spotModifyDepositAccount()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1086) | :closed_lock_with_key: | POST | `/api/v2/spot/wallet/modify-deposit-account` | -| [getSpotAccountBills()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1096) | :closed_lock_with_key: | GET | `/api/v2/spot/account/bills` | -| [spotTransfer()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1102) | :closed_lock_with_key: | POST | `/api/v2/spot/wallet/transfer` | -| [getSpotTransferableCoins()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1111) | :closed_lock_with_key: | GET | `/api/v2/spot/wallet/transfer-coin-info` | -| [spotSubTransfer()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1118) | :closed_lock_with_key: | POST | `/api/v2/spot/wallet/subaccount-transfer` | -| [spotWithdraw()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1127) | :closed_lock_with_key: | POST | `/api/v2/spot/wallet/withdrawal` | -| [getSpotMainSubTransferRecord()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1136) | :closed_lock_with_key: | GET | `/api/v2/spot/account/sub-main-trans-record` | -| [getSpotTransferHistory()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1145) | :closed_lock_with_key: | GET | `/api/v2/spot/account/transferRecords` | -| [spotSwitchBGBDeduct()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1151) | :closed_lock_with_key: | POST | `/api/v2/spot/account/switch-deduct` | -| [getSpotDepositAddress()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1157) | :closed_lock_with_key: | GET | `/api/v2/spot/wallet/deposit-address` | -| [getSpotSubDepositAddress()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1165) | :closed_lock_with_key: | GET | `/api/v2/spot/wallet/subaccount-deposit-address` | -| [getSpotBGBDeductInfo()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1177) | :closed_lock_with_key: | GET | `/api/v2/spot/account/deduct-info` | -| [spotCancelWithdrawal()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1185) | :closed_lock_with_key: | POST | `/api/v2/spot/wallet/cancel-withdrawal` | -| [getSubAccountDepositRecords()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1191) | :closed_lock_with_key: | GET | `/api/v2/spot/wallet/subaccount-deposit-records` | -| [getSpotWithdrawalHistory()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1200) | :closed_lock_with_key: | GET | `/api/v2/spot/wallet/withdrawal-records` | -| [getSpotDepositHistory()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1206) | :closed_lock_with_key: | GET | `/api/v2/spot/wallet/deposit-records` | -| [upgradeToUnifiedAccount()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1221) | :closed_lock_with_key: | POST | `/api/v2/spot/account/upgrade` | -| [getUnifiedAccountSwitchStatus()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1231) | :closed_lock_with_key: | GET | `/api/v2/spot/account/upgrade-status` | -| [getFuturesVIPFeeRate()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1253) | | GET | `/api/v2/mix/market/vip-fee-rate` | -| [getFuturesInterestRateHistory()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1257) | | GET | `/api/v2/mix/market/union-interest-rate-history` | -| [getFuturesInterestExchangeRate()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1266) | | GET | `/api/v2/mix/market/exchange-rate` | -| [getFuturesDiscountRate()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1277) | | GET | `/api/v2/mix/market/discount-rate` | -| [getFuturesMergeDepth()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1281) | | GET | `/api/v2/mix/market/merge-depth` | -| [getFuturesTicker()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1287) | | GET | `/api/v2/mix/market/ticker` | -| [getFuturesAllTickers()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1294) | | GET | `/api/v2/mix/market/tickers` | -| [getFuturesRecentTrades()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1300) | | GET | `/api/v2/mix/market/fills` | -| [getFuturesHistoricTrades()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1306) | | GET | `/api/v2/mix/market/fills-history` | -| [getFuturesCandles()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1312) | | GET | `/api/v2/mix/market/candles` | -| [getFuturesHistoricCandles()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1318) | | GET | `/api/v2/mix/market/history-candles` | -| [getFuturesHistoricIndexPriceCandles()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1324) | | GET | `/api/v2/mix/market/history-index-candles` | -| [getFuturesHistoricMarkPriceCandles()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1330) | | GET | `/api/v2/mix/market/history-mark-candles` | -| [getFuturesOpenInterest()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1336) | | GET | `/api/v2/mix/market/open-interest` | -| [getFuturesNextFundingTime()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1348) | | GET | `/api/v2/mix/market/funding-time` | -| [getFuturesSymbolPrice()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1355) | | GET | `/api/v2/mix/market/symbol-price` | -| [getFuturesHistoricFundingRates()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1362) | | GET | `/api/v2/mix/market/history-fund-rate` | -| [getFuturesCurrentFundingRate()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1371) | | GET | `/api/v2/mix/market/current-fund-rate` | -| [getFuturesContractConfig()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1389) | | GET | `/api/v2/mix/market/contracts` | -| [getFuturesAccountAsset()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1402) | :closed_lock_with_key: | GET | `/api/v2/mix/account/account` | -| [getFuturesAccountAssets()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1408) | :closed_lock_with_key: | GET | `/api/v2/mix/account/accounts` | -| [getFuturesSubAccountAssets()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1414) | :closed_lock_with_key: | GET | `/api/v2/mix/account/sub-account-assets` | -| [getFuturesInterestHistory()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1427) | :closed_lock_with_key: | GET | `/api/v2/mix/account/interest-history` | -| [getFuturesOpenCount()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1433) | :closed_lock_with_key: | GET | `/api/v2/mix/account/open-count` | -| [setFuturesPositionAutoMargin()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1441) | :closed_lock_with_key: | POST | `/api/v2/mix/account/set-auto-margin` | -| [setFuturesLeverage()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1447) | :closed_lock_with_key: | POST | `/api/v2/mix/account/set-leverage` | -| [setFuturesPositionMargin()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1453) | :closed_lock_with_key: | POST | `/api/v2/mix/account/set-margin` | -| [setFuturesAssetMode()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1459) | :closed_lock_with_key: | POST | `/api/v2/mix/account/set-asset-mode` | -| [setFuturesMarginMode()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1466) | :closed_lock_with_key: | POST | `/api/v2/mix/account/set-margin-mode` | -| [setFuturesPositionMode()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1472) | :closed_lock_with_key: | POST | `/api/v2/mix/account/set-position-mode` | -| [getFuturesAccountBills()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1483) | :closed_lock_with_key: | GET | `/api/v2/mix/account/bill` | -| [getUnionTransferLimits()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1498) | :closed_lock_with_key: | GET | `/api/v2/mix/account/transfer-limits` | -| [getUnionConfig()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1510) | :closed_lock_with_key: | GET | `/api/v2/mix/account/union-config` | -| [getSwitchUnionUsdt()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1520) | :closed_lock_with_key: | GET | `/api/v2/mix/account/switch-union-usdt` | -| [unionConvert()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1530) | :closed_lock_with_key: | POST | `/api/v2/mix/account/union-convert` | -| [getFuturesMaxOpenableQuantity()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1542) | :closed_lock_with_key: | GET | `/api/v2/mix/account/max-open` | -| [getFuturesLiquidationPrice()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1554) | :closed_lock_with_key: | GET | `/api/v2/mix/account/liq-price` | -| [getFuturesIsolatedSymbols()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1566) | :closed_lock_with_key: | GET | `/api/v2/mix/account/isolated-symbols` | -| [getFuturesPositionTier()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1578) | | GET | `/api/v2/mix/market/query-position-lever` | -| [getFuturesPosition()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1585) | :closed_lock_with_key: | GET | `/api/v2/mix/position/single-position` | -| [getFuturesPositions()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1593) | :closed_lock_with_key: | GET | `/api/v2/mix/position/all-position` | -| [getFuturesHistoricPositions()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1600) | :closed_lock_with_key: | GET | `/api/v2/mix/position/history-position` | -| [futuresSubmitOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1617) | :closed_lock_with_key: | POST | `/api/v2/mix/order/place-order` | -| [futuresSubmitReversal()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1626) | :closed_lock_with_key: | POST | `/api/v2/mix/order/click-backhand` | -| [futuresBatchSubmitOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1635) | :closed_lock_with_key: | POST | `/api/v2/mix/order/batch-place-order` | -| [futuresModifyOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1641) | :closed_lock_with_key: | POST | `/api/v2/mix/order/modify-order` | -| [futuresCancelOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1650) | :closed_lock_with_key: | POST | `/api/v2/mix/order/cancel-order` | -| [futuresBatchCancelOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1659) | :closed_lock_with_key: | POST | `/api/v2/mix/order/batch-cancel-orders` | -| [futuresFlashClosePositions()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1665) | :closed_lock_with_key: | POST | `/api/v2/mix/order/close-positions` | -| [getFuturesOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1671) | :closed_lock_with_key: | GET | `/api/v2/mix/order/detail` | -| [getFuturesFills()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1677) | :closed_lock_with_key: | GET | `/api/v2/mix/order/fills` | -| [getFuturesHistoricOrderFills()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1686) | :closed_lock_with_key: | GET | `/api/v2/mix/order/fill-history` | -| [getFuturesOpenOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1697) | :closed_lock_with_key: | GET | `/api/v2/mix/order/orders-pending` | -| [getFuturesHistoricOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1706) | :closed_lock_with_key: | GET | `/api/v2/mix/order/orders-history` | -| [futuresCancelAllOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1715) | :closed_lock_with_key: | POST | `/api/v2/mix/order/cancel-all-orders` | -| [getFuturesTriggerSubOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1727) | :closed_lock_with_key: | GET | `/api/v2/mix/order/plan-sub-order` | -| [futuresSubmitTPSLOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1735) | :closed_lock_with_key: | POST | `/api/v2/mix/order/place-tpsl-order` | -| [futuresSubmitPlanOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1744) | :closed_lock_with_key: | POST | `/api/v2/mix/order/place-plan-order` | -| [futuresModifyTPSLPOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1753) | :closed_lock_with_key: | POST | `/api/v2/mix/order/modify-tpsl-order` | -| [futuresModifyPlanOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1762) | :closed_lock_with_key: | POST | `/api/v2/mix/order/modify-plan-order` | -| [getFuturesPlanOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1771) | :closed_lock_with_key: | GET | `/api/v2/mix/order/orders-plan-pending` | -| [futuresCancelPlanOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1780) | :closed_lock_with_key: | POST | `/api/v2/mix/order/cancel-plan-order` | -| [getFuturesHistoricPlanOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1786) | :closed_lock_with_key: | GET | `/api/v2/mix/order/orders-plan-history` | -| [modifySubaccountEmail()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1811) | :closed_lock_with_key: | POST | `/api/v2/broker/account/modify-subaccount-email` | -| [getBrokerInfo()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1821) | :closed_lock_with_key: | GET | `/api/v2/broker/account/info` | -| [createSubaccount()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1831) | :closed_lock_with_key: | POST | `/api/v2/broker/account/create-subaccount` | -| [getSubaccounts()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1838) | :closed_lock_with_key: | GET | `/api/v2/broker/account/subaccount-list` | -| [modifySubaccount()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1848) | :closed_lock_with_key: | POST | `/api/v2/broker/account/modify-subaccount` | -| [getSubaccountEmail()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1854) | :closed_lock_with_key: | GET | `/api/v2/broker/account/subaccount-email` | -| [getSubaccountSpotAssets()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1860) | :closed_lock_with_key: | GET | `/api/v2/broker/account/subaccount-spot-assets` | -| [getSubaccountFuturesAssets()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1875) | :closed_lock_with_key: | GET | `/api/v2/broker/account/subaccount-future-assets` | -| [createSubaccountDepositAddress()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1889) | :closed_lock_with_key: | POST | `/api/v2/broker/account/subaccount-address` | -| [subaccountWithdrawal()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1900) | :closed_lock_with_key: | POST | `/api/v2/broker/account/subaccount-withdrawal` | -| [subaccountSetAutoTransfer()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1912) | :closed_lock_with_key: | POST | `/api/v2/broker/account/set-subaccount-autotransfer` | -| [subaccountDepositRecords()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1928) | :closed_lock_with_key: | GET | `/api/v2/broker/subaccount-deposit` | -| [subaccountWithdrawalRecords()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1939) | :closed_lock_with_key: | GET | `/api/v2/broker/subaccount-withdrawal` | -| [createSubaccountApiKey()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1954) | :closed_lock_with_key: | POST | `/api/v2/broker/manage/create-subaccount-apikey` | -| [getSubaccountApiKey()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1963) | :closed_lock_with_key: | GET | `/api/v2/broker/manage/subaccount-apikey-list` | -| [modifySubaccountApiKey()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1972) | :closed_lock_with_key: | POST | `/api/v2/broker/manage/modify-subaccount-apikey` | -| [getAllSubDepositWithdrawalRecords()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L1988) | :closed_lock_with_key: | GET | `/api/v2/broker/all-sub-deposit-withdrawal` | -| [getBrokerSubaccounts()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2005) | :closed_lock_with_key: | GET | `/api/v2/broker/subaccounts` | -| [getBrokerCommissions()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2017) | :closed_lock_with_key: | GET | `/api/v2/broker/commissions` | -| [getBrokerTradeVolume()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2029) | :closed_lock_with_key: | GET | `/api/v2/broker/trade-volume` | -| [getBrokerTotalCommission()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2049) | :closed_lock_with_key: | GET | `/api/v2/broker/total-commission` | -| [getBrokerOrderCommission()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2071) | :closed_lock_with_key: | GET | `/api/v2/broker/order-commission` | -| [getBrokerRebateInfo()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2084) | :closed_lock_with_key: | GET | `/api/v2/broker/rebate-info` | -| [getAgentCustomerCommissions()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2096) | :closed_lock_with_key: | GET | `/api/v2/broker/customer-commissions` | -| [getAgentSubCustomerList()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2105) | :closed_lock_with_key: | GET | `/api/v2/broker/sub-customer-list` | -| [getAgentCustomerTradeVolume()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2111) | :closed_lock_with_key: | POST | `/api/v2/broker/customer-trade-volume` | -| [getAgentCustomerList()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2120) | :closed_lock_with_key: | POST | `/api/v2/broker/customer-list` | -| [getAgentCustomerKycResult()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2126) | :closed_lock_with_key: | GET | `/api/v2/broker/customer-kyc-result` | -| [getAgentCustomerDeposits()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2132) | :closed_lock_with_key: | POST | `/api/v2/broker/customer-deposit` | -| [getAgentCustomerAssets()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2138) | :closed_lock_with_key: | POST | `/api/v2/broker/customer-asset` | -| [getAgentCommissionDetail()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2144) | :closed_lock_with_key: | GET | `/api/v2/broker/agent-commission` | -| [getMarginCurrencies()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2164) | | GET | `/api/v2/margin/currencies` | -| [getMarginBorrowHistory()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2174) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/borrow-history` | -| [getMarginRepayHistory()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2191) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/repay-history` | -| [getMarginInterestHistory()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2208) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/interest-history` | -| [getMarginLiquidationHistory()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2225) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/liquidation-history` | -| [getMarginFinancialHistory()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2242) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/financial-records` | -| [getMarginAccountAssets()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2265) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/account/assets` | -| [marginBorrow()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2276) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/account/borrow` | -| [marginRepay()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2299) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/account/repay` | -| [getMarginRiskRate()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2324) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/account/risk-rate` | -| [getMarginMaxBorrowable()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2336) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/account/max-borrowable-amount` | -| [getMarginMaxTransferable()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2349) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/account/max-transfer-out-amount` | -| [getMarginInterestRateAndMaxBorrowable()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2364) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/interest-rate-and-limit` | -| [getMarginTierConfiguration()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2380) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/tier-data` | -| [marginFlashRepay()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2392) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/account/flash-repay` | -| [getMarginFlashRepayResult()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2410) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/account/query-flash-repay-status` | -| [marginSubmitOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2434) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/place-order` | -| [marginBatchSubmitOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2447) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/batch-place-order` | -| [marginCancelOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2458) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/cancel-order` | -| [marginBatchCancelOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2478) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/batch-cancel-order` | -| [getMarginOpenOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2492) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/open-orders` | -| [getMarginHistoricOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2506) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/history-orders` | -| [getMarginHistoricOrderFills()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2523) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/fills` | -| [getMarginLiquidationOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2537) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/liquidation-order` | -| [getFuturesTraderCurrentOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2569) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/order-current-track` | -| [getFuturesTraderHistoryOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2578) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/order-history-track` | -| [modifyFuturesTraderOrderTPSL()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2587) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-trader/order-modify-tpsl` | -| [getFuturesTraderOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2596) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/order-total-detail` | -| [getFuturesTraderProfitHistory()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2602) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/profit-history-summarys` | -| [getFuturesTraderProfitShareHistory()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2608) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/profit-history-details` | -| [closeFuturesTraderOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2617) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-trader/order-close-positions` | -| [getFuturesTraderProfitShare()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2636) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/profit-details` | -| [getFuturesTraderProfitShareGroup()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2652) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/profits-group-coin-date` | -| [getFuturesTraderSymbolSettings()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2670) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/config-query-symbols` | -| [updateFuturesTraderSymbolSettings()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2679) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-trader/config-setting-symbols` | -| [updateFuturesTraderGlobalSettings()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2688) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-trader/config-settings-base` | -| [getFuturesTraderFollowers()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2699) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/config-query-followers` | -| [removeFuturesTraderFollower()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2708) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-trader/config-remove-follower` | -| [getFuturesFollowerCurrentOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2725) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-follower/query-current-orders` | -| [getFuturesFollowerHistoryOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2734) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-follower/query-history-orders` | -| [updateFuturesFollowerTPSL()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2743) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-follower/setting-tpsl` | -| [updateFuturesFollowerSettings()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2749) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-follower/settings` | -| [getFuturesFollowerSettings()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2755) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-follower/query-settings` | -| [closeFuturesFollowerPositions()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2761) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-follower/close-positions` | -| [getFuturesFollowerTraders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2774) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-follower/query-traders` | -| [getFuturesFollowerFollowLimit()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2780) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-follower/query-quantity-limit` | -| [unfollowFuturesTrader()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2798) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-follower/cancel-trader` | -| [getBrokerTraders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2812) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-broker/query-traders` | -| [getBrokerTradersHistoricalOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2816) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-broker/query-history-traces` | -| [getBrokerTradersPendingOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2823) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-broker/query-current-traces` | -| [getSpotTraderProfit()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2838) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/profit-summarys` | -| [getSpotTraderHistoryProfit()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2842) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/profit-history-details` | -| [getSpotTraderUnrealizedProfit()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2851) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/profit-details` | -| [getSpotTraderOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2859) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/order-total-detail` | -| [modifySpotTraderOrderTPSL()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2863) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-trader/order-modify-tpsl` | -| [getSpotTraderHistoryOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2874) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/order-history-track` | -| [getSpotTraderCurrentOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2883) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/order-current-track` | -| [sellSpotTrader()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2892) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-trader/order-close-tracking` | -| [getSpotTraderSymbolSettings()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2902) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-trader/config-setting-symbols` | -| [removeSpotTraderFollowers()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2912) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-trader/config-remove-follower` | -| [getSpotTraderConfiguration()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2921) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/config-query-settings` | -| [getSpotTraderFollowers()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2925) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/config-query-followers` | -| [cancelSpotFollowerOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2942) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-follower/stop-order` | -| [updateSpotFollowerSettings()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2948) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-follower/settings` | -| [updateSpotFollowerTPSL()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2957) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-follower/setting-tpsl` | -| [getSpotFollowerTraders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2965) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-follower/query-traders` | -| [getSpotFollowerCurrentTraderSymbols()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2974) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-follower/query-trader-symbols` | -| [getSpotFollowerSettings()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2985) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-follower/query-settings` | -| [getSpotFollowerHistoryOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L2991) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-follower/query-history-orders` | -| [getSpotFollowerOpenOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3000) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-follower/query-current-orders` | -| [sellSpotFollower()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3009) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-follower/order-close-tracking` | -| [unfollowSpotTrader()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3019) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-follower/cancel-trader` | -| [getEarnSavingsProducts()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3033) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/product` | -| [getEarnSavingsAccount()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3040) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/account` | -| [getEarnSavingsAssets()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3044) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/assets` | -| [getEarnSavingsRecords()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3050) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/records` | -| [getEarnSavingsSubscription()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3056) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/subscribe-info` | -| [earnSubscribeSavings()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3063) | :closed_lock_with_key: | POST | `/api/v2/earn/savings/subscribe` | -| [getEarnSavingsSubscriptionResult()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3076) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/subscribe-result` | -| [earnRedeemSavings()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3088) | :closed_lock_with_key: | POST | `/api/v2/earn/savings/redeem` | -| [getEarnSavingsRedemptionResult()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3097) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/redeem-result` | -| [getEarnAccount()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3117) | :closed_lock_with_key: | GET | `/api/v2/earn/account/assets` | -| [getEarnEliteProducts()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3136) | :closed_lock_with_key: | GET | `/api/v2/earn/elite/product` | -| [getEarnEliteAssets()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3140) | :closed_lock_with_key: | GET | `/api/v2/earn/elite/assets` | -| [getEarnEliteRecords()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3144) | :closed_lock_with_key: | GET | `/api/v2/earn/elite/records` | -| [getEarnEliteSubscribeInfo()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3150) | :closed_lock_with_key: | GET | `/api/v2/earn/elite/subscribe-info` | -| [subscribeEarnElite()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3156) | :closed_lock_with_key: | POST | `/api/v2/earn/elite/subscribe` | -| [getEarnEliteSubscribeResult()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3162) | :closed_lock_with_key: | GET | `/api/v2/earn/elite/subscribe-result` | -| [getEarnEliteRedeemInfo()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3168) | :closed_lock_with_key: | GET | `/api/v2/earn/elite/redeem-info` | -| [redeemEarnElite()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3174) | :closed_lock_with_key: | POST | `/api/v2/earn/elite/redeem` | -| [getSharkfinProducts()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3188) | :closed_lock_with_key: | GET | `/api/v2/earn/sharkfin/product` | -| [getSharkfinAccount()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3196) | :closed_lock_with_key: | GET | `/api/v2/earn/sharkfin/account` | -| [getSharkfinAssets()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3200) | :closed_lock_with_key: | GET | `/api/v2/earn/sharkfin/assets` | -| [getSharkfinRecords()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3206) | :closed_lock_with_key: | GET | `/api/v2/earn/sharkfin/records` | -| [getSharkfinSubscription()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3212) | :closed_lock_with_key: | GET | `/api/v2/earn/sharkfin/subscribe-info` | -| [subscribeSharkfin()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3218) | :closed_lock_with_key: | POST | `/api/v2/earn/sharkfin/subscribe` | -| [getSharkfinSubscriptionResult()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3227) | :closed_lock_with_key: | GET | `/api/v2/earn/sharkfin/subscribe-result` | -| [getLoanCurrencies()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3244) | | GET | `/api/v2/earn/loan/public/coinInfos` | -| [getLoanEstInterestAndBorrowable()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3250) | | GET | `/api/v2/earn/loan/public/hour-interest` | -| [borrowLoan()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3261) | :closed_lock_with_key: | POST | `/api/v2/earn/loan/borrow` | -| [getOngoingLoanOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3269) | :closed_lock_with_key: | GET | `/api/v2/earn/loan/ongoing-orders` | -| [repayLoan()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3277) | :closed_lock_with_key: | POST | `/api/v2/earn/loan/repay` | -| [getRepayHistory()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3283) | :closed_lock_with_key: | GET | `/api/v2/earn/loan/repay-history` | -| [updateLoanPledgeRate()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3289) | :closed_lock_with_key: | POST | `/api/v2/earn/loan/revise-pledge` | -| [getLoanPledgeRateHistory()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3299) | :closed_lock_with_key: | GET | `/api/v2/earn/loan/revise-history` | -| [getLoanHistory()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3305) | :closed_lock_with_key: | GET | `/api/v2/earn/loan/borrow-history` | -| [getLoanDebts()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3311) | :closed_lock_with_key: | GET | `/api/v2/earn/loan/debts` | -| [getLoanLiquidationRecords()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v2.ts#L3315) | :closed_lock_with_key: | GET | `/api/v2/earn/loan/reduces` | +| [getAnnouncements()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L506) | | GET | `/api/v2/public/annoucements` | +| [getServerTime()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L518) | | GET | `/api/v2/public/time` | +| [getTradeRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L526) | :closed_lock_with_key: | GET | `/api/v2/common/trade-rate` | +| [getAllTradeRates()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L535) | :closed_lock_with_key: | GET | `/api/v2/common/all-trade-rate` | +| [getSpotTransactionRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L553) | :closed_lock_with_key: | GET | `/api/v2/tax/spot-record` | +| [getFuturesTransactionRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L559) | :closed_lock_with_key: | GET | `/api/v2/tax/future-record` | +| [getMarginTransactionRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L565) | :closed_lock_with_key: | GET | `/api/v2/tax/margin-record` | +| [getP2PTransactionRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L571) | :closed_lock_with_key: | GET | `/api/v2/tax/p2p-record` | +| [getP2PMerchantList()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L583) | :closed_lock_with_key: | GET | `/api/v2/p2p/merchantList` | +| [getP2PMerchantInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L592) | :closed_lock_with_key: | GET | `/api/v2/p2p/merchantInfo` | +| [getP2PMerchantOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L596) | :closed_lock_with_key: | GET | `/api/v2/p2p/orderList` | +| [getP2PMerchantAdvertisementList()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L605) | :closed_lock_with_key: | GET | `/api/v2/p2p/advList` | +| [getSpotWhaleNetFlowData()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L622) | :closed_lock_with_key: | GET | `/api/v2/spot/market/whale-net-flow` | +| [getFuturesActiveTakerBuySellVolumeData()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L628) | | GET | `/api/v2/mix/market/taker-buy-sell` | +| [getFuturesActiveLongShortPositionData()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L635) | | GET | `/api/v2/mix/market/position-long-short` | +| [getFuturesLongShortRatio()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L642) | | GET | `/api/v2/mix/market/long-short-ratio` | +| [getMarginLoanGrowthRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L650) | | GET | `/api/v2/mix/market/loan-growth` | +| [getIsolatedMarginBorrowingRatio()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L658) | | GET | `/api/v2/mix/market/isolated-borrow-rate` | +| [getFuturesActiveBuySellVolumeData()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L665) | | GET | `/api/v2/mix/market/long-short` | +| [getSpotFundFlow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L672) | | GET | `/api/v2/spot/market/fund-flow` | +| [getTradeDataSupportSymbols()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L679) | | GET | `/api/v2/spot/market/support-symbols` | +| [getSpotFundNetFlowData()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L688) | | GET | `/api/v2/spot/market/fund-net-flow` | +| [getFuturesActiveLongShortAccountData()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L699) | | GET | `/api/v2/mix/market/account-long-short` | +| [createVirtualSubaccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L712) | :closed_lock_with_key: | POST | `/api/v2/user/create-virtual-subaccount` | +| [modifyVirtualSubaccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L718) | :closed_lock_with_key: | POST | `/api/v2/user/modify-virtual-subaccount` | +| [batchCreateVirtualSubaccountAndAPIKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L726) | :closed_lock_with_key: | POST | `/api/v2/user/batch-create-subaccount-and-apikey` | +| [getVirtualSubaccounts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L735) | :closed_lock_with_key: | GET | `/api/v2/user/virtual-subaccount-list` | +| [createVirtualSubaccountAPIKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L748) | :closed_lock_with_key: | POST | `/api/v2/user/create-virtual-subaccount-apikey` | +| [modifyVirtualSubaccountAPIKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L757) | :closed_lock_with_key: | POST | `/api/v2/user/modify-virtual-subaccount-apikey` | +| [getVirtualSubaccountAPIKeys()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L766) | :closed_lock_with_key: | GET | `/api/v2/user/virtual-subaccount-apikey-list` | +| [createAgentSubaccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L779) | :closed_lock_with_key: | POST | `/api/v2/user/create-agent-subaccount` | +| [getFundingAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L790) | :closed_lock_with_key: | GET | `/api/v2/account/funding-assets` | +| [getBotAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L796) | :closed_lock_with_key: | GET | `/api/v2/account/bot-assets` | +| [getBalances()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L803) | :closed_lock_with_key: | GET | `/api/v2/account/all-account-balance` | +| [getConvertCoins()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L820) | :closed_lock_with_key: | GET | `/api/v2/convert/currencies` | +| [getConvertQuotedPrice()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L824) | :closed_lock_with_key: | GET | `/api/v2/convert/quoted-price` | +| [convert()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L830) | :closed_lock_with_key: | POST | `/api/v2/convert/trade` | +| [getConvertHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L836) | :closed_lock_with_key: | GET | `/api/v2/convert/convert-record` | +| [getConvertBGBCoins()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L851) | :closed_lock_with_key: | GET | `/api/v2/convert/bgb-convert-coin-list` | +| [convertBGB()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L859) | :closed_lock_with_key: | POST | `/api/v2/convert/bgb-convert` | +| [getConvertBGBHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L865) | :closed_lock_with_key: | GET | `/api/v2/convert/bgb-convert-records` | +| [getSpotCoinInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L885) | :closed_lock_with_key: | GET | `/api/v2/spot/public/coins` | +| [getSpotSymbolInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L891) | :closed_lock_with_key: | GET | `/api/v2/spot/public/symbols` | +| [getSpotVIPFeeRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L897) | :closed_lock_with_key: | GET | `/api/v2/spot/market/vip-fee-rate` | +| [getSpotTicker()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L901) | :closed_lock_with_key: | GET | `/api/v2/spot/market/tickers` | +| [getSpotMergeDepth()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L907) | :closed_lock_with_key: | GET | `/api/v2/spot/market/merge-depth` | +| [getSpotOrderBookDepth()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L915) | :closed_lock_with_key: | GET | `/api/v2/spot/market/orderbook` | +| [getSpotCandles()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L923) | :closed_lock_with_key: | GET | `/api/v2/spot/market/candles` | +| [getSpotHistoricCandles()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L929) | :closed_lock_with_key: | GET | `/api/v2/spot/market/history-candles` | +| [getSpotRecentTrades()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L935) | :closed_lock_with_key: | GET | `/api/v2/spot/market/fills` | +| [getSpotHistoricTrades()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L942) | :closed_lock_with_key: | GET | `/api/v2/spot/market/fills-history` | +| [getSpotCallAuction()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L948) | | GET | `/api/v2/spot/market/auction` | +| [spotSubmitOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L960) | :closed_lock_with_key: | POST | `/api/v2/spot/trade/place-order` | +| [spotCancelandSubmitOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L969) | :closed_lock_with_key: | POST | `/api/v2/spot/trade/cancel-replace-order` | +| [spotBatchCancelandSubmitOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L975) | :closed_lock_with_key: | POST | `/api/v2/spot/trade/batch-cancel-replace-order` | +| [spotCancelOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L984) | :closed_lock_with_key: | POST | `/api/v2/spot/trade/cancel-order` | +| [spotBatchSubmitOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L993) | :closed_lock_with_key: | POST | `/api/v2/spot/trade/batch-orders` | +| [spotBatchCancelOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L999) | :closed_lock_with_key: | POST | `/api/v2/spot/trade/batch-cancel-order` | +| [spotCancelSymbolOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1005) | :closed_lock_with_key: | POST | `/api/v2/spot/trade/cancel-symbol-order` | +| [getSpotOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1013) | :closed_lock_with_key: | GET | `/api/v2/spot/trade/orderInfo` | +| [getSpotOpenOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1019) | :closed_lock_with_key: | GET | `/api/v2/spot/trade/unfilled-orders` | +| [getSpotHistoricOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1025) | :closed_lock_with_key: | GET | `/api/v2/spot/trade/history-orders` | +| [getSpotFills()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1031) | :closed_lock_with_key: | GET | `/api/v2/spot/trade/fills` | +| [spotSubmitPlanOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1043) | :closed_lock_with_key: | POST | `/api/v2/spot/trade/place-plan-order` | +| [spotModifyPlanOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1052) | :closed_lock_with_key: | POST | `/api/v2/spot/trade/modify-plan-order` | +| [spotCancelPlanOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1061) | :closed_lock_with_key: | POST | `/api/v2/spot/trade/cancel-plan-order` | +| [getSpotCurrentPlanOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1072) | :closed_lock_with_key: | GET | `/api/v2/spot/trade/current-plan-order` | +| [getSpotPlanSubOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1082) | :closed_lock_with_key: | GET | `/api/v2/spot/trade/plan-sub-order` | +| [getSpotHistoricPlanOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1088) | :closed_lock_with_key: | GET | `/api/v2/spot/trade/history-plan-order` | +| [spotCancelPlanOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1098) | :closed_lock_with_key: | POST | `/api/v2/spot/trade/batch-cancel-plan-order` | +| [getSpotAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1113) | :closed_lock_with_key: | GET | `/api/v2/spot/account/info` | +| [getSpotAccountAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1117) | :closed_lock_with_key: | GET | `/api/v2/spot/account/assets` | +| [getSpotSubAccountAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1124) | :closed_lock_with_key: | GET | `/api/v2/spot/account/subaccount-assets` | +| [spotModifyDepositAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1128) | :closed_lock_with_key: | POST | `/api/v2/spot/wallet/modify-deposit-account` | +| [getSpotAccountBills()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1138) | :closed_lock_with_key: | GET | `/api/v2/spot/account/bills` | +| [spotTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1144) | :closed_lock_with_key: | POST | `/api/v2/spot/wallet/transfer` | +| [getSpotTransferableCoins()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1153) | :closed_lock_with_key: | GET | `/api/v2/spot/wallet/transfer-coin-info` | +| [spotSubTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1160) | :closed_lock_with_key: | POST | `/api/v2/spot/wallet/subaccount-transfer` | +| [spotWithdraw()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1169) | :closed_lock_with_key: | POST | `/api/v2/spot/wallet/withdrawal` | +| [getSpotMainSubTransferRecord()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1178) | :closed_lock_with_key: | GET | `/api/v2/spot/account/sub-main-trans-record` | +| [getSpotTransferHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1187) | :closed_lock_with_key: | GET | `/api/v2/spot/account/transferRecords` | +| [spotSwitchBGBDeduct()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1193) | :closed_lock_with_key: | POST | `/api/v2/spot/account/switch-deduct` | +| [getSpotDepositAddress()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1199) | :closed_lock_with_key: | GET | `/api/v2/spot/wallet/deposit-address` | +| [getSpotSubDepositAddress()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1207) | :closed_lock_with_key: | GET | `/api/v2/spot/wallet/subaccount-deposit-address` | +| [getSpotBGBDeductInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1219) | :closed_lock_with_key: | GET | `/api/v2/spot/account/deduct-info` | +| [spotCancelWithdrawal()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1227) | :closed_lock_with_key: | POST | `/api/v2/spot/wallet/cancel-withdrawal` | +| [getSubAccountDepositRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1233) | :closed_lock_with_key: | GET | `/api/v2/spot/wallet/subaccount-deposit-records` | +| [getSpotWithdrawalHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1242) | :closed_lock_with_key: | GET | `/api/v2/spot/wallet/withdrawal-records` | +| [getSpotDepositHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1248) | :closed_lock_with_key: | GET | `/api/v2/spot/wallet/deposit-records` | +| [upgradeToUnifiedAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1263) | :closed_lock_with_key: | POST | `/api/v2/spot/account/upgrade` | +| [getUnifiedAccountSwitchStatus()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1273) | :closed_lock_with_key: | GET | `/api/v2/spot/account/upgrade-status` | +| [getFuturesVIPFeeRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1295) | | GET | `/api/v2/mix/market/vip-fee-rate` | +| [getFuturesInterestRateHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1299) | | GET | `/api/v2/mix/market/union-interest-rate-history` | +| [getFuturesInterestExchangeRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1308) | | GET | `/api/v2/mix/market/exchange-rate` | +| [getFuturesDiscountRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1319) | | GET | `/api/v2/mix/market/discount-rate` | +| [getFuturesMergeDepth()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1323) | | GET | `/api/v2/mix/market/merge-depth` | +| [getFuturesTicker()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1329) | | GET | `/api/v2/mix/market/ticker` | +| [getFuturesAllTickers()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1336) | | GET | `/api/v2/mix/market/tickers` | +| [getFuturesRecentTrades()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1342) | | GET | `/api/v2/mix/market/fills` | +| [getFuturesHistoricTrades()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1348) | | GET | `/api/v2/mix/market/fills-history` | +| [getFuturesCandles()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1354) | | GET | `/api/v2/mix/market/candles` | +| [getFuturesHistoricCandles()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1360) | | GET | `/api/v2/mix/market/history-candles` | +| [getFuturesHistoricIndexPriceCandles()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1366) | | GET | `/api/v2/mix/market/history-index-candles` | +| [getFuturesHistoricMarkPriceCandles()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1372) | | GET | `/api/v2/mix/market/history-mark-candles` | +| [getFuturesOpenInterest()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1378) | | GET | `/api/v2/mix/market/open-interest` | +| [getFuturesNextFundingTime()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1390) | | GET | `/api/v2/mix/market/funding-time` | +| [getFuturesSymbolPrice()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1397) | | GET | `/api/v2/mix/market/symbol-price` | +| [getFuturesHistoricFundingRates()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1404) | | GET | `/api/v2/mix/market/history-fund-rate` | +| [getFuturesCurrentFundingRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1413) | | GET | `/api/v2/mix/market/current-fund-rate` | +| [getFuturesContractConfig()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1431) | | GET | `/api/v2/mix/market/contracts` | +| [getFuturesOiLimit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1438) | | GET | `/api/v2/mix/market/oi-limit` | +| [getFuturesAccountAsset()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1456) | :closed_lock_with_key: | GET | `/api/v2/mix/account/account` | +| [getFuturesAccountAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1462) | :closed_lock_with_key: | GET | `/api/v2/mix/account/accounts` | +| [getFuturesSubAccountAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1468) | :closed_lock_with_key: | GET | `/api/v2/mix/account/sub-account-assets` | +| [getFuturesInterestHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1481) | :closed_lock_with_key: | GET | `/api/v2/mix/account/interest-history` | +| [getFuturesOpenCount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1487) | :closed_lock_with_key: | GET | `/api/v2/mix/account/open-count` | +| [setFuturesPositionAutoMargin()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1495) | :closed_lock_with_key: | POST | `/api/v2/mix/account/set-auto-margin` | +| [setFuturesLeverage()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1501) | :closed_lock_with_key: | POST | `/api/v2/mix/account/set-leverage` | +| [setFuturesPositionMargin()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1507) | :closed_lock_with_key: | POST | `/api/v2/mix/account/set-margin` | +| [setFuturesAssetMode()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1513) | :closed_lock_with_key: | POST | `/api/v2/mix/account/set-asset-mode` | +| [setFuturesMarginMode()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1520) | :closed_lock_with_key: | POST | `/api/v2/mix/account/set-margin-mode` | +| [setFuturesPositionMode()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1526) | :closed_lock_with_key: | POST | `/api/v2/mix/account/set-position-mode` | +| [getFuturesAccountBills()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1537) | :closed_lock_with_key: | GET | `/api/v2/mix/account/bill` | +| [getUnionTransferLimits()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1552) | :closed_lock_with_key: | GET | `/api/v2/mix/account/transfer-limits` | +| [getUnionConfig()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1564) | :closed_lock_with_key: | GET | `/api/v2/mix/account/union-config` | +| [getSwitchUnionUsdt()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1574) | :closed_lock_with_key: | GET | `/api/v2/mix/account/switch-union-usdt` | +| [unionConvert()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1584) | :closed_lock_with_key: | POST | `/api/v2/mix/account/union-convert` | +| [getFuturesMaxOpenableQuantity()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1596) | :closed_lock_with_key: | GET | `/api/v2/mix/account/max-open` | +| [getFuturesLiquidationPrice()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1608) | :closed_lock_with_key: | GET | `/api/v2/mix/account/liq-price` | +| [getFuturesIsolatedSymbols()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1620) | :closed_lock_with_key: | GET | `/api/v2/mix/account/isolated-symbols` | +| [getFuturesPositionTier()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1632) | | GET | `/api/v2/mix/market/query-position-lever` | +| [getFuturesPosition()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1639) | :closed_lock_with_key: | GET | `/api/v2/mix/position/single-position` | +| [getFuturesPositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1647) | :closed_lock_with_key: | GET | `/api/v2/mix/position/all-position` | +| [getFuturesHistoricPositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1654) | :closed_lock_with_key: | GET | `/api/v2/mix/position/history-position` | +| [getFuturesPositionAdlRank()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1665) | :closed_lock_with_key: | GET | `/api/v2/mix/position/adlRank` | +| [futuresSubmitOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1677) | :closed_lock_with_key: | POST | `/api/v2/mix/order/place-order` | +| [futuresSubmitReversal()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1686) | :closed_lock_with_key: | POST | `/api/v2/mix/order/click-backhand` | +| [futuresBatchSubmitOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1695) | :closed_lock_with_key: | POST | `/api/v2/mix/order/batch-place-order` | +| [futuresModifyOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1701) | :closed_lock_with_key: | POST | `/api/v2/mix/order/modify-order` | +| [futuresCancelOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1710) | :closed_lock_with_key: | POST | `/api/v2/mix/order/cancel-order` | +| [futuresBatchCancelOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1719) | :closed_lock_with_key: | POST | `/api/v2/mix/order/batch-cancel-orders` | +| [futuresFlashClosePositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1725) | :closed_lock_with_key: | POST | `/api/v2/mix/order/close-positions` | +| [getFuturesOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1731) | :closed_lock_with_key: | GET | `/api/v2/mix/order/detail` | +| [getFuturesFills()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1737) | :closed_lock_with_key: | GET | `/api/v2/mix/order/fills` | +| [getFuturesHistoricOrderFills()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1746) | :closed_lock_with_key: | GET | `/api/v2/mix/order/fill-history` | +| [getFuturesOpenOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1757) | :closed_lock_with_key: | GET | `/api/v2/mix/order/orders-pending` | +| [getFuturesHistoricOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1766) | :closed_lock_with_key: | GET | `/api/v2/mix/order/orders-history` | +| [futuresCancelAllOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1775) | :closed_lock_with_key: | POST | `/api/v2/mix/order/cancel-all-orders` | +| [getFuturesTriggerSubOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1787) | :closed_lock_with_key: | GET | `/api/v2/mix/order/plan-sub-order` | +| [futuresSubmitTPSLOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1795) | :closed_lock_with_key: | POST | `/api/v2/mix/order/place-tpsl-order` | +| [futuresSubmitPositionTPSL()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1804) | :closed_lock_with_key: | POST | `/api/v2/mix/order/place-pos-tpsl` | +| [futuresSubmitPlanOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1816) | :closed_lock_with_key: | POST | `/api/v2/mix/order/place-plan-order` | +| [futuresModifyTPSLPOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1825) | :closed_lock_with_key: | POST | `/api/v2/mix/order/modify-tpsl-order` | +| [futuresModifyPlanOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1834) | :closed_lock_with_key: | POST | `/api/v2/mix/order/modify-plan-order` | +| [getFuturesPlanOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1843) | :closed_lock_with_key: | GET | `/api/v2/mix/order/orders-plan-pending` | +| [futuresCancelPlanOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1852) | :closed_lock_with_key: | POST | `/api/v2/mix/order/cancel-plan-order` | +| [getFuturesHistoricPlanOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1858) | :closed_lock_with_key: | GET | `/api/v2/mix/order/orders-plan-history` | +| [modifySubaccountEmail()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1883) | :closed_lock_with_key: | POST | `/api/v2/broker/account/modify-subaccount-email` | +| [getBrokerInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1893) | :closed_lock_with_key: | GET | `/api/v2/broker/account/info` | +| [createSubaccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1903) | :closed_lock_with_key: | POST | `/api/v2/broker/account/create-subaccount` | +| [getSubaccounts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1910) | :closed_lock_with_key: | GET | `/api/v2/broker/account/subaccount-list` | +| [modifySubaccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1920) | :closed_lock_with_key: | POST | `/api/v2/broker/account/modify-subaccount` | +| [getSubaccountEmail()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1926) | :closed_lock_with_key: | GET | `/api/v2/broker/account/subaccount-email` | +| [getSubaccountSpotAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1932) | :closed_lock_with_key: | GET | `/api/v2/broker/account/subaccount-spot-assets` | +| [getSubaccountFuturesAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1947) | :closed_lock_with_key: | GET | `/api/v2/broker/account/subaccount-future-assets` | +| [createSubaccountDepositAddress()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1961) | :closed_lock_with_key: | POST | `/api/v2/broker/account/subaccount-address` | +| [subaccountWithdrawal()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1972) | :closed_lock_with_key: | POST | `/api/v2/broker/account/subaccount-withdrawal` | +| [subaccountSetAutoTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1984) | :closed_lock_with_key: | POST | `/api/v2/broker/account/set-subaccount-autotransfer` | +| [subaccountDepositRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2000) | :closed_lock_with_key: | GET | `/api/v2/broker/subaccount-deposit` | +| [subaccountWithdrawalRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2011) | :closed_lock_with_key: | GET | `/api/v2/broker/subaccount-withdrawal` | +| [createSubaccountApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2026) | :closed_lock_with_key: | POST | `/api/v2/broker/manage/create-subaccount-apikey` | +| [getSubaccountApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2035) | :closed_lock_with_key: | GET | `/api/v2/broker/manage/subaccount-apikey-list` | +| [modifySubaccountApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2044) | :closed_lock_with_key: | POST | `/api/v2/broker/manage/modify-subaccount-apikey` | +| [deleteSubaccountApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2053) | :closed_lock_with_key: | POST | `/api/v2/broker/manage/delete-subaccount-apikey` | +| [getAllSubDepositWithdrawalRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2069) | :closed_lock_with_key: | GET | `/api/v2/broker/all-sub-deposit-withdrawal` | +| [getBrokerSubaccounts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2086) | :closed_lock_with_key: | GET | `/api/v2/broker/subaccounts` | +| [getBrokerCommissions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2098) | :closed_lock_with_key: | GET | `/api/v2/broker/commissions` | +| [getBrokerTradeVolume()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2110) | :closed_lock_with_key: | GET | `/api/v2/broker/trade-volume` | +| [getBrokerTotalCommission()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2130) | :closed_lock_with_key: | GET | `/api/v2/broker/total-commission` | +| [getBrokerOrderCommission()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2152) | :closed_lock_with_key: | GET | `/api/v2/broker/order-commission` | +| [getBrokerRebateInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2165) | :closed_lock_with_key: | GET | `/api/v2/broker/rebate-info` | +| [getAgentCustomerCommissions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2177) | :closed_lock_with_key: | GET | `/api/v2/broker/customer-commissions` | +| [getAgentSubCustomerList()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2186) | :closed_lock_with_key: | GET | `/api/v2/broker/sub-customer-list` | +| [getAgentCustomerTradeVolume()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2192) | :closed_lock_with_key: | POST | `/api/v2/broker/customer-trade-volume` | +| [getAgentCustomerList()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2201) | :closed_lock_with_key: | POST | `/api/v2/broker/customer-list` | +| [getAgentCustomerKycResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2207) | :closed_lock_with_key: | GET | `/api/v2/broker/customer-kyc-result` | +| [getAgentCustomerDeposits()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2213) | :closed_lock_with_key: | POST | `/api/v2/broker/customer-deposit` | +| [getAgentCustomerAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2219) | :closed_lock_with_key: | POST | `/api/v2/broker/customer-asset` | +| [getAgentCommissionDetail()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2225) | :closed_lock_with_key: | GET | `/api/v2/broker/agent-commission` | +| [getMarginCurrencies()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2245) | | GET | `/api/v2/margin/currencies` | +| [getMarginBorrowHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2255) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/borrow-history` | +| [getMarginRepayHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2272) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/repay-history` | +| [getMarginInterestHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2289) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/interest-history` | +| [getMarginLiquidationHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2306) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/liquidation-history` | +| [getMarginFinancialHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2323) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/financial-records` | +| [getMarginAccountAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2346) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/account/assets` | +| [marginBorrow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2357) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/account/borrow` | +| [marginRepay()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2380) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/account/repay` | +| [getMarginRiskRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2405) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/account/risk-rate` | +| [getMarginMaxBorrowable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2417) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/account/max-borrowable-amount` | +| [getMarginMaxTransferable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2430) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/account/max-transfer-out-amount` | +| [getMarginInterestRateAndMaxBorrowable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2445) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/interest-rate-and-limit` | +| [getMarginTierConfiguration()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2461) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/tier-data` | +| [marginFlashRepay()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2473) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/account/flash-repay` | +| [getMarginFlashRepayResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2491) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/account/query-flash-repay-status` | +| [marginSubmitOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2515) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/place-order` | +| [marginBatchSubmitOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2528) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/batch-place-order` | +| [marginCancelOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2539) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/cancel-order` | +| [marginBatchCancelOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2559) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/batch-cancel-order` | +| [getMarginOpenOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2573) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/open-orders` | +| [getMarginHistoricOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2587) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/history-orders` | +| [getMarginHistoricOrderFills()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2604) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/fills` | +| [getMarginLiquidationOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2618) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/liquidation-order` | +| [getFuturesTraderCurrentOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2650) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/order-current-track` | +| [getFuturesTraderHistoryOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2659) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/order-history-track` | +| [modifyFuturesTraderOrderTPSL()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2668) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-trader/order-modify-tpsl` | +| [getFuturesTraderOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2677) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/order-total-detail` | +| [getFuturesTraderProfitHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2683) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/profit-history-summarys` | +| [getFuturesTraderProfitShareHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2689) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/profit-history-details` | +| [closeFuturesTraderOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2698) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-trader/order-close-positions` | +| [getFuturesTraderProfitShare()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2717) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/profit-details` | +| [getFuturesTraderProfitShareGroup()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2733) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/profits-group-coin-date` | +| [getFuturesTraderSymbolSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2751) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/config-query-symbols` | +| [updateFuturesTraderSymbolSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2760) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-trader/config-setting-symbols` | +| [updateFuturesTraderGlobalSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2769) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-trader/config-settings-base` | +| [getFuturesTraderFollowers()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2780) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/config-query-followers` | +| [removeFuturesTraderFollower()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2789) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-trader/config-remove-follower` | +| [getFuturesFollowerCurrentOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2806) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-follower/query-current-orders` | +| [getFuturesFollowerHistoryOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2815) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-follower/query-history-orders` | +| [updateFuturesFollowerTPSL()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2824) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-follower/setting-tpsl` | +| [updateFuturesFollowerSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2830) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-follower/settings` | +| [getFuturesFollowerSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2836) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-follower/query-settings` | +| [closeFuturesFollowerPositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2842) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-follower/close-positions` | +| [getFuturesFollowerTraders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2855) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-follower/query-traders` | +| [getFuturesFollowerFollowLimit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2861) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-follower/query-quantity-limit` | +| [unfollowFuturesTrader()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2879) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-follower/cancel-trader` | +| [getBrokerTraders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2893) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-broker/query-traders` | +| [getBrokerTradersHistoricalOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2897) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-broker/query-history-traces` | +| [getBrokerTradersPendingOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2904) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-broker/query-current-traces` | +| [getSpotTraderProfit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2919) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/profit-summarys` | +| [getSpotTraderHistoryProfit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2923) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/profit-history-details` | +| [getSpotTraderUnrealizedProfit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2932) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/profit-details` | +| [getSpotTraderOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2940) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/order-total-detail` | +| [modifySpotTraderOrderTPSL()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2944) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-trader/order-modify-tpsl` | +| [getSpotTraderHistoryOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2955) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/order-history-track` | +| [getSpotTraderCurrentOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2964) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/order-current-track` | +| [sellSpotTrader()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2973) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-trader/order-close-tracking` | +| [getSpotTraderSymbolSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2983) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-trader/config-setting-symbols` | +| [removeSpotTraderFollowers()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2993) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-trader/config-remove-follower` | +| [getSpotTraderConfiguration()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3002) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/config-query-settings` | +| [getSpotTraderFollowers()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3006) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/config-query-followers` | +| [cancelSpotFollowerOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3023) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-follower/stop-order` | +| [updateSpotFollowerSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3029) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-follower/settings` | +| [updateSpotFollowerTPSL()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3038) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-follower/setting-tpsl` | +| [getSpotFollowerTraders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3046) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-follower/query-traders` | +| [getSpotFollowerCurrentTraderSymbols()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3055) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-follower/query-trader-symbols` | +| [getSpotFollowerSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3066) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-follower/query-settings` | +| [getSpotFollowerHistoryOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3072) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-follower/query-history-orders` | +| [getSpotFollowerOpenOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3081) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-follower/query-current-orders` | +| [sellSpotFollower()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3090) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-follower/order-close-tracking` | +| [unfollowSpotTrader()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3100) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-follower/cancel-trader` | +| [getEarnSavingsProducts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3114) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/product` | +| [getEarnSavingsAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3121) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/account` | +| [getEarnSavingsAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3125) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/assets` | +| [getEarnSavingsRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3131) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/records` | +| [getEarnSavingsSubscription()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3137) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/subscribe-info` | +| [earnSubscribeSavings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3144) | :closed_lock_with_key: | POST | `/api/v2/earn/savings/subscribe` | +| [getEarnSavingsSubscriptionResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3157) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/subscribe-result` | +| [earnRedeemSavings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3169) | :closed_lock_with_key: | POST | `/api/v2/earn/savings/redeem` | +| [getEarnSavingsRedemptionResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3178) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/redeem-result` | +| [getEarnAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3198) | :closed_lock_with_key: | GET | `/api/v2/earn/account/assets` | +| [getEarnEliteProducts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3217) | :closed_lock_with_key: | GET | `/api/v2/earn/elite/product` | +| [getEarnEliteAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3221) | :closed_lock_with_key: | GET | `/api/v2/earn/elite/assets` | +| [getEarnEliteRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3225) | :closed_lock_with_key: | GET | `/api/v2/earn/elite/records` | +| [getEarnEliteSubscribeInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3231) | :closed_lock_with_key: | GET | `/api/v2/earn/elite/subscribe-info` | +| [subscribeEarnElite()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3237) | :closed_lock_with_key: | POST | `/api/v2/earn/elite/subscribe` | +| [getEarnEliteSubscribeResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3243) | :closed_lock_with_key: | GET | `/api/v2/earn/elite/subscribe-result` | +| [getEarnEliteRedeemInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3249) | :closed_lock_with_key: | GET | `/api/v2/earn/elite/redeem-info` | +| [redeemEarnElite()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3255) | :closed_lock_with_key: | POST | `/api/v2/earn/elite/redeem` | +| [getSharkfinProducts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3269) | :closed_lock_with_key: | GET | `/api/v2/earn/sharkfin/product` | +| [getSharkfinAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3277) | :closed_lock_with_key: | GET | `/api/v2/earn/sharkfin/account` | +| [getSharkfinAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3281) | :closed_lock_with_key: | GET | `/api/v2/earn/sharkfin/assets` | +| [getSharkfinRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3287) | :closed_lock_with_key: | GET | `/api/v2/earn/sharkfin/records` | +| [getSharkfinSubscription()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3293) | :closed_lock_with_key: | GET | `/api/v2/earn/sharkfin/subscribe-info` | +| [subscribeSharkfin()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3299) | :closed_lock_with_key: | POST | `/api/v2/earn/sharkfin/subscribe` | +| [getSharkfinSubscriptionResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3308) | :closed_lock_with_key: | GET | `/api/v2/earn/sharkfin/subscribe-result` | +| [getLoanCurrencies()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3325) | | GET | `/api/v2/earn/loan/public/coinInfos` | +| [getLoanEstInterestAndBorrowable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3331) | | GET | `/api/v2/earn/loan/public/hour-interest` | +| [borrowLoan()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3342) | :closed_lock_with_key: | POST | `/api/v2/earn/loan/borrow` | +| [getOngoingLoanOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3350) | :closed_lock_with_key: | GET | `/api/v2/earn/loan/ongoing-orders` | +| [repayLoan()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3358) | :closed_lock_with_key: | POST | `/api/v2/earn/loan/repay` | +| [getRepayHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3364) | :closed_lock_with_key: | GET | `/api/v2/earn/loan/repay-history` | +| [updateLoanPledgeRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3370) | :closed_lock_with_key: | POST | `/api/v2/earn/loan/revise-pledge` | +| [getLoanPledgeRateHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3380) | :closed_lock_with_key: | GET | `/api/v2/earn/loan/revise-history` | +| [getLoanHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3386) | :closed_lock_with_key: | GET | `/api/v2/earn/loan/borrow-history` | +| [getLoanDebts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3392) | :closed_lock_with_key: | GET | `/api/v2/earn/loan/debts` | +| [getLoanLiquidationRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3396) | :closed_lock_with_key: | GET | `/api/v2/earn/loan/reduces` | +| [getLoanProductInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3408) | :closed_lock_with_key: | GET | `/api/v2/spot/ins-loan/product-infos` | +| [getLoanSymbols()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3414) | :closed_lock_with_key: | GET | `/api/v2/spot/ins-loan/symbols` | +| [getLoanMarginCoinInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3420) | :closed_lock_with_key: | GET | `/api/v2/spot/ins-loan/ensure-coins-convert` | +| [getLoanRiskUnit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3438) | :closed_lock_with_key: | GET | `/api/v2/spot/ins-loan/risk-unit` | +| [getLoanLTVConvert()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3446) | :closed_lock_with_key: | GET | `/api/v2/spot/ins-loan/ltv-convert` | +| [getLoanRepaidHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3458) | :closed_lock_with_key: | GET | `/api/v2/spot/ins-loan/repaid-history` | +| [getLoanOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3464) | :closed_lock_with_key: | GET | `/api/v2/spot/ins-loan/loan-order` | # rest-client-v3.ts @@ -348,177 +361,216 @@ This table includes all endpoints from the official Exchange API docs and corres | Function | AUTH | HTTP Method | Endpoint | | -------- | :------: | :------: | -------- | -| [getServerTime()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L402) | | GET | `/api/v3/public/time` | -| [getInstruments()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L419) | | GET | `/api/v3/market/instruments` | -| [getMarketFeeGroup()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L428) | | GET | `/api/v3/market/fee-group` | -| [getLiquidations()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L437) | | GET | `/api/v3/market/liquidations` | -| [getRpiSymbols()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L446) | | GET | `/api/v3/market/rpi-symbols` | -| [getRpiOrderBook()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L453) | | GET | `/api/v3/market/rpi-orderbook` | -| [getCashDividendRecords()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L462) | | GET | `/api/v3/market/cash-dividend-records` | -| [getSpotWhaleFlow()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L471) | | GET | `/api/v3/market/spot-whale-flow` | -| [getSpotFundFlow()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L480) | | GET | `/api/v3/market/spot-fund-flow` | -| [getSpotNetFlow()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L489) | | GET | `/api/v3/market/spot-net-flow` | -| [getMarginLongShort()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L498) | | GET | `/api/v3/market/margin-long-short` | -| [getMarginLoanGrowth()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L507) | | GET | `/api/v3/market/margin-loan-growth` | -| [getMarginIsolatedBorrow()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L516) | | GET | `/api/v3/market/margin-isolated-borrow` | -| [getFuturesActiveBuySell()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L525) | | GET | `/api/v3/market/futures-active-buy-sell` | -| [getFuturesLongShort()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L534) | | GET | `/api/v3/market/futures-long-short` | -| [getFuturesPositionLongShort()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L543) | | GET | `/api/v3/market/futures-position-long-short` | -| [getFuturesAccountLongShort()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L552) | | GET | `/api/v3/market/futures-account-long-short` | -| [getMarketScoreWeights()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L561) | | GET | `/api/v3/market/score-weights` | -| [getTickers()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L570) | | GET | `/api/v3/market/tickers` | -| [getOrderBook()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L577) | | GET | `/api/v3/market/orderbook` | -| [getFills()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L586) | | GET | `/api/v3/market/fills` | -| [getProofOfReserves()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L595) | | GET | `/api/v3/market/proof-of-reserves` | -| [getOpenInterest()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L602) | | GET | `/api/v3/market/open-interest` | -| [getCandles()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L612) | | GET | `/api/v3/market/candles` | -| [getHistoryCandles()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L621) | | GET | `/api/v3/market/history-candles` | -| [getCurrentFundingRate()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L630) | | GET | `/api/v3/market/current-fund-rate` | -| [getHistoryFundingRate()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L639) | | GET | `/api/v3/market/history-fund-rate` | -| [getRiskReserve()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L648) | | GET | `/api/v3/market/risk-reserve` | -| [getRiskReserveHour()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L657) | | GET | `/api/v3/market/risk-reserve-hour` | -| [getRiskReserveAll()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L666) | | GET | `/api/v3/market/risk-reserve-all` | -| [getDiscountRate()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L675) | | GET | `/api/v3/market/discount-rate` | -| [getMarginLoans()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L682) | | GET | `/api/v3/market/margin-loans` | -| [getPositionTier()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L691) | | GET | `/api/v3/market/position-tier` | -| [getContractsOi()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L700) | | GET | `/api/v3/market/oi-limit` | -| [getIndexComponents()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L709) | | GET | `/api/v3/market/index-components` | -| [getCopyFuturesTradingPairs()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L726) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/trading-pairs` | -| [getCopyFuturesPositionSummary()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L737) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/position-summary` | -| [getCopyFuturesMaxTransferable()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L747) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/max-transferable` | -| [copyFuturesTransfer()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L757) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/transfer` | -| [getCopyFuturesTransferRecords()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L767) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/transfer-record` | -| [getBalances()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L782) | :closed_lock_with_key: | GET | `/api/v3/account/assets` | -| [getFundingAssets()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L789) | :closed_lock_with_key: | GET | `/api/v3/account/funding-assets` | -| [getAccountInfo()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L799) | :closed_lock_with_key: | GET | `/api/v3/account/info` | -| [getAccountSettings()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L807) | :closed_lock_with_key: | GET | `/api/v3/account/settings` | -| [adjustAccountMode()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L814) | :closed_lock_with_key: | POST | `/api/v3/account/adjust-account-mode` | -| [getDeltaInfo()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L824) | :closed_lock_with_key: | GET | `/api/v3/account/delta-info` | -| [setLeverage()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L831) | :closed_lock_with_key: | POST | `/api/v3/account/set-leverage` | -| [setHoldMode()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L838) | :closed_lock_with_key: | POST | `/api/v3/account/set-hold-mode` | -| [getCollateralType()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L847) | :closed_lock_with_key: | GET | `/api/v3/account/collateral-type` | -| [setCollateralType()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L854) | :closed_lock_with_key: | POST | `/api/v3/account/set-collateral-type` | -| [getCustomCollateralCoins()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L863) | | GET | `/api/v3/account/custom-collateral-coins` | -| [preSetLeverage()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L870) | :closed_lock_with_key: | GET | `/api/v3/account/pre-set-leverage` | -| [setMargin()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L879) | :closed_lock_with_key: | POST | `/api/v3/account/set-margin` | -| [getMaxWithdrawal()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L886) | :closed_lock_with_key: | GET | `/api/v3/account/max-withdrawal` | -| [getFinancialRecords()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L895) | :closed_lock_with_key: | GET | `/api/v3/account/financial-records` | -| [getRepayableCoins()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L907) | :closed_lock_with_key: | GET | `/api/v3/account/repayable-coins` | -| [getPaymentCoins()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L919) | :closed_lock_with_key: | GET | `/api/v3/account/payment-coins` | -| [submitRepay()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L931) | :closed_lock_with_key: | POST | `/api/v3/account/repay` | -| [getConvertRecords()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L938) | :closed_lock_with_key: | GET | `/api/v3/account/convert-records` | -| [setDepositAccount()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L953) | :closed_lock_with_key: | POST | `/api/v3/account/deposit-account` | -| [switchDeduct()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L962) | :closed_lock_with_key: | POST | `/api/v3/account/switch-deduct` | -| [getDeductInfo()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L969) | :closed_lock_with_key: | GET | `/api/v3/account/deduct-info` | -| [getFeeRate()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L980) | :closed_lock_with_key: | GET | `/api/v3/account/fee-rate` | -| [getAllFeeRates()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L992) | :closed_lock_with_key: | GET | `/api/v3/account/all-fee-rate` | -| [getMaxTransferable()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1005) | :closed_lock_with_key: | GET | `/api/v3/account/max-transferable` | -| [getOpenInterestLimit()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1017) | :closed_lock_with_key: | GET | `/api/v3/account/open-interest-limit` | -| [downgradeAccountToClassic()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1032) | :closed_lock_with_key: | POST | `/api/v3/account/switch` | -| [getUnifiedAccountSwitchStatus()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1040) | :closed_lock_with_key: | GET | `/api/v3/account/switch-status` | -| [getTaxRecords()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1056) | :closed_lock_with_key: | GET | `/api/v3/tax/records` | -| [createSubAccount()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1071) | :closed_lock_with_key: | POST | `/api/v3/user/create-sub` | -| [freezeSubAccount()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1080) | :closed_lock_with_key: | POST | `/api/v3/user/freeze-sub` | -| [getSubUnifiedAssets()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1089) | :closed_lock_with_key: | GET | `/api/v3/account/sub-unified-assets` | -| [getSubAccountList()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1098) | :closed_lock_with_key: | GET | `/api/v3/user/sub-list` | -| [createSubAccountApiKey()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1111) | :closed_lock_with_key: | POST | `/api/v3/user/create-sub-api` | -| [updateSubAccountApiKey()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1120) | :closed_lock_with_key: | POST | `/api/v3/user/update-sub-api` | -| [deleteSubAccountApiKey()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1129) | :closed_lock_with_key: | POST | `/api/v3/user/delete-sub-api` | -| [getSubAccountApiKeys()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1138) | :closed_lock_with_key: | GET | `/api/v3/user/sub-api-list` | -| [getTransferableCoins()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1157) | :closed_lock_with_key: | GET | `/api/v3/account/transferable-coins` | -| [submitTransfer()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1166) | :closed_lock_with_key: | POST | `/api/v3/account/transfer` | -| [subAccountTransfer()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1175) | :closed_lock_with_key: | POST | `/api/v3/account/sub-transfer` | -| [getSubTransferRecords()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1187) | :closed_lock_with_key: | GET | `/api/v3/account/sub-transfer-record` | -| [getDepositAddress()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1205) | :closed_lock_with_key: | GET | `/api/v3/account/deposit-address` | -| [getSubDepositAddress()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1214) | :closed_lock_with_key: | GET | `/api/v3/account/sub-deposit-address` | -| [getDepositRecords()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1223) | :closed_lock_with_key: | GET | `/api/v3/account/deposit-records` | -| [getSubDepositRecords()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1232) | :closed_lock_with_key: | POST | `/api/v3/account/sub-deposit-records` | -| [submitWithdraw()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1247) | :closed_lock_with_key: | POST | `/api/v3/account/withdraw` | -| [getWithdrawRecords()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1256) | :closed_lock_with_key: | GET | `/api/v3/account/withdrawal-records` | -| [getWithdrawAddressBook()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1265) | :closed_lock_with_key: | GET | `/api/v3/account/withdraw-address` | -| [cancelWithdrawal()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1274) | :closed_lock_with_key: | POST | `/api/v3/account/cancel-withdrawal` | -| [submitNewOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1289) | :closed_lock_with_key: | POST | `/api/v3/trade/place-order` | -| [modifyOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1298) | :closed_lock_with_key: | POST | `/api/v3/trade/modify-order` | -| [placeRealityOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1307) | :closed_lock_with_key: | POST | `/api/v3/trade/place-reality-order` | -| [cancelRealityOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1316) | :closed_lock_with_key: | POST | `/api/v3/trade/cancel-reality-order` | -| [getLoanData()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1325) | :closed_lock_with_key: | GET | `/api/v3/trade/loan-data` | -| [cancelOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1332) | :closed_lock_with_key: | POST | `/api/v3/trade/cancel-order` | -| [placeBatchOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1341) | :closed_lock_with_key: | POST | `/api/v3/trade/place-batch` | -| [batchModifyOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1350) | :closed_lock_with_key: | POST | `/api/v3/trade/batch-modify-order` | -| [cancelBatchOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1359) | :closed_lock_with_key: | POST | `/api/v3/trade/cancel-batch` | -| [cancelAllOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1368) | :closed_lock_with_key: | POST | `/api/v3/trade/cancel-symbol-order` | -| [closeAllPositions()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1377) | :closed_lock_with_key: | POST | `/api/v3/trade/close-positions` | -| [getOrderInfo()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1386) | :closed_lock_with_key: | GET | `/api/v3/trade/order-info` | -| [getUnfilledOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1395) | :closed_lock_with_key: | GET | `/api/v3/trade/unfilled-orders` | -| [getHistoryOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1407) | :closed_lock_with_key: | GET | `/api/v3/trade/history-orders` | -| [getTradeFills()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1419) | :closed_lock_with_key: | GET | `/api/v3/trade/fills` | -| [getCurrentPosition()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1431) | :closed_lock_with_key: | GET | `/api/v3/position/current-position` | -| [getPositionHistory()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1442) | :closed_lock_with_key: | GET | `/api/v3/position/history-position` | -| [getMaxOpenAvailable()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1454) | :closed_lock_with_key: | POST | `/api/v3/account/max-open-available` | -| [getPositionAdlRank()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1463) | :closed_lock_with_key: | GET | `/api/v3/position/adlRank` | -| [countdownCancelAll()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1470) | :closed_lock_with_key: | POST | `/api/v3/trade/countdown-cancel-all` | -| [getLoanTransfered()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1485) | :closed_lock_with_key: | GET | `/api/v3/ins-loan/transfered` | -| [getLoanSymbols()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1494) | :closed_lock_with_key: | GET | `/api/v3/ins-loan/symbols` | -| [getLoanRiskUnit()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1503) | :closed_lock_with_key: | GET | `/api/v3/ins-loan/risk-unit` | -| [getLoanRepaidHistory()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1514) | :closed_lock_with_key: | GET | `/api/v3/ins-loan/repaid-history` | -| [getLoanProductInfo()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1523) | :closed_lock_with_key: | GET | `/api/v3/ins-loan/product-infos` | -| [getLoanOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1532) | :closed_lock_with_key: | GET | `/api/v3/ins-loan/loan-order` | -| [getLoanLTVConvert()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1541) | :closed_lock_with_key: | GET | `/api/v3/ins-loan/ltv-convert` | -| [getLoanMarginCoinInfo()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1550) | :closed_lock_with_key: | GET | `/api/v3/ins-loan/ensure-coins-convert` | -| [bindLoanUid()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1562) | :closed_lock_with_key: | POST | `/api/v3/ins-loan/bind-uid` | -| [getLoanCoins()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1577) | :closed_lock_with_key: | GET | `/api/v3/loan/coins` | -| [getLoanInterest()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1586) | :closed_lock_with_key: | GET | `/api/v3/loan/interest` | -| [loanBorrow()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1595) | :closed_lock_with_key: | POST | `/api/v3/loan/borrow` | -| [getLoanBorrowOngoing()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1604) | :closed_lock_with_key: | GET | `/api/v3/loan/borrow-ongoing` | -| [getLoanBorrowHistory()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1613) | :closed_lock_with_key: | GET | `/api/v3/loan/borrow-history` | -| [loanRepay()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1622) | :closed_lock_with_key: | POST | `/api/v3/loan/repay` | -| [getLoanRepayHistory()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1631) | :closed_lock_with_key: | GET | `/api/v3/loan/repay-history` | -| [loanRevisePledge()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1640) | :closed_lock_with_key: | POST | `/api/v3/loan/revise-pledge` | -| [getLoanPledgeRateHistory()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1649) | :closed_lock_with_key: | GET | `/api/v3/loan/pledge-rate-history` | -| [getLoanDebts()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1658) | :closed_lock_with_key: | GET | `/api/v3/loan/debts` | -| [getLoanReduces()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1665) | :closed_lock_with_key: | GET | `/api/v3/loan/reduces` | -| [submitStrategyOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1680) | :closed_lock_with_key: | POST | `/api/v3/trade/place-strategy-order` | -| [modifyStrategyOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1689) | :closed_lock_with_key: | POST | `/api/v3/trade/modify-strategy-order` | -| [cancelStrategyOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1698) | :closed_lock_with_key: | POST | `/api/v3/trade/cancel-strategy-order` | -| [getUnfilledStrategyOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1707) | :closed_lock_with_key: | GET | `/api/v3/trade/unfilled-strategy-orders` | -| [getHistoryStrategyOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1716) | :closed_lock_with_key: | GET | `/api/v3/trade/history-strategy-orders` | -| [createBrokerSubAccount()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1737) | :closed_lock_with_key: | POST | `/api/v3/broker/create-sub` | -| [getBrokerSubAccountList()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1749) | :closed_lock_with_key: | GET | `/api/v3/broker/sub-list` | -| [modifyBrokerSubAccount()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1761) | :closed_lock_with_key: | POST | `/api/v3/broker/modify-sub` | -| [brokerSubWithdrawal()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1776) | :closed_lock_with_key: | POST | `/api/v3/broker/sub-withdrawal` | -| [getBrokerSubDepositAddress()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1788) | :closed_lock_with_key: | POST | `/api/v3/broker/sub-deposit-address` | -| [getBrokerAllSubDepositWithdrawal()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1800) | :closed_lock_with_key: | GET | `/api/v3/broker/all-sub-deposit-withdrawal` | -| [getBrokerCommission()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1812) | :closed_lock_with_key: | GET | `/api/v3/broker/commission` | -| [createBrokerSubApiKey()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1824) | :closed_lock_with_key: | POST | `/api/v3/broker/create-sub-apikey` | -| [modifyBrokerSubApiKey()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1836) | :closed_lock_with_key: | POST | `/api/v3/broker/modify-sub-apikey` | -| [deleteBrokerSubApiKey()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1852) | :closed_lock_with_key: | POST | `/api/v3/broker/delete-sub-apikey` | -| [getBrokerSubApiKey()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1864) | :closed_lock_with_key: | GET | `/api/v3/broker/query-sub-apikey` | -| [getP2pAdList()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1876) | :closed_lock_with_key: | GET | `/api/v3/p2p/ad-list` | -| [getP2pExchangeRate()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1882) | :closed_lock_with_key: | GET | `/api/v3/p2p/exchange-rate` | -| [simulateP2pFee()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1888) | :closed_lock_with_key: | POST | `/api/v3/p2p/fee-simulate` | -| [getP2pAdLimit()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1894) | :closed_lock_with_key: | GET | `/api/v3/p2p/ad-limit` | -| [createP2pAd()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1900) | :closed_lock_with_key: | POST | `/api/v3/p2p/ad-create` | -| [updateP2pAd()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1906) | :closed_lock_with_key: | POST | `/api/v3/p2p/ad-update` | -| [operateP2pAd()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1910) | :closed_lock_with_key: | POST | `/api/v3/p2p/ad-operate` | -| [getP2pAdInfo()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1914) | :closed_lock_with_key: | GET | `/api/v3/p2p/ad-info` | -| [getP2pMyAds()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1920) | :closed_lock_with_key: | GET | `/api/v3/p2p/my-ads` | -| [getP2pPendingOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1926) | :closed_lock_with_key: | GET | `/api/v3/p2p/pending-orders` | -| [getP2pAllOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1932) | :closed_lock_with_key: | GET | `/api/v3/p2p/all-orders` | -| [getP2pOrderInfo()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1938) | :closed_lock_with_key: | GET | `/api/v3/p2p/order-info` | -| [confirmP2pOrderPayment()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1944) | :closed_lock_with_key: | POST | `/api/v3/p2p/order-pay` | -| [releaseP2pOrderAsset()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1950) | :closed_lock_with_key: | POST | `/api/v3/p2p/order-release` | -| [getP2pUserInfo()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1956) | :closed_lock_with_key: | GET | `/api/v3/p2p/user-info` | -| [getP2pCurrencies()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1960) | :closed_lock_with_key: | GET | `/api/v3/p2p/currencies` | -| [getP2pPayMethods()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1964) | :closed_lock_with_key: | GET | `/api/v3/p2p/pay-method` | -| [getP2pBalance()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1968) | :closed_lock_with_key: | GET | `/api/v3/p2p/balance` | -| [getEarnEliteProducts()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1980) | :closed_lock_with_key: | GET | `/api/v3/earn/elite-product` | -| [getEarnEliteAssets()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1984) | :closed_lock_with_key: | GET | `/api/v3/earn/elite-assets` | -| [getEarnEliteRecords()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1988) | :closed_lock_with_key: | GET | `/api/v3/earn/elite-records` | -| [getEarnEliteSubscribeInfo()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L1994) | :closed_lock_with_key: | GET | `/api/v3/earn/elite-subscribe-info` | -| [subscribeEarnElite()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L2000) | :closed_lock_with_key: | POST | `/api/v3/earn/elite-subscribe` | -| [getEarnEliteSubscribeResult()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L2006) | :closed_lock_with_key: | GET | `/api/v3/earn/elite-subscribe-result` | -| [getEarnEliteRedeemInfo()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L2012) | :closed_lock_with_key: | GET | `/api/v3/earn/elite-redeem-info` | -| [redeemEarnElite()](https://github.com/tiagosiebler/bitget-api/blob/master/src/rest-client-v3.ts#L2018) | :closed_lock_with_key: | POST | `/api/v3/earn/elite-redeem` | +| [getServerTime()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L480) | | GET | `/api/v3/public/time` | +| [getInstruments()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L497) | | GET | `/api/v3/market/instruments` | +| [getMarketFeeGroup()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L506) | | GET | `/api/v3/market/fee-group` | +| [getLiquidations()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L515) | | GET | `/api/v3/market/liquidations` | +| [getRpiSymbols()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L524) | | GET | `/api/v3/market/rpi-symbols` | +| [getRpiOrderBook()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L531) | | GET | `/api/v3/market/rpi-orderbook` | +| [getCashDividendRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L540) | | GET | `/api/v3/market/cash-dividend-records` | +| [getSpotWhaleFlow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L549) | | GET | `/api/v3/market/spot-whale-flow` | +| [getSpotFundFlow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L558) | | GET | `/api/v3/market/spot-fund-flow` | +| [getSpotNetFlow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L567) | | GET | `/api/v3/market/spot-net-flow` | +| [getMarginLongShort()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L576) | | GET | `/api/v3/market/margin-long-short` | +| [getMarginLoanGrowth()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L585) | | GET | `/api/v3/market/margin-loan-growth` | +| [getMarginIsolatedBorrow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L594) | | GET | `/api/v3/market/margin-isolated-borrow` | +| [getFuturesActiveBuySell()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L603) | | GET | `/api/v3/market/futures-active-buy-sell` | +| [getFuturesLongShort()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L612) | | GET | `/api/v3/market/futures-long-short` | +| [getFuturesPositionLongShort()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L621) | | GET | `/api/v3/market/futures-position-long-short` | +| [getFuturesAccountLongShort()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L630) | | GET | `/api/v3/market/futures-account-long-short` | +| [getMarketScoreWeights()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L639) | | GET | `/api/v3/market/score-weights` | +| [getTickers()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L648) | | GET | `/api/v3/market/tickers` | +| [getOrderBook()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L655) | | GET | `/api/v3/market/orderbook` | +| [getFills()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L664) | | GET | `/api/v3/market/fills` | +| [getProofOfReserves()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L673) | | GET | `/api/v3/market/proof-of-reserves` | +| [getOpenInterest()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L680) | | GET | `/api/v3/market/open-interest` | +| [getCandles()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L690) | | GET | `/api/v3/market/candles` | +| [getHistoryCandles()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L699) | | GET | `/api/v3/market/history-candles` | +| [getCurrentFundingRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L708) | | GET | `/api/v3/market/current-fund-rate` | +| [getHistoryFundingRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L717) | | GET | `/api/v3/market/history-fund-rate` | +| [getRiskReserve()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L726) | | GET | `/api/v3/market/risk-reserve` | +| [getRiskReserveHour()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L735) | | GET | `/api/v3/market/risk-reserve-hour` | +| [getRiskReserveAll()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L744) | | GET | `/api/v3/market/risk-reserve-all` | +| [getDiscountRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L753) | | GET | `/api/v3/market/discount-rate` | +| [getMarginLoans()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L760) | | GET | `/api/v3/market/margin-loans` | +| [getPositionTier()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L769) | | GET | `/api/v3/market/position-tier` | +| [getContractsOi()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L778) | | GET | `/api/v3/market/oi-limit` | +| [getIndexComponents()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L787) | | GET | `/api/v3/market/index-components` | +| [getRealityOrderBook()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L796) | :closed_lock_with_key: | GET | `/api/v3/account/reality-orderbook` | +| [getRealityFills()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L805) | :closed_lock_with_key: | GET | `/api/v3/account/reality-fills` | +| [getCopyFuturesTradingPairs()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L822) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/trading-pairs` | +| [getCopyFuturesPositionSummary()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L833) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/position-summary` | +| [getCopyFuturesMaxTransferable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L843) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/max-transferable` | +| [copyFuturesTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L853) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/transfer` | +| [getCopyFuturesTransferRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L863) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/transfer-record` | +| [getCopyFuturesCurrentFollowers()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L869) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/current-follower` | +| [getCopyFuturesHistoryFollowers()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L875) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/history-follower` | +| [getCopyFuturesProfitSummary()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L881) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/profit-summary` | +| [getCopyFuturesProfitDetails()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L887) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/profit-details` | +| [getStockPlusOptionQuote()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L899) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/option-quote` | +| [getStockPlusOptionChainInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L905) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/option-chain-info` | +| [getStockPlusOptionExpiryDate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L914) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/option-expiry-date` | +| [getStockPlusOptionVolume()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L923) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/option-volume` | +| [getStockPlusStaticInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L929) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/static` | +| [getStockPlusQuote()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L935) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/quote` | +| [getStockPlusTradeDetail()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L941) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/trade` | +| [getStockPlusIntraday()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L947) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/intraday` | +| [getStockPlusHistoryCandlestick()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L953) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/history-candlestick` | +| [getStockPlusCandlestick()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L962) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/candlestick` | +| [getStockPlusDepth()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L968) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/depth` | +| [placeStockPlusOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L974) | :closed_lock_with_key: | POST | `/api/v3/stockplus/trade/place-order` | +| [cancelStockPlusOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L980) | :closed_lock_with_key: | POST | `/api/v3/stockplus/trade/cancel-order` | +| [modifyStockPlusOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L986) | :closed_lock_with_key: | POST | `/api/v3/stockplus/trade/modify-order` | +| [getStockPlusTodayOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L992) | :closed_lock_with_key: | GET | `/api/v3/stockplus/trade/today-orders` | +| [getStockPlusHistoryOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L998) | :closed_lock_with_key: | GET | `/api/v3/stockplus/trade/history-orders` | +| [getStockPlusOrderDetail()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1004) | :closed_lock_with_key: | GET | `/api/v3/stockplus/trade/order-detail` | +| [getStockPlusTodayExecutions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1010) | :closed_lock_with_key: | GET | `/api/v3/stockplus/trade/today-executions` | +| [getStockPlusHistoryExecutions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1016) | :closed_lock_with_key: | GET | `/api/v3/stockplus/trade/history-executions` | +| [getStockPlusAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1025) | :closed_lock_with_key: | GET | `/api/v3/stockplus/asset/account` | +| [getStockPlusCashFlow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1031) | :closed_lock_with_key: | GET | `/api/v3/stockplus/asset/cash-flow` | +| [getStockPlusStockPosition()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1037) | :closed_lock_with_key: | GET | `/api/v3/stockplus/asset/stock-position` | +| [stockPlusTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1043) | :closed_lock_with_key: | POST | `/api/v3/stockplus/asset/transfer` | +| [getStockPlusTransferRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1049) | :closed_lock_with_key: | GET | `/api/v3/stockplus/asset/transfer-records` | +| [getBalances()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1064) | :closed_lock_with_key: | GET | `/api/v3/account/assets` | +| [getFundingAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1071) | :closed_lock_with_key: | GET | `/api/v3/account/funding-assets` | +| [getAccountInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1081) | :closed_lock_with_key: | GET | `/api/v3/account/info` | +| [getAccountSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1089) | :closed_lock_with_key: | GET | `/api/v3/account/settings` | +| [adjustAccountMode()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1096) | :closed_lock_with_key: | POST | `/api/v3/account/adjust-account-mode` | +| [getDeltaInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1106) | :closed_lock_with_key: | GET | `/api/v3/account/delta-info` | +| [setLeverage()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1113) | :closed_lock_with_key: | POST | `/api/v3/account/set-leverage` | +| [setHoldMode()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1120) | :closed_lock_with_key: | POST | `/api/v3/account/set-hold-mode` | +| [getCollateralType()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1129) | :closed_lock_with_key: | GET | `/api/v3/account/collateral-type` | +| [setCollateralType()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1136) | :closed_lock_with_key: | POST | `/api/v3/account/set-collateral-type` | +| [getCustomCollateralCoins()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1145) | | GET | `/api/v3/account/custom-collateral-coins` | +| [preSetLeverage()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1152) | :closed_lock_with_key: | GET | `/api/v3/account/pre-set-leverage` | +| [setMargin()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1161) | :closed_lock_with_key: | POST | `/api/v3/account/set-margin` | +| [getMaxWithdrawal()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1168) | :closed_lock_with_key: | GET | `/api/v3/account/max-withdrawal` | +| [getFinancialRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1177) | :closed_lock_with_key: | GET | `/api/v3/account/financial-records` | +| [getRepayableCoins()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1189) | :closed_lock_with_key: | GET | `/api/v3/account/repayable-coins` | +| [getPaymentCoins()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1201) | :closed_lock_with_key: | GET | `/api/v3/account/payment-coins` | +| [submitRepay()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1213) | :closed_lock_with_key: | POST | `/api/v3/account/repay` | +| [getConvertRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1220) | :closed_lock_with_key: | GET | `/api/v3/account/convert-records` | +| [setDepositAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1235) | :closed_lock_with_key: | POST | `/api/v3/account/deposit-account` | +| [switchDeduct()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1244) | :closed_lock_with_key: | POST | `/api/v3/account/switch-deduct` | +| [getDeductInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1251) | :closed_lock_with_key: | GET | `/api/v3/account/deduct-info` | +| [getFeeRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1262) | :closed_lock_with_key: | GET | `/api/v3/account/fee-rate` | +| [getAllFeeRates()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1274) | :closed_lock_with_key: | GET | `/api/v3/account/all-fee-rate` | +| [getMaxTransferable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1287) | :closed_lock_with_key: | GET | `/api/v3/account/max-transferable` | +| [getOpenInterestLimit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1299) | :closed_lock_with_key: | GET | `/api/v3/account/open-interest-limit` | +| [getEligibleSymbols()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1305) | :closed_lock_with_key: | GET | `/api/v3/account/eligible-symbols` | +| [getEligibleMarginTier()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1311) | :closed_lock_with_key: | GET | `/api/v3/account/eligible-margin-tier` | +| [getEligibleLoanInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1317) | :closed_lock_with_key: | GET | `/api/v3/account/eligible-loan-info` | +| [downgradeAccountToClassic()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1332) | :closed_lock_with_key: | POST | `/api/v3/account/switch` | +| [getUnifiedAccountSwitchStatus()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1340) | :closed_lock_with_key: | GET | `/api/v3/account/switch-status` | +| [getTaxRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1356) | :closed_lock_with_key: | GET | `/api/v3/tax/records` | +| [createSubAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1371) | :closed_lock_with_key: | POST | `/api/v3/user/create-sub` | +| [createAgentSubAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1380) | :closed_lock_with_key: | POST | `/api/v3/user/sub-account/agent-create` | +| [freezeSubAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1389) | :closed_lock_with_key: | POST | `/api/v3/user/freeze-sub` | +| [getSubUnifiedAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1398) | :closed_lock_with_key: | GET | `/api/v3/account/sub-unified-assets` | +| [getSubAccountList()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1407) | :closed_lock_with_key: | GET | `/api/v3/user/sub-list` | +| [createSubAccountApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1420) | :closed_lock_with_key: | POST | `/api/v3/user/create-sub-api` | +| [updateSubAccountApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1429) | :closed_lock_with_key: | POST | `/api/v3/user/update-sub-api` | +| [deleteSubAccountApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1438) | :closed_lock_with_key: | POST | `/api/v3/user/delete-sub-api` | +| [getSubAccountApiKeys()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1447) | :closed_lock_with_key: | GET | `/api/v3/user/sub-api-list` | +| [getRateLimitQuota()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1457) | :closed_lock_with_key: | GET | `/api/v3/user/rate-limit-quota` | +| [setRateLimitQuota()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1463) | :closed_lock_with_key: | POST | `/api/v3/user/set-rate-limit-quota` | +| [getTransferableCoins()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1478) | :closed_lock_with_key: | GET | `/api/v3/account/transferable-coins` | +| [submitTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1487) | :closed_lock_with_key: | POST | `/api/v3/account/transfer` | +| [subAccountTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1496) | :closed_lock_with_key: | POST | `/api/v3/account/sub-transfer` | +| [getSubTransferRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1508) | :closed_lock_with_key: | GET | `/api/v3/account/sub-transfer-record` | +| [subMasterTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1520) | :closed_lock_with_key: | POST | `/api/v3/account/sub-master-transfer` | +| [getDepositAddress()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1538) | :closed_lock_with_key: | GET | `/api/v3/account/deposit-address` | +| [getSubDepositAddress()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1547) | :closed_lock_with_key: | GET | `/api/v3/account/sub-deposit-address` | +| [getDepositRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1556) | :closed_lock_with_key: | GET | `/api/v3/account/deposit-records` | +| [getSubDepositRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1565) | :closed_lock_with_key: | POST | `/api/v3/account/sub-deposit-records` | +| [submitWithdraw()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1580) | :closed_lock_with_key: | POST | `/api/v3/account/withdraw` | +| [getWithdrawRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1589) | :closed_lock_with_key: | GET | `/api/v3/account/withdrawal-records` | +| [getWithdrawAddressBook()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1598) | :closed_lock_with_key: | GET | `/api/v3/account/withdraw-address` | +| [cancelWithdrawal()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1607) | :closed_lock_with_key: | POST | `/api/v3/account/cancel-withdrawal` | +| [submitNewOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1622) | :closed_lock_with_key: | POST | `/api/v3/trade/place-order` | +| [modifyOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1631) | :closed_lock_with_key: | POST | `/api/v3/trade/modify-order` | +| [placeRealityOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1640) | :closed_lock_with_key: | POST | `/api/v3/trade/place-reality-order` | +| [cancelRealityOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1649) | :closed_lock_with_key: | POST | `/api/v3/trade/cancel-reality-order` | +| [getLoanData()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1658) | :closed_lock_with_key: | GET | `/api/v3/trade/loan-data` | +| [cancelOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1665) | :closed_lock_with_key: | POST | `/api/v3/trade/cancel-order` | +| [placeBatchOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1674) | :closed_lock_with_key: | POST | `/api/v3/trade/place-batch` | +| [batchModifyOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1683) | :closed_lock_with_key: | POST | `/api/v3/trade/batch-modify-order` | +| [cancelBatchOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1692) | :closed_lock_with_key: | POST | `/api/v3/trade/cancel-batch` | +| [cancelAllOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1701) | :closed_lock_with_key: | POST | `/api/v3/trade/cancel-symbol-order` | +| [closeAllPositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1710) | :closed_lock_with_key: | POST | `/api/v3/trade/close-positions` | +| [getOrderInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1719) | :closed_lock_with_key: | GET | `/api/v3/trade/order-info` | +| [getUnfilledOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1728) | :closed_lock_with_key: | GET | `/api/v3/trade/unfilled-orders` | +| [getHistoryOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1740) | :closed_lock_with_key: | GET | `/api/v3/trade/history-orders` | +| [movePositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1752) | :closed_lock_with_key: | POST | `/api/v3/account/move-positions` | +| [getMovePositionHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1761) | :closed_lock_with_key: | GET | `/api/v3/account/move-position-history` | +| [getTradeFills()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1773) | :closed_lock_with_key: | GET | `/api/v3/trade/fills` | +| [getCurrentPosition()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1785) | :closed_lock_with_key: | GET | `/api/v3/position/current-position` | +| [getPositionHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1796) | :closed_lock_with_key: | GET | `/api/v3/position/history-position` | +| [getMaxOpenAvailable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1808) | :closed_lock_with_key: | POST | `/api/v3/account/max-open-available` | +| [getPositionAdlRank()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1817) | :closed_lock_with_key: | GET | `/api/v3/position/adlRank` | +| [countdownCancelAll()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1824) | :closed_lock_with_key: | POST | `/api/v3/trade/countdown-cancel-all` | +| [getLoanTransfered()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1839) | :closed_lock_with_key: | GET | `/api/v3/ins-loan/transfered` | +| [getLoanSymbols()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1848) | :closed_lock_with_key: | GET | `/api/v3/ins-loan/symbols` | +| [getLoanRiskUnit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1857) | :closed_lock_with_key: | GET | `/api/v3/ins-loan/risk-unit` | +| [getLoanRepaidHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1868) | :closed_lock_with_key: | GET | `/api/v3/ins-loan/repaid-history` | +| [getLoanProductInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1877) | :closed_lock_with_key: | GET | `/api/v3/ins-loan/product-infos` | +| [getLoanOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1886) | :closed_lock_with_key: | GET | `/api/v3/ins-loan/loan-order` | +| [getLoanLTVConvert()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1895) | :closed_lock_with_key: | GET | `/api/v3/ins-loan/ltv-convert` | +| [getLoanMarginCoinInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1904) | :closed_lock_with_key: | GET | `/api/v3/ins-loan/ensure-coins-convert` | +| [bindLoanUid()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1916) | :closed_lock_with_key: | POST | `/api/v3/ins-loan/bind-uid` | +| [getLoanCoins()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1931) | :closed_lock_with_key: | GET | `/api/v3/loan/coins` | +| [getLoanInterest()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1940) | :closed_lock_with_key: | GET | `/api/v3/loan/interest` | +| [loanBorrow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1949) | :closed_lock_with_key: | POST | `/api/v3/loan/borrow` | +| [getLoanBorrowOngoing()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1958) | :closed_lock_with_key: | GET | `/api/v3/loan/borrow-ongoing` | +| [getLoanBorrowHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1967) | :closed_lock_with_key: | GET | `/api/v3/loan/borrow-history` | +| [loanRepay()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1976) | :closed_lock_with_key: | POST | `/api/v3/loan/repay` | +| [getLoanRepayHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1985) | :closed_lock_with_key: | GET | `/api/v3/loan/repay-history` | +| [loanRevisePledge()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1994) | :closed_lock_with_key: | POST | `/api/v3/loan/revise-pledge` | +| [getLoanPledgeRateHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2003) | :closed_lock_with_key: | GET | `/api/v3/loan/pledge-rate-history` | +| [getLoanDebts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2012) | :closed_lock_with_key: | GET | `/api/v3/loan/debts` | +| [getLoanReduces()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2019) | :closed_lock_with_key: | GET | `/api/v3/loan/reduces` | +| [submitStrategyOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2034) | :closed_lock_with_key: | POST | `/api/v3/trade/place-strategy-order` | +| [modifyStrategyOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2043) | :closed_lock_with_key: | POST | `/api/v3/trade/modify-strategy-order` | +| [cancelStrategyOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2052) | :closed_lock_with_key: | POST | `/api/v3/trade/cancel-strategy-order` | +| [getUnfilledStrategyOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2061) | :closed_lock_with_key: | GET | `/api/v3/trade/unfilled-strategy-orders` | +| [getHistoryStrategyOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2070) | :closed_lock_with_key: | GET | `/api/v3/trade/history-strategy-orders` | +| [createBrokerSubAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2091) | :closed_lock_with_key: | POST | `/api/v3/broker/create-sub` | +| [getBrokerSubAccountList()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2103) | :closed_lock_with_key: | GET | `/api/v3/broker/sub-list` | +| [modifyBrokerSubAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2115) | :closed_lock_with_key: | POST | `/api/v3/broker/modify-sub` | +| [brokerSubWithdrawal()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2130) | :closed_lock_with_key: | POST | `/api/v3/broker/sub-withdrawal` | +| [getBrokerSubDepositAddress()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2142) | :closed_lock_with_key: | POST | `/api/v3/broker/sub-deposit-address` | +| [getBrokerAllSubDepositWithdrawal()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2154) | :closed_lock_with_key: | GET | `/api/v3/broker/all-sub-deposit-withdrawal` | +| [getBrokerCommission()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2166) | :closed_lock_with_key: | GET | `/api/v3/broker/commission` | +| [createBrokerSubApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2178) | :closed_lock_with_key: | POST | `/api/v3/broker/create-sub-apikey` | +| [modifyBrokerSubApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2190) | :closed_lock_with_key: | POST | `/api/v3/broker/modify-sub-apikey` | +| [deleteBrokerSubApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2206) | :closed_lock_with_key: | POST | `/api/v3/broker/delete-sub-apikey` | +| [getBrokerSubApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2218) | :closed_lock_with_key: | GET | `/api/v3/broker/query-sub-apikey` | +| [getP2pAdList()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2230) | :closed_lock_with_key: | GET | `/api/v3/p2p/ad-list` | +| [getP2pExchangeRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2236) | :closed_lock_with_key: | GET | `/api/v3/p2p/exchange-rate` | +| [simulateP2pFee()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2242) | :closed_lock_with_key: | POST | `/api/v3/p2p/fee-simulate` | +| [getP2pAdLimit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2248) | :closed_lock_with_key: | GET | `/api/v3/p2p/ad-limit` | +| [createP2pAd()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2254) | :closed_lock_with_key: | POST | `/api/v3/p2p/ad-create` | +| [updateP2pAd()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2260) | :closed_lock_with_key: | POST | `/api/v3/p2p/ad-update` | +| [operateP2pAd()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2264) | :closed_lock_with_key: | POST | `/api/v3/p2p/ad-operate` | +| [getP2pAdInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2268) | :closed_lock_with_key: | GET | `/api/v3/p2p/ad-info` | +| [getP2pMyAds()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2274) | :closed_lock_with_key: | GET | `/api/v3/p2p/my-ads` | +| [getP2pPendingOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2280) | :closed_lock_with_key: | GET | `/api/v3/p2p/pending-orders` | +| [getP2pAllOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2286) | :closed_lock_with_key: | GET | `/api/v3/p2p/all-orders` | +| [getP2pOrderInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2292) | :closed_lock_with_key: | GET | `/api/v3/p2p/order-info` | +| [confirmP2pOrderPayment()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2298) | :closed_lock_with_key: | POST | `/api/v3/p2p/order-pay` | +| [releaseP2pOrderAsset()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2304) | :closed_lock_with_key: | POST | `/api/v3/p2p/order-release` | +| [getP2pUserInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2310) | :closed_lock_with_key: | GET | `/api/v3/p2p/user-info` | +| [getP2pCurrencies()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2314) | :closed_lock_with_key: | GET | `/api/v3/p2p/currencies` | +| [getP2pPayMethods()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2318) | :closed_lock_with_key: | GET | `/api/v3/p2p/pay-method` | +| [getP2pBalance()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2322) | :closed_lock_with_key: | GET | `/api/v3/p2p/balance` | +| [getEarnEliteProducts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2334) | :closed_lock_with_key: | GET | `/api/v3/earn/elite-product` | +| [getEarnEliteAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2338) | :closed_lock_with_key: | GET | `/api/v3/earn/elite-assets` | +| [getEarnEliteRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2342) | :closed_lock_with_key: | GET | `/api/v3/earn/elite-records` | +| [getEarnEliteSubscribeInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2348) | :closed_lock_with_key: | GET | `/api/v3/earn/elite-subscribe-info` | +| [subscribeEarnElite()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2354) | :closed_lock_with_key: | POST | `/api/v3/earn/elite-subscribe` | +| [getEarnEliteSubscribeResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2360) | :closed_lock_with_key: | GET | `/api/v3/earn/elite-subscribe-result` | +| [getEarnEliteRedeemInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2366) | :closed_lock_with_key: | GET | `/api/v3/earn/elite-redeem-info` | +| [redeemEarnElite()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2372) | :closed_lock_with_key: | POST | `/api/v3/earn/elite-redeem` | # websocket-api-client.ts @@ -528,7 +580,7 @@ This client provides WebSocket API endpoints which allow for faster interactions | Function | AUTH | HTTP Method | Endpoint | | -------- | :------: | :------: | -------- | -| [submitNewOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/websocket-api-client.ts#L79) | | WS | `place-order` | -| [placeBatchOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/websocket-api-client.ts#L98) | | WS | `batch-place` | -| [cancelOrder()](https://github.com/tiagosiebler/bitget-api/blob/master/src/websocket-api-client.ts#L122) | | WS | `cancel-order` | -| [cancelBatchOrders()](https://github.com/tiagosiebler/bitget-api/blob/master/src/websocket-api-client.ts#L141) | | WS | `batch-cancel` | \ No newline at end of file +| [submitNewOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/websocket-api-client.ts#L79) | | WS | `place-order` | +| [placeBatchOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/websocket-api-client.ts#L98) | | WS | `batch-place` | +| [cancelOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/websocket-api-client.ts#L122) | | WS | `cancel-order` | +| [cancelBatchOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/websocket-api-client.ts#L141) | | WS | `batch-cancel` | \ No newline at end of file diff --git a/examples/apidoc/RestClientV3/Account/get-eligible-loan-info.js b/examples/apidoc/RestClientV3/Account/get-eligible-loan-info.js new file mode 100644 index 0000000..1a87d19 --- /dev/null +++ b/examples/apidoc/RestClientV3/Account/get-eligible-loan-info.js @@ -0,0 +1,18 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getEligibleLoanInfo() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Account/get-eligible-margin-tier.js b/examples/apidoc/RestClientV3/Account/get-eligible-margin-tier.js new file mode 100644 index 0000000..aa13e22 --- /dev/null +++ b/examples/apidoc/RestClientV3/Account/get-eligible-margin-tier.js @@ -0,0 +1,18 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getEligibleMarginTier() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Account/get-eligible-symbols.js b/examples/apidoc/RestClientV3/Account/get-eligible-symbols.js new file mode 100644 index 0000000..d732bc2 --- /dev/null +++ b/examples/apidoc/RestClientV3/Account/get-eligible-symbols.js @@ -0,0 +1,18 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getEligibleSymbols() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Copy-Trading/copy-trading-transfer.js b/examples/apidoc/RestClientV3/Copy-Trading/copy-trading-transfer.js index a6c8b31..810f4da 100644 --- a/examples/apidoc/RestClientV3/Copy-Trading/copy-trading-transfer.js +++ b/examples/apidoc/RestClientV3/Copy-Trading/copy-trading-transfer.js @@ -13,6 +13,7 @@ client type: 'in', coin: 'USDT', amount: '100', + inAccountType: 'funding,uta,otc', }) .then((response) => { console.log(response); diff --git a/examples/apidoc/RestClientV3/Copy-Trading/get-current-followers.js b/examples/apidoc/RestClientV3/Copy-Trading/get-current-followers.js new file mode 100644 index 0000000..46ca48d --- /dev/null +++ b/examples/apidoc/RestClientV3/Copy-Trading/get-current-followers.js @@ -0,0 +1,18 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getCopyFuturesCurrentFollowers() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Copy-Trading/get-history-followers.js b/examples/apidoc/RestClientV3/Copy-Trading/get-history-followers.js new file mode 100644 index 0000000..422cb39 --- /dev/null +++ b/examples/apidoc/RestClientV3/Copy-Trading/get-history-followers.js @@ -0,0 +1,18 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getCopyFuturesHistoryFollowers() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Copy-Trading/get-profit-details.js b/examples/apidoc/RestClientV3/Copy-Trading/get-profit-details.js new file mode 100644 index 0000000..aad3cf8 --- /dev/null +++ b/examples/apidoc/RestClientV3/Copy-Trading/get-profit-details.js @@ -0,0 +1,18 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getCopyFuturesProfitDetails() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Copy-Trading/get-profit-summary.js b/examples/apidoc/RestClientV3/Copy-Trading/get-profit-summary.js new file mode 100644 index 0000000..f3c745e --- /dev/null +++ b/examples/apidoc/RestClientV3/Copy-Trading/get-profit-summary.js @@ -0,0 +1,18 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getCopyFuturesProfitSummary() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Stock+/Asset/get-account.js b/examples/apidoc/RestClientV3/Stock+/Asset/get-account.js new file mode 100644 index 0000000..063e22f --- /dev/null +++ b/examples/apidoc/RestClientV3/Stock+/Asset/get-account.js @@ -0,0 +1,18 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getStockPlusAccount() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Stock+/Asset/get-cash-flow.js b/examples/apidoc/RestClientV3/Stock+/Asset/get-cash-flow.js new file mode 100644 index 0000000..9afdd54 --- /dev/null +++ b/examples/apidoc/RestClientV3/Stock+/Asset/get-cash-flow.js @@ -0,0 +1,21 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getStockPlusCashFlow({ + startTime: '1650037563', + endTime: '1650747581', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Stock+/Asset/get-stock-position.js b/examples/apidoc/RestClientV3/Stock+/Asset/get-stock-position.js new file mode 100644 index 0000000..f035a3d --- /dev/null +++ b/examples/apidoc/RestClientV3/Stock+/Asset/get-stock-position.js @@ -0,0 +1,20 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getStockPlusStockPosition({ + symbol: 'AAPL.US,MSTR.US', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Stock+/Asset/get-transfer-records.js b/examples/apidoc/RestClientV3/Stock+/Asset/get-transfer-records.js new file mode 100644 index 0000000..b5b79a9 --- /dev/null +++ b/examples/apidoc/RestClientV3/Stock+/Asset/get-transfer-records.js @@ -0,0 +1,18 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getStockPlusTransferRecords() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Stock+/Asset/transfer.js b/examples/apidoc/RestClientV3/Stock+/Asset/transfer.js new file mode 100644 index 0000000..4db770c --- /dev/null +++ b/examples/apidoc/RestClientV3/Stock+/Asset/transfer.js @@ -0,0 +1,22 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .stockPlusTransfer({ + coin: 'USDC', + amount: '100', + direction: 'in', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Stock+/Market/Options/get-option-chain-info.js b/examples/apidoc/RestClientV3/Stock+/Market/Options/get-option-chain-info.js new file mode 100644 index 0000000..04c126b --- /dev/null +++ b/examples/apidoc/RestClientV3/Stock+/Market/Options/get-option-chain-info.js @@ -0,0 +1,21 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getStockPlusOptionChainInfo({ + symbol: 'AAPL.US', + expiryDate: '20220429', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Stock+/Market/Options/get-option-expiry-date.js b/examples/apidoc/RestClientV3/Stock+/Market/Options/get-option-expiry-date.js new file mode 100644 index 0000000..c5ce3f4 --- /dev/null +++ b/examples/apidoc/RestClientV3/Stock+/Market/Options/get-option-expiry-date.js @@ -0,0 +1,20 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getStockPlusOptionExpiryDate({ + symbol: 'AAPL.US', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Stock+/Market/Options/get-option-quote.js b/examples/apidoc/RestClientV3/Stock+/Market/Options/get-option-quote.js new file mode 100644 index 0000000..f89f1cb --- /dev/null +++ b/examples/apidoc/RestClientV3/Stock+/Market/Options/get-option-quote.js @@ -0,0 +1,20 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getStockPlusOptionQuote({ + symbol: 'AAPL220429P162500.US', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Stock+/Market/Options/get-option-volume.js b/examples/apidoc/RestClientV3/Stock+/Market/Options/get-option-volume.js new file mode 100644 index 0000000..32901c4 --- /dev/null +++ b/examples/apidoc/RestClientV3/Stock+/Market/Options/get-option-volume.js @@ -0,0 +1,20 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getStockPlusOptionVolume({ + symbol: 'AAPL.US', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Stock+/Market/equity-etf/get-candlestick.js b/examples/apidoc/RestClientV3/Stock+/Market/equity-etf/get-candlestick.js new file mode 100644 index 0000000..06cb47f --- /dev/null +++ b/examples/apidoc/RestClientV3/Stock+/Market/equity-etf/get-candlestick.js @@ -0,0 +1,23 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getStockPlusCandlestick({ + symbol: 'AAPL.US', + period: 'Min_1', + count: '10', + adjustType: 'NoAdjust', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Stock+/Market/equity-etf/get-depth.js b/examples/apidoc/RestClientV3/Stock+/Market/equity-etf/get-depth.js new file mode 100644 index 0000000..fc249d1 --- /dev/null +++ b/examples/apidoc/RestClientV3/Stock+/Market/equity-etf/get-depth.js @@ -0,0 +1,20 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getStockPlusDepth({ + symbol: 'AAPL.US', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Stock+/Market/equity-etf/get-history-candlestick.js b/examples/apidoc/RestClientV3/Stock+/Market/equity-etf/get-history-candlestick.js new file mode 100644 index 0000000..6fbb1a8 --- /dev/null +++ b/examples/apidoc/RestClientV3/Stock+/Market/equity-etf/get-history-candlestick.js @@ -0,0 +1,23 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getStockPlusHistoryCandlestick({ + symbol: 'AAPL.US', + period: 'Min_1', + count: '10', + adjustType: 'NoAdjust', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Stock+/Market/equity-etf/get-intraday.js b/examples/apidoc/RestClientV3/Stock+/Market/equity-etf/get-intraday.js new file mode 100644 index 0000000..e193276 --- /dev/null +++ b/examples/apidoc/RestClientV3/Stock+/Market/equity-etf/get-intraday.js @@ -0,0 +1,20 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getStockPlusIntraday({ + symbol: 'AAPL.US', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Stock+/Market/equity-etf/get-quote.js b/examples/apidoc/RestClientV3/Stock+/Market/equity-etf/get-quote.js new file mode 100644 index 0000000..2786c58 --- /dev/null +++ b/examples/apidoc/RestClientV3/Stock+/Market/equity-etf/get-quote.js @@ -0,0 +1,20 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getStockPlusQuote({ + symbol: 'AAPL.US', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Stock+/Market/equity-etf/get-static-info.js b/examples/apidoc/RestClientV3/Stock+/Market/equity-etf/get-static-info.js new file mode 100644 index 0000000..cc1d308 --- /dev/null +++ b/examples/apidoc/RestClientV3/Stock+/Market/equity-etf/get-static-info.js @@ -0,0 +1,20 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getStockPlusStaticInfo({ + symbol: 'AAPL.US', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Stock+/Market/equity-etf/get-trade-detail.js b/examples/apidoc/RestClientV3/Stock+/Market/equity-etf/get-trade-detail.js new file mode 100644 index 0000000..b7fc3cb --- /dev/null +++ b/examples/apidoc/RestClientV3/Stock+/Market/equity-etf/get-trade-detail.js @@ -0,0 +1,21 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getStockPlusTradeDetail({ + symbol: 'AAPL.US', + count: '10', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Stock+/Trade/cancel-order.js b/examples/apidoc/RestClientV3/Stock+/Trade/cancel-order.js new file mode 100644 index 0000000..f8e53da --- /dev/null +++ b/examples/apidoc/RestClientV3/Stock+/Trade/cancel-order.js @@ -0,0 +1,21 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .cancelStockPlusOrder({ + symbol: 'AAPL220429C150000.US', + orderId: '701276261045858304', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Stock+/Trade/get-history-executions.js b/examples/apidoc/RestClientV3/Stock+/Trade/get-history-executions.js new file mode 100644 index 0000000..8e535a0 --- /dev/null +++ b/examples/apidoc/RestClientV3/Stock+/Trade/get-history-executions.js @@ -0,0 +1,20 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getStockPlusHistoryExecutions({ + symbol: 'AAPL.US', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Stock+/Trade/get-history-orders.js b/examples/apidoc/RestClientV3/Stock+/Trade/get-history-orders.js new file mode 100644 index 0000000..60f189f --- /dev/null +++ b/examples/apidoc/RestClientV3/Stock+/Trade/get-history-orders.js @@ -0,0 +1,20 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getStockPlusHistoryOrders({ + symbol: 'AAPL.US', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Stock+/Trade/get-order-detail.js b/examples/apidoc/RestClientV3/Stock+/Trade/get-order-detail.js new file mode 100644 index 0000000..16fea7d --- /dev/null +++ b/examples/apidoc/RestClientV3/Stock+/Trade/get-order-detail.js @@ -0,0 +1,20 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getStockPlusOrderDetail({ + orderId: '701276261045858304', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Stock+/Trade/get-today-executions.js b/examples/apidoc/RestClientV3/Stock+/Trade/get-today-executions.js new file mode 100644 index 0000000..a4464f0 --- /dev/null +++ b/examples/apidoc/RestClientV3/Stock+/Trade/get-today-executions.js @@ -0,0 +1,20 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getStockPlusTodayExecutions({ + symbol: 'AAPL.US', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Stock+/Trade/get-today-orders.js b/examples/apidoc/RestClientV3/Stock+/Trade/get-today-orders.js new file mode 100644 index 0000000..09b83c1 --- /dev/null +++ b/examples/apidoc/RestClientV3/Stock+/Trade/get-today-orders.js @@ -0,0 +1,20 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getStockPlusTodayOrders({ + symbol: 'AAPL.US', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Stock+/Trade/modify-order.js b/examples/apidoc/RestClientV3/Stock+/Trade/modify-order.js new file mode 100644 index 0000000..72c82b6 --- /dev/null +++ b/examples/apidoc/RestClientV3/Stock+/Trade/modify-order.js @@ -0,0 +1,22 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .modifyStockPlusOrder({ + orderId: '701276261045858304', + quantity: '200', + price: '155.00', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Stock+/Trade/place-order.js b/examples/apidoc/RestClientV3/Stock+/Trade/place-order.js new file mode 100644 index 0000000..57b0cb0 --- /dev/null +++ b/examples/apidoc/RestClientV3/Stock+/Trade/place-order.js @@ -0,0 +1,26 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .placeStockPlusOrder({ + symbol: 'AAPL.US', + orderType: 'LO', + side: 'Buy', + submittedQuantity: '100', + timeInForce: 'Day', + submittedPrice: '150.00', + outsideRth: 'RTHOnly', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Sub-Account/get-ratelimit-quota.js b/examples/apidoc/RestClientV3/Sub-Account/get-ratelimit-quota.js new file mode 100644 index 0000000..188311d --- /dev/null +++ b/examples/apidoc/RestClientV3/Sub-Account/get-ratelimit-quota.js @@ -0,0 +1,20 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .getRateLimitQuota({ + category: 'futures', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Sub-Account/set-ratelimit-quota.js b/examples/apidoc/RestClientV3/Sub-Account/set-ratelimit-quota.js new file mode 100644 index 0000000..2f86546 --- /dev/null +++ b/examples/apidoc/RestClientV3/Sub-Account/set-ratelimit-quota.js @@ -0,0 +1,22 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', + apiPass: 'insert_api_pass_here', +}); + +client + .setRateLimitQuota({ + category: 'futures', + uids: ['123456', '123457'], + quota: '100', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Trade/cancel-reality-order.js b/examples/apidoc/RestClientV3/Trade/cancel-reality-order.js index b2d1d2e..9766a31 100644 --- a/examples/apidoc/RestClientV3/Trade/cancel-reality-order.js +++ b/examples/apidoc/RestClientV3/Trade/cancel-reality-order.js @@ -10,6 +10,7 @@ const client = new RestClientV3({ client .cancelRealityOrder({ + category: 'SPOT', symbol: 'rAAPLUSDT', orderId: '121211212122', }) diff --git a/examples/apidoc/RestClientV3/Trade/place-reality-order.js b/examples/apidoc/RestClientV3/Trade/place-reality-order.js index 8fd6c37..76b1d0b 100644 --- a/examples/apidoc/RestClientV3/Trade/place-reality-order.js +++ b/examples/apidoc/RestClientV3/Trade/place-reality-order.js @@ -10,6 +10,7 @@ const client = new RestClientV3({ client .placeRealityOrder({ + category: 'SPOT', symbol: 'rAAPLUSDT', side: 'buy', orderType: 'limit', diff --git a/llms.txt b/llms.txt index a7dc479..5091c9c 100644 --- a/llms.txt +++ b/llms.txt @@ -48,6 +48,8 @@ Notes: ================================================================ Directory Structure ================================================================ +docs/ + BITGET_SDK_QUICKSTART_GUIDE.md examples/ auth/ fasterHmacSign.ts @@ -90,6 +92,7 @@ src/ copytrading.ts earn.ts futures.ts + instloan.ts margin.ts spot.ts v3/ @@ -100,6 +103,7 @@ src/ loan.ts p2p.ts public.ts + stockplus.ts strategy.ts trade.ts shared.ts @@ -110,6 +114,7 @@ src/ copy-trading.ts earn.ts futures.ts + instloan.ts margin.ts spot.ts v3/ @@ -120,6 +125,7 @@ src/ loan.ts p2p.ts public.ts + stockplus.ts strategy.ts trade.ts websockets/ @@ -745,535 +751,377 @@ export interface GetMarginLiquidationOrdersRequestV2 { } ================ -File: src/types/request/v2/spot.ts +File: src/types/request/shared.ts ================ -type SpotKlineIntervalV2 = - | '1min' - | '5min' - | '15min' - | '30min' - | '1h' - | '4h' - | '6h' - | '12h' - | '1day' - | '3day' - | '1week' - | '1M' - | '6Hutc' - | '12Hutc' - | '1Dutc' - | '3Dutc' - | '1Wutc' - | '1Mutc'; -⋮---- -export interface SpotCandlesRequestV2 { - symbol: string; - granularity: SpotKlineIntervalV2; - startTime?: string; - endTime?: string; +/** Pagination */ +export interface Pagination { + /** Time after */ + after?: string; + /** Time before */ + before?: string; + /** Elements per page */ limit?: string; } ⋮---- -export interface SpotHistoricCandlesRequestV2 { - symbol: string; - granularity: SpotKlineIntervalV2; - endTime?: string; - limit?: string; -} +/** Time after */ ⋮---- -export interface SpotHistoricTradesRequestV2 { +/** Time before */ +⋮---- +/** Elements per page */ +⋮---- +export type OrderTimeInForce = 'normal' | 'post_only' | 'fok' | 'ioc'; +⋮---- +export interface GetHistoricTradesParams { symbol: string; limit?: string; - idLessThan?: string; + tradeId?: string; startTime?: string; endTime?: string; } ⋮---- /** - * - * * Spot | Trade - * + * The margin type, used directly in building the endpoint URL */ +export type MarginType = 'crossed' | 'isolated'; ⋮---- -export type SpotOrderSideV2 = 'buy' | 'sell'; -⋮---- -export type SpotOrderTypeV2 = 'limit' | 'market'; -⋮---- -export type SpotOrderForceV2 = 'gtc' | 'post_only' | 'fok' | 'ioc'; +export type FuturesProductTypeV2 = + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES' + | 'SUSDT-FUTURES' + | 'SCOIN-FUTURES' + | 'SUSDC-FUTURES'; ⋮---- -export type SpotTPSLTypeV2 = 'normal' | 'tpsl'; +export type FuturesPlanTypeV2 = + | 'profit_plan' + | 'loss_plan' + | 'moving_plan' + | 'pos_profit' + | 'pos_loss'; + +================ +File: src/types/response/v2/copy-trading.ts +================ +/** + * + * + * Copy Trading | Future copy trading | Trader Api + * + * + */ ⋮---- -export type SpotSTPModeV2 = - | 'none' - | 'cancel_taker' - | 'cancel_maker' - | 'cancel_both'; +export interface CTFuturesTraderCurrentOrderV2 { + trackingNo: string; + openOrderId: string; + symbol: string; + posSide: string; + openLeverage: string; + openPriceAvg: string; + openTime: string; + openSize: string; + presetStopSurplusPrice: string; + presetStopLossPrice: string; + openFee: string; + followCount: string; +} ⋮---- -export type SpotBatchModeV2 = 'single' | 'multiple'; +export interface CTFuturesTraderCurrentOrdersV2 { + trackingList: CTFuturesTraderCurrentOrderV2[]; + endId: string; +} ⋮---- -export interface SpotOrderRequestV2 { +export interface CTFuturesTraderHistoryOrderV2 { + trackingNo: string; symbol: string; - side: SpotOrderSideV2; - orderType: SpotOrderTypeV2; - force: SpotOrderForceV2; - price?: string; - size: string; - clientOid?: string; - triggerPrice?: string; - tpslType?: SpotTPSLTypeV2; - requestTime?: string; - receiveWindow?: string; - stpMode?: SpotSTPModeV2; - presetTakeProfitPrice?: string; - executeTakeProfitPrice?: string; - presetStopLossPrice?: string; - executeStopLossPrice?: string; + openOrderId: string; + closeOrderId: string; + productType: string; + posSide: string; + openLeverage: string; + openPriceAvg: string; + openTime: string; + openSize: string; + closeSize: string; + closeTime: string; + closePriceAvg: string; + stopType: string; + achievedPL: string; + openFee: string; + closeFee: string; + cTime: string; } ⋮---- -export interface SpotCancelandSubmitOrderRequestV2 { - symbol: string; - price: string; - size: string; - orderId?: string; - clientOid?: string; - newClientOid?: string; - presetTakeProfitPrice?: string; - executeTakeProfitPrice?: string; - presetStopLossPrice?: string; - executeStopLossPrice?: string; +export interface CTFuturesTraderHistoryOrderV2 { + trackingList: CTFuturesTraderHistoryOrderV2[]; + endId: string; } ⋮---- -export interface SpotCancelOrderRequestV2 { - symbol: string; - tpslType?: SpotTPSLTypeV2; - orderId?: string; - clientOid?: string; +export interface CTRateCTimeV2 { + rate: string; + ctime: string; } ⋮---- -export interface SpotBatchOrderRequestItemV2 { - symbol?: string; - side: SpotOrderSideV2; - orderType: SpotOrderTypeV2; - force: SpotOrderForceV2; - price?: string; - size: string; - clientOid?: string; - stpMode?: SpotSTPModeV2; - presetTakeProfitPrice?: string; - executeTakeProfitPrice?: string; - presetStopLossPrice?: string; - executeStopLossPrice?: string; +export interface CTAmountCTimeV2 { + amount: string; + ctime: string; } ⋮---- -export interface SpotBatchOrderRequestV2 { - symbol?: string; - batchMode?: SpotBatchModeV2; - orderList: SpotBatchOrderRequestItemV2[]; +export interface CTFuturesTraderTotalOrderSummaryV2 { + roi: string; + tradingOrderNum: string; + totalFollowerNum: string; + currentFollowerNum: string; + totalpl: string; + gainNum: string; + lossNum: string; + winRate: string; + tradingPairsAvailableList: string[]; + lastWeekRoiList: CTRateCTimeV2[]; + lastWeekProfitList: CTAmountCTimeV2[]; + lastMonthRoiList: CTRateCTimeV2[]; + lastMonthProfitList: CTAmountCTimeV2[]; + totalEquity: string; } ⋮---- -export interface SpotBatchCancelOrderRequestV2 { - symbol?: string; - batchMode?: SpotBatchModeV2; - orderList: { - symbol?: string; - orderId?: string; - clientOid?: string; - }[]; +export interface CTFuturesTraderProfitHistoryItemV2 { + coin: string; + profitCount: string; + lastProfitTime: string; } ⋮---- -export interface GetSpotOrderInfoRequestV2 { - orderId?: string; - clientOid?: string; - requestTime?: string; - receiveWindow?: string; +export interface CTFuturesTraderHistoryProfitSummaryV2 { + profitSummary: { + yesterdayProfit: string; + sumProfit: string; + waitProfit: string; + yesterdayTime: string; + }; + profitHistoryList: CTFuturesTraderProfitHistoryItemV2[]; } ⋮---- -export interface GetSpotOpenOrdersRequestV2 { - symbol?: string; - startTime?: string; - endTime?: string; - idLessThan?: string; - limit?: string; - orderId?: string; - tpslType?: SpotTPSLTypeV2; - requestTime?: string; - receiveWindow?: string; +export interface CTFuturesTraderProfitShare { + profitId: string; + coin: string; + profit: string; + nickName: string; + profitTime: string; } ⋮---- -export interface GetSpotHistoryOrdersRequestV2 { - symbol?: string; - startTime?: string; - endTime?: string; - idLessThan?: string; - limit?: string; - orderId?: string; - tpslType?: SpotTPSLTypeV2; - requestTime?: string; - receiveWindow?: string; +export interface CTFuturesTraderProfitShareHistoryV2 { + profitList: CTFuturesTraderProfitShare[]; + endId: string; } ⋮---- -export interface GetSpotFillsRequestV2 { +export interface CTFuturesTraderSymbolSettingsV2 { symbol: string; - orderId?: string; - startTime?: string; - endTime?: string; - limit?: string; - idLessThan?: string; + openTrader: string; + minOpenCount: string; + maxLeverage: string; + stopSurplusRatio: string; + stopLossRatio: string; +} +⋮---- +export interface CTFuturesTraderMyFollowersV2 { + accountEquity: string; + isRemove: string; + followerHeadPic: string; + followerName: string; + followerUid: string; + followerTime: string; } ⋮---- /** * - * * Spot | Trigger Orders + * + * Copy Trading | Future copy trading | Follower Api + * * */ ⋮---- -export type SpotPlanTypeV2 = 'amount' | 'total'; -⋮---- -export type SpotTriggerTypeV2 = 'fill_price' | 'mark_price'; +export interface CTFuturesFollowerCurrentOrdersV2 { + trackingNo: string; + traderName: string; + openOrderId: string; + closeOrderId: string; + traderId: string; + symbol: string; + posSide: string; + openLeverage: string; + openAvgPrice: string; + openTime: string; + openSize: string; + closeAvgPrice: string; + closeSize: string; + openMarginSz: string; + closeTime: string; +} ⋮---- -export interface SpotPlanOrderRequestV2 { +export interface CTFuturesFollowerHistoryOrderV2 { + trackingNo: string; + posSide: string; + openLeverage: string; + openSize: string; + closeSize: string; + openPriceAvg: string; + closePriceAvg: string; + achievedPL: string; + openFee: string; + closeFee: string; symbol: string; - side: SpotOrderSideV2; - triggerPrice: string; - orderType: SpotOrderTypeV2; - executePrice?: string; - planType?: SpotPlanTypeV2; - size: string; - triggerType: SpotTriggerTypeV2; - clientOid?: string; - force?: SpotOrderForceV2; - stpMode?: SpotSTPModeV2; + profitRate: string; + netProfit: string; + openOrderId: string; + closeOrderId: string; + openTime: string; + closeTime: string; + traderId: string; + productType: string; } ⋮---- -export interface SpotModifyPlanOrderRequestV2 { - orderId?: string; - clientOid?: string; - triggerPrice: string; - orderType: SpotOrderTypeV2; - executePrice?: string; - size: string; +export interface CTFuturesFollowerHistoryOrdersV2 { + trackingList: CTFuturesFollowerHistoryOrderV2[]; + endId: string; } ⋮---- -export interface GetSpotCurrentPlanOrdersRequestV2 { +export interface CTFuturesFollowerSettingV2 { symbol: string; - limit?: string; - idLessThan?: string; - startTime?: string; - endTime?: string; + productType: string; + marginType: string; + marginCoin: string; + leverType: string; + longLeverage: string; + shortLeverage: string; + traceType: string; } ⋮---- -export interface GetSpotHistoryPlanOrdersRequestV2 { - symbol: string; - startTime: string; - endTime: string; - limit?: string; +export interface CTFuturesFollowerSettingsV2 { + followerEnable: string; + detailList: CTFuturesFollowerSettingV2[]; +} +⋮---- +export interface CTFuturesFollowerMyTradersV2 { + certificationType: string; + traderId: string; + traderName: string; + maxFollowLimit: string; + followCount: string; + traceTotalMarginAmount: string; + traceTotalNetProfit: string; + traceTotalProfit: string; + currentTradingPairs: string[]; + followerTime: string; + bgbMaxFollowLimit: string; + bgbFollowCount: string; } ⋮---- /** * - * * Spot | Account + * + * Copy Trading | Spot copy trading | Trader api + * * */ ⋮---- -export type SpotBillGroupTypeV2 = - | 'deposit' - | 'withdraw' - | 'transaction' - | 'transfer' - | 'other'; -⋮---- -export type SpotBusinessTypeV2 = - | 'deposit' - | 'withdraw' - | 'buy' - | 'sell' - | 'deduction of handling fee' - | 'transfer-in' - | 'transfer-out' - | 'rebate rewards' - | 'airdrop rewards' - | 'USDT contract rewards' - | 'mix contract rewards' - | 'system lock' - | 'user lock'; -⋮---- -export type SpotAccountTypeV2 = - | 'spot' - | 'p2p' - | 'coin_futures' - | 'usdt_futures' - | 'usdc_futures' - | 'crossed_margin' - | 'isolated_margin'; -⋮---- -export interface GetSpotAccountBillsRequestV2 { - coin?: string; - groupType?: SpotBillGroupTypeV2; - businessType?: SpotBusinessTypeV2; - startTime?: string; - endTime?: string; - limit?: string; - idLessThan?: string; +export interface CTSpotTraderProfitSummaryV2 { + profitSummarys: { + yesterdayProfit: string; + yesterdayTime: string; + sumProfit: string; + waitProfit: string; + }; + profitHistoryList: { + coin: string; + profitCount: string; + lastProfitTime: string; + historysByDateList: { + profit: string; + profitTime: string; + }[]; + }[]; } ⋮---- -export interface SpotTransferRequestV2 { - fromType: SpotAccountTypeV2; - toType: SpotAccountTypeV2; - amount: string; +export interface CTSpotTraderHistoryProfitShareItemV2 { + profitId: string; coin: string; - symbol: string; - clientOid?: string; + distributeRatio: string; + profit: string; + followerName: string; + profitTime: string; } ⋮---- -export interface SpotSubAccountTransferRequestV2 { - fromType: SpotAccountTypeV2; - toType: SpotAccountTypeV2; - amount: string; - coin: string; - symbol?: string; - clientOid?: string; - fromUserId: string; - toUserId: string; +export interface CTSpotTraderHistoryProfitSharingV2 { + endId: string; + profitList: CTSpotTraderHistoryProfitShareItemV2[]; } ⋮---- -export interface SpotWithdrawalRequestV2 { +export interface CTSpotTraderUnrealizedProfitV2 { + distributeRatio: string; coin: string; - transferType: 'on_chain' | 'internal_transfer'; - address: string; - chain?: string; - innerToType?: 'email' | 'mobile' | 'uid'; - areaCode?: string; - tag?: string; - size: string; - remark?: string; - clientOid?: string; -} -⋮---- -export interface SpotMainSubTransferRecordRequestV2 { - coin?: string; - role?: 'initiator' | 'receiver'; - subUid?: string; - startTime?: string; - endTime?: string; - clientOid?: string; - limit?: string; - idLessThan?: string; + profit: string; + followerName: string; } ⋮---- -export interface GetSpotTransferRecordRequestV2 { - coin: string; - fromType: SpotAccountTypeV2; - startTime?: string; - endTime?: string; - clientOid?: string; - limit?: string; - idLessThan?: string; +export interface CTSpotTraderTotalOrderDetailV2 { + totalFollowerNum: string; + currentFollowerNum: string; + maxFollowerNum: string; + tradingOrderNum: string; + totalpl: string; + gainNum: string; + lossNum: string; + totalEquity: string; + winRate: string; + lastWeekRoiList: CTAmountCTimeV2[]; + lastMonthRoiList: CTRateCTimeV2[]; + lastWeekProfitList: CTAmountCTimeV2[]; + lastMonthProfitList: CTAmountCTimeV2[]; } ⋮---- -export interface GetSpotSubAccountDepositRecordRequestV2 { - subUid: string; - coin?: string; - startTime?: string; - endTime?: string; - idLessThan?: string; - limit?: string; -} -⋮---- -export interface GetSpotWithdrawalRecordRequestV2 { - coin?: string; - clientOid?: string; - startTime: string; - endTime: string; - idLessThan?: string; - orderId?: string; - limit?: string; -} -⋮---- -export interface GetSpotDepositRecordRequestV2 { - coin?: string; - orderId?: string; - startTime: string; - endTime: string; - idLessThan?: string; - limit?: string; -} - -================ -File: src/types/request/shared.ts -================ -/** Pagination */ -export interface Pagination { - /** Time after */ - after?: string; - /** Time before */ - before?: string; - /** Elements per page */ - limit?: string; -} -⋮---- -/** Time after */ -⋮---- -/** Time before */ -⋮---- -/** Elements per page */ -⋮---- -export type OrderTimeInForce = 'normal' | 'post_only' | 'fok' | 'ioc'; -⋮---- -export interface GetHistoricTradesParams { - symbol: string; - limit?: string; - tradeId?: string; - startTime?: string; - endTime?: string; -} -⋮---- -/** - * The margin type, used directly in building the endpoint URL - */ -export type MarginType = 'crossed' | 'isolated'; -⋮---- -export type FuturesProductTypeV2 = - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES' - | 'SUSDT-FUTURES' - | 'SCOIN-FUTURES' - | 'SUSDC-FUTURES'; -⋮---- -export type FuturesPlanTypeV2 = - | 'profit_plan' - | 'loss_plan' - | 'moving_plan' - | 'pos_profit' - | 'pos_loss'; - -================ -File: src/types/response/v2/copy-trading.ts -================ -/** - * - * - * Copy Trading | Future copy trading | Trader Api - * - * - */ -⋮---- -export interface CTFuturesTraderCurrentOrderV2 { +export interface CTSpotTraderHistoryOrderV2 { trackingNo: string; - openOrderId: string; + fillSize: string; + buyPrice: string; + sellPrice: string; + achievedPL: string; + buyTime: string; + sellTime: string; + buyFee: string; + sellFee: string; + achievedPLR: string; symbol: string; - posSide: string; - openLeverage: string; - openPriceAvg: string; - openTime: string; - openSize: string; - presetStopSurplusPrice: string; - presetStopLossPrice: string; - openFee: string; + netProfit: string; followCount: string; } -⋮---- -export interface CTFuturesTraderCurrentOrdersV2 { - trackingList: CTFuturesTraderCurrentOrderV2[]; +export interface CTSpotTraderHistoryOrdersV2 { endId: string; + trackingList: CTSpotTraderHistoryOrderV2[]; } ⋮---- -export interface CTFuturesTraderHistoryOrderV2 { +export interface CTSpotTraderCurrentTrackingOrderV2 { trackingNo: string; + orderId: string; + buyFillSize: string; + buyDelegateSize: string; + buyPrice: string; + unrealizedPL: string; + buyTime: string; + buyFee: string; + unrealizedPLR: string; symbol: string; - openOrderId: string; - closeOrderId: string; - productType: string; - posSide: string; - openLeverage: string; - openPriceAvg: string; - openTime: string; - openSize: string; - closeSize: string; - closeTime: string; - closePriceAvg: string; - stopType: string; - achievedPL: string; - openFee: string; - closeFee: string; - cTime: string; -} -⋮---- -export interface CTFuturesTraderHistoryOrderV2 { - trackingList: CTFuturesTraderHistoryOrderV2[]; - endId: string; -} -⋮---- -export interface CTRateCTimeV2 { - rate: string; - ctime: string; -} -⋮---- -export interface CTAmountCTimeV2 { - amount: string; - ctime: string; -} -⋮---- -export interface CTFuturesTraderTotalOrderSummaryV2 { - roi: string; - tradingOrderNum: string; - totalFollowerNum: string; - currentFollowerNum: string; - totalpl: string; - gainNum: string; - lossNum: string; - winRate: string; - tradingPairsAvailableList: string[]; - lastWeekRoiList: CTRateCTimeV2[]; - lastWeekProfitList: CTAmountCTimeV2[]; - lastMonthRoiList: CTRateCTimeV2[]; - lastMonthProfitList: CTAmountCTimeV2[]; - totalEquity: string; -} -⋮---- -export interface CTFuturesTraderProfitHistoryItemV2 { - coin: string; - profitCount: string; - lastProfitTime: string; -} -⋮---- -export interface CTFuturesTraderHistoryProfitSummaryV2 { - profitSummary: { - yesterdayProfit: string; - sumProfit: string; - waitProfit: string; - yesterdayTime: string; - }; - profitHistoryList: CTFuturesTraderProfitHistoryItemV2[]; -} -⋮---- -export interface CTFuturesTraderProfitShare { - profitId: string; - coin: string; - profit: string; - nickName: string; - profitTime: string; + stopLossPrice: string | null; + stopSurplusPrice: string | null; + followCount: string; } ⋮---- -export interface CTFuturesTraderProfitShareHistoryV2 { - profitList: CTFuturesTraderProfitShare[]; +export interface CTSpotTraderCurrentTrackingOrdersV2 { endId: string; + trackingList: CTSpotTraderCurrentTrackingOrderV2[]; } ⋮---- -export interface CTFuturesTraderSymbolSettingsV2 { - symbol: string; - openTrader: string; - minOpenCount: string; - maxLeverage: string; - stopSurplusRatio: string; - stopLossRatio: string; -} -⋮---- -export interface CTFuturesTraderMyFollowersV2 { +export interface CTSpotTraderFollowerListV2 { accountEquity: string; isRemove: string; - followerHeadPic: string; + followerHeadPic: string | null; followerName: string; followerUid: string; followerTime: string; @@ -1282,230 +1130,33 @@ export interface CTFuturesTraderMyFollowersV2 { /** * * - * Copy Trading | Future copy trading | Follower Api + * Copy Trading | Spot copy trading | Follower api * * */ ⋮---- -export interface CTFuturesFollowerCurrentOrdersV2 { - trackingNo: string; +export interface CTSpotFollowerMyTraderV2 { + certificationType: string; + traceTotalAmount: string; + traceTotalNetProfit: string; + traceTotalProfit: string; traderName: string; - openOrderId: string; - closeOrderId: string; traderId: string; - symbol: string; - posSide: string; - openLeverage: string; - openAvgPrice: string; - openTime: string; - openSize: string; - closeAvgPrice: string; - closeSize: string; - openMarginSz: string; - closeTime: string; + maxFollowLimit: string; + bgbMaxFollowLimit: string; + followCount: string; + bgbFollowCount: string; + followerTime: string; } ⋮---- -export interface CTFuturesFollowerHistoryOrderV2 { - trackingNo: string; - posSide: string; - openLeverage: string; - openSize: string; - closeSize: string; - openPriceAvg: string; - closePriceAvg: string; - achievedPL: string; - openFee: string; - closeFee: string; - symbol: string; - profitRate: string; - netProfit: string; - openOrderId: string; - closeOrderId: string; - openTime: string; - closeTime: string; - traderId: string; - productType: string; -} -⋮---- -export interface CTFuturesFollowerHistoryOrdersV2 { - trackingList: CTFuturesFollowerHistoryOrderV2[]; - endId: string; -} -⋮---- -export interface CTFuturesFollowerSettingV2 { - symbol: string; - productType: string; - marginType: string; - marginCoin: string; - leverType: string; - longLeverage: string; - shortLeverage: string; - traceType: string; -} -⋮---- -export interface CTFuturesFollowerSettingsV2 { - followerEnable: string; - detailList: CTFuturesFollowerSettingV2[]; -} -⋮---- -export interface CTFuturesFollowerMyTradersV2 { - certificationType: string; - traderId: string; - traderName: string; - maxFollowLimit: string; - followCount: string; - traceTotalMarginAmount: string; - traceTotalNetProfit: string; - traceTotalProfit: string; - currentTradingPairs: string[]; - followerTime: string; - bgbMaxFollowLimit: string; - bgbFollowCount: string; -} -⋮---- -/** - * - * - * Copy Trading | Spot copy trading | Trader api - * - * - */ -⋮---- -export interface CTSpotTraderProfitSummaryV2 { - profitSummarys: { - yesterdayProfit: string; - yesterdayTime: string; - sumProfit: string; - waitProfit: string; - }; - profitHistoryList: { - coin: string; - profitCount: string; - lastProfitTime: string; - historysByDateList: { - profit: string; - profitTime: string; - }[]; - }[]; -} -⋮---- -export interface CTSpotTraderHistoryProfitShareItemV2 { - profitId: string; - coin: string; - distributeRatio: string; - profit: string; - followerName: string; - profitTime: string; -} -⋮---- -export interface CTSpotTraderHistoryProfitSharingV2 { - endId: string; - profitList: CTSpotTraderHistoryProfitShareItemV2[]; -} -⋮---- -export interface CTSpotTraderUnrealizedProfitV2 { - distributeRatio: string; - coin: string; - profit: string; - followerName: string; -} -⋮---- -export interface CTSpotTraderTotalOrderDetailV2 { - totalFollowerNum: string; - currentFollowerNum: string; - maxFollowerNum: string; - tradingOrderNum: string; - totalpl: string; - gainNum: string; - lossNum: string; - totalEquity: string; - winRate: string; - lastWeekRoiList: CTAmountCTimeV2[]; - lastMonthRoiList: CTRateCTimeV2[]; - lastWeekProfitList: CTAmountCTimeV2[]; - lastMonthProfitList: CTAmountCTimeV2[]; -} -⋮---- -export interface CTSpotTraderHistoryOrderV2 { - trackingNo: string; - fillSize: string; - buyPrice: string; - sellPrice: string; - achievedPL: string; - buyTime: string; - sellTime: string; - buyFee: string; - sellFee: string; - achievedPLR: string; - symbol: string; - netProfit: string; - followCount: string; -} -export interface CTSpotTraderHistoryOrdersV2 { - endId: string; - trackingList: CTSpotTraderHistoryOrderV2[]; -} -⋮---- -export interface CTSpotTraderCurrentTrackingOrderV2 { - trackingNo: string; - orderId: string; - buyFillSize: string; - buyDelegateSize: string; - buyPrice: string; - unrealizedPL: string; - buyTime: string; - buyFee: string; - unrealizedPLR: string; - symbol: string; - stopLossPrice: string | null; - stopSurplusPrice: string | null; - followCount: string; -} -⋮---- -export interface CTSpotTraderCurrentTrackingOrdersV2 { - endId: string; - trackingList: CTSpotTraderCurrentTrackingOrderV2[]; -} -⋮---- -export interface CTSpotTraderFollowerListV2 { - accountEquity: string; - isRemove: string; - followerHeadPic: string | null; - followerName: string; - followerUid: string; - followerTime: string; -} -⋮---- -/** - * - * - * Copy Trading | Spot copy trading | Follower api - * - * - */ -⋮---- -export interface CTSpotFollowerMyTraderV2 { - certificationType: string; - traceTotalAmount: string; - traceTotalNetProfit: string; - traceTotalProfit: string; - traderName: string; - traderId: string; - maxFollowLimit: string; - bgbMaxFollowLimit: string; - followCount: string; - bgbFollowCount: string; - followerTime: string; -} -⋮---- -export interface CTSpotFollowerMyTradersV2 { - resultList: CTSpotFollowerMyTraderV2[]; -} -⋮---- -export interface CTSpotFollowerTradeSettingV2 { - maxTraceAmount: string; - stopLossRation: string; - stopSurplusRation: string; +export interface CTSpotFollowerMyTradersV2 { + resultList: CTSpotFollowerMyTraderV2[]; +} +⋮---- +export interface CTSpotFollowerTradeSettingV2 { + maxTraceAmount: string; + stopLossRation: string; + stopSurplusRation: string; symbol: string; traceType: string; } @@ -1891,110 +1542,153 @@ export interface WSAPIPlaceOrderResponseV3 { } ================ -File: src/types/websockets/ws-events.ts +File: src/websocket-api-client.ts ================ -export interface MessageEventLike { - target: WebSocket; - type: 'message'; - data: string; -} -⋮---- -export function isMessageEvent(msg: unknown): msg is MessageEventLike -⋮---- -export interface WsBaseEvent { - action: TAction; - arg: unknown; - data: TData[]; -} +import { CancelOrderRequestV3 } from './types/request/v3/trade.js'; +import { CancelOrderResponseV3 } from './types/response/v3/trade.js'; +import { WSAPIResponse } from './types/websockets/ws-api.js'; +import { WSAPIPlaceOrderRequestV3 } from './types/websockets/ws-api-request.js'; +import { WSAPIPlaceOrderResponseV3 } from './types/websockets/ws-api-response.js'; +import { + BitgetInstTypeV3, + WSClientConfigurableOptions, +} from './types/websockets/ws-general.js'; +import { DefaultLogger } from './util/logger.js'; +import { WS_KEY_MAP } from './util/websocket-util.js'; +import { WebsocketClientV3 } from './websocket-client-v3.js'; ⋮---- -export interface WsSnapshotChannelEvent extends WsBaseEvent<'snapshot'> { - arg: { - instType: string; - channel: string; - instId: string; - }; +/** + * Configurable options specific to only the REST-like WebsocketAPIClient + */ +export interface WSAPIClientConfigurableOptions { + /** + * Default: true + * + * Attach default event listeners, which will console log any high level + * events (opened/reconnecting/reconnected/etc). + * + * If you disable this, you should set your own event listeners + * on the embedded WS Client `wsApiClient.getWSClient().on(....)`. + */ + attachEventListeners: boolean; } ⋮---- -export interface WsSnapshotAccountEvent extends WsBaseEvent<'snapshot'> { - arg: { - instType: string; - channel: 'account'; - instId: string; - }; -} +/** + * Default: true + * + * Attach default event listeners, which will console log any high level + * events (opened/reconnecting/reconnected/etc). + * + * If you disable this, you should set your own event listeners + * on the embedded WS Client `wsApiClient.getWSClient().on(....)`. + */ ⋮---- -export interface WsSnapshotPositionsEvent extends WsBaseEvent<'snapshot'> { - arg: { - instType: string; - channel: 'positions'; - instId: string; - }; -} +/** + * This is a minimal Websocket API wrapper around the WebsocketClient. + * + * Note: You can also directly use the sendWSAPIRequest() method to make WS API calls, but some + * may find the below methods slightly more intuitive. + * + * Refer to the WS API promises example for a more detailed example on using sendWSAPIRequest() directly: + * https://github.com/tiagosiebler/bitget-api/blob/master/examples/V3/ws-api-trade-raw.ts + */ +export class WebsocketAPIClient ⋮---- -export interface WsAccountSnapshotDataUMCBL { - marginCoin: string; - locked: string; - available: string; - maxOpenPosAvailable: string; - maxTransferOut: string; - equity: string; - usdtEquity: string; -} +constructor( + options?: WSClientConfigurableOptions & + Partial, + logger?: DefaultLogger, +) ⋮---- -export interface WsAccountSnapshotUMCBL extends WsBaseEvent<'snapshot'> { - arg: { - instType: 'umcbl'; - channel: 'account'; - instId: string; - }; - data: WsAccountSnapshotDataUMCBL[]; -} +public getWSClient(): WebsocketClientV3 ⋮---- -export interface WsPositionSnapshotDataUMCBL { - posId: string; - instId: string; - instName: string; - marginCoin: string; - margin: string; - marginMode: string; - holdSide: string; - holdMode: string; - total: string; - available: string; - locked: string; - averageOpenPrice: string; - leverage: number; - achievedProfits: string; - upl: string; - uplRate: string; - liqPx: string; - keepMarginRate: string; - marginRate: string; - cTime: string; - uTime: string; - markPrice: string; -} +public setTimeOffsetMs(newOffset: number): void ⋮---- -export interface WSPositionSnapshotUMCBL extends WsBaseEvent<'snapshot'> { - arg: { - instType: 'umcbl'; - channel: 'positions'; - instId: string; - }; - data: WsPositionSnapshotDataUMCBL[]; -} +/* + * Bitget WebSocket API Methods + * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel + */ ⋮---- -/** Classic V2 depth channel push data. checksum removed May 2026 - use seq instead */ -export interface WsDepthBookDataV2 { - asks: [string, string][]; - bids: [string, string][]; - ts: string; - seq: string; - /** Futures books channel only - previous push serial number */ - pseq?: string; -} +/** + * Submit a new order + * + * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel + * + * @returns + */ +submitNewOrder( + category: BitgetInstTypeV3, + params: WSAPIPlaceOrderRequestV3, +): Promise> ⋮---- -/** Futures books channel only - previous push serial number */ +/** + * Submit a new order + * + * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel + * + * @returns + */ +placeBatchOrders( + category: BitgetInstTypeV3, + params: WSAPIPlaceOrderRequestV3[], +): Promise> +⋮---- +/* + * Bitget WebSocket API Methods + * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel + */ +⋮---- +/** + * Cancel Order + * + * https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel + * + * @returns + */ +cancelOrder( + category: BitgetInstTypeV3, + params: CancelOrderRequestV3, +): Promise> +⋮---- +/** + * Batch Cancel Order + * + * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Cancel-Order-Channel + * + * @returns + */ +cancelBatchOrders( + category: BitgetInstTypeV3, + params: CancelOrderRequestV3[], +): Promise> +⋮---- +/** + * + * + * + * + * + * + * + * Private methods for handling some of the convenience/automation provided by the WS API Client + * + * + * + * + * + * + * + */ +⋮---- +private setupDefaultEventListeners() +⋮---- +/** + * General event handlers for monitoring the WebsocketClient + */ +⋮---- +// Blind JSON.stringify can fail on circular references +⋮---- +// JSON.stringify({ ...data, target: 'WebSocket' }), ================ File: src/websocket-client-v2.ts @@ -2217,6 +1911,42 @@ File: .eslintrc.cjs ================ // 'no-unused-vars': ['warn'], +================ +File: .gitignore +================ +!.gitkeep +.DS_STORE +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json +pids +*.pid +*.seed +*.pid.lock +node_modules/ +.npm +.eslintcache +.node_repl_history +*.tgz +.yarn-integrity +.env +.env.test +.cache +lib +bundleReport.html +.history/ +tiagoSpot.ts +restClientRegex.ts +localtest.sh +privaterepotracker +testfile.ts +dist +repomix.sh +coverage + ================ File: .jshintrc ================ @@ -2227,11 +1957,6 @@ File: .jshintrc "predef": [ "-Promise" ] } -================ -File: .nvmrc -================ -v22.17.1 - ================ File: .prettierrc ================ @@ -2672,256 +2397,58 @@ import { RestClientV3 } from '../../../src/index.js'; // import { RestClientV3 } from 'bitget-api'; ================ -File: src/types/request/v2/common.ts +File: src/constants/enum.ts +================ +/** Parameter verification exception margin mode == FIXED */ + +================ +File: src/types/request/v2/earn.ts ================ -import { FuturesProductTypeV2, MarginType } from '../shared.js'; -⋮---- /** * - * * Common | Notice + * + * Earn | Savings + * * */ ⋮---- -export interface GetAnnouncementsRequestV2 { - annType?: string; +export interface GetEarnSavingsAssetsRequestV2 { + periodType: string; startTime?: string; endTime?: string; - language: string; + limit?: string; + idLessThan?: string; } ⋮---- -/** - * - * * Common | Public - * - */ +export interface GetEarnSavingsRecordsRequestV2 { + coin?: string; + periodType: string; + orderType?: string; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} ⋮---- -export interface GetTradeRateRequestV2 { - symbol: string; - businessType: string; +export interface RedeemSavingsRequestV2 { + productId: string; + orderId?: string; + periodType: string; + amount: string; } ⋮---- /** * - * * Common | Tax + * + * Earn | Shark Fin + * * */ ⋮---- -export interface GetSpotTransactionsRequestV2 { - coin?: string; - startTime: string; - endTime: string; - limit?: string; - idLessThan?: string; -} -⋮---- -export interface GetFuturesTransactionsRequestV2 { - productType?: FuturesProductTypeV2; - marginCoin?: string; - startTime: string; - endTime: string; - limit?: string; - idLessThan?: string; -} -⋮---- -export interface GetMarginTransactionsRequestV2 { - marginType?: MarginType; - coin?: string; - startTime: string; - endTime: string; - limit?: string; - idLessThan?: string; -} -⋮---- -export interface GetP2PTransactionsRequestV2 { - coin?: string; - startTime: string; - endTime: string; - limit?: string; - idLessThan?: string; -} -⋮---- -/** - * - * * Common | P2P - * - */ -⋮---- -export interface GetP2PMerchantsRequestV2 { - online?: 'yes' | 'no'; - idLessThan?: string; - limit?: string; -} -⋮---- -export interface GetMerchantP2POrdersRequestV2 { - startTime: string; - endTime?: string; - idLessThan?: string; - limit?: string; - status?: string; - advNo: string; - side?: string; - coin?: string; - language: string; - fiat?: string; - orderNo?: string; -} -⋮---- -export interface GetMerchantAdvertisementsRequestV2 { - startTime: string; - endTime?: string; - idLessThan?: string; - limit?: string; - status: string; - advNo?: string; - side: string; - coin: string; - language?: string; - fiat: string; - orderBy?: string; - payMethodId?: string; - sourceType?: string; -} -⋮---- -/** - * - * * Common | Virtual Subaccount - * - */ -⋮---- -export interface ModifyVirtualSubRequestV2 { - subAccountUid: string; - permList: string[]; - status: string; -} -⋮---- -export interface CreateVirtualSubRequestV2 { - subAccountName: string; - passphrase: string; - label: string; - ipList?: string[]; - permList?: string[]; -} -⋮---- -export interface CreateVirtualSubApiKeyRequestV2 { - subAccountUid: string; - passphrase: string; - label: string; - ipList?: string[]; - permList?: string[]; -} -⋮---- -export interface ModifyVirtualSubApiKeyRequestV2 { - subAccountUid: string; - subAccountApiKey: string; - passphrase: string; - label: string; - ipList?: string[]; - permList?: string[]; -} -⋮---- -export interface CreateAgentSubaccountRequestV2 { - /** Lowercase letters only; max 20 characters */ - username: string; - /** 8–32 characters, letters and numbers */ - passphrase: string; - note?: string; -} -⋮---- -/** Lowercase letters only; max 20 characters */ -⋮---- -/** 8–32 characters, letters and numbers */ -⋮---- -/** - * - * * Common | Convert - * - */ -⋮---- -export interface ConvertQuoteRequestV2 { - fromCoin: string; - fromCoinSize?: string; - toCoin: string; - toCoinSize?: string; -} -⋮---- -export interface ConvertRequestV2 { - fromCoin: string; - fromCoinSize: string; - cnvtPrice: string; - toCoin: string; - toCoinSize: string; - traceId: string; -} -⋮---- -export interface GetConvertHistoryRequestV2 { - startTime: string; - endTime: string; - limit?: string; - idLessThan?: string; -} -⋮---- -/** - * - * * Common | BGB Convert - * - */ -⋮---- -export interface GetConvertBGBHistoryRequestV2 { - orderId?: string; - startTime: string; - endTime: string; - limit?: string; - idLessThan?: string; -} - -================ -File: src/types/request/v2/earn.ts -================ -/** - * - * - * Earn | Savings - * - * - */ -⋮---- -export interface GetEarnSavingsAssetsRequestV2 { - periodType: string; - startTime?: string; - endTime?: string; - limit?: string; - idLessThan?: string; -} -⋮---- -export interface GetEarnSavingsRecordsRequestV2 { - coin?: string; - periodType: string; - orderType?: string; - startTime?: string; - endTime?: string; - limit?: string; - idLessThan?: string; -} -⋮---- -export interface RedeemSavingsRequestV2 { - productId: string; - orderId?: string; - periodType: string; - amount: string; -} -⋮---- -/** - * - * - * Earn | Shark Fin - * - * - */ -⋮---- -export interface GetSharkfinAssetsRequestV2 { - status: string; - startTime?: string; - endTime?: string; +export interface GetSharkfinAssetsRequestV2 { + status: string; + startTime?: string; + endTime?: string; limit?: string; idLessThan?: string; } @@ -3060,3018 +2587,3124 @@ export interface RedeemEarnEliteRequestV2 { } ================ -File: src/types/request/v3/copytrading.ts +File: src/types/request/v2/instloan.ts ================ -export interface GetCopyFuturesMaxTransferableRequestV3 { - coin: string; +export interface GetInstLoanProductInfoRequestV2 { + productId: string; } ⋮---- -export interface CopyFuturesTransferRequestV3 { - type: 'in' | 'out'; - coin: string; - amount: string; +export interface GetInstLoanSymbolsRequestV2 { + productId: string; } ⋮---- -export interface GetCopyFuturesTransferRecordRequestV3 { +export interface GetInstLoanRepaidHistoryRequestV2 { startTime?: string; endTime?: string; limit?: string; - /** Pass transferId from the previous page to paginate forward */ - cursor?: string; } ⋮---- -/** Pass transferId from the previous page to paginate forward */ - -================ -File: src/types/request/v3/earn.ts -================ -/** - * - * - * Earn | On-Chain Elite (UTA) - * - * - */ -⋮---- -export interface GetEarnEliteRecordsRequestV3 { - type: 'subscribe' | 'redeem' | 'interest'; +export interface GetInstLoanOrderRequestV2 { + orderId?: string; startTime?: string; endTime?: string; - limit?: string; - cursor?: string; -} -⋮---- -export interface GetEarnEliteSubscribeInfoRequestV3 { - productId: string; } ⋮---- -export interface EarnEliteSubscribeRequestV3 { - productSubId: string; - amount: string; - coin?: string; - paymentAccount?: 'spot' | 'unified'; +export interface GetInstLoanLTVConvertRequestV2 { + riskUnitId?: string; } ⋮---- -export interface GetEarnEliteSubscribeResultRequestV3 { - orderId: string; -} -⋮---- -export interface GetEarnEliteRedeemInfoRequestV3 { - productId: string; -} -⋮---- -export interface RedeemEarnEliteRequestV3 { - productId: string; - productSubId: string; - redeemType: 'fast' | 'standard'; - amount: string; - receiveAccount: 'spot' | 'unified'; - advancedSettle?: 'yes' | 'no'; - coin?: string; +export interface GetInstLoanMarginCoinInfoRequestV2 { + productId: string; } ================ -File: src/types/request/v3/loan.ts +File: src/types/request/v2/spot.ts ================ -export interface GetTransferedRequestV3 { - userId?: string; - coin: string; -} -⋮---- -export interface GetSymbolsRequestV3 { - productId: string; -} +type SpotKlineIntervalV2 = + | '1min' + | '5min' + | '15min' + | '30min' + | '1h' + | '4h' + | '6h' + | '12h' + | '1day' + | '3day' + | '1week' + | '1M' + | '6Hutc' + | '12Hutc' + | '1Dutc' + | '3Dutc' + | '1Wutc' + | '1Mutc'; ⋮---- -export interface GetRepaidHistoryRequestV3 { +export interface SpotCandlesRequestV2 { + symbol: string; + granularity: SpotKlineIntervalV2; startTime?: string; endTime?: string; limit?: string; } ⋮---- -export interface GetProductInfosRequestV3 { - productId: string; +export interface SpotHistoricCandlesRequestV2 { + symbol: string; + granularity: SpotKlineIntervalV2; + endTime?: string; + limit?: string; } ⋮---- -export interface GetLoanOrderRequestV3 { - orderId?: string; +export interface SpotHistoricTradesRequestV2 { + symbol: string; + limit?: string; + idLessThan?: string; startTime?: string; endTime?: string; } ⋮---- -export interface GetEnsureCoinsRequestV3 { - productId: string; +export interface SpotCallAuctionRequestV2 { + symbol: string; } ⋮---- -export interface BindUidRequestV3 { - riskUnitId?: string; - uid: string; - operate: 'bind' | 'unbind'; -} +/** + * + * * Spot | Trade + * + */ ⋮---- -export interface GetLTVConvertRequestV3 { - riskUnitId?: string; -} +export type SpotOrderSideV2 = 'buy' | 'sell'; ⋮---- -/* Unified Account Staking & Lending (Crypto Loans) - /api/v3/loan/* */ +export type SpotOrderTypeV2 = 'limit' | 'market'; ⋮---- -export interface GetLoanCoinsRequestV3 { - coin?: string; -} +export type SpotOrderForceV2 = 'gtc' | 'post_only' | 'fok' | 'ioc'; ⋮---- -export interface GetLoanInterestRequestV3 { - loanCoin: string; - pledgeCoin: string; - daily: 'SEVEN' | 'THIRTY' | 'FLEXIBLE'; - pledgeAmount: string; -} +export type SpotTPSLTypeV2 = 'normal' | 'tpsl'; ⋮---- -export interface LoanBorrowRequestV3 { - loanCoin: string; - pledgeCoin: string; - daily: 'SEVEN' | 'THIRTY' | 'FLEXIBLE'; - pledgeAmount?: string; - loanAmount?: string; +export type SpotSTPModeV2 = + | 'none' + | 'cancel_taker' + | 'cancel_maker' + | 'cancel_both'; +⋮---- +export type SpotBatchModeV2 = 'single' | 'multiple'; +⋮---- +export interface SpotOrderRequestV2 { + symbol: string; + side: SpotOrderSideV2; + orderType: SpotOrderTypeV2; + force: SpotOrderForceV2; + price?: string; + size: string; + clientOid?: string; + triggerPrice?: string; + tpslType?: SpotTPSLTypeV2; + requestTime?: string; + receiveWindow?: string; + stpMode?: SpotSTPModeV2; + presetTakeProfitPrice?: string; + executeTakeProfitPrice?: string; + presetStopLossPrice?: string; + executeStopLossPrice?: string; } ⋮---- -export interface GetLoanBorrowOngoingRequestV3 { +export interface SpotCancelandSubmitOrderRequestV2 { + symbol: string; + price: string; + size: string; orderId?: string; - loanCoin?: string; - pledgeCoin?: string; + clientOid?: string; + newClientOid?: string; + presetTakeProfitPrice?: string; + executeTakeProfitPrice?: string; + presetStopLossPrice?: string; + executeStopLossPrice?: string; } ⋮---- -export interface GetLoanBorrowHistoryRequestV3 { +export interface SpotCancelOrderRequestV2 { + symbol: string; + tpslType?: SpotTPSLTypeV2; orderId?: string; - loanCoin?: string; - pledgeCoin?: string; - status?: 'ROLLBACK' | 'FORCE' | 'REPAY'; - startTime: string; - endTime: string; - pageNum?: string; - pageSize?: string; + clientOid?: string; } ⋮---- -export interface LoanRepayRequestV3 { - orderId: string; - method: 'borrowed_coin' | 'collateral'; - repayAll: 'yes' | 'no'; - amount?: string; - repayUnlock?: 'yes' | 'no'; +export interface SpotBatchOrderRequestItemV2 { + symbol?: string; + side: SpotOrderSideV2; + orderType: SpotOrderTypeV2; + force: SpotOrderForceV2; + price?: string; + size: string; + clientOid?: string; + stpMode?: SpotSTPModeV2; + presetTakeProfitPrice?: string; + executeTakeProfitPrice?: string; + presetStopLossPrice?: string; + executeStopLossPrice?: string; } ⋮---- -export interface GetLoanRepayHistoryRequestV3 { - orderId?: string; - loanCoin?: string; - pledgeCoin?: string; - startTime: string; - endTime: string; - pageNum?: string; - pageSize?: string; +export interface SpotBatchOrderRequestV2 { + symbol?: string; + batchMode?: SpotBatchModeV2; + orderList: SpotBatchOrderRequestItemV2[]; } ⋮---- -export interface LoanRevisePledgeRequestV3 { - orderId: string; - amount: string; - pledgeCoin: string; - reviseType?: 'OUT' | 'IN'; +export interface SpotBatchCancelOrderRequestV2 { + symbol?: string; + batchMode?: SpotBatchModeV2; + orderList: { + symbol?: string; + orderId?: string; + clientOid?: string; + }[]; } ⋮---- -export interface GetLoanPledgeRateHistoryRequestV3 { +export interface GetSpotOrderInfoRequestV2 { orderId?: string; - reviseSide?: 'down' | 'up'; - pledgeCoin?: string; - startTime: string; - endTime: string; - pageNum?: string; - pageSize?: string; + clientOid?: string; + requestTime?: string; + receiveWindow?: string; } ⋮---- -export interface GetLoanReducesRequestV3 { +export interface GetSpotOpenOrdersRequestV2 { + symbol?: string; + startTime?: string; + endTime?: string; + idLessThan?: string; + limit?: string; orderId?: string; - loanCoin?: string; - pledgeCoin?: string; - status?: 'COMPLETE' | 'WAIT'; - startTime: string; - endTime: string; - pageNum?: string; - pageSize?: string; + tpslType?: SpotTPSLTypeV2; + requestTime?: string; + receiveWindow?: string; } - -================ -File: src/types/request/v3/p2p.ts -================ -export type P2pSideV3 = 'buy' | 'sell'; ⋮---- -export type P2pPriceTypeV3 = 'fixed' | 'floating'; +export interface GetSpotHistoryOrdersRequestV2 { + symbol?: string; + startTime?: string; + endTime?: string; + idLessThan?: string; + limit?: string; + orderId?: string; + tpslType?: SpotTPSLTypeV2; + requestTime?: string; + receiveWindow?: string; +} ⋮---- -export type P2pMarketTypeV3 = 'public' | 'private'; +export interface GetSpotFillsRequestV2 { + symbol: string; + orderId?: string; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} ⋮---- -export type P2pAdStatusV3 = 'publish' | 'delist' | 'remove'; +/** + * + * * Spot | Trigger Orders + * + */ ⋮---- -export type P2pAdOperationV3 = 'publish' | 'delist' | 'remove'; +export type SpotPlanTypeV2 = 'amount' | 'total'; ⋮---- -export type P2pOrderStatusV3 = - | 'pending_payment' - | 'pending_release' - | 'completed' - | 'cancelled' - | 'in_appeal'; +export type SpotTriggerTypeV2 = 'fill_price' | 'mark_price'; ⋮---- -export interface P2pPayMethodIdRefV3 { - payMethodId: string; - userPayMethodId?: string; +export interface SpotPlanOrderRequestV2 { + symbol: string; + side: SpotOrderSideV2; + triggerPrice: string; + orderType: SpotOrderTypeV2; + executePrice?: string; + planType?: SpotPlanTypeV2; + size: string; + triggerType: SpotTriggerTypeV2; + clientOid?: string; + force?: SpotOrderForceV2; + stpMode?: SpotSTPModeV2; } ⋮---- -export interface GetP2pAdListRequestV3 { - token: string; - fiat: string; - side: P2pSideV3; - amount?: string; - pageNum: string; - limit: string; +export interface SpotModifyPlanOrderRequestV2 { + orderId?: string; + clientOid?: string; + triggerPrice: string; + orderType: SpotOrderTypeV2; + executePrice?: string; + size: string; } ⋮---- -export interface GetP2pExchangeRateRequestV3 { - token: string; - fiat: string; +export interface GetSpotCurrentPlanOrdersRequestV2 { + symbol: string; + limit?: string; + idLessThan?: string; + startTime?: string; + endTime?: string; } ⋮---- -export interface P2pFeeSimulateRequestV3 { - token: string; - fiat: string; - side: P2pSideV3; - marketType: P2pMarketTypeV3; - amount: string; +export interface GetSpotHistoryPlanOrdersRequestV2 { + symbol: string; + startTime: string; + endTime: string; + limit?: string; } ⋮---- -export interface GetP2pAdLimitRequestV3 { - token: string; - fiat: string; - side: P2pSideV3; +/** + * + * * Spot | Account + * + */ +⋮---- +export type SpotBillGroupTypeV2 = + | 'deposit' + | 'withdraw' + | 'transaction' + | 'transfer' + | 'other'; +⋮---- +export type SpotBusinessTypeV2 = + | 'deposit' + | 'withdraw' + | 'buy' + | 'sell' + | 'deduction of handling fee' + | 'transfer-in' + | 'transfer-out' + | 'rebate rewards' + | 'airdrop rewards' + | 'USDT contract rewards' + | 'mix contract rewards' + | 'system lock' + | 'user lock'; +⋮---- +export type SpotAccountTypeV2 = + | 'spot' + | 'p2p' + | 'coin_futures' + | 'usdt_futures' + | 'usdc_futures' + | 'crossed_margin' + | 'isolated_margin'; +⋮---- +export interface GetSpotAccountBillsRequestV2 { + coin?: string; + groupType?: SpotBillGroupTypeV2; + businessType?: SpotBusinessTypeV2; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; } ⋮---- -export interface CreateP2pAdRequestV3 { - token: string; - fiat: string; - side: P2pSideV3; - priceType: P2pPriceTypeV3; - price?: string; - premium?: string; - minAmount: string; - maxAmount: string; - quantity: string; - payMethodIds: P2pPayMethodIdRefV3[]; - remark?: string; - tradeTerms?: string; - payTimeLimit: string; +export interface SpotTransferRequestV2 { + fromType: SpotAccountTypeV2; + toType: SpotAccountTypeV2; + amount: string; + coin: string; + symbol: string; + clientOid?: string; } ⋮---- -export interface UpdateP2pAdRequestV3 { - advId: string; - priceType?: P2pPriceTypeV3; - price?: string; - premium?: string; - minAmount?: string; - maxAmount?: string; - quantity?: string; - payMethodIds?: P2pPayMethodIdRefV3[]; - payTimeLimit?: string; - remark?: string; - tradeTerms?: string; +export interface SpotSubAccountTransferRequestV2 { + fromType: SpotAccountTypeV2; + toType: SpotAccountTypeV2; + amount: string; + coin: string; + symbol?: string; + clientOid?: string; + fromUserId: string; + toUserId: string; } ⋮---- -export interface OperateP2pAdRequestV3 { - advId: string; - operation: P2pAdOperationV3; +export interface SpotWithdrawalRequestV2 { + coin: string; + transferType: 'on_chain' | 'internal_transfer'; + address: string; + chain?: string; + innerToType?: 'email' | 'mobile' | 'uid'; + areaCode?: string; + tag?: string; + size: string; + remark?: string; + clientOid?: string; } ⋮---- -export interface GetP2pAdInfoRequestV3 { - advId: string; +export interface SpotMainSubTransferRecordRequestV2 { + coin?: string; + role?: 'initiator' | 'receiver'; + subUid?: string; + startTime?: string; + endTime?: string; + clientOid?: string; + limit?: string; + idLessThan?: string; } ⋮---- -export interface GetP2pMyAdsRequestV3 { +export interface GetSpotTransferRecordRequestV2 { + coin: string; + fromType: SpotAccountTypeV2; startTime?: string; endTime?: string; + clientOid?: string; limit?: string; - cursor?: string; - advId?: string; - token?: string; - fiat?: string; - status?: P2pAdStatusV3; + idLessThan?: string; } ⋮---- -export interface GetP2pPendingOrdersRequestV3 { - orderId?: string; - side?: P2pSideV3; +export interface GetSpotSubAccountDepositRecordRequestV2 { + subUid: string; + coin?: string; startTime?: string; endTime?: string; - cursor?: string; + idLessThan?: string; limit?: string; } ⋮---- -export interface GetP2pAllOrdersRequestV3 { +export interface GetSpotWithdrawalRecordRequestV2 { + coin?: string; + clientOid?: string; + startTime: string; + endTime: string; + idLessThan?: string; + orderId?: string; + limit?: string; +} +⋮---- +export interface GetSpotDepositRecordRequestV2 { + coin?: string; + orderId?: string; + startTime: string; + endTime: string; + idLessThan?: string; + limit?: string; +} + +================ +File: src/types/request/v3/earn.ts +================ +/** + * + * + * Earn | On-Chain Elite (UTA) + * + * + */ +⋮---- +export interface GetEarnEliteRecordsRequestV3 { + type: 'subscribe' | 'redeem' | 'interest'; startTime?: string; endTime?: string; limit?: string; cursor?: string; - orderId?: string; - side?: P2pSideV3; - status?: P2pOrderStatusV3; } ⋮---- -export interface GetP2pOrderInfoRequestV3 { - orderId: string; +export interface GetEarnEliteSubscribeInfoRequestV3 { + productId: string; } ⋮---- -export interface P2pOrderActionRequestV3 { +export interface EarnEliteSubscribeRequestV3 { + productSubId: string; + amount: string; + coin?: string; + paymentAccount?: 'spot' | 'unified'; +} +⋮---- +export interface GetEarnEliteSubscribeResultRequestV3 { orderId: string; } ⋮---- -export interface GetP2pBalanceRequestV3 { - token: string; +export interface GetEarnEliteRedeemInfoRequestV3 { + productId: string; +} +⋮---- +export interface RedeemEarnEliteRequestV3 { + productId: string; + productSubId: string; + redeemType: 'fast' | 'standard'; + amount: string; + receiveAccount: 'spot' | 'unified'; + advancedSettle?: 'yes' | 'no'; + coin?: string; } ================ -File: src/types/request/v3/strategy.ts +File: src/types/request/v3/loan.ts ================ -export type StrategyOrderTypeV3 = 'tpsl' | 'trigger'; +export interface GetTransferedRequestV3 { + userId?: string; + coin: string; +} ⋮---- -export type StrategyOrderStatusV3 = - | 'pending' - | 'success' - | 'failed' - | 'cancelled' - | 'submitting'; -⋮---- -export type StrategyTriggerByV3 = 'market' | 'mark'; -⋮---- -export type StrategyTriggerOrderTypeV3 = 'limit' | 'market'; -⋮---- -export interface PlaceStrategyOrderRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol: string; - clientOid?: string; - type?: StrategyOrderTypeV3; - tpslMode?: 'full' | 'partial'; - /** Required when tpslMode=partial or for trigger orders */ - qty?: string; - side?: 'buy' | 'sell'; - posSide?: 'long' | 'short'; - reduceOnly?: 'yes' | 'no'; - tpTriggerBy?: StrategyTriggerByV3; - slTriggerBy?: StrategyTriggerByV3; - takeProfit?: string; - stopLoss?: string; - tpOrderType?: StrategyTriggerOrderTypeV3; - slOrderType?: StrategyTriggerOrderTypeV3; - tpLimitPrice?: string; - slLimitPrice?: string; - triggerBy?: StrategyTriggerByV3; - triggerPrice?: string; - triggerOrderType?: StrategyTriggerOrderTypeV3; - triggerOrderPrice?: string; -} -⋮---- -/** Required when tpslMode=partial or for trigger orders */ -⋮---- -export interface ModifyStrategyOrderRequestV3 { - orderId?: string; - clientOid?: string; - qty: string; - tpTriggerBy?: StrategyTriggerByV3; - slTriggerBy?: StrategyTriggerByV3; - takeProfit?: string; - stopLoss?: string; - tpOrderType?: StrategyTriggerOrderTypeV3; - slOrderType?: StrategyTriggerOrderTypeV3; - tpLimitPrice?: string; - slLimitPrice?: string; - triggerBy?: StrategyTriggerByV3; - triggerPrice?: string; - triggerOrderType?: StrategyTriggerOrderTypeV3; - triggerOrderPrice?: string; +export interface GetSymbolsRequestV3 { + productId: string; } ⋮---- -export interface CancelStrategyOrderRequestV3 { - orderId?: string; - clientOid?: string; +export interface GetRepaidHistoryRequestV3 { + startTime?: string; + endTime?: string; + limit?: string; } ⋮---- -export interface GetUnfilledStrategyOrdersRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - type?: StrategyOrderTypeV3; +export interface GetProductInfosRequestV3 { + productId: string; } ⋮---- -export interface GetHistoryStrategyOrdersRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - type?: StrategyOrderTypeV3; +export interface GetLoanOrderRequestV3 { + orderId?: string; startTime?: string; endTime?: string; - limit?: string; - cursor?: string; } - -================ -File: src/types/request/v3/trade.ts -================ -export interface BatchModifyOrderRequestV3 { - orderId?: string; - clientOid?: string; - qty?: string; - price?: string; - autoCancel?: 'yes' | 'no'; +⋮---- +export interface GetEnsureCoinsRequestV3 { + productId: string; } ⋮---- -export interface CancelAllOrdersRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol?: string; +export interface BindUidRequestV3 { + riskUnitId?: string; + uid: string; + operate: 'bind' | 'unbind'; } ⋮---- -export interface CancelBatchOrdersRequestV3 { - orderId?: string; - clientOid?: string; - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol: string; +export interface GetLTVConvertRequestV3 { + riskUnitId?: string; } ⋮---- -export interface CloseAllPositionsRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - posSide?: 'long' | 'short'; +/* Unified Account Staking & Lending (Crypto Loans) - /api/v3/loan/* */ +⋮---- +export interface GetLoanCoinsRequestV3 { + coin?: string; } ⋮---- -export interface CancelOrderRequestV3 { - orderId?: string; - clientOid?: string; +export interface GetLoanInterestRequestV3 { + loanCoin: string; + pledgeCoin: string; + daily: 'SEVEN' | 'THIRTY' | 'FLEXIBLE'; + pledgeAmount: string; } ⋮---- -export interface GetMaxOpenAvailableRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol: string; - orderType: 'limit' | 'market'; - side: 'buy' | 'sell'; - price?: string; - size?: string; +export interface LoanBorrowRequestV3 { + loanCoin: string; + pledgeCoin: string; + daily: 'SEVEN' | 'THIRTY' | 'FLEXIBLE'; + pledgeAmount?: string; + loanAmount?: string; } ⋮---- -export interface GetOrderInfoRequestV3 { +export interface GetLoanBorrowOngoingRequestV3 { orderId?: string; - clientOid?: string; + loanCoin?: string; + pledgeCoin?: string; } ⋮---- -export interface GetFillsRequestV3 { +export interface GetLoanBorrowHistoryRequestV3 { orderId?: string; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; + loanCoin?: string; + pledgeCoin?: string; + status?: 'ROLLBACK' | 'FORCE' | 'REPAY'; + startTime: string; + endTime: string; + pageNum?: string; + pageSize?: string; } ⋮---- -export interface GetUnfilledOrdersRequestV3 { - category?: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol?: string; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; +export interface LoanRepayRequestV3 { + orderId: string; + method: 'borrowed_coin' | 'collateral'; + repayAll: 'yes' | 'no'; + amount?: string; + repayUnlock?: 'yes' | 'no'; } ⋮---- -export interface GetHistoryOrdersRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; +export interface GetLoanRepayHistoryRequestV3 { + orderId?: string; + loanCoin?: string; + pledgeCoin?: string; + startTime: string; + endTime: string; + pageNum?: string; + pageSize?: string; } ⋮---- -export interface GetPositionHistoryRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; +export interface LoanRevisePledgeRequestV3 { + orderId: string; + amount: string; + pledgeCoin: string; + reviseType?: 'OUT' | 'IN'; } ⋮---- -export interface GetCurrentPositionRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - posSide?: 'long' | 'short'; +export interface GetLoanPledgeRateHistoryRequestV3 { + orderId?: string; + reviseSide?: 'down' | 'up'; + pledgeCoin?: string; + startTime: string; + endTime: string; + pageNum?: string; + pageSize?: string; } ⋮---- -export interface ModifyOrderRequestV3 { +export interface GetLoanReducesRequestV3 { orderId?: string; - clientOid?: string; - qty?: string; - price?: string; - autoCancel?: 'yes' | 'no'; - symbol?: string; - category?: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - tpTriggerBy?: 'market' | 'mark'; - slTriggerBy?: 'market' | 'mark'; - takeProfit?: string; - stopLoss?: string; - tpOrderType?: 'limit' | 'market'; - slOrderType?: 'limit' | 'market'; - tpLimitPrice?: string; - slLimitPrice?: string; + loanCoin?: string; + pledgeCoin?: string; + status?: 'COMPLETE' | 'WAIT'; + startTime: string; + endTime: string; + pageNum?: string; + pageSize?: string; } + +================ +File: src/types/request/v3/p2p.ts +================ +export type P2pSideV3 = 'buy' | 'sell'; ⋮---- -export interface PlaceRealityOrderRequestV3 { - symbol: string; - side: 'buy' | 'sell'; - orderType: 'limit' | 'market'; - qty: string; - price?: string; - clientOid?: string; +export type P2pPriceTypeV3 = 'fixed' | 'floating'; +⋮---- +export type P2pMarketTypeV3 = 'public' | 'private'; +⋮---- +export type P2pAdStatusV3 = 'publish' | 'delist' | 'remove'; +⋮---- +export type P2pAdOperationV3 = 'publish' | 'delist' | 'remove'; +⋮---- +export type P2pOrderStatusV3 = + | 'pending_payment' + | 'pending_release' + | 'completed' + | 'cancelled' + | 'in_appeal'; +⋮---- +export interface P2pPayMethodIdRefV3 { + payMethodId: string; + userPayMethodId?: string; } ⋮---- -export interface CancelRealityOrderRequestV3 { - symbol: string; - orderId?: string; - clientOid?: string; +export interface GetP2pAdListRequestV3 { + token: string; + fiat: string; + side: P2pSideV3; + amount?: string; + pageNum: string; + limit: string; } ⋮---- -export interface PlaceBatchOrdersRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol: string; - qty: string; - price?: string; - side: 'buy' | 'sell'; - orderType: 'limit' | 'market'; - timeInForce?: 'ioc' | 'fok' | 'gtc' | 'post_only'; - posSide?: 'long' | 'short'; - clientOid?: string; - reduceOnly?: 'yes' | 'no'; +export interface GetP2pExchangeRateRequestV3 { + token: string; + fiat: string; } ⋮---- -export type FuturesMarginModeV3 = 'crossed' | 'isolated'; +export interface P2pFeeSimulateRequestV3 { + token: string; + fiat: string; + side: P2pSideV3; + marketType: P2pMarketTypeV3; + amount: string; +} ⋮---- -export interface PlaceOrderRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol: string; - qty: string; +export interface GetP2pAdLimitRequestV3 { + token: string; + fiat: string; + side: P2pSideV3; +} +⋮---- +export interface CreateP2pAdRequestV3 { + token: string; + fiat: string; + side: P2pSideV3; + priceType: P2pPriceTypeV3; price?: string; - side: 'buy' | 'sell'; - orderType: 'limit' | 'market'; - timeInForce?: 'ioc' | 'fok' | 'gtc' | 'post_only'; - posSide?: 'long' | 'short'; - clientOid?: string; - reduceOnly?: 'yes' | 'no'; - /** Futures only. Defaults to crossed */ - marginMode?: FuturesMarginModeV3; - stpMode?: 'none' | 'cancel_taker' | 'cancel_maker' | 'cancel_both'; - takeProfitPrice?: string; - stopLossPrice?: string; - takeProfitTriggerType?: 'mark_price' | 'last_price'; - stopLossTriggerType?: 'mark_price' | 'last_price'; + premium?: string; + minAmount: string; + maxAmount: string; + quantity: string; + payMethodIds: P2pPayMethodIdRefV3[]; + remark?: string; + tradeTerms?: string; + payTimeLimit: string; } ⋮---- -/** Futures only. Defaults to crossed */ +export interface UpdateP2pAdRequestV3 { + advId: string; + priceType?: P2pPriceTypeV3; + price?: string; + premium?: string; + minAmount?: string; + maxAmount?: string; + quantity?: string; + payMethodIds?: P2pPayMethodIdRefV3[]; + payTimeLimit?: string; + remark?: string; + tradeTerms?: string; +} ⋮---- -export interface CountdownCancelAllRequestV3 { - countdown: string; // seconds until auto-cancel (5-60, or 0 to disable) +export interface OperateP2pAdRequestV3 { + advId: string; + operation: P2pAdOperationV3; } ⋮---- -countdown: string; // seconds until auto-cancel (5-60, or 0 to disable) +export interface GetP2pAdInfoRequestV3 { + advId: string; +} +⋮---- +export interface GetP2pMyAdsRequestV3 { + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; + advId?: string; + token?: string; + fiat?: string; + status?: P2pAdStatusV3; +} +⋮---- +export interface GetP2pPendingOrdersRequestV3 { + orderId?: string; + side?: P2pSideV3; + startTime?: string; + endTime?: string; + cursor?: string; + limit?: string; +} +⋮---- +export interface GetP2pAllOrdersRequestV3 { + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; + orderId?: string; + side?: P2pSideV3; + status?: P2pOrderStatusV3; +} +⋮---- +export interface GetP2pOrderInfoRequestV3 { + orderId: string; +} +⋮---- +export interface P2pOrderActionRequestV3 { + orderId: string; +} +⋮---- +export interface GetP2pBalanceRequestV3 { + token: string; +} ================ -File: src/types/response/v2/common.ts +File: src/types/request/v3/stockplus.ts ================ /** * - * * Common | Notice + * + * Stock+ (UTA) + * * */ ⋮---- -export interface AnnouncementV2 { - annId: string; - annTitle: string; - annDesc: string; - cTime: string; - language: string; - annUrl: string; +export interface GetStockPlusOptionQuoteRequestV3 { + symbol: string; } ⋮---- -/** - * - * * Common | Public - * - */ +export interface GetStockPlusOptionChainInfoRequestV3 { + symbol: string; + expiryDate: string; +} ⋮---- -/** - * - * * Common | Tax - * - */ +export interface GetStockPlusOptionExpiryDateRequestV3 { + symbol: string; +} ⋮---- -export interface SpotTransactionRecordV2 { - id: string; - coin: string; - spotTaxType: string; - amount: string; - fee: string; - balance: string; - ts: string; +export interface GetStockPlusOptionVolumeRequestV3 { + symbol: string; } ⋮---- -export interface FuturesTransactionRecordV2 { - id: string; +export interface GetStockPlusStaticInfoRequestV3 { symbol: string; - marginCoin: string; - futureTaxType: string; - amount: string; - fee: string; - ts: string; } ⋮---- -export interface MarginTransactionRecordV2 { - id: string; - coin: string; - marginTaxType: string; - amount: string; - fee: string; - total: string; +export interface GetStockPlusQuoteRequestV3 { symbol: string; - ts: string; } ⋮---- -export interface P2PMerchantOrdersV2 { - id: string; - coin: string; - p2pTaxType: string; - total: string; - ts: string; +export interface GetStockPlusTradeDetailRequestV3 { + symbol: string; + count?: string; } ⋮---- -/** - * - * * Common | P2P - * - */ +export interface GetStockPlusIntradayRequestV3 { + symbol: string; +} ⋮---- -export interface P2PMerchantV2 { - registerTime: string; - nickName: string; - isOnline: string; - avgPaymentTime: string; - avgReleaseTime: string; - totalTrades: string; - totalBuy: string; - totalSell: string; - totalCompletionRate: string; - trades30d: string; - sell30d: string; - buy30d: string; - completionRate30d: string; +export interface GetStockPlusHistoryCandlestickRequestV3 { + symbol: string; + period: string; + count?: string; + adjustType?: string; + forward?: boolean; + time?: string; + tradeSessions?: string; } ⋮---- -export interface P2PMerchantInfoV2 { - registerTime: string; - nickName: string; - merchantId: string; - avgPaymentTime: string; - avgReleaseTime: string; - totalTrades: string; - totalBuy: string; - totalSell: string; - totalCompletionRate: string; - trades30d: string; - sell30d: string; - buy30d: string; - completionRate30d: string; - kycStatus: boolean; - emailBindStatus: boolean; - mobileBindStatus: boolean; - email: string; - mobile: string; +export interface GetStockPlusCandlestickRequestV3 { + symbol: string; + period: string; + count?: string; + adjustType?: string; + tradeSessions?: string; } ⋮---- -export interface P2PMerchantOrderV2 { - orderId: string; - orderNo: string; - advNo: string; - side: string; - count: string; - coin: string; - price: string; - fiat: string; - withdrawTime: string; - representTime: string; - releaseTime: string; - paymentTime: string; - amount: string; - status: string; - buyerRealName: string; - sellerRealName: string; - ctime: string; - utime: string; - paymentInfo: { - paymethodName: string; - paymethodId: string; - paymethodInfo: { - name: string; - required: string; - type: string; - value: string; - }[]; - }; +export interface GetStockPlusDepthRequestV3 { + symbol: string; } ⋮---- -export interface P2PMerchantAdvertismentV2 { - advId: string; - advNo: string; - side: string; - advSize: string; - size: string; - coin: string; - price: string; - coinPrecision: string; - fiat: string; - fiatPrecision: string; - fiatSymbol: string; - status: string; - hide: string; - maxTradeAmount: string; - minTradeAmount: string; - payDuration: string; - turnoverNum: string; - turnoverRate: string; - label: string | null; - userLimitList: { - minCompleteNum: string; - maxCompleteNum: string; - placeOrderNum: string; - allowMerchantPlace: string; - completeRate30d: string; - country: string; - }; - paymentMethodList: { - paymentMethod: string; - paymentId: string; - paymentInfo: { - name: string; - required: boolean; - type: string; - }[]; - }[]; - merchantCertifiedList: { - imageUrl: string; - desc: string; - }[]; - utime: string; - ctime: string; +export interface PlaceStockPlusOrderRequestV3 { + symbol: string; + orderType: 'LO' | 'MO' | 'LIT' | 'MIT' | 'TSLPAMT' | 'TSLPPCT'; + side: 'Buy' | 'Sell'; + submittedQuantity: string; + timeInForce: 'Day' | 'GoodTilCanceled' | 'GoodTilDate'; + submittedPrice?: string; + triggerPrice?: string; + limitOffset?: string; + trailingAmount?: string; + trailingPercent?: string; + expireDate?: string; + outsideRth?: 'RTHOnly' | 'AnyTime' | 'Overnight'; + limitDepthLevel?: number; + triggerCount?: number; + monitorPrice?: string; + remark?: string; } ⋮---- -/** - * - * * Common | Trading insights - * - */ +export interface CancelStockPlusOrderRequestV3 { + symbol: string; + orderId?: string; + clientOid?: string; +} ⋮---- -export interface SpotWhaleNetFlowV2 { - volume: string; - date: string; +export interface ModifyStockPlusOrderRequestV3 { + orderId: string; + quantity: string; + price?: string; + triggerPrice?: string; + limitOffset?: string; + trailingAmount?: string; + trailingPercent?: string; + limitDepthLevel?: number; + triggerCount?: number; + monitorPrice?: string; + remark?: string; } ⋮---- -export interface FuturesActiveBuySellVolumeV2 { - buyVolume: string; - sellVolume: string; - ts: string; +export interface GetStockPlusTodayOrdersRequestV3 { + symbol?: string; + status?: string | string[]; + side?: string; + market?: string; + orderId?: string; } ⋮---- -export interface FuturesActiveLongShortPositionV2 { - longPositionRatio: string; - shortPositionRatio: string; - longShortPositionRatio: string; - ts: string; +export interface GetStockPlusHistoryOrdersRequestV3 { + symbol?: string; + status?: string | string[]; + side?: string; + market?: string; + startAt?: string; + endAt?: string; } ⋮---- -export interface LeveragedLongShortRatioV2 { - ts: string; - longShortRatio: string; +export interface GetStockPlusOrderDetailRequestV3 { + orderId: string; } ⋮---- -export interface MarginLoanGrowthRateV2 { - ts: string; - growthRate: string; +export interface GetStockPlusTodayExecutionsRequestV3 { + symbol?: string; + orderId?: string; } ⋮---- -export interface IsolatedMarginBorrowingRatioV2 { - ts: string; - borrowRate: string; +export interface GetStockPlusHistoryExecutionsRequestV3 { + symbol?: string; + startAt?: string; + endAt?: string; } ⋮---- -export interface FuturesLongShortRatioV2 { - longRatio: string; - shortRatio: string; - longShortRatio: string; - ts: string; +export interface GetStockPlusAccountRequestV3 { + currency?: string; } ⋮---- -export interface SpotFundFlowV2 { - whaleBuyVolume: string; - dolphinBuyVolume: string; - fishBuyVolume: string; - whaleSellVolume: string; - dolphinSellVolume: string; - fishSellVolume: string; - whaleBuyRatio: string; - dolphinBuyRatio: string; - fishBuyRatio: string; - whaleSellRatio: string; - dolphinSellRatio: string; - fishSellRatio: string; +export interface GetStockPlusCashFlowRequestV3 { + startTime: string; + endTime: string; + businessType?: string; + symbol?: string; + page?: string; + size?: string; } ⋮---- -export interface FuturesActiveLongShortAccountV2 { - longAccountRatio: string; - shortAccountRatio: string; - longShortAccountRatio: string; - ts: string; +export interface GetStockPlusStockPositionRequestV3 { + symbol?: string; +} +⋮---- +export interface StockPlusTransferRequestV3 { + coin?: string; + amount?: string; + direction?: 'in' | 'out'; } ⋮---- +export interface GetStockPlusTransferRecordsRequestV3 { + transferId?: string; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; +} + +================ +File: src/types/response/v2/broker.ts +================ /** * - * * Common | Virtual Subaccount + * * Broker | Subaccount * */ ⋮---- -export interface CreateVirtualSubAccountV2 { - failureList: { - subaAccountName: string; - }[]; - successList: { - subaAccountUid: string; - subaAccountName: string; - status: string; - label: string; - permList: string[]; - cTime: string; - uTime: string; - }[]; -} -⋮---- -export interface CreateVirtualSubAccountAndApiKeyV2 { - subAccountUid: string; - subAccountName: string; - label: string; - subAccountApiKey: string; - secretKey: string; +export interface CreateSubaccountResponseV2 { + subUid: string; + subaccountName: string; + status: string; permList: string[]; - ipList: string[]; + label: string; + cTime: string; } ⋮---- -export interface VirtualSubAccountV2 { - subAccountUid: string; - subAccountName: string; +export interface BrokerSubaccountV2 { + subUid: string; + subaccountName: string; status: string; permList: string[]; label: string; - accountType: string; - bindingTime: string; + language: string; cTime: string; uTime: string; } ⋮---- -export interface CreateVirtualSubAccountApiKeyV2 { - subAccountUid: string; - label: string; - subAccountApiKey: string; - secretKey: string; +export interface ModifySubaccountResponseV2 { + subUid: string; + subaccountName: string; + status: string; permList: string[]; - ipList: string[]; -} -⋮---- -export interface ModifyVirtualSubAccountApiKeyV2 { - subAccountUid: string; label: string; - subAccountApiKey: string; - secretKey: string; - permList: string[]; - ipList: string[]; + language: string; + cTime: string; + uTime: string; } ⋮---- -export interface CreateAgentSubaccountV2 { - username: string; +export interface SubaccountEmailV2 { subUid: string; - apiKey: string; - secret: string; - note: string; - createdTime: string; -} -⋮---- -export interface SubAccountApiKeyItemV2 { - subAccountUid: string; - label: string; - subAccountApiKey: string; - permList: string[]; - ipList: string[]; + subaccountName: string; + subaccountEmail: string; + cTime: string; + uTime: string; } ⋮---- -/** - * - * * Common | Assets - * - */ -⋮---- -export interface FundingAssetV2 { +export interface BrokerSubaccountSpotAssetV2 { coin: string; available: string; frozen: string; - usdtValue: string; + locked: string; + uTime: string; } ⋮---- -export interface BotAssetV2 { - coin: string; +export interface BrokerSubaccountFutureAssetV2 { + marginCoin: string; available: string; - equity: string; - bonus: string; frozen: string; - usdtValue: string; + locked: string; + crossedMaxAvailable: string; + isolatedMaxAvailable: string; + maxTransferOut: string; + accountEquity: string; + usdtEquity: string; + btcEquity: string; + uTime: string; } ⋮---- -/** - * - * * Common | Convert - * - */ -⋮---- -export interface ConvertCurrencyV2 { +export interface CreateSubaccountDepositAddressV2 { + subUid: string; coin: string; - available: string; - maxAmount: string; - minAmount: string; + address: string; + chain: string; + tag: string; + url: string; + cTime: string; } ⋮---- -export interface ConvertQuotedPriceV2 { +export interface SubaccountDepositV2 { + orderId: string; + txId: string; + coin: string; + type: string; + dest: string; + amount: string; + status: string; + fromAddress: string; + toAddress: string; fee: string; - fromCoinSize: string; - fromCoin: string; - cnvtPrice: string; - toCoinSize: string; - toCoin: string; - traceId: string; -} -⋮---- -export interface ConvertTradeResponseV2 { - ts: string; - cnvtPrice: string; - toCoinSize: string; - toCoin: string; + chain: string; + confirm: string; + tag: string; + cTime: string; + uTime: string; } ⋮---- -export interface ConvertRecordV2 { - id: string; - ts: string; - cnvtPrice: string; +export interface BrokerSubaccountWithdrawalV2 { + orderId: string; + txId: string; + coin: string; + type: string; + dest: string; + amount: string; + status: string; + fromAddress: string; + toAddress: string; fee: string; - fromCoinSize: string; - fromCoin: string; - toCoinSize: string; - toCoin: string; + chain: string; + confirm: string; + tag: string; + userId: string; + cTime: string; + uTime: string; } ⋮---- /** * - * * Common | BGB Convert + * Broker | Api Key * */ ⋮---- -export interface BGBConvertCoinV2 { - coin: string; - available: string; - bgbEstAmount: string; - precision: string; - feeDetail: { - feeRate: string; - fee: string; - }[]; - cTime: string; +export interface CreateSubaccountApiKeyResponseV2 { + subUid: string; + apiKey: string; + secretKey: string; + label: string; + ipList: string[]; + permType: string; + permList: string[]; } ⋮---- -export interface ConvertBGBResponseV2 { - orderList: { - coin: string; - orderId: string; - }[]; +export interface SubaccountApiKeyV2 { + subUid: string; + label: string; + apiKey: string; + secretKey: string; + permType: string; + permList: string[]; + ipList: string[]; } ⋮---- -export interface BGBConvertHistoryV2 { - orderId: string; - fromCoin: string; - fromAmount: string; - fromCoinPrice: string; - toCoin: string; - toAmount: string; - toCoinPrice: string; - feeDetail: { - feeCoin: string; - fee: string; - }[]; - status: string; - ctime: string; +export interface ModifySubaccountApiKeyResponseV2 { + subUid: string; + apiKey: string; + label: string; + ipList: string[]; + permType: string; + permList: string[]; } - -================ -File: src/types/response/v2/earn.ts -================ +⋮---- /** * - * - * Earn | Savings - * + * * Broker | All Sub-accounts Deposit and Withdrawal Records * */ ⋮---- -export interface EarnSavingsProductsV2 { - productId: string; +export interface AllSubDepositWithdrawalRecordV2 { + uid: string; + txId: string; + type: 'deposit' | 'withdrawal'; + subType: 'onchain' | 'internal' | 'fast'; coin: string; - periodType: string; - period: string; - apyType: string; - advanceRedeem: string; - settleMethod: string; - apyList: { - rateLevel: string; - minStepVal: string; - maxStepVal: string; - currentApy: string; - }[]; - status: string; - productLevel: string; + amount: string; + status: 'pending' | 'fail' | 'success'; + ts: string; } ⋮---- -export interface EarnSavingsAccountV2 { - btcAmount: string; - usdtAmount: string; - btc24hEarning: string; - usdt24hEarning: string; - btcTotalEarning: string; - usdtTotalEarning: string; -} +/** + * + * * Broker | Subaccounts + * + */ ⋮---- -export interface EarnSavingsAssetV2 { - productId: string; - orderId: string; - productCoin: string; - interestCoin: string; - periodType: string; - period: string; - holdAmount: string; - lastProfit: string; - totalProfit: string; - holdDays: string; - status: string; - allowRedemption: string; - productLevel: string; - apy: { - rateLevel: string; - minApy: string; - maxApy: string; - currentApy: string; - }[]; +export interface BrokerSubaccountInfoV2 { + uid: string; + asset: string; + firstTimeDeposit: string; + firstTimeTrade: string; + registerTime: string; } ⋮---- -export interface EarnSavingsAssetsV2 { - resultList: EarnSavingsAssetV2[]; - endId: string; +/** + * + * * Broker | Commissions + * + */ +⋮---- +export interface BrokerCommissionV2 { + uid: string; + coin: string; + symbol: string; + dealtAmount: string; + totalFee: string; + deductedFee: string; + paidFee: string; + markUpFee: string; + totalCommission: string; } ⋮---- -export interface EarnSavingsRecordV2 { - orderId: string; - coinName: string; - settleCoinName: string; - productType: string; - period: string; - productLevel: string; - amount: string; - ts: string; - orderType: string; -} -⋮---- -export interface EarnSavingsRecordsV2 { - resultList: EarnSavingsRecordV2[]; - endId: string; -} +/** + * + * * Broker | Trade Volume + * + */ ⋮---- -export interface EarnSavingsSubscriptionDetailV2 { - singleMinAmount: string; - singleMaxAmount: string; - remainingAmount: string; - subscribePrecision: string; - profitPrecision: string; - subscribeTime: string; - interestTime: string; - settleTime: string; - expireTime: string; - redeemTime: string; - settleMethod: string; - apyList: { - rateLevel: string; - minStepVal: string; - maxStepVal: string; - currentApy: string; - }[]; - redeemDelay: string; +export interface BrokerTradeVolumeV2 { + uid: string; + volume: string; + spotVolume: string; + futureVolume: string; } ⋮---- /** * - * - * Earn | Earn Account - * + * * Broker | Total Commission * */ ⋮---- +export interface BrokerTotalCommissionV2 { + date: string; + totalTradingVolume: string; + totalActiveTraders: string; + totalCommission: string; + spot: { + spotTradingVolume: string; + spotTradingFee: string; + spotPureTradingFee: string; + spotCommission: string; + }; + futures: { + futuresTradingVolume: string; + futuresTradingFee: string; + futuresPureTradingFee: string; + futuresCommission: string; + }; +} +⋮---- /** * - * - * Earn | Shark Fin - * + * * Broker | Order Commission * */ ⋮---- -export interface EarnSharkfinProductV2 { - productId: string; - productName: string; - productCoin: string; - subscribeCoin: string; - farmingStartTime: string; - farmingEndTime: string; - lowerRate: string; - defaultRate: string; - upperRate: string; - period: string; - interestStartTime: string; - status: string; - minAmount: string; - limitAmount: string; - soldAmount: string; - endTime: string; - startTime: string; +export interface BrokerOrderCommissionItemV2 { + fillId: string; + orderId: string; + ts: string; + clientOid: string; + bizType: 'spot' | 'futures'; + subBizType: + | 'spot_trade' + | 'spot_margin' + | 'usdt_futures' + | 'coin_futures' + | 'usdc_futures'; + symbol: string; + volume: string; + fee: string; + pureFee: string; + rebateAmount: string; } ⋮---- -export interface EarnSharkfinProductsV2 { - resultList: EarnSharkfinProductV2[]; +export interface BrokerOrderCommissionV2 { + commissionlist: BrokerOrderCommissionItemV2[]; endId: string; } ⋮---- -export interface EarnSharkfinAccountV2 { - btcSubscribeAmount: string; - usdtSubscribeAmount: string; - btcHistoricalAmount: string; - usdtHistoricalAmount: string; - btcTotalEarning: string; - usdtTotalEarning: string; +/** + * + * * Broker | Rebate Info + * + */ +⋮---- +export interface BrokerRebateInfoV2 { + affiliationType: 'affiliate' | 'official'; + userLevel: string; + clientSpotRebateRatio: string; + clientFuturesRebateRatio: string; } ⋮---- -export interface EarnSharkfinAssetV2 { - productId: string; - interestStartTime: string; - interestEndTime: string; - productCoin: string; - subscribeCoin: string; - trend: string; - settleTime: string; - interestAmount: string; - productStatus: string; +/** + * + * * Broker | Agent (affiliate) customer APIs + * + */ +⋮---- +export interface AgentCustomerCommissionItemV2 { + uid: string; + date: string; + coin: string; + symbol: string; + productType: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES' + | string; + dealAmount: string; + fee: string; + feeDeduction: string; + activityBonusDeduct: string; + spotCouponDeduct: string; + futuresCouponDeduct: string; + spotFeeDiscountDeduct: string; + negativeMakerFeeDeduct: string; + feePaid: string; + rebateAmount: string; + userTotalRebateAmount: string; + dayTotalRebateAmount: string; + totalRebateAmount: string; } ⋮---- -export interface EarnSharkfinAssetsV2 { - resultList: EarnSharkfinAssetV2[]; +export interface AgentCustomerCommissionsV2 { endId: string; + commissionList: AgentCustomerCommissionItemV2[]; } ⋮---- -export interface EarnSharkfinRecordV2 { - orderId: string; - product: string; - period: string; - amount: string; - ts: string; - type: string; +export interface AgentSubCustomerItemV2 { + uid: string; + registerTime: string; } -export interface EarnSharkfinRecordsV2 { - resultList: EarnSharkfinRecordV2[]; - endId: string; +⋮---- +export interface AgentSubCustomerListV2 { + list: AgentSubCustomerItemV2[]; + minId: string; } ⋮---- -export interface EarnSharkfinSubscriptionDetailV2 { - productCoin: string; - subscribeCoin: string; - interestTime: string; - expirationTime: string; - minPrice: string; - currentPrice: string; - maxPrice: string; - minRate: string; - defaultRate: string; - maxRate: string; - period: string; - productMinAmount: string; - availableBalance: string; - userAmount: string; - remainingAmount: string; - profitPrecision: string; - subscribePrecision: string; +export interface AgentCustomerTradeVolumeItemV2 { + uid: string; + /** API field name (Bitget spelling). */ + volumn: string; + spotVolume: string; + futuresVolume: string; + time: string; } ⋮---- -/** - * - * - * Earn | Loan - * - * - */ +/** API field name (Bitget spelling). */ ⋮---- -export interface EarnLoanCurrencyLoanInfoV2 { - coin: string; - hourRate7D: string; - rate7D: string; - hourRate30D: string; - rate30D: string; - minUsdt: string; - maxUsdt: string; - min: string; - max: string; +export interface AgentCustomerListItemV2 { + uid: string; + registerTime: string; } -export interface EarnLoanCurrencyPledgeInfoV2 { - coin: string; - initRate: string; - supRate: string; - forceRate: string; - minUsdt: string; - maxUsdt: string; +⋮---- +export interface AgentCustomerKycItemV2 { + uid: string; + kycResult: 'passed' | 'not_passed' | string; } ⋮---- -export interface EarnLoanCurrenciesV2 { - loanInfos: EarnLoanCurrencyLoanInfoV2[]; - pledgeInfos: EarnLoanCurrencyPledgeInfoV2[]; +export interface AgentCustomerKycResultV2 { + userList: AgentCustomerKycItemV2[]; + endId: string; } ⋮---- -export interface EarnLoanOrdersV2 { +export interface AgentCustomerDepositItemV2 { orderId: string; - loanCoin: string; - loanAmount: string; - interestAmount: string; - hourInterestRate: string; - pledgeCoin: string; - pledgeAmount: string; - pledgeRate: string; - supRate: string; - forceRate: string; - borrowTime: string; - expireTime: string; -} -⋮---- -export interface EarnLoanRepayResponseV2 { - loanCoin: string; - pledgeCoin: string; - repayAmount: string; - payInterest: string; - repayLoanAmount: string; - repayUnlockAmount: string; -} -⋮---- -export interface EarnLoanRepayHistoryV2 { - orderId: string; - loanCoin: string; - pledgeCoin: string; - repayAmount: string; - payInterest: string; - repayLoanAmount: string; - repayUnlockAmount: string; - repayTime: string; -} -⋮---- -export interface EarnLoanPledgeRateHistoryV2 { - loanCoin: string; - pledgeCoin: string; - orderId: string; - reviseTime: string; - reviseSide: string; - reviseAmount: string; - afterPledgeRate: string; - beforePledgeRate: string; -} -⋮---- -export interface EarnLoanHistoryV2 { - orderId: string; - loanCoin: string; - pledgeCoin: string; - initPledgeAmount: string; - initLoanAmount: string; - hourRate: string; - daily: string; - borrowTime: string; - status: string; + uid: string; + depositTime: string; + depositCoin: string; + depositAmount: string; } ⋮---- -export interface EarnLoanDebtPledgeInfoV2 { - coin: string; - amount: string; - amountUsdt: string; +export interface AgentCustomerAssetItemV2 { + balance: string; + uid: string; + uTime: string; + remark: string; } ⋮---- -export interface EarnLoanDebtLoanInfoV2 { +export interface AgentCommissionDetailItemV2 { + uid: string; + bizType: 'spot' | 'futures' | string; + subBizType: string; + symbol: string; coin: string; - amount: string; - amountUsdt: string; + fee: string; + volume: string; + activityBonusDeduct: string; + spotCouponDeduct: string; + futuresCouponDeduct: string; + spotFeeDiscountDeduct: string; + negativeMakerFeeDeduct: string; + feePaid: string; + directCommission: string; + subCommission: string; + partnerCommission: string; + partnerActualCommission: string; + traderType: string; + apiType: string; + status: 'settled' | 'unsettled' | 'notIssued' | string; + startCalculationTime: string; + endCalculationTime: string; } ⋮---- -export interface EarnLoanDebtsV2 { - pledgeInfos: EarnLoanDebtPledgeInfoV2[]; - loanInfos: EarnLoanDebtLoanInfoV2[]; +export interface AgentCommissionDetailV2 { + endId: string; + commissionList: AgentCommissionDetailItemV2[]; } + +================ +File: src/types/response/v2/common.ts +================ +/** + * + * * Common | Notice + * + */ ⋮---- -export interface EarnLoanLiquidationRecordsV2 { - orderId: string; - loanCoin: string; - pledgeCoin: string; - reduceTime: string; - pledgeRate: string; - pledgePrice: string; - status: string; - pledgeAmount: string; - reduceFee: string; - residueAmount: string; - runlockAmount: string; - repayLoanAmount: string; +export interface AnnouncementV2 { + annId: string; + annTitle: string; + annDesc: string; + cTime: string; + language: string; + annUrl: string; } ⋮---- /** * + * * Common | Public * - * Earn | On-Chain Elite + */ +⋮---- +/** * + * * Common | Tax * */ ⋮---- -export interface EarnEliteSubscriptionCoinV2 { - subscriptionCoin: string; - precision: string; - feeRate: string; - exchangeRate: string; - remainQuota?: string; - minAmount?: string; -} -⋮---- -export interface EarnEliteProductV2 { - productId: string; +export interface SpotTransactionRecordV2 { + id: string; coin: string; - minApr: string; - maxApr: string; - subscriptionCoinList: EarnEliteSubscriptionCoinV2[]; - sellOut: 'YES' | 'NO' | string; -} -⋮---- -export interface EarnEliteAssetProjectV2 { - projectName: string; -} -⋮---- -export interface EarnEliteAssetV2 { - productId: string; - productCoin: string; - holdingAmount: string; - usdtHoldingAmount: string; - exchangeRate: string; - apr: string; - minApy?: string; - maxApy?: string; - subscriptionCoin: string; - exchangeAmount: string; - projectList?: EarnEliteAssetProjectV2[]; - unsettledBGPoints: string; - interestCoin: string; - totalProfit: string; + spotTaxType: string; + amount: string; + fee: string; + balance: string; + ts: string; } ⋮---- -export interface EarnEliteAssetsV2 { - resultList: EarnEliteAssetV2[]; +export interface FuturesTransactionRecordV2 { + id: string; + symbol: string; + marginCoin: string; + futureTaxType: string; + amount: string; + fee: string; + ts: string; } ⋮---- -export interface EarnEliteRecordV2 { - recordId: string; - productId: string; +export interface MarginTransactionRecordV2 { + id: string; coin: string; - status: string; - exchangeRate: string; - receivedCoin: string; - receivedAmount: string; - investAmount: string; - feeRate: string; - redeemType?: string | string[]; - receivingAccount: string; - actualReceivingAccount: string; - paymentAccount?: string[]; - settlePoints: string; + marginTaxType: string; + amount: string; fee: string; + total: string; + symbol: string; + ts: string; } ⋮---- -export interface EarnEliteRecordsV2 { - recordList: EarnEliteRecordV2[]; - endId: string; -} -⋮---- -export interface EarnEliteSubscribeInfoV2 { - productSubId: string; - minAmount: string; - remainQuota: string; - exchangeRate: string; - productCoin: string; - interestTime: string; - settleTime: string; - precision: string; - feeRate: string; - /** Present for BGUSD per API docs. */ - subscriptionCoinList?: EarnEliteSubscriptionCoinV2[]; +export interface P2PMerchantOrdersV2 { + id: string; + coin: string; + p2pTaxType: string; + total: string; + ts: string; } ⋮---- -/** Present for BGUSD per API docs. */ -⋮---- -export interface EarnEliteSubscribeResultV2 { - orderId: string; -} +/** + * + * * Common | P2P + * + */ ⋮---- -export interface EarnEliteSubscribeStatusV2 { - result: 'settled' | 'pending' | 'rejected' | string; +export interface P2PMerchantV2 { + registerTime: string; + nickName: string; + isOnline: string; + avgPaymentTime: string; + avgReleaseTime: string; + totalTrades: string; + totalBuy: string; + totalSell: string; + totalCompletionRate: string; + trades30d: string; + sell30d: string; + buy30d: string; + completionRate30d: string; } ⋮---- -export interface EarnEliteRedeemInfoBgusdReceiveCoinV2 { - bgusdReceiveCoin: string; - bgusdExchangeRate: string; +export interface P2PMerchantInfoV2 { + registerTime: string; + nickName: string; + merchantId: string; + avgPaymentTime: string; + avgReleaseTime: string; + totalTrades: string; + totalBuy: string; + totalSell: string; + totalCompletionRate: string; + trades30d: string; + sell30d: string; + buy30d: string; + completionRate30d: string; + kycStatus: boolean; + emailBindStatus: boolean; + mobileBindStatus: boolean; + email: string; + mobile: string; } ⋮---- -export interface EarnEliteRedeemModeV2 { - redeemFeeRate: string; - remainQuota: string; - redeemType: 'fast' | 'standard' | string; - redeemScale: string; - redeemDelayDate: string; - minRedeemAmount: string; - redeemTime: string; +export interface P2PMerchantOrderV2 { + orderId: string; + orderNo: string; + advNo: string; + side: string; + count: string; + coin: string; + price: string; + fiat: string; + withdrawTime: string; + representTime: string; + releaseTime: string; + paymentTime: string; + amount: string; + status: string; + buyerRealName: string; + sellerRealName: string; + ctime: string; + utime: string; + paymentInfo: { + paymethodName: string; + paymethodId: string; + paymethodInfo: { + name: string; + required: string; + type: string; + value: string; + }[]; + }; } ⋮---- -export interface EarnEliteRedeemInfoV2 { - productId: string; - productSubId: string; - productCoin: string; - subscriptionCoin: string; - profitCoin: string; - exchangeRate: string; - totalUnPayInterestAmount: string; - preSettleApr: string; - receivedCoin: string; - unsettledPoints: string; - bgusdReceiveCoinList: EarnEliteRedeemInfoBgusdReceiveCoinV2[]; - redeemModeList: EarnEliteRedeemModeV2[]; +export interface P2PMerchantAdvertismentV2 { + advId: string; + advNo: string; + side: string; + advSize: string; + size: string; + coin: string; + price: string; + coinPrecision: string; + fiat: string; + fiatPrecision: string; + fiatSymbol: string; + status: string; + hide: string; + maxTradeAmount: string; + minTradeAmount: string; + payDuration: string; + turnoverNum: string; + turnoverRate: string; + label: string | null; + userLimitList: { + minCompleteNum: string; + maxCompleteNum: string; + placeOrderNum: string; + allowMerchantPlace: string; + completeRate30d: string; + country: string; + }; + paymentMethodList: { + paymentMethod: string; + paymentId: string; + paymentInfo: { + name: string; + required: boolean; + type: string; + }[]; + }[]; + merchantCertifiedList: { + imageUrl: string; + desc: string; + }[]; + utime: string; + ctime: string; } ⋮---- -export interface RedeemEarnEliteResultV2 { - orderId: string; -} - -================ -File: src/types/response/v2/spot.ts -================ /** * - * * Spot | Market + * * Common | Trading insights * */ ⋮---- -export interface SpotCoinChainV2 { - chain: string; - needTag: boolean; - withdrawable: boolean; - rechargeable: boolean; - withdrawFee: string; - extraWithdrawFee: string; - depositConfirm: string; - withdrawConfirm: string; - minDepositAmount: string; - minWithdrawAmount: string; - browserUrl: string; - contractAddress: string; - withdrawStep: string; - withdrawMinScale: string; - congestion: string; +export interface SpotWhaleNetFlowV2 { + volume: string; + date: string; } ⋮---- -export interface SpotCoinInfoV2 { - coinId: string; - coin: string; - transfer: boolean; - chains: SpotCoinChainV2[]; +export interface FuturesActiveBuySellVolumeV2 { + buyVolume: string; + sellVolume: string; + ts: string; } ⋮---- -export interface SpotSymbolInfoV2 { - symbol: string; - baseCoin: string; - quoteCoin: string; - minTradeAmount: string; - maxTradeAmount: string; - takerFeeRate: string; - makerFeeRate: string; - pricePrecision: string; - quantityPrecision: string; - quotePrecision: string; - minTradeUSDT: string; - status: string; - buyLimitPriceRatio: string; - sellLimitPriceRatio: string; - orderQuantity: string; - areaSymbol: string; - maxLimitOrderValue?: string; - maxMarketOrderValue?: string; +export interface FuturesActiveLongShortPositionV2 { + longPositionRatio: string; + shortPositionRatio: string; + longShortPositionRatio: string; + ts: string; } ⋮---- -export interface SpotVipFeeRateV2 { - level: number; - dealAmount: string; - assetAmount: string; - takerFeeRate: string; - makerFeeRate: string; - btcWithdrawAmount: string; - usdtWithdrawAmount: string; +export interface LeveragedLongShortRatioV2 { + ts: string; + longShortRatio: string; } ⋮---- -export interface SpotTickerV2 { - symbol: string; - high24h: string; - open: string; - low24h: string; - lastPr: string; - quoteVolume: string; - baseVolume: string; - usdtVolume: string; - bidPr: string; - askPr: string; - bidSz: string; - askSz: string; - openUtc: string; +export interface MarginLoanGrowthRateV2 { ts: string; - changeUtc24h: string; - change24h: string; + growthRate: string; } ⋮---- -export interface SpotMergeDepthV2 { - asks: [string, string][]; - bids: [string, string][]; +export interface IsolatedMarginBorrowingRatioV2 { ts: string; - scale: string; - precision: string; - isMaxPrecision: string; + borrowRate: string; } ⋮---- -export interface SpotOrderBookDepthV2 { - asks: [string, string][]; - bids: [string, string][]; +export interface FuturesLongShortRatioV2 { + longRatio: string; + shortRatio: string; + longShortRatio: string; ts: string; } ⋮---- -export type SpotCandlestickV2 = [ - string, // timestamp - string, // open - string, // high - string, // low - string, // close - string, // baseVolume - string, // usdtVolume - string, // quoteVolume -]; +export interface SpotFundFlowV2 { + whaleBuyVolume: string; + dolphinBuyVolume: string; + fishBuyVolume: string; + whaleSellVolume: string; + dolphinSellVolume: string; + fishSellVolume: string; + whaleBuyRatio: string; + dolphinBuyRatio: string; + fishBuyRatio: string; + whaleSellRatio: string; + dolphinSellRatio: string; + fishSellRatio: string; +} ⋮---- -string, // timestamp -string, // open -string, // high -string, // low -string, // close -string, // baseVolume -string, // usdtVolume -string, // quoteVolume -⋮---- -export interface SpotTradeV2 { - symbol: string; - tradeId: string; - side: string; - price: string; - size: string; - ts: string; -} +export interface FuturesActiveLongShortAccountV2 { + longAccountRatio: string; + shortAccountRatio: string; + longShortAccountRatio: string; + ts: string; +} ⋮---- /** * - * * Spot | Trade + * * Common | Virtual Subaccount * */ ⋮---- -export interface CancelAndSubmitSpotOrderResponseV2 { - orderId: string; - clientOid: string | null; - success: string; - msg: string | null; -} -⋮---- -export interface SubmitSpotBatchOrdersResponseV2 { - successList: { - orderId: string; - clientOid: string; - }[]; +export interface CreateVirtualSubAccountV2 { failureList: { - orderId: string; - clientOid: string; - errorMsg: string; - errorCode?: string; + subaAccountName: string; + }[]; + successList: { + subaAccountUid: string; + subaAccountName: string; + status: string; + label: string; + permList: string[]; + cTime: string; + uTime: string; }[]; } ⋮---- -export interface SpotOrderInfoV2 { - userId: string; - symbol: string; - orderId: string; - clientOid: string; - price: string; - size: string; - orderType: string; - side: string; - status: string; - priceAvg: string; - baseVolume: string; - quoteVolume: string; - enterPointSource: string; - feeDetail: { - BGB?: { - deduction: boolean; - feeCoinCode: string; - totalDeductionFee: string; - totalFee: string; - }; - newFees?: { - c: number; - d: number; - deduction: boolean; - r: string; - t: string; - totalDeductionFee: number; - }; - }; - orderSource: string; - cancelReason: string; - cTime: string; - uTime: string; +export interface CreateVirtualSubAccountAndApiKeyV2 { + subAccountUid: string; + subAccountName: string; + label: string; + subAccountApiKey: string; + secretKey: string; + permList: string[]; + ipList: string[]; } ⋮---- -export interface SpotOpenOrderV2 { - userId: string; - symbol: string; - orderId: string; - clientOid: string; - priceAvg: string; - size: string; - orderType: string; - side: string; +export interface VirtualSubAccountV2 { + subAccountUid: string; + subAccountName: string; status: string; - basePrice: string; - baseVolume: string; - quoteVolume: string; - enterPointSource: string; - orderSource?: string; - presetTakeProfitPrice: string; - executeTakeProfitPrice: string; - presetStopLossPrice: string; - executeStopLossPrice: string; - cTime: string; - uTime?: string; - tpslType: string; - triggerPrice: string | null; -} -⋮---- -export interface SpotFillV2 { - userId: string; - symbol: string; - orderId: string; - tradeId: string; - orderType: string; - side: string; - priceAvg: string; - size: string; - amount: string; - feeDetail: { - deduction: string; - feeCoin: string; - totalDeductionFee: string; - totalFee: string; - }; - tradeScope: string; + permList: string[]; + label: string; + accountType: string; + bindingTime: string; cTime: string; uTime: string; } ⋮---- -/** - * - * * Spot | Trigger Orders - * - */ -⋮---- -export interface SpotCurrentPlanOrderV2 { - orderId: string; - clientOid: string; - symbol: string; - size: string; - executePrice: string; - triggerPrice: string; - status: string; - orderType: string; - side: string; - planType: string; - triggerType: string; - enterPointSource: string; - uTime: string; - cTime: string; +export interface CreateVirtualSubAccountApiKeyV2 { + subAccountUid: string; + label: string; + subAccountApiKey: string; + secretKey: string; + permList: string[]; + ipList: string[]; } ⋮---- -export interface SpotHistoryPlanOrderV2 { - orderId: string; - clientOid: string; - symbol: string; - size: string; - executePrice: string; - triggerPrice: string; - status: string; - orderType: string; - side: string; - planType: string; - triggerType: string; - enterPointSource: string; - uTime: string; - cTime: string; +export interface ModifyVirtualSubAccountApiKeyV2 { + subAccountUid: string; + label: string; + subAccountApiKey: string; + secretKey: string; + permList: string[]; + ipList: string[]; } ⋮---- -export interface SpotPlanSubOrderV2 { - orderId: string; - price: string; - type: string; - status: string; +export interface CreateAgentSubaccountV2 { + username: string; + subUid: string; + apiKey: string; + secret: string; + note: string; + createdTime: string; } ⋮---- -export interface SpotCancelPlanOrdersV2 { - successList: { - orderId: string; - clientOid: string; - }[]; - failureList: { - orderId: string; - clientOid: string; - errorMsg: string; - }[]; +export interface SubAccountApiKeyItemV2 { + subAccountUid: string; + label: string; + subAccountApiKey: string; + permList: string[]; + ipList: string[]; } ⋮---- /** * - * * Spot | Account + * * Common | Assets * */ ⋮---- -export interface SpotAccountInfoV2 { - userId: string; - inviterId: string; - ips: string; - authorities: string[]; - parentId: number; - traderType: string; - channelCode: string; - channel: string; - regisTime: string; -} -⋮---- -export interface SpotAccountAssetV2 { +export interface FundingAssetV2 { coin: string; available: string; frozen: string; - locked: string; - limitAvailable: string; - uTime: string; + usdtValue: string; } ⋮---- -export interface SpotSubAccountAssetV2 { +export interface BotAssetV2 { coin: string; available: string; - limitAvailable: string; + equity: string; + bonus: string; frozen: string; - locked: string; - uTime: string; -} -export interface SpotSubAccountAssetsV2 { - userId: number; - assetsList: SpotSubAccountAssetV2[]; + usdtValue: string; } ⋮---- -export interface SpotAccountBillV2 { - cTime: string; +/** + * + * * Common | Convert + * + */ +⋮---- +export interface ConvertCurrencyV2 { coin: string; - groupType: string; - businessType: string; - size: string; - balance: string; - fees: string; - billId: string; + available: string; + maxAmount: string; + minAmount: string; } ⋮---- -export interface SpotMainSubTransferRecordV2 { - coin: string; - status: string; - toType: string; - fromType: string; - size: string; - ts: string; - clientOid: string; - transferId: string; - fromUserId: string; - toUserId: string; +export interface ConvertQuotedPriceV2 { + fee: string; + fromCoinSize: string; + fromCoin: string; + cnvtPrice: string; + toCoinSize: string; + toCoin: string; + traceId: string; } ⋮---- -export interface SpotTransferRecordV2 { - coin: string; - status: string; - toType: string; - toSymbol: string; - fromType: string; - fromSymbol: string; - size: string; +export interface ConvertTradeResponseV2 { ts: string; - clientOid: string; - transferId: string; + cnvtPrice: string; + toCoinSize: string; + toCoin: string; } ⋮---- -export interface SpotDepositAddressV2 { - address: string; - chain: string; - coin: string; - tag: string; - url: string; +export interface ConvertRecordV2 { + id: string; + ts: string; + cnvtPrice: string; + fee: string; + fromCoinSize: string; + fromCoin: string; + toCoinSize: string; + toCoin: string; } ⋮---- -export interface SpotSubAccountDepositRecordV2 { - orderId: string; - tradeId: string; +/** + * + * * Common | BGB Convert + * + */ +⋮---- +export interface BGBConvertCoinV2 { coin: string; - size: string; - status: string; - toAddress: string; - dest: string; - chain: string; - fromAddress: string; - clientOid?: string; - confirm?: string; - tag?: string; + available: string; + bgbEstAmount: string; + precision: string; + feeDetail: { + feeRate: string; + fee: string; + }[]; cTime: string; - uTime: string; } ⋮---- -export interface SpotWithdrawalRecordV2 { - orderId: string; - tradeId: string; - coin: string; - dest: string; - clientOid: string; - type: string; - tag: string; - size: string; - fee: string; - status: string; - toAddress: string; - fromAddress: string; - confirm: string; - chain: string; - cTime: string; - uTime: string; +export interface ConvertBGBResponseV2 { + orderList: { + coin: string; + orderId: string; + }[]; } ⋮---- -export interface SpotDepositRecordV2 { +export interface BGBConvertHistoryV2 { orderId: string; - tradeId: string; - coin: string; - type: string; - size: string; + fromCoin: string; + fromAmount: string; + fromCoinPrice: string; + toCoin: string; + toAmount: string; + toCoinPrice: string; + feeDetail: { + feeCoin: string; + fee: string; + }[]; status: string; - toAddress: string; - dest: string; - chain: string; - fromAddress: string; - cTime: string; - uTime: string; + ctime: string; } ================ -File: src/types/response/v3/earn.ts +File: src/types/response/v2/earn.ts ================ /** * * - * Earn | On-Chain Elite (UTA) + * Earn | Savings * * */ ⋮---- -export interface EarnEliteSubscriptionCoinV3 { - subscriptionCoin: string; - precision: string; - feeRate: string; - exchangeRate: string; - remainQuota?: string; - minAmount?: string; -} -⋮---- -export interface EarnEliteProductV3 { +export interface EarnSavingsProductsV2 { productId: string; coin: string; - minApr: string; - maxApr: string; - subscriptionCoinList: EarnEliteSubscriptionCoinV3[]; - sellOut: 'YES' | 'NO' | string; + periodType: string; + period: string; + apyType: string; + advanceRedeem: string; + settleMethod: string; + apyList: { + rateLevel: string; + minStepVal: string; + maxStepVal: string; + currentApy: string; + }[]; + status: string; + productLevel: string; } ⋮---- -export interface EarnEliteAssetProjectV3 { - projectName: string; +export interface EarnSavingsAccountV2 { + btcAmount: string; + usdtAmount: string; + btc24hEarning: string; + usdt24hEarning: string; + btcTotalEarning: string; + usdtTotalEarning: string; } ⋮---- -export interface EarnEliteAssetV3 { +export interface EarnSavingsAssetV2 { productId: string; + orderId: string; productCoin: string; - holdingAmount: string; - usdtHoldingAmount: string; - exchangeRate: string; - apr: string; - minApy?: string; - maxApy?: string; - subscriptionCoin: string; - exchangeAmount: string; - projectList?: EarnEliteAssetProjectV3[]; - unsettledBGPoints: string; interestCoin: string; + periodType: string; + period: string; + holdAmount: string; + lastProfit: string; totalProfit: string; + holdDays: string; + status: string; + allowRedemption: string; + productLevel: string; + apy: { + rateLevel: string; + minApy: string; + maxApy: string; + currentApy: string; + }[]; } ⋮---- -export interface EarnEliteAssetsV3 { - resultList: EarnEliteAssetV3[]; +export interface EarnSavingsAssetsV2 { + resultList: EarnSavingsAssetV2[]; + endId: string; } ⋮---- -export interface EarnEliteRecordV3 { - recordId: string; - productId: string; - coin: string; - status: string; - exchangeRate: string; - receivedCoin: string; - receivedAmount: string; - investAmount: string; - feeRate: string; - redeemType?: string | string[]; - receivingAccount: string; - actualReceivingAccount: string; - paymentAccount?: string[]; - settlePoints: string; - fee: string; +export interface EarnSavingsRecordV2 { + orderId: string; + coinName: string; + settleCoinName: string; + productType: string; + period: string; + productLevel: string; + amount: string; + ts: string; + orderType: string; } ⋮---- -export interface EarnEliteRecordsV3 { - recordList: EarnEliteRecordV3[]; +export interface EarnSavingsRecordsV2 { + resultList: EarnSavingsRecordV2[]; endId: string; } ⋮---- -export interface EarnEliteSubscribeInfoV3 { - productSubId: string; - minAmount: string; - remainQuota: string; - exchangeRate: string; - productCoin: string; +export interface EarnSavingsSubscriptionDetailV2 { + singleMinAmount: string; + singleMaxAmount: string; + remainingAmount: string; + subscribePrecision: string; + profitPrecision: string; + subscribeTime: string; interestTime: string; settleTime: string; - precision: string; - feeRate: string; - subscriptionCoinList?: EarnEliteSubscriptionCoinV3[]; -} -⋮---- -export interface EarnEliteSubscribeResultV3 { - orderId: string; -} -⋮---- -export interface EarnEliteSubscribeStatusV3 { - result: 'settled' | 'pending' | 'rejected' | string; + expireTime: string; + redeemTime: string; + settleMethod: string; + apyList: { + rateLevel: string; + minStepVal: string; + maxStepVal: string; + currentApy: string; + }[]; + redeemDelay: string; } ⋮---- -export interface EarnEliteRedeemInfoBgusdReceiveCoinV3 { - bgusdReceiveCoin: string; - bgusdExchangeRate: string; -} +/** + * + * + * Earn | Earn Account + * + * + */ ⋮---- -export interface EarnEliteRedeemModeV3 { - redeemFeeRate: string; - remainQuota: string; - redeemType: 'fast' | 'standard' | string; - redeemScale: string; - redeemDelayDate: string; - minRedeemAmount: string; - redeemTime: string; -} +/** + * + * + * Earn | Shark Fin + * + * + */ ⋮---- -export interface EarnEliteRedeemInfoV3 { +export interface EarnSharkfinProductV2 { productId: string; - productSubId: string; + productName: string; productCoin: string; - subscriptionCoin: string; - profitCoin: string; - exchangeRate: string; - totalUnPayInterestAmount: string; - preSettleApr: string; - receivedCoin: string; - unsettledPoints: string; - bgusdReceiveCoinList: EarnEliteRedeemInfoBgusdReceiveCoinV3[]; - redeemModeList: EarnEliteRedeemModeV3[]; -} -⋮---- -export interface RedeemEarnEliteResultV3 { - orderId: string; + subscribeCoin: string; + farmingStartTime: string; + farmingEndTime: string; + lowerRate: string; + defaultRate: string; + upperRate: string; + period: string; + interestStartTime: string; + status: string; + minAmount: string; + limitAmount: string; + soldAmount: string; + endTime: string; + startTime: string; } - -================ -File: src/types/response/v3/p2p.ts -================ -import type { - P2pAdStatusV3, - P2pMarketTypeV3, - P2pOrderStatusV3, - P2pPriceTypeV3, - P2pSideV3, -} from '../../request/v3/p2p.js'; ⋮---- -export interface P2pPayMethodInfoFieldV3 { - name: string; - type: 'file' | 'number' | 'txt'; - value: string; +export interface EarnSharkfinProductsV2 { + resultList: EarnSharkfinProductV2[]; + endId: string; } ⋮---- -export interface P2pPayMethodV3 { - payMethodId: string; - payMethodName: string; - payMethodUserName: string; - userPayMethodId: string; - payMethodInfo: P2pPayMethodInfoFieldV3[]; +export interface EarnSharkfinAccountV2 { + btcSubscribeAmount: string; + usdtSubscribeAmount: string; + btcHistoricalAmount: string; + usdtHistoricalAmount: string; + btcTotalEarning: string; + usdtTotalEarning: string; } ⋮---- -export interface P2pTokenDetailV3 { - token: string; - precision: string; +export interface EarnSharkfinAssetV2 { + productId: string; + interestStartTime: string; + interestEndTime: string; + productCoin: string; + subscribeCoin: string; + trend: string; + settleTime: string; + interestAmount: string; + productStatus: string; } ⋮---- -export interface P2pFiatPayMethodV3 { - payMethodName: string; - iconUrl: string; - payMethodId: string; +export interface EarnSharkfinAssetsV2 { + resultList: EarnSharkfinAssetV2[]; + endId: string; } ⋮---- -export interface P2pWithdrawalLimitV3 { - withdrawLimitKey: string; - withdrawLimitValue: string; +export interface EarnSharkfinRecordV2 { + orderId: string; + product: string; + period: string; + amount: string; + ts: string; + type: string; } -⋮---- -export interface P2pFiatDetailV3 { - fiat: string; - precision: string; - floatRateMin: string; - floatRateMax: string; - fixedRateMin: string; - fixedRateMax: string; - adMinLimit: string; - adMaxLimit: string; - payMethods: P2pFiatPayMethodV3; - withdrawalLimit: P2pWithdrawalLimitV3; - payTimeLimit: number[]; +export interface EarnSharkfinRecordsV2 { + resultList: EarnSharkfinRecordV2[]; + endId: string; } ⋮---- -export interface P2pCurrenciesV3 { - tokenDetailList: P2pTokenDetailV3[]; - fiatDetailList: P2pFiatDetailV3[]; +export interface EarnSharkfinSubscriptionDetailV2 { + productCoin: string; + subscribeCoin: string; + interestTime: string; + expirationTime: string; + minPrice: string; + currentPrice: string; + maxPrice: string; + minRate: string; + defaultRate: string; + maxRate: string; + period: string; + productMinAmount: string; + availableBalance: string; + userAmount: string; + remainingAmount: string; + profitPrecision: string; + subscribePrecision: string; } ⋮---- -export interface P2pUserEquityDetailV3 { - maxAdvSellNum: string; - maxAdvSellLimit: string; - maxAdvBuyNum: string; - maxAdvBuyLimit: string; - totalMaxPendingOrder: string; - advMaxPendingOrder: string; -} +/** + * + * + * Earn | Loan + * + * + */ ⋮---- -export interface P2pUserInfoV3 { - uid: string; - nickName: string; - accountLevel: 'starter' | 'advanced' | 'master'; - completedOrderNum: string; - positiveRate: string; - completedOrderNum30D: string; - completedRate30D: string; - avgPayTime30D: string; - avgReleaseTime30D: string; - equityDetail: P2pUserEquityDetailV3; - registerTime: string; +export interface EarnLoanCurrencyLoanInfoV2 { + coin: string; + hourRate7D: string; + rate7D: string; + hourRate30D: string; + rate30D: string; + minUsdt: string; + maxUsdt: string; + min: string; + max: string; } -⋮---- -export interface P2pBalanceV3 { - token: string; - totalBalance: string; - frozenBalance: string; - availableBalance: string; +export interface EarnLoanCurrencyPledgeInfoV2 { + coin: string; + initRate: string; + supRate: string; + forceRate: string; + minUsdt: string; + maxUsdt: string; } ⋮---- -export interface P2pExchangeRateV3 { - rate: string; +export interface EarnLoanCurrenciesV2 { + loanInfos: EarnLoanCurrencyLoanInfoV2[]; + pledgeInfos: EarnLoanCurrencyPledgeInfoV2[]; } ⋮---- -export interface P2pFeeSimulateV3 { - feeToken: string; - feeAmount: string; - taxToken: string; - taxAmount: string; +export interface EarnLoanOrdersV2 { + orderId: string; + loanCoin: string; + loanAmount: string; + interestAmount: string; + hourInterestRate: string; + pledgeCoin: string; + pledgeAmount: string; + pledgeRate: string; + supRate: string; + forceRate: string; + borrowTime: string; + expireTime: string; } ⋮---- -export interface P2pAdLimitV3 { - buyMinTokenAmount: string; - buyMaxTokenAmount: string; - sellMinTokenAmount: string; - sellMaxTokenAmount: string; +export interface EarnLoanRepayResponseV2 { + loanCoin: string; + pledgeCoin: string; + repayAmount: string; + payInterest: string; + repayLoanAmount: string; + repayUnlockAmount: string; } ⋮---- -export interface P2pCreateAdResponseV3 { - advId: string; +export interface EarnLoanRepayHistoryV2 { + orderId: string; + loanCoin: string; + pledgeCoin: string; + repayAmount: string; + payInterest: string; + repayLoanAmount: string; + repayUnlockAmount: string; + repayTime: string; } ⋮---- -export interface P2pAdPayMethodRefV3 { - payMethodId: string; - userPayMethodId?: string; -} +export interface EarnLoanPledgeRateHistoryV2 { + loanCoin: string; + pledgeCoin: string; + orderId: string; + reviseTime: string; + reviseSide: string; + reviseAmount: string; + afterPledgeRate: string; + beforePledgeRate: string; +} ⋮---- -export interface P2pAdInfoV3 { - advId: string; - side: P2pSideV3; - priceType: P2pPriceTypeV3; - token: string; - fiat: string; - price: string; - amount: string; - minAmount: string; - maxAmount: string; - payDuration: string; - soldAmount: string; - lastAmount: string; - premium: string; - turnover: string; - remark: string; - tradeTerm: string; - payMethodIds: P2pAdPayMethodRefV3[]; - tokenPrecision: string; - fiatPrecision: string; - market: P2pMarketTypeV3; - avgTime: string; - createdTime: string; - updatedTime: string; +export interface EarnLoanHistoryV2 { + orderId: string; + loanCoin: string; + pledgeCoin: string; + initPledgeAmount: string; + initLoanAmount: string; + hourRate: string; + daily: string; + borrowTime: string; + status: string; } ⋮---- -export interface P2pPublicAdListItemV3 { - advId: string; - merchantId: string; - merchantName: string; - token: string; - fiat: string; - side: P2pSideV3; - price: string; - minAmount: string; - maxAmount: string; - quantity: string; - payMethods: { - payMethodId: string; - payMethodName: string; - }[]; - completedOrderNum: string; - completedRate: string; - avgReleaseTime: string; - createdTime: string; +export interface EarnLoanDebtPledgeInfoV2 { + coin: string; + amount: string; + amountUsdt: string; } ⋮---- -export interface P2pMyAdListItemV3 { - advId: string; - side: P2pSideV3; - priceType: P2pPriceTypeV3; - token: string; - fiat: string; - price: string; - soldAmount: string; - lastAmount: string; - payMethods: { payMethodId: string }[]; - status: P2pAdStatusV3; - createdTime: string; - updatedTime: string; +export interface EarnLoanDebtLoanInfoV2 { + coin: string; + amount: string; + amountUsdt: string; } ⋮---- -export interface P2pCursorListV3 { - items: T[]; - nextId?: string; +export interface EarnLoanDebtsV2 { + pledgeInfos: EarnLoanDebtPledgeInfoV2[]; + loanInfos: EarnLoanDebtLoanInfoV2[]; } ⋮---- -export interface P2pOrderListItemV3 { +export interface EarnLoanLiquidationRecordsV2 { orderId: string; - side: P2pSideV3; - token: string; - fiat: string; - price: string; - amount: string; - quantity: string; - fee: string; - counterparty: string; - status: P2pOrderStatusV3; - createdTime: string; - updatedTime: string; + loanCoin: string; + pledgeCoin: string; + reduceTime: string; + pledgeRate: string; + pledgePrice: string; + status: string; + pledgeAmount: string; + reduceFee: string; + residueAmount: string; + runlockAmount: string; + repayLoanAmount: string; } ⋮---- -export interface P2pOrderPayMethodDetailV3 { - payMethodId: string; - payMethodName: string; - payMethodUserName: string; - postscript: string; - payMethodInfo: P2pPayMethodInfoFieldV3[]; +/** + * + * + * Earn | On-Chain Elite + * + * + */ +⋮---- +export interface EarnEliteSubscriptionCoinV2 { + subscriptionCoin: string; + precision: string; + feeRate: string; + exchangeRate: string; + remainQuota?: string; + minAmount?: string; } ⋮---- -export interface P2pOrderUserInfoV3 { - nickName: string; - realName: string; +export interface EarnEliteProductV2 { + productId: string; + coin: string; + minApr: string; + maxApr: string; + subscriptionCoinList: EarnEliteSubscriptionCoinV2[]; + sellOut: 'YES' | 'NO' | string; } ⋮---- -export interface P2pOrderInfoV3 { - orderId: string; - side: P2pSideV3; - token: string; - fiat: string; - price: string; - quantity: string; - amount: string; - status: P2pOrderStatusV3; - advId: string; - remark: string; - orderCancelCountdown: string; - fee: string; - verifyCapital: 'yes' | 'no'; - payMethodDetail?: P2pOrderPayMethodDetailV3; - sellUserInfo: P2pOrderUserInfoV3; - buyUserInfo: P2pOrderUserInfoV3; - createdTime: string; - updatedTime: string; +export interface EarnEliteAssetProjectV2 { + projectName: string; } - -================ -File: src/types/response/v3/strategy.ts -================ -import type { - StrategyOrderStatusV3, - StrategyTriggerByV3, - StrategyTriggerOrderTypeV3, -} from '../../request/v3/strategy.js'; ⋮---- -export interface PlaceStrategyOrderResponseV3 { - orderId: string; - clientOid: string; +export interface EarnEliteAssetV2 { + productId: string; + productCoin: string; + holdingAmount: string; + usdtHoldingAmount: string; + exchangeRate: string; + apr: string; + minApy?: string; + maxApy?: string; + subscriptionCoin: string; + exchangeAmount: string; + projectList?: EarnEliteAssetProjectV2[]; + unsettledBGPoints: string; + interestCoin: string; + totalProfit: string; } ⋮---- -export interface ModifyStrategyOrderResponseV3 { - orderId: string; - clientOid: string; +export interface EarnEliteAssetsV2 { + resultList: EarnEliteAssetV2[]; } ⋮---- -export interface StrategyOrderV3 { - orderId: string; - clientOid: string; - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol: string; - qty: string; - posSide: 'long' | 'short'; - status: StrategyOrderStatusV3; - triggerType?: 'takeProfit' | 'stopLoss'; - tpTriggerBy?: StrategyTriggerByV3; - slTriggerBy?: StrategyTriggerByV3; - takeProfit?: string; - stopLoss?: string; - tpOrderType?: StrategyTriggerOrderTypeV3; - slOrderType?: StrategyTriggerOrderTypeV3; - tpLimitPrice?: string; - slLimitPrice?: string; - triggerBy?: StrategyTriggerByV3; - triggerPrice?: string; - triggerOrderType?: StrategyTriggerOrderTypeV3; - triggerOrderPrice?: string; - createdTime: string; - updatedTime: string; +export interface EarnEliteRecordV2 { + recordId: string; + productId: string; + coin: string; + status: string; + exchangeRate: string; + receivedCoin: string; + receivedAmount: string; + investAmount: string; + feeRate: string; + redeemType?: string | string[]; + receivingAccount: string; + actualReceivingAccount: string; + paymentAccount?: string[]; + settlePoints: string; + fee: string; } - -================ -File: src/types/websockets/ws-api-request.ts -================ -import type { FuturesMarginModeV3 } from '../request/v3/trade.js'; ⋮---- -export interface WSAPIPlaceOrderRequestV3 { - symbol: string; - orderType: 'limit' | 'market'; - qty: string; - price?: string; - side: 'buy' | 'sell'; - posSide?: 'long' | 'short'; - timeInForce?: 'gtc' | 'ioc' | 'fok' | 'post_only'; - reduceOnly?: 'YES' | 'NO'; // Note: reduceOnly is not supported for batch place WS API. Might be supported starting late Q4 2025, but not supported yet. - /** Futures only. Defaults to crossed */ - marginMode?: FuturesMarginModeV3; - clientOid?: string; - stpMode?: 'none' | 'cancel_taker' | 'cancel_maker' | 'cancel_both'; - tpTriggerBy?: 'market' | 'mark'; - slTriggerBy?: 'market' | 'mark'; - takeProfit?: string; - stopLoss?: string; - tpOrderType?: 'limit' | 'market'; - slOrderType?: 'limit' | 'market'; - tpLimitPrice?: string; - slLimitPrice?: string; +export interface EarnEliteRecordsV2 { + recordList: EarnEliteRecordV2[]; + endId: string; } ⋮---- -reduceOnly?: 'YES' | 'NO'; // Note: reduceOnly is not supported for batch place WS API. Might be supported starting late Q4 2025, but not supported yet. -/** Futures only. Defaults to crossed */ - -================ -File: src/types/websockets/ws-api.ts -================ -import { WS_KEY_MAP } from '../../util/websocket-util.js'; -import { CancelOrderRequestV3 } from '../request/v3/trade.js'; -import { CancelOrderResponseV3 } from '../response/v3/trade.js'; -import { WSAPIPlaceOrderRequestV3 } from './ws-api-request.js'; -import { WSAPIPlaceOrderResponseV3 } from './ws-api-response.js'; -import { BitgetInstTypeV3, WsKey } from './ws-general.js'; -⋮---- -export type WSOperation = 'subscribe' | 'unsubscribe' | 'login'; +export interface EarnEliteSubscribeInfoV2 { + productSubId: string; + minAmount: string; + remainQuota: string; + exchangeRate: string; + productCoin: string; + interestTime: string; + settleTime: string; + precision: string; + feeRate: string; + /** Present for BGUSD per API docs. */ + subscriptionCoinList?: EarnEliteSubscriptionCoinV2[]; +} ⋮---- -// When new WS API operations are added, make sure to also update WS_API_Operations[] below -export type WSAPIOperation = - | 'place-order' - | 'batch-place' - | 'cancel-order' - | 'batch-cancel'; +/** Present for BGUSD per API docs. */ ⋮---- -export interface WSOperationLoginParams { - apiKey: string; - passphrase: string; - timestamp: number; - sign: string; +export interface EarnEliteSubscribeResultV2 { + orderId: string; } ⋮---- -export interface WSAPIRequestBitgetV3 { - op: 'trade'; - id: string; - category: BitgetInstTypeV3; - topic: WSAPIOperation; - args: TWSParams | TWSParams[]; +export interface EarnEliteSubscribeStatusV2 { + result: 'settled' | 'pending' | 'rejected' | string; } ⋮---- -export interface WSAPIRequestFlags { - /** If true, will skip auth requirement for WS API connection */ - authIsOptional?: boolean | undefined; +export interface EarnEliteRedeemInfoBgusdReceiveCoinV2 { + bgusdReceiveCoin: string; + bgusdExchangeRate: string; } ⋮---- -/** If true, will skip auth requirement for WS API connection */ -⋮---- -export type Exact = { - // This part says: if there's any key that's not in T, it's an error - [K: string]: never; -} & { - [K in keyof T]: T[K]; -}; -⋮---- -// This part says: if there's any key that's not in T, it's an error +export interface EarnEliteRedeemModeV2 { + redeemFeeRate: string; + remainQuota: string; + redeemType: 'fast' | 'standard' | string; + redeemScale: string; + redeemDelayDate: string; + minRedeemAmount: string; + redeemTime: string; +} ⋮---- -/** - -/** - * V2 request looks like this: -{ - "op":"subscribe", - "args":[ - { - "instType":"SPOT", - "channel":"ticker", - "instId":"BTCUSDT" - }, - { - "instType":"SPOT", - "channel":"candle5m", - "instId":"BTCUSDT" - } - ] +export interface EarnEliteRedeemInfoV2 { + productId: string; + productSubId: string; + productCoin: string; + subscriptionCoin: string; + profitCoin: string; + exchangeRate: string; + totalUnPayInterestAmount: string; + preSettleApr: string; + receivedCoin: string; + unsettledPoints: string; + bgusdReceiveCoinList: EarnEliteRedeemInfoBgusdReceiveCoinV2[]; + redeemModeList: EarnEliteRedeemModeV2[]; } - */ -export interface WsRequestOperationBitget { - op: WSOperation; - args?: (TWSRequestArg | string | number)[]; +⋮---- +export interface RedeemEarnEliteResultV2 { + orderId: string; } -export interface WSAPIResponse< - TResponseData extends object = object, - TOperation extends WSAPIOperation = WSAPIOperation, -> { - wsKey: WsKey; - /** Auto-generated */ - id: string; - event: 'trade'; - category: BitgetInstTypeV3; - topic: TOperation; - args: TResponseData; - code: '0' | string; - msg: 'success' | string; - ts: string; - /** Connection ID (trade operation responses, May 2026+) */ - connId?: string; + +================ +File: src/types/response/v2/instloan.ts +================ +export interface InstLoanProductInfoV2 { + productId: string; + leverage: string; + transferLine: string; + spotBuyLine: string; + liquidationLine: string; + stopLiquidationLine: string; } ⋮---- -/** Auto-generated */ -⋮---- -/** Connection ID (trade operation responses, May 2026+) */ -⋮---- -/** - * List of operations supported for this WsKey (connection) - */ -export interface WsAPIWsKeyTopicMap { - [WS_KEY_MAP.v3Private]: WSAPIOperation; +export interface InstLoanSymbolsV2 { + productId: string; + spotSymbols: string[]; } ⋮---- -/** - * Request parameters expected per operation - */ -export interface WsAPITopicRequestParamMap { - // https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters - 'place-order': WSAPIPlaceOrderRequestV3; - // https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel - 'batch-place': WSAPIPlaceOrderRequestV3[]; - // https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel - 'cancel-order': CancelOrderRequestV3; - // https://www.bitget.com/api-doc/uta/websocket/private/Batch-Cancel-Order-Channel - 'batch-cancel': CancelOrderRequestV3[]; +export interface InstLoanRepaidHistoryItemV2 { + repayOrderId: string; + businessType: string; + repayType: string; + repaidTime: string; + coin: string; + repaidAmount: string; + repaidInterest: string; } ⋮---- -// https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters -⋮---- -// https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel -⋮---- -// https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel -⋮---- -// https://www.bitget.com/api-doc/uta/websocket/private/Batch-Cancel-Order-Channel -⋮---- -/** - * Response structure expected for each operation - */ -export interface WsAPIOperationResponseMap { - // https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters - 'place-order': WSAPIResponse<[WSAPIPlaceOrderResponseV3], 'place-order'>; - // https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel - 'batch-place': WSAPIResponse; - // https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel - 'cancel-order': WSAPIResponse<[CancelOrderResponseV3], 'cancel-order'>; - // https://www.bitget.com/api-doc/uta/websocket/private/Batch-Cancel-Order-Channel - 'batch-cancel': WSAPIResponse; +export interface InstLoanOrderV2 { + orderId: string; + orderProductId: string; + uid: string; + loanTime: string; + loanCoin: string; + loanAmount: string; + unpaidAmount: string; + unpaidInterest: string; + repaidAmount: string; + repaidInterest: string; + status: string; } ⋮---- -// https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters -⋮---- -// https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel -⋮---- -// https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel +export interface InstLoanCoinInfoV2 { + coin: string; + convertRatio: string; + maxConvertValue: string; +} ⋮---- -// https://www.bitget.com/api-doc/uta/websocket/private/Batch-Cancel-Order-Channel +export interface InstLoanLTVConvertV2 { + ltv: string; + subAccountUids: string[]; + unpaidUsdtAmount: string; + usdtBalance: string; + unpaidInfo: { + coin: string; + unpaidQty: string; + unpaidInterest: string; + }[]; + balanceInfo: { + coin: string; + price: string; + amount: string; + convertedUsdtAmount: string; + }[]; +} ================ -File: src/types/shared.ts +File: src/types/response/v3/earn.ts ================ -import { REST_CLIENT_TYPE_ENUM } from '../util/requestUtils.js'; +/** + * + * + * Earn | On-Chain Elite (UTA) + * + * + */ ⋮---- -export type numberInString = string; +export interface EarnEliteSubscriptionCoinV3 { + subscriptionCoin: string; + precision: string; + feeRate: string; + exchangeRate: string; + remainQuota?: string; + minAmount?: string; +} ⋮---- -export type OrderSide = 'Buy' | 'Sell'; +export interface EarnEliteProductV3 { + productId: string; + coin: string; + minApr: string; + maxApr: string; + subscriptionCoinList: EarnEliteSubscriptionCoinV3[]; + sellOut: 'YES' | 'NO' | string; +} ⋮---- -/** - * @deprecated use SpotKlineInterval or FuturesKlineInterval, depending on which API group you're using - */ -export type KlineInterval = - | '1min' - | '5min' - | '15min' - | '30min' - | '1h' - | '4h' - | '6h' - | '12h' - | '1M' - | '1W' - | '1week' - | '6Hutc' - | '12Hutc' - | '1Dutc' - | '3Dutc' - | '1Wutc' - | '1Mutc'; -⋮---- -export type RestClientType = - (typeof REST_CLIENT_TYPE_ENUM)[keyof typeof REST_CLIENT_TYPE_ENUM]; -⋮---- -export interface APIResponse { - code: string; - requestTime: number; - msg: 'success' | string; - data: T; +export interface EarnEliteAssetProjectV3 { + projectName: string; } - -================ -File: webpack/webpack.config.cjs -================ -function generateConfig(name) -⋮---- -// Add '.ts' and '.tsx' as resolvable extensions. -⋮---- -// Node.js core modules not available in browsers -// The REST client's https.Agent (for keepAlive) is Node.js-only and won't work in browsers -⋮---- -// Code is already transpiled from TypeScript, no additional loaders needed - -================ -File: .gitignore -================ -!.gitkeep -.DS_STORE -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json -pids -*.pid -*.seed -*.pid.lock -node_modules/ -.npm -.eslintcache -.node_repl_history -*.tgz -.yarn-integrity -.env -.env.test -.cache -lib -bundleReport.html -.history/ -tiagoSpot.ts -restClientRegex.ts -localtest.sh -privaterepotracker -testfile.ts -dist -repomix.sh -coverage - -================ -File: examples/auth/fasterHmacSign.ts -================ -import { createHmac } from 'crypto'; -⋮---- -import { - DefaultLogger, - RestClientV3, - WebsocketClientV3, -} from '../../src/index.js'; -⋮---- -// or -// import { createHmac } from 'crypto'; -// import { DefaultLogger, RestClientV3, WebsocketClientV3 } from 'bitget-api'; ⋮---- -/** - * Injecting a custom signMessage function. - * - * As of version 3.0.0 of the bitget-api Node.js/TypeScript/JavaScript - * SDK for Bitget, the SDK uses the Web Crypto API for signing requests. - * While it is compatible with Node and Browser environments, it is - * slightly slower than using Node's native crypto module (only - * available in backend Node environments). - * - * For latency sensitive users, you can inject the previous node crypto sign - * method (or your own even faster implementation), if this change affects you. - * - * This example demonstrates how to inject a custom sign function, to achieve - * the same peformance as seen before the Web Crypto API was introduced. - * - * For context on standard usage, the "signMessage" function is used: - * - During every single API call - * - After opening a new private WebSocket connection - */ +export interface EarnEliteAssetV3 { + productId: string; + productCoin: string; + holdingAmount: string; + usdtHoldingAmount: string; + exchangeRate: string; + apr: string; + minApy?: string; + maxApy?: string; + subscriptionCoin: string; + exchangeAmount: string; + projectList?: EarnEliteAssetProjectV3[]; + unsettledBGPoints: string; + interestCoin: string; + totalProfit: string; +} ⋮---- -/** - * Set this to true to enable demo trading: - */ +export interface EarnEliteAssetsV3 { + resultList: EarnEliteAssetV3[]; +} ⋮---- -/** - * Overkill in almost every case, but if you need any optimisation available, - * you can inject a faster sign mechanism such as node's native createHmac: - */ +export interface EarnEliteRecordV3 { + recordId: string; + productId: string; + coin: string; + status: string; + exchangeRate: string; + receivedCoin: string; + receivedAmount: string; + investAmount: string; + feeRate: string; + redeemType?: string | string[]; + receivingAccount: string; + actualReceivingAccount: string; + paymentAccount?: string[]; + settlePoints: string; + fee: string; +} ⋮---- -// Optional, uncomment the "trace" override to log a lot more info about what the WS client is doing +export interface EarnEliteRecordsV3 { + recordList: EarnEliteRecordV3[]; + endId: string; +} ⋮---- -// trace: (...params) => console.log('trace', ...params), +export interface EarnEliteSubscribeInfoV3 { + productSubId: string; + minAmount: string; + remainQuota: string; + exchangeRate: string; + productCoin: string; + interestTime: string; + settleTime: string; + precision: string; + feeRate: string; + subscriptionCoinList?: EarnEliteSubscriptionCoinV3[]; +} ⋮---- -/** - * Set this to true to enable demo trading for the private account data WS - * Topics: order,execution,position,wallet,greeks - */ +export interface EarnEliteSubscribeResultV3 { + orderId: string; +} ⋮---- -/** - * Overkill in almost every case, but if you need any optimisation available, - * you can inject a faster sign mechanism such as node's native createHmac: - */ +export interface EarnEliteSubscribeStatusV3 { + result: 'settled' | 'pending' | 'rejected' | string; +} ⋮---- -function setWsClientEventListeners( - websocketClient: WebsocketClientV3, - accountRef: string, -): Promise +export interface EarnEliteRedeemInfoBgusdReceiveCoinV3 { + bgusdReceiveCoin: string; + bgusdExchangeRate: string; +} ⋮---- -// console.log('raw message received ', JSON.stringify(data, null, 2)); +export interface EarnEliteRedeemModeV3 { + redeemFeeRate: string; + remainQuota: string; + redeemType: 'fast' | 'standard' | string; + redeemScale: string; + redeemDelayDate: string; + minRedeemAmount: string; + redeemTime: string; +} ⋮---- -// Simple promise to ensure we're subscribed before trying anything else +export interface EarnEliteRedeemInfoV3 { + productId: string; + productSubId: string; + productCoin: string; + subscriptionCoin: string; + profitCoin: string; + exchangeRate: string; + totalUnPayInterestAmount: string; + preSettleApr: string; + receivedCoin: string; + unsettledPoints: string; + bgusdReceiveCoinList: EarnEliteRedeemInfoBgusdReceiveCoinV3[]; + redeemModeList: EarnEliteRedeemModeV3[]; +} ⋮---- -// Start trading +export interface RedeemEarnEliteResultV3 { + orderId: string; +} ================ -File: examples/V2 - Classic/Rest/rest-trade-futures.ts +File: src/types/response/v3/p2p.ts ================ -import { - FuturesPlaceOrderRequestV2, - RestClientV2, - WebsocketClientV2, -} from '../../../src/index.js'; +import type { + P2pAdStatusV3, + P2pMarketTypeV3, + P2pOrderStatusV3, + P2pPriceTypeV3, + P2pSideV3, +} from '../../request/v3/p2p.js'; ⋮---- -// or -// import { FuturesPlaceOrderRequestV2, RestClientV2, WebsocketClientV2 } from '../src'; +export interface P2pPayMethodInfoFieldV3 { + name: string; + type: 'file' | 'number' | 'txt'; + value: string; +} ⋮---- -// read from environmental variables +export interface P2pPayMethodV3 { + payMethodId: string; + payMethodName: string; + payMethodUserName: string; + userPayMethodId: string; + payMethodInfo: P2pPayMethodInfoFieldV3[]; +} ⋮---- -// 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-futures.ts -⋮---- -// note the single quotes, preventing special characters such as $ from being incorrectly passed -⋮---- -// apiKey: 'apiKeyHere', -// apiSecret: 'apiSecretHere', -// apiPass: 'apiPassHere', -⋮---- -function logWSEvent(type: string, data: any) -⋮---- -// simple sleep function -function promiseSleep(milliseconds: number) -⋮---- -/** - * This is a simple script wrapped in a immediately invoked function expression (to execute the below workflow immediately). - * - * It is designed to: - * - open a private websocket channel to log account events - * - check for any available USDT balance in the futures account - * - immediately open a minimum sized long position on BTCUSDT - * - check active positions - * - immediately send closing orders for any active futures positions - * - check positions again - * - */ +export interface P2pTokenDetailV3 { + token: string; + precision: string; +} ⋮---- -// Add event listeners to log websocket events on account +export interface P2pFiatPayMethodV3 { + payMethodName: string; + iconUrl: string; + payMethodId: string; +} ⋮---- -// futures private -// : account updates +export interface P2pWithdrawalLimitV3 { + withdrawLimitKey: string; + withdrawLimitValue: string; +} ⋮---- -// : position updates +export interface P2pFiatDetailV3 { + fiat: string; + precision: string; + floatRateMin: string; + floatRateMax: string; + fixedRateMin: string; + fixedRateMax: string; + adMinLimit: string; + adMaxLimit: string; + payMethods: P2pFiatPayMethodV3; + withdrawalLimit: P2pWithdrawalLimitV3; + payTimeLimit: number[]; +} ⋮---- -// : order updates +export interface P2pCurrenciesV3 { + tokenDetailList: P2pTokenDetailV3[]; + fiatDetailList: P2pFiatDetailV3[]; +} ⋮---- -// wait briefly for ws to be ready (could also use the response or authenticated events, to make sure topics are subscribed to before starting) +export interface P2pUserEquityDetailV3 { + maxAdvSellNum: string; + maxAdvSellLimit: string; + maxAdvBuyNum: string; + maxAdvBuyLimit: string; + totalMaxPendingOrder: string; + advMaxPendingOrder: string; +} ⋮---- -// const balances = allBalances.filter((bal) => Number(bal.available) != 0); +export interface P2pUserInfoV3 { + uid: string; + nickName: string; + accountLevel: 'starter' | 'advanced' | 'master'; + completedOrderNum: string; + positiveRate: string; + completedOrderNum30D: string; + completedRate30D: string; + avgPayTime30D: string; + avgReleaseTime30D: string; + equityDetail: P2pUserEquityDetailV3; + registerTime: string; +} ⋮---- -// Loop through any active positions and send a closing market order on each position - -================ -File: examples/V2 - Classic/Rest/rest-trade-spot.ts -================ -import { - RestClientV2, - SpotOrderRequestV2, - WebsocketClientV2, -} from '../../../src/index.js'; +export interface P2pBalanceV3 { + token: string; + totalBalance: string; + frozenBalance: string; + availableBalance: string; +} ⋮---- -// import { RestClientV2, WebsocketClient } from '../src/index'; +export interface P2pExchangeRateV3 { + rate: string; +} ⋮---- -// read from environmental variables +export interface P2pFeeSimulateV3 { + feeToken: string; + feeAmount: string; + taxToken: string; + taxAmount: string; +} ⋮---- -// 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 +export interface P2pAdLimitV3 { + buyMinTokenAmount: string; + buyMaxTokenAmount: string; + sellMinTokenAmount: string; + sellMaxTokenAmount: string; +} ⋮---- -// note the single quotes, preventing special characters such as $ from being incorrectly passed +export interface P2pCreateAdResponseV3 { + advId: string; +} ⋮---- -// apiKey: 'apiKeyHere', -// apiSecret: 'apiSecretHere', -// apiPass: 'apiPassHere', +export interface P2pAdPayMethodRefV3 { + payMethodId: string; + userPayMethodId?: string; +} ⋮---- -function logWSEvent(type: string, data: any) +export interface P2pAdInfoV3 { + advId: string; + side: P2pSideV3; + priceType: P2pPriceTypeV3; + token: string; + fiat: string; + price: string; + amount: string; + minAmount: string; + maxAmount: string; + payDuration: string; + soldAmount: string; + lastAmount: string; + premium: string; + turnover: string; + remark: string; + tradeTerm: string; + payMethodIds: P2pAdPayMethodRefV3[]; + tokenPrecision: string; + fiatPrecision: string; + market: P2pMarketTypeV3; + avgTime: string; + createdTime: string; + updatedTime: string; +} ⋮---- -// simple sleep function -function promiseSleep(milliseconds: number) +export interface P2pPublicAdListItemV3 { + advId: string; + merchantId: string; + merchantName: string; + token: string; + fiat: string; + side: P2pSideV3; + price: string; + minAmount: string; + maxAmount: string; + quantity: string; + payMethods: { + payMethodId: string; + payMethodName: string; + }[]; + completedOrderNum: string; + completedRate: string; + avgReleaseTime: string; + createdTime: string; +} ⋮---- -/** 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 */ +export interface P2pMyAdListItemV3 { + advId: string; + side: P2pSideV3; + priceType: P2pPriceTypeV3; + token: string; + fiat: string; + price: string; + soldAmount: string; + lastAmount: string; + payMethods: { payMethodId: string }[]; + status: P2pAdStatusV3; + createdTime: string; + updatedTime: string; +} ⋮---- -// Add event listeners to log websocket events on account +export interface P2pCursorListV3 { + items: T[]; + nextId?: string; +} ⋮---- -// Subscribe to private account topics -// spot private -// : account updates +export interface P2pOrderListItemV3 { + orderId: string; + side: P2pSideV3; + token: string; + fiat: string; + price: string; + amount: string; + quantity: string; + fee: string; + counterparty: string; + status: P2pOrderStatusV3; + createdTime: string; + updatedTime: string; +} ⋮---- -// : order updates (note: symbol is required) +export interface P2pOrderPayMethodDetailV3 { + payMethodId: string; + payMethodName: string; + payMethodUserName: string; + postscript: string; + payMethodInfo: P2pPayMethodInfoFieldV3[]; +} ⋮---- -// wait briefly for ws to be ready (could also use the response or authenticated events, to make sure topics are subscribed to before starting) +export interface P2pOrderUserInfoV3 { + nickName: string; + realName: string; +} ⋮---- -// console.log('balance: ', JSON.stringify(balances, null, 2)); +export interface P2pOrderInfoV3 { + orderId: string; + side: P2pSideV3; + token: string; + fiat: string; + price: string; + quantity: string; + amount: string; + status: P2pOrderStatusV3; + advId: string; + remark: string; + orderCancelCountdown: string; + fee: string; + verifyCapital: 'yes' | 'no'; + payMethodDetail?: P2pOrderPayMethodDetailV3; + sellUserInfo: P2pOrderUserInfoV3; + buyUserInfo: P2pOrderUserInfoV3; + createdTime: string; + updatedTime: string; +} ================ -File: examples/V2 - Classic/Websocket/ws-demo-trading.ts +File: src/types/response/v3/stockplus.ts ================ -import { DefaultLogger, WebsocketClientV2 } from '../../../src/index.js'; +/** + * + * + * Stock+ (UTA) + * + * + */ ⋮---- -// or -// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; -⋮---- -// 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/ws-private.ts -⋮---- -// restOptions: { -// optionally provide rest options, e.g. to pass through a proxy -// }, -⋮---- -// Set demoTrading to true, to route all connections to the demo trading wss URLs: -⋮---- -// If using private topics, make sure to include API keys -⋮---- -// console.log('WS raw message received ', JSON.stringify(data, null, 2)); -⋮---- -/** - * Public events - */ - -================ -File: examples/V2 - Classic/Websocket/ws-private.ts -================ -import { DefaultLogger, WebsocketClientV2 } from '../../../src/index.js'; -⋮---- -// or -// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; -⋮---- -// 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/ws-private.ts -⋮---- -// note the single quotes, preventing special characters such as $ from being incorrectly passed +export interface StockPlusOptionQuoteItemV3 { + symbol: string; + lastDone: string; + prevClose: string; + open: string; + high: string; + low: string; + timestamp: string; + volume: string; + turnover: string; + tradeStatus: string; + impliedVolatility: string; + openInterest: string; + expiryDate: string; + strikePrice: string; + contractMultipier: string; + contractType: string; + contractSize: string; + direction: string; + historicalVolatility: string; + underlyingSymbol: string; +} ⋮---- -// restOptions: { -// optionally provide rest options, e.g. to pass through a proxy -// }, +export interface StockPlusOptionQuoteV3 { + secuQuote: StockPlusOptionQuoteItemV3[]; +} ⋮---- -// console.log('WS raw message received ', JSON.stringify(data, null, 2)); +export interface StockPlusOptionStrikePriceInfoV3 { + price: string; + callSymbol: string; + putSymbol: string; + standard: boolean; +} ⋮---- -// auth happens async after the ws connection opens +export interface StockPlusOptionChainInfoV3 { + strikePriceInfo: StockPlusOptionStrikePriceInfoV3[]; +} ⋮---- -// wsClient.subscribePublicSpotTickers(['BTCUSDT', 'LTCUSDT']); +export interface StockPlusOptionExpiryDateV3 { + expiryDate: string[]; +} ⋮---- -/** - * Private account updates - */ +export interface StockPlusOptionVolumeV3 { + c: string; + p: string; +} ⋮---- -// spot private -// : account updates +export interface StockPlusStaticInfoItemV3 { + symbol: string; + nameCn: string; + nameEn: string; + exchange: string; + currency: string; + lotSize: number | string; + totalShares: string | number; + circulatingShares: string | number; + eps: string | number; + epsTtm: string | number; + bps: string | number; + dividendYield: string | number; + stockDerivatives: string[]; + board: string; +} ⋮---- -// : order updates (note: symbol is required) -// wsClient.subscribeTopic('SPOT', 'orders', 'BTCUSDT'); +export interface StockPlusStaticInfoV3 { + list: StockPlusStaticInfoItemV3[]; +} ⋮---- -// futures private -// : account updates +export interface StockPlusSessionQuoteV3 { + lastDone: string | number; + timestamp: string; + volume: string | number; + turnover: string | number; + high: string | number; + low: string | number; + prevClose: string | number; +} ⋮---- -// : position updates -// wsClient.subscribeTopic('USDT-FUTURES', 'positions'); +export interface StockPlusQuoteItemV3 { + symbol: string; + lastDone: string | number; + prevClose: string | number; + open: string | number; + high: string | number; + low: string | number; + timestamp: string; + volume: string | number; + turnover: string | number; + tradeStatus: string; + preMarketQuote?: StockPlusSessionQuoteV3 | null; + postMarketQuote?: StockPlusSessionQuoteV3 | null; + overnightQuote?: StockPlusSessionQuoteV3 | null; +} ⋮---- -// : order updates -// wsClient.subscribeTopic('USDT-FUTURES', 'orders'); +export interface StockPlusQuoteV3 { + list: StockPlusQuoteItemV3[]; +} ⋮---- -// : plan order updates -// wsClient.subscribeTopic('USDT-FUTURES', 'orders-algo'); +export interface StockPlusTradeDetailItemV3 { + price: string | number; + volume: string | number; + timestamp: string; + tradeType: string; + direction: string; + tradeSession: string; +} ⋮---- -// wsClient -// .getWsStore() -// .getKeys() -// .forEach((wsKey) => { -// const state = wsClient.getWsStore().get(wsKey); -// console.log(`${wsKey} state: `, state.subscribedTopics.values()); -// }); +export type StockPlusTradeDetailV3 = StockPlusTradeDetailItemV3[]; ⋮---- -// setTimeout(() => { -// wsClient.unsubscribeTopic('USDT-FUTURES', 'account'); -// }, 1000 * 2); +export interface StockPlusIntradayItemV3 { + price: string | number; + timestamp: string; + volume: string | number; + turnover: string | number; + avgPrice: string | number; +} ⋮---- -// setTimeout(() => { -// wsClient -// .getWsStore() -// .getKeys() -// .forEach((wsKey) => { -// const state = wsClient.getWsStore().get(wsKey); -// console.log(`${wsKey} state: `, state.subscribedTopics.values()); -// }); -// }, 1000 * 5); - -================ -File: examples/V2 - Classic/Websocket/ws-public.ts -================ -import { - DefaultLogger, - WebsocketClientV2, - WS_KEY_MAP, -} from '../../../src/index.js'; +export interface StockPlusIntradayV3 { + list: StockPlusIntradayItemV3[]; +} ⋮---- -// or -// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; +export interface StockPlusCandlestickItemV3 { + close: string; + open: string; + low: string; + high: string; + volume: string; + turnover: string; + timestamp: string; + tradeSession: string; +} ⋮---- -// restOptions: { -// optionally provide rest options, e.g. to pass through a proxy -// }, +export interface StockPlusCandlestickV3 { + list: StockPlusCandlestickItemV3[]; +} ⋮---- -// console.log('WS raw message received ', JSON.stringify(data, null, 2)); +export type StockPlusHistoryCandlestickV3 = StockPlusCandlestickV3; ⋮---- -/** - * Public events - */ +export interface StockPlusDepthLevelV3 { + position: number; + price: string; + volume: string; + orderNum: number; +} ⋮---- -// Spot public +export interface StockPlusDepthV3 { + asks: StockPlusDepthLevelV3[]; + bids: StockPlusDepthLevelV3[]; +} ⋮---- -// tickers +export interface StockPlusPlaceOrderResponseV3 { + orderId: string; + clientOid: string; + symbol: string; +} ⋮---- -// candles -// wsClient.subscribeTopic('SPOT', 'candle1m', symbol); +export type StockPlusCancelOrderResponseV3 = StockPlusPlaceOrderResponseV3; +export type StockPlusModifyOrderResponseV3 = StockPlusPlaceOrderResponseV3; ⋮---- -// orderbook updates -// wsClient.subscribeTopic('SPOT', 'books', symbol); +export interface StockPlusOrderV3 { + orderId: string; + status: string; + stockName: string; + quantity: string | number; + executedQuantity: string | number; + price: string | number | null; + executedPrice: string | number | null; + submittedAt: string; + side: string; + symbol: string; + orderType: string; + lastDone: string | number | null; + triggerPrice: string | number | null; + msg: string; + tag: string; + timeInForce: string; + expireDate: string | null; + updatedAt: string | null; + triggerAt: string | null; + trailingAmount: string | number | null; + trailingPercent: string | number | null; + limitOffset: string | number | null; + triggerStatus: string | null; + currency: string; + outsideRth: string; + remark?: string; + limitDepthLevel: number | null; + triggerCount: number | null; + monitorPrice: string | null; +} ⋮---- -// trades -// wsClient.subscribeTopic('SPOT', 'trade', symbol); +export interface StockPlusOrdersV3 { + orders: StockPlusOrderV3[]; +} ⋮---- -// Futures public +export interface StockPlusHistoryOrdersV3 { + hasMore: boolean; + orders: StockPlusOrderV3[]; +} ⋮---- -// tickers -// wsClient.subscribeTopic('USDT-FUTURES', 'ticker', symbol); +export interface StockPlusOrderHistoryItemV3 { + price: string | number; + quantity: string | number; + status: string; + msg: string; + time: string; +} ⋮---- -// candles -// wsClient.subscribeTopic('USDT-FUTURES', 'candle1m', symbol); +export interface StockPlusChargeFeeItemV3 { + code: string; + name: string; + amount: number | string; + currency: string; +} ⋮---- -// orderbook updates -// wsClient.subscribeTopic('USDT-FUTURES', 'books', symbol); +export interface StockPlusChargeCategoryV3 { + code: string; + name: string; + fees: StockPlusChargeFeeItemV3[]; +} ⋮---- -// trades -// wsClient.subscribeTopic('USDT-FUTURES', 'trade', symbol); +export interface StockPlusChargeDetailV3 { + totalAmount: number | string; + currency: string; + items: StockPlusChargeCategoryV3[]; +} ⋮---- -// Topics are tracked per websocket type -// Get a list of subscribed topics (e.g. all public topics) (after a 5 second delay) - -================ -File: examples/V3 - UTA/Rest/rest-trade-UTA-futures.ts -================ -/* eslint-disable @typescript-eslint/no-unused-vars */ -import { - PlaceOrderRequestV3, - RestClientV3, - WebsocketClientV3, -} from '../../../src/index.js'; +export interface StockPlusOrderDetailV3 extends StockPlusOrderV3 { + freeStatus?: string; + freeAmount?: string | null; + freeCurrency?: string | null; + deductionsStatus?: string; + deductionsAmount?: string | null; + deductionsCurrency?: string | null; + platformDeductedStatus?: string; + platformDeductedAmount?: string | null; + platformDeductedCurrency?: string | null; + history?: StockPlusOrderHistoryItemV3[]; + chargeDetail?: StockPlusChargeDetailV3; +} ⋮---- -// or -// import { PlaceOrderRequestV3, RestClientV3, WebsocketClientV3 } from '../src'; +export interface StockPlusExecutionV3 { + orderId: string; + tradeId: string; + symbol: string; + tradeDoneAt: string; + quantity: number | string; + price: number | string; +} ⋮---- -// read from environmental variables +export interface StockPlusTodayExecutionsV3 { + trades: StockPlusExecutionV3[]; +} ⋮---- -// 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/V3/rest-trade-futures.ts +export interface StockPlusHistoryExecutionsV3 { + hasMore: boolean; + trades: StockPlusExecutionV3[]; +} ⋮---- -// note the single quotes, preventing special characters such as $ from being incorrectly passed +export interface StockPlusCashInfoV3 { + withdrawCash: number | string; + availableCash: number | string; + frozenCash: number | string; + settlingCash: number | string; + currency: string; +} ⋮---- -// apiKey: 'apiKeyHere', -// apiSecret: 'apiSecretHere', -// apiPass: 'apiPassHere', +export interface StockPlusFrozenTransactionFeeV3 { + currency?: string; + amount?: number | string; + [key: string]: unknown; +} ⋮---- -function logWSEvent(type: string, data: any) +export interface StockPlusAccountItemV3 { + totalCash: number | string; + maxFinanceAmount: number | string; + remainingFinanceAmount: number | string; + riskLevel: number | string; + marginCall: number | string; + netAssets: number | string; + initMargin: number | string; + maintenanceMargin: number | string; + currency: string; + buyPower: number | string; + cashInfos: StockPlusCashInfoV3[]; + frozenTransactionFees: StockPlusFrozenTransactionFeeV3[]; +} ⋮---- -// simple sleep function -function promiseSleep(milliseconds: number) +export interface StockPlusAccountV3 { + list: StockPlusAccountItemV3[]; +} ⋮---- -/** - * This is a simple script wrapped in a immediately invoked function expression (to execute the below workflow immediately). - * - * It is designed to: - * - open a private websocket channel to log account events - * - check for any available USDT balance in the account - * - immediately open a minimum sized long position on BTCUSDT - * - check active positions - * - immediately send closing orders for any active futures positions - * - check positions again - * - */ +export interface StockPlusCashFlowItemV3 { + transactionFlowName: string; + direction: string; + businessType: string; + balance: number | string; + currency: string; + businessTime: string; + symbol: string | null; + description: string; +} ⋮---- -// Add event listeners to log websocket events on account +export interface StockPlusCashFlowV3 { + list: StockPlusCashFlowItemV3[]; +} ⋮---- -// Subscribe to private topics for UTA account +export interface StockPlusPositionItemV3 { + symbol: string; + symbolName: string; + quantity: number | string; + availableQuantity: number | string; + currency: string; + costPrice: number | string; + market: string; + initQuantity: number | string; +} ⋮---- -// Subscribe to position updates +export interface StockPlusPositionChannelV3 { + accountChannel: string; + positions: StockPlusPositionItemV3[]; +} ⋮---- -// Subscribe to order updates +export interface StockPlusStockPositionV3 { + channels: StockPlusPositionChannelV3[]; +} ⋮---- -// wait briefly for ws to be ready (could also use the response or authenticated events, to make sure topics are subscribed to before starting) +export interface StockPlusTransferResponseV3 { + transferId: string; +} ⋮---- -// Loop through any active positions and send a closing market order on each position +export interface StockPlusTransferRecordsV3 { + transferId: string; + coin: string; + amount: string; + direction: string; + cursor: string; +} ================ -File: examples/V3 - UTA/Rest/rest-trade-UTA-spot.ts +File: src/types/response/v3/strategy.ts ================ -/* eslint-disable @typescript-eslint/no-unused-vars */ -import { - PlaceOrderRequestV3, - RestClientV3, - WebsocketClientV3, -} from '../../../src/index.js'; +import type { + StrategyOrderStatusV3, + StrategyTriggerByV3, + StrategyTriggerOrderTypeV3, +} from '../../request/v3/strategy.js'; ⋮---- -// import { RestClientV3, WebsocketClientV3 } from '../src/index'; +export interface PlaceStrategyOrderResponseV3 { + orderId: string; + clientOid: string; +} ⋮---- -// read from environmental variables +export interface ModifyStrategyOrderResponseV3 { + orderId: string; + clientOid: string; +} ⋮---- -// 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/V3/rest-trade-spot.ts +export interface StrategyOrderV3 { + orderId: string; + clientOid: string; + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol: string; + qty: string; + posSide: 'long' | 'short'; + status: StrategyOrderStatusV3; + triggerType?: 'takeProfit' | 'stopLoss'; + tpTriggerBy?: StrategyTriggerByV3; + slTriggerBy?: StrategyTriggerByV3; + takeProfit?: string; + stopLoss?: string; + tpOrderType?: StrategyTriggerOrderTypeV3; + slOrderType?: StrategyTriggerOrderTypeV3; + tpLimitPrice?: string; + slLimitPrice?: string; + triggerBy?: StrategyTriggerByV3; + triggerPrice?: string; + triggerOrderType?: StrategyTriggerOrderTypeV3; + triggerOrderPrice?: string; + createdTime: string; + updatedTime: string; +} + +================ +File: src/types/shared.ts +================ +import { REST_CLIENT_TYPE_ENUM } from '../util/requestUtils.js'; +⋮---- +export type numberInString = string; +⋮---- +export type OrderSide = 'Buy' | 'Sell'; +⋮---- +/** + * @deprecated use SpotKlineInterval or FuturesKlineInterval, depending on which API group you're using + */ +export type KlineInterval = + | '1min' + | '5min' + | '15min' + | '30min' + | '1h' + | '4h' + | '6h' + | '12h' + | '1M' + | '1W' + | '1week' + | '6Hutc' + | '12Hutc' + | '1Dutc' + | '3Dutc' + | '1Wutc' + | '1Mutc'; +⋮---- +export type RestClientType = + (typeof REST_CLIENT_TYPE_ENUM)[keyof typeof REST_CLIENT_TYPE_ENUM]; +⋮---- +export interface APIResponse { + code: string; + requestTime: number; + msg: 'success' | string; + data: T; +} + +================ +File: .nvmrc +================ +v24.18.0 + +================ +File: examples/auth/fasterHmacSign.ts +================ +import { createHmac } from 'crypto'; +⋮---- +import { + DefaultLogger, + RestClientV3, + WebsocketClientV3, +} from '../../src/index.js'; +⋮---- +// or +// import { createHmac } from 'crypto'; +// import { DefaultLogger, RestClientV3, WebsocketClientV3 } from 'bitget-api'; +⋮---- +/** + * Injecting a custom signMessage function. + * + * As of version 3.0.0 of the bitget-api Node.js/TypeScript/JavaScript + * SDK for Bitget, the SDK uses the Web Crypto API for signing requests. + * While it is compatible with Node and Browser environments, it is + * slightly slower than using Node's native crypto module (only + * available in backend Node environments). + * + * For latency sensitive users, you can inject the previous node crypto sign + * method (or your own even faster implementation), if this change affects you. + * + * This example demonstrates how to inject a custom sign function, to achieve + * the same peformance as seen before the Web Crypto API was introduced. + * + * For context on standard usage, the "signMessage" function is used: + * - During every single API call + * - After opening a new private WebSocket connection + */ +⋮---- +/** + * Set this to true to enable demo trading: + */ +⋮---- +/** + * Overkill in almost every case, but if you need any optimisation available, + * you can inject a faster sign mechanism such as node's native createHmac: + */ +⋮---- +// Optional, uncomment the "trace" override to log a lot more info about what the WS client is doing +⋮---- +// trace: (...params) => console.log('trace', ...params), +⋮---- +/** + * Set this to true to enable demo trading for the private account data WS + * Topics: order,execution,position,wallet,greeks + */ +⋮---- +/** + * Overkill in almost every case, but if you need any optimisation available, + * you can inject a faster sign mechanism such as node's native createHmac: + */ +⋮---- +function setWsClientEventListeners( + websocketClient: WebsocketClientV3, + accountRef: string, +): Promise +⋮---- +// console.log('raw message received ', JSON.stringify(data, null, 2)); +⋮---- +// Simple promise to ensure we're subscribed before trying anything else +⋮---- +// Start trading + +================ +File: examples/V2 - Classic/Rest/rest-trade-futures.ts +================ +import { + FuturesPlaceOrderRequestV2, + RestClientV2, + WebsocketClientV2, +} from '../../../src/index.js'; +⋮---- +// or +// import { FuturesPlaceOrderRequestV2, RestClientV2, WebsocketClientV2 } from '../src'; +⋮---- +// read from environmental variables +⋮---- +// 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-futures.ts ⋮---- // note the single quotes, preventing special characters such as $ from being incorrectly passed ⋮---- @@ -6084,74 +5717,369 @@ function logWSEvent(type: string, data: any) // simple sleep function function promiseSleep(milliseconds: number) ⋮---- -/** 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 */ +/** + * This is a simple script wrapped in a immediately invoked function expression (to execute the below workflow immediately). + * + * It is designed to: + * - open a private websocket channel to log account events + * - check for any available USDT balance in the futures account + * - immediately open a minimum sized long position on BTCUSDT + * - check active positions + * - immediately send closing orders for any active futures positions + * - check positions again + * + */ ⋮---- // Add event listeners to log websocket events on account ⋮---- -// Subscribe to private account topics -// Account updates for UTA (unified trading account) +// futures private +// : account updates ⋮---- -// Order updates for spot +// : position updates +⋮---- +// : order updates ⋮---- // wait briefly for ws to be ready (could also use the response or authenticated events, to make sure topics are subscribed to before starting) +⋮---- +// const balances = allBalances.filter((bal) => Number(bal.available) != 0); +⋮---- +// Loop through any active positions and send a closing market order on each position ================ -File: examples/V3 - UTA/Websocket/ws-private.ts +File: examples/V2 - Classic/Rest/rest-trade-spot.ts ================ import { - DefaultLogger, - WebsocketClientV3, - WS_KEY_MAP, + RestClientV2, + SpotOrderRequestV2, + WebsocketClientV2, } from '../../../src/index.js'; ⋮---- -// or -// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; +// import { RestClientV2, WebsocketClient } from '../src/index'; +⋮---- +// read from environmental variables ⋮---- // 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/ws-private.ts +// 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 ⋮---- -// console.log('WS raw message received ', JSON.stringify(data, null, 2)); +// note the single quotes, preventing special characters such as $ from being incorrectly passed ⋮---- -// You can subscribe to one topic at a time +// apiKey: 'apiKeyHere', +// apiSecret: 'apiSecretHere', +// apiPass: 'apiPassHere', ⋮---- -instType: 'UTA', // Note: all account events go on the UTA instType +function logWSEvent(type: string, data: any) ⋮---- -WS_KEY_MAP.v3Private, // This parameter points to private or public +// simple sleep function +function promiseSleep(milliseconds: number) ⋮---- -// Note: all account events go on the UTA instType +/** 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 */ ⋮---- -// Or multiple at once: +// Add event listeners to log websocket events on account ⋮---- -// Topics are tracked per websocket type -// The below example will pull a list of subscribed topics on that connection (e.g. all private topics), after a 5 second delay: +// Subscribe to private account topics +// spot private +// : account updates +⋮---- +// : order updates (note: symbol is required) +⋮---- +// wait briefly for ws to be ready (could also use the response or authenticated events, to make sure topics are subscribed to before starting) +⋮---- +// console.log('balance: ', JSON.stringify(balances, null, 2)); ================ -File: examples/V3 - UTA/Websocket/ws-public.ts +File: examples/V2 - Classic/Websocket/ws-demo-trading.ts ================ -import { - DefaultLogger, - WebsocketClientV3, - WS_KEY_MAP, -} from '../../../src/index.js'; +import { DefaultLogger, WebsocketClientV2 } from '../../../src/index.js'; ⋮---- // or // import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; ⋮---- +// 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/ws-private.ts +⋮---- +// restOptions: { +// optionally provide rest options, e.g. to pass through a proxy +// }, +⋮---- +// Set demoTrading to true, to route all connections to the demo trading wss URLs: +⋮---- +// If using private topics, make sure to include API keys +⋮---- // console.log('WS raw message received ', JSON.stringify(data, null, 2)); ⋮---- /** * Public events */ + +================ +File: examples/V2 - Classic/Websocket/ws-private.ts +================ +import { DefaultLogger, WebsocketClientV2 } from '../../../src/index.js'; ⋮---- -// You can subscribe to one topic at a time +// or +// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; ⋮---- -WS_KEY_MAP.v3Public, // This parameter points to private or public +// 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/ws-private.ts ⋮---- -// Or multiple at once: +// note the single quotes, preventing special characters such as $ from being incorrectly passed ⋮---- -// Topics are tracked per websocket type -// The below example will pull a list of subscribed topics on that connection (e.g. all public topics), after a 5 second delay: - +// restOptions: { +// optionally provide rest options, e.g. to pass through a proxy +// }, +⋮---- +// console.log('WS raw message received ', JSON.stringify(data, null, 2)); +⋮---- +// auth happens async after the ws connection opens +⋮---- +// wsClient.subscribePublicSpotTickers(['BTCUSDT', 'LTCUSDT']); +⋮---- +/** + * Private account updates + */ +⋮---- +// spot private +// : account updates +⋮---- +// : order updates (note: symbol is required) +// wsClient.subscribeTopic('SPOT', 'orders', 'BTCUSDT'); +⋮---- +// futures private +// : account updates +⋮---- +// : position updates +// wsClient.subscribeTopic('USDT-FUTURES', 'positions'); +⋮---- +// : order updates +// wsClient.subscribeTopic('USDT-FUTURES', 'orders'); +⋮---- +// : plan order updates +// wsClient.subscribeTopic('USDT-FUTURES', 'orders-algo'); +⋮---- +// wsClient +// .getWsStore() +// .getKeys() +// .forEach((wsKey) => { +// const state = wsClient.getWsStore().get(wsKey); +// console.log(`${wsKey} state: `, state.subscribedTopics.values()); +// }); +⋮---- +// setTimeout(() => { +// wsClient.unsubscribeTopic('USDT-FUTURES', 'account'); +// }, 1000 * 2); +⋮---- +// setTimeout(() => { +// wsClient +// .getWsStore() +// .getKeys() +// .forEach((wsKey) => { +// const state = wsClient.getWsStore().get(wsKey); +// console.log(`${wsKey} state: `, state.subscribedTopics.values()); +// }); +// }, 1000 * 5); + +================ +File: examples/V2 - Classic/Websocket/ws-public.ts +================ +import { + DefaultLogger, + WebsocketClientV2, + WS_KEY_MAP, +} from '../../../src/index.js'; +⋮---- +// or +// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; +⋮---- +// restOptions: { +// optionally provide rest options, e.g. to pass through a proxy +// }, +⋮---- +// console.log('WS raw message received ', JSON.stringify(data, null, 2)); +⋮---- +/** + * Public events + */ +⋮---- +// Spot public +⋮---- +// tickers +⋮---- +// candles +// wsClient.subscribeTopic('SPOT', 'candle1m', symbol); +⋮---- +// orderbook updates +// wsClient.subscribeTopic('SPOT', 'books', symbol); +⋮---- +// trades +// wsClient.subscribeTopic('SPOT', 'trade', symbol); +⋮---- +// Futures public +⋮---- +// tickers +// wsClient.subscribeTopic('USDT-FUTURES', 'ticker', symbol); +⋮---- +// candles +// wsClient.subscribeTopic('USDT-FUTURES', 'candle1m', symbol); +⋮---- +// orderbook updates +// wsClient.subscribeTopic('USDT-FUTURES', 'books', symbol); +⋮---- +// trades +// wsClient.subscribeTopic('USDT-FUTURES', 'trade', symbol); +⋮---- +// Topics are tracked per websocket type +// Get a list of subscribed topics (e.g. all public topics) (after a 5 second delay) + +================ +File: examples/V3 - UTA/Rest/rest-trade-UTA-futures.ts +================ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import { + PlaceOrderRequestV3, + RestClientV3, + WebsocketClientV3, +} from '../../../src/index.js'; +⋮---- +// or +// import { PlaceOrderRequestV3, RestClientV3, WebsocketClientV3 } from '../src'; +⋮---- +// read from environmental variables +⋮---- +// 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/V3/rest-trade-futures.ts +⋮---- +// note the single quotes, preventing special characters such as $ from being incorrectly passed +⋮---- +// apiKey: 'apiKeyHere', +// apiSecret: 'apiSecretHere', +// apiPass: 'apiPassHere', +⋮---- +function logWSEvent(type: string, data: any) +⋮---- +// simple sleep function +function promiseSleep(milliseconds: number) +⋮---- +/** + * This is a simple script wrapped in a immediately invoked function expression (to execute the below workflow immediately). + * + * It is designed to: + * - open a private websocket channel to log account events + * - check for any available USDT balance in the account + * - immediately open a minimum sized long position on BTCUSDT + * - check active positions + * - immediately send closing orders for any active futures positions + * - check positions again + * + */ +⋮---- +// Add event listeners to log websocket events on account +⋮---- +// Subscribe to private topics for UTA account +⋮---- +// Subscribe to position updates +⋮---- +// Subscribe to order updates +⋮---- +// wait briefly for ws to be ready (could also use the response or authenticated events, to make sure topics are subscribed to before starting) +⋮---- +// Loop through any active positions and send a closing market order on each position + +================ +File: examples/V3 - UTA/Rest/rest-trade-UTA-spot.ts +================ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import { + PlaceOrderRequestV3, + RestClientV3, + WebsocketClientV3, +} from '../../../src/index.js'; +⋮---- +// import { RestClientV3, WebsocketClientV3 } from '../src/index'; +⋮---- +// read from environmental variables +⋮---- +// 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/V3/rest-trade-spot.ts +⋮---- +// note the single quotes, preventing special characters such as $ from being incorrectly passed +⋮---- +// apiKey: 'apiKeyHere', +// apiSecret: 'apiSecretHere', +// apiPass: 'apiPassHere', +⋮---- +function logWSEvent(type: string, data: any) +⋮---- +// simple sleep function +function promiseSleep(milliseconds: number) +⋮---- +/** 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 */ +⋮---- +// Add event listeners to log websocket events on account +⋮---- +// Subscribe to private account topics +// Account updates for UTA (unified trading account) +⋮---- +// Order updates for spot +⋮---- +// wait briefly for ws to be ready (could also use the response or authenticated events, to make sure topics are subscribed to before starting) + +================ +File: examples/V3 - UTA/Websocket/ws-private.ts +================ +import { + DefaultLogger, + WebsocketClientV3, + WS_KEY_MAP, +} from '../../../src/index.js'; +⋮---- +// or +// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; +⋮---- +// 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/ws-private.ts +⋮---- +// console.log('WS raw message received ', JSON.stringify(data, null, 2)); +⋮---- +// You can subscribe to one topic at a time +⋮---- +instType: 'UTA', // Note: all account events go on the UTA instType +⋮---- +WS_KEY_MAP.v3Private, // This parameter points to private or public +⋮---- +// Note: all account events go on the UTA instType +⋮---- +// Or multiple at once: +⋮---- +// Topics are tracked per websocket type +// The below example will pull a list of subscribed topics on that connection (e.g. all private topics), after a 5 second delay: + +================ +File: examples/V3 - UTA/Websocket/ws-public.ts +================ +import { + DefaultLogger, + WebsocketClientV3, + WS_KEY_MAP, +} from '../../../src/index.js'; +⋮---- +// or +// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; +⋮---- +// console.log('WS raw message received ', JSON.stringify(data, null, 2)); +⋮---- +/** + * Public events + */ +⋮---- +// You can subscribe to one topic at a time +⋮---- +WS_KEY_MAP.v3Public, // This parameter points to private or public +⋮---- +// Or multiple at once: +⋮---- +// Topics are tracked per websocket type +// The below example will pull a list of subscribed topics on that connection (e.g. all public topics), after a 5 second delay: + ================ File: examples/V3 - UTA/WS-API/ws-api-trade-raw.ts ================ @@ -6293,4045 +6221,5044 @@ import { */ ================ -File: src/constants/enum.ts -================ -/** Parameter verification exception margin mode == FIXED */ - -================ -File: src/types/request/v3/broker.ts +File: src/types/request/v2/broker.ts ================ -export interface CreateBrokerSubAccountRequestV3 { - subaccountName: string; - label: string; -} +/** + * + * * Broker | Subaccount + * + */ ⋮---- -export interface GetBrokerSubAccountListRequestV3 { +export interface GetSubAccountsRequestV2 { limit?: string; - cursor?: string; - status?: 'normal' | 'freeze'; + idLessThan?: string; + status?: 'normal' | 'freeze' | 'del'; + startTime?: string; + endTime?: string; } ⋮---- -export interface ModifyBrokerSubAccountRequestV3 { +export type SubAccountPermissionV2 = + | 'withdraw' + | 'transfer' + | 'spot_trade' + | 'contract_trade' + | 'read' + | 'deposit' + | 'margin_trade'; +⋮---- +export type SubAccountLanguageV2 = + | 'en_US' + | 'zh_CN' + | 'ja_JP' + | 'vi_VN' + | 'zh_TW' + | 'ru_RU' + | 'es_ES' + | 'tr_TR' + | 'fr_FR' + | 'de_DE' + | 'pt_PT' + | 'th_TH'; +⋮---- +export type SubAccountStatusV2 = 'normal' | 'freeze'; +⋮---- +export interface ModifySubRequestV2 { subUid: string; - status?: 'normal' | 'freeze'; - permList?: string[]; + permList: SubAccountPermissionV2[]; + status: SubAccountStatusV2; + language?: SubAccountLanguageV2; } ⋮---- -export interface BrokerSubWithdrawalRequestV3 { +export interface SubWithdrawalRequestV2 { subUid: string; coin: string; dest: 'on_chain' | 'internal_transfer'; + chain?: string; address: string; amount: string; - chain?: string; tag?: string; clientOid?: string; } ⋮---- -export interface GetBrokerSubDepositAddressRequestV3 { - subUid: string; - coin: string; - chain?: string; -} -⋮---- -export interface GetBrokerAllSubDepositWithdrawalRequestV3 { +export interface SubDepositRecordsRequestV2 { + orderId?: string; + userId?: string; startTime?: string; endTime?: string; limit?: string; - cursor?: string; - status?: 'pending' | 'fail' | 'success'; + idLessThan?: string; } ⋮---- -export interface GetBrokerCommissionRequestV3 { +export interface SubWithdrawalRecordsRequestV2 { + orderId?: string; + userId?: string; startTime?: string; endTime?: string; - pageSize?: string; - pageNo?: string; - bizType?: 'spot' | 'futures'; - subBizType?: - | 'spot_trade' - | 'spot_margin' - | 'usdt_futures' - | 'usdc_futures' - | 'coin_futures'; + limit?: string; + idLessThan?: string; } ⋮---- -export interface CreateBrokerSubApiKeyRequestV3 { +/** + * + * * Broker | Subaccount + * + */ +⋮---- +export interface CreateSubAccountApiKeyRequestV2 { subUid: string; passphrase: string; - label: string; - ipList?: string[]; - permType: 'read_write' | 'read_only'; + label?: string; + ipList: string[]; + permType: string; permList: string[]; } ⋮---- -export interface ModifyBrokerSubApiKeyRequestV3 { +export interface ModifySubAccountApiKeyRequestV2 { subUid: string; - passphrase: string; apiKey: string; label?: string; + passphrase: string; ipList?: string[]; - permType?: 'read_write' | 'read_only'; - permList?: string[]; + permType?: string; + permList: string[]; } ⋮---- -export interface DeleteBrokerSubApiKeyRequestV3 { +export interface DeleteSubAccountApiKeyRequestV2 { subUid: string; apiKey: string; } ⋮---- -export interface GetBrokerSubApiKeyRequestV3 { - subUid: string; -} - -================ -File: src/types/response/v3/broker.ts -================ -export interface CreateBrokerSubAccountResponseV3 { - subUid: string; - subaccountName: string; - subaccountEmail: string; - status: 'normal' | 'freeze'; - permList: string[]; - label: string; - cTime: string; +/** + * + * * Broker | All Sub-accounts Deposit and Withdrawal Records + * + */ +⋮---- +export interface GetAllSubDepositWithdrawalRequestV2 { + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; + type?: 'all' | 'deposit' | 'withdrawal'; } ⋮---- -export interface BrokerSubAccountV3 { - subUid: string; - subaccountName: string; - subaccountEmail: string | null; - status: 'normal' | 'freeze'; - permList: string[]; - label: string; - language: string; - cTime: string; - uTime: string; +/** + * + * * Broker | Subaccounts + * + */ +⋮---- +export interface GetBrokerSubaccountsRequestV2 { + startTime?: string; + endTime?: string; + pageSize?: string; + pageNo?: string; } ⋮---- -export interface GetBrokerSubAccountListResponseV3 { - subList: BrokerSubAccountV3[]; +/** + * + * * Broker | Commissions + * + */ +⋮---- +export interface GetBrokerCommissionsRequestV2 { + startTime?: string; + endTime?: string; + pageSize?: string; + pageNo?: string; + bizType?: 'spot' | 'futures'; + subBizType?: + | 'spot_trade' + | 'spot_margin' + | 'usdt_futures' + | 'usdc_futures' + | 'coin_futures'; } ⋮---- -export interface ModifyBrokerSubAccountResponseV3 { - subUid: string; - subaccountName: string; - status: 'normal' | 'freeze'; - permList: string[]; - label: string; - cTime: string; - uTime: string; +/** + * + * * Broker | Trade Volume + * + */ +⋮---- +export interface GetBrokerTradeVolumeRequestV2 { + startTime?: string; + endTime?: string; + pageSize?: string; + pageNo?: string; } ⋮---- -export interface BrokerSubWithdrawalResponseV3 { - orderId: string; - clientOid: string; +/** + * + * * Broker | Total Commission + * + */ +⋮---- +export interface GetBrokerTotalCommissionRequestV2 { + startTime?: string; + endTime?: string; } ⋮---- -export interface BrokerSubDepositAddressV3 { - subUid: string; - coin: string; - address: string; - chain: string; - tag: string | null; - url: string; - cTime: string; +/** + * + * * Broker | Order Commission + * + */ +⋮---- +export interface GetBrokerOrderCommissionRequestV2 { + startTime?: string; + endTime?: string; + limit?: string; + uid?: string; + orderId?: string; + idLessThan?: string; } ⋮---- -export interface BrokerSubDepositWithdrawalRecordV3 { +/** + * + * * Broker | Rebate Info + * + */ +⋮---- +export interface GetBrokerRebateInfoRequestV2 { uid: string; - txId: string; - type: 'deposit' | 'withdrawal'; - subType: 'onchain' | 'internal' | 'fast'; - coin: string; - amount: string; - status: 'pending' | 'fail' | 'success'; - ts: string; } ⋮---- -export interface GetBrokerAllSubDepositWithdrawalResponseV3 { - list: BrokerSubDepositWithdrawalRecordV3[]; - endId: string; -} +/** + * + * * Broker | Agent (affiliate) customer APIs + * + */ ⋮---- -export interface BrokerCommissionRecordV3 { - uid: string; - coin: string; - symbol: string; - dealtAmount: string; - totalFee: string; - deductedFee: string; - paidFee: string; - markUpFee: string; - totalCommission: string; +export interface GetAgentCustomerCommissionsRequestV2 { + startTime?: string; + endTime?: string; + idLessThan?: string; + limit?: string; + uid?: string; + coin?: string; + symbol?: string; + showSub?: 'yes' | 'no'; } ⋮---- -export interface CreateBrokerSubApiKeyResponseV3 { - subUid: string; - label: string; - apiKey: string; - secretKey: string; - permType: 'read_write' | 'read_only'; - permList: string[]; - ipList: string[] | null; +export interface GetAgentSubCustomerListRequestV2 { + startTime?: string; + endTime?: string; + idLessThan?: string; + limit?: string; + uid?: string; + showSub?: 'yes' | 'no'; } ⋮---- -export interface ModifyBrokerSubApiKeyResponseV3 { - subUid: string; - label: string; - apiKey: string; - permType: 'read_write' | 'read_only'; - permList: string[]; - ipList: string[]; +export interface AgentCustomerTradeVolumeRequestV2 { + startTime?: string; + endTime?: string; + pageNo?: string; + pageSize?: string; + uid?: string; + showSub?: 'yes' | 'no'; } ⋮---- -export interface GetBrokerSubApiKeyResponseV3 { - subUid: string; - label: string; - apiKey: string; - secretKey: string; - permType: 'read_write' | 'read_only'; - permList: string[]; - ipList: string[] | null; +export interface AgentCustomerListRequestV2 { + startTime?: string; + endTime?: string; + pageNo?: string; + pageSize?: string; + uid?: string; + referralCode?: string; + showSub?: 'yes' | 'no'; +} +⋮---- +export interface GetAgentCustomerKycResultRequestV2 { + startTime?: string; + endTime?: string; + idLessThan?: string; + limit?: string; + uid?: string; + showSub?: 'yes' | 'no'; +} +⋮---- +export interface AgentCustomerDepositRequestV2 { + startTime?: string; + endTime?: string; + pageNo?: string; + pageSize?: string; + uid?: string; + showSub?: 'yes' | 'no'; +} +⋮---- +export interface AgentCustomerAssetRequestV2 { + pageNo?: string; + pageSize?: string; + uid?: string; + showSub?: 'yes' | 'no'; +} +⋮---- +export interface GetAgentCommissionDetailRequestV2 { + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; } ================ -File: src/types/response/v3/copytrading.ts +File: src/types/request/v2/common.ts ================ +import { FuturesProductTypeV2, MarginType } from '../shared.js'; +⋮---- /** * - * - * Copy Trading | Futures (UTA) - * + * * Common | Notice * */ ⋮---- -export interface CopyFuturesMarginDetailV3 { - marginCoin: string; - maxLongCount: string; - remainingLongCount: string; - maxShortCount: string; - remainingShortCount: string; +export interface GetAnnouncementsRequestV2 { + annType?: string; + startTime?: string; + endTime?: string; + language: string; } ⋮---- -export interface CopyFuturesTradingPairV3 { - symbol: string; - leverage: string; - marginDetails: CopyFuturesMarginDetailV3[]; -} +/** + * + * * Common | Public + * + */ ⋮---- -export interface CopyFuturesPositionSummaryV3 { - unrealizedPnl: string; - realizedPnl: string; - holdSize: string; - avgPrice: string; +export interface GetTradeRateRequestV2 { symbol: string; - leverage: string; - marginMode: string; - liqPrice: string; - margin: string; - holdSide: string; - roi: string; - markPrice: string; - positionValue: string; + businessType: string; } ⋮---- -export interface CopyFuturesMaxTransferableV3 { - maxTransferable: string; - available: string; +export interface GetAllTradeRatesRequestV2 { + businessType: string; } ⋮---- -export interface CopyFuturesTransferResponseV3 { - transferId: string; -} +/** + * + * * Common | Tax + * + */ ⋮---- -export type CopyFuturesTransferAccountTypeV3 = 'spot' | 'uta' | 'lead'; +export interface GetSpotTransactionsRequestV2 { + coin?: string; + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; +} ⋮---- -export interface CopyFuturesTransferRecordV3 { - transferId: string; - fromType: CopyFuturesTransferAccountTypeV3; - toType: CopyFuturesTransferAccountTypeV3; - amount: string; - coin: string; - status: 'Successful' | 'Failed' | 'Processing'; - createdTime: string; +export interface GetFuturesTransactionsRequestV2 { + productType?: FuturesProductTypeV2; + marginCoin?: string; + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; } ⋮---- -export interface CopyFuturesTransferRecordListV3 { - list: CopyFuturesTransferRecordV3[]; +export interface GetMarginTransactionsRequestV2 { + marginType?: MarginType; + coin?: string; + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; } - -================ -File: src/types/response/v3/loan.ts -================ -export interface LoanTransfersV3 { - coin: string; - transfered: string; - userId: string; +⋮---- +export interface GetP2PTransactionsRequestV2 { + coin?: string; + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; } ⋮---- -export interface LoanSymbolSettingV3 { - symbol: string; - leverage: string; +/** + * + * * Common | P2P + * + */ +⋮---- +export interface GetP2PMerchantsRequestV2 { + online?: 'yes' | 'no'; + idLessThan?: string; + limit?: string; } ⋮---- -export interface LoanSymbolsV3 { - productId: string; - spotSymbols: string[]; - marginLeverage: string; - usdtContractLeverage: string; - coinContractLeverage: string; - usdcContractLeverage: string; - usdtContractSymbols: LoanSymbolSettingV3[]; - coinContractSymbols: LoanSymbolSettingV3[]; - usdcContractSymbols: LoanSymbolSettingV3[]; +export interface GetMerchantP2POrdersRequestV2 { + startTime: string; + endTime?: string; + idLessThan?: string; + limit?: string; + status?: string; + advNo: string; + side?: string; + coin?: string; + language: string; + fiat?: string; + orderNo?: string; } ⋮---- -export interface RepaidHistoryItemV3 { - repayOrderId: string; - businessType: 'normal' | 'liquidation'; - repayType: 'all' | 'part'; - repaidTime: string; +export interface GetMerchantAdvertisementsRequestV2 { + startTime: string; + endTime?: string; + idLessThan?: string; + limit?: string; + status: string; + advNo?: string; + side: string; coin: string; - repayAmount: string; - repayInterest: string; + language?: string; + fiat: string; + orderBy?: string; + payMethodId?: string; + sourceType?: string; } ⋮---- -export interface LoanProductInfoV3 { - productId: string; - leverage: string; - supportUsdtContract: 'YES' | 'NO'; - supportCoinContract: 'YES' | 'NO'; - supportUsdcContract: 'YES' | 'NO'; - transferLine: string; - spotBuyLine: string; - usdtContractOpenLine: string; - coinContractOpenLine: string; - usdcContractOpenLine: string; - liquidationLine: string; - stopLiquidationLine: string; -} +/** + * + * * Common | Virtual Subaccount + * + */ ⋮---- -export interface LoanOrderV3 { - orderId: string; - orderProductId: string; - uid: string; - loanTime: string; - loanCoin: string; - loanAmount: string; - unpaidAmount: string; - unpaidInterest: string; - repaidAmount: string; - repaidInterest: string; - reserve: string; - status: 'not_paid_off' | 'paid_off'; +export interface ModifyVirtualSubRequestV2 { + subAccountUid: string; + permList: string[]; + status: string; } ⋮---- -/** Tiered conversion rate item (when Tiered Discount Rate Model is enabled) */ -export interface ConvertRatioListItemV3 { - ladder: string; - convertRatio: string; +export interface CreateVirtualSubRequestV2 { + subAccountName: string; + passphrase: string; + label: string; + ipList?: string[]; + permList?: string[]; } ⋮---- -export interface CoinInfoV3 { - coin: string; - convertRatio: string; - maxConvertValue: string; - /** Tiered conversion rate (when margin mode is Tiered Discount Rate Model) */ - convertRatioList?: ConvertRatioListItemV3[]; +export interface CreateVirtualSubApiKeyRequestV2 { + subAccountUid: string; + passphrase: string; + label: string; + ipList?: string[]; + permList?: string[]; } ⋮---- -/** Tiered conversion rate (when margin mode is Tiered Discount Rate Model) */ -⋮---- -export interface BindUidResponseV3 { - riskUnitId: string; - uid: string; - operate: 'bind' | 'unbind'; +export interface ModifyVirtualSubApiKeyRequestV2 { + subAccountUid: string; + subAccountApiKey: string; + passphrase: string; + label: string; + ipList?: string[]; + permList?: string[]; } ⋮---- -export interface UnpaidInfoV3 { - coin: string; - unpaidQty: string; - unpaidInterest: string; +export interface CreateAgentSubaccountRequestV2 { + /** Lowercase letters only; max 20 characters */ + username: string; + /** 8–32 characters, letters and numbers */ + passphrase: string; + note?: string; } ⋮---- -export interface BalanceInfoV3 { - coin: string; - price: string; - amount: string; - convertedUsdtAmount: string; -} +/** Lowercase letters only; max 20 characters */ ⋮---- -export interface LTVConvertResponseV3 { - ltv: string; - subAccountUids: string[]; - unpaidUsdtAmount: string; - usdtBalance: string; - unpaidInfo: UnpaidInfoV3[]; - balanceInfo: BalanceInfoV3[]; -} +/** 8–32 characters, letters and numbers */ ⋮---- -/* Unified Account Staking & Lending (Crypto Loans) - /api/v3/loan/* */ +/** + * + * * Common | Convert + * + */ ⋮---- -export interface LoanCoinInfoV3 { - coin: string; - hourRateFlexible: string; - rateFlexible: string; - hourRate7D: string; - rate7D: string; - hourRate30D: string; - rate30D: string; - minBorrowAmount: string; - maxBorrowAmount: string; - minBorrowLimit: string; - maxBorrowLimit: string; +export interface ConvertQuoteRequestV2 { + fromCoin: string; + fromCoinSize?: string; + toCoin: string; + toCoinSize?: string; } ⋮---- -export interface LoanPledgeInfoV3 { - coin: string; - initRate: string; - supRate: string; - forceRate: string; - minPledgeAmount: string; - maxPledgeAmount: string; +export interface ConvertRequestV2 { + fromCoin: string; + fromCoinSize: string; + cnvtPrice: string; + toCoin: string; + toCoinSize: string; + traceId: string; } ⋮---- -export interface GetLoanCoinsResponseV3 { - loanInfos: LoanCoinInfoV3[]; - pledgeInfos: LoanPledgeInfoV3[]; +export interface GetConvertHistoryRequestV2 { + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; } ⋮---- -export interface GetLoanInterestResponseV3 { - hourInterest: string; - loanAmount: string; -} +/** + * + * * Common | BGB Convert + * + */ ⋮---- -export interface LoanBorrowResponseV3 { - orderId: string; +export interface GetConvertBGBHistoryRequestV2 { + orderId?: string; + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; } + +================ +File: src/types/request/v2/futures.ts +================ +import { FuturesPlanTypeV2, FuturesProductTypeV2 } from '../shared.js'; ⋮---- -export interface LoanBorrowOngoingItemV3 { - orderId: string; - loanCoin: string; - loanAmount: string; - interestAmount: string; - hourInterestRate: string; - pledgeCoin: string; - pledgeAmount: string; - pledgeRate: string; - supRate: string; - forceRate: string; - borrowTime: string; - expireTime: string; +export type FuturesKlineInterval = + | '1m' + | '3m' + | '5m' + | '15m' + | '30m' + | '1H' + | '2H' + | '4H' + | '6H' + | '12H' + | '1D' + | '3D' + | '1W' + | '1M' + | '6Hutc' + | '12Hutc' + | '1Dutc' + | '3Dutc' + | '1Wutc' + | '1Mutc'; +⋮---- +export type FuturesKlineTypeV2 = 'MARKET' | 'MARK' | 'INDEX'; +⋮---- +export interface FuturesAccountBillRequestV2 { + productType: FuturesProductTypeV2; + symbol?: string; + coin?: string; + businessType?: string; + idLessThan?: string; + startTime?: string; + endTime?: string; + limit?: string; } ⋮---- -export interface LoanBorrowHistoryItemV3 { - orderId: string; - loanCoin: string; - pledgeCoin: string; - initPledgeAmount: string; - initLoanAmount: string; - hourRate: string; - daily: string; - borrowTime: string; - status: string; +/** + * + * * Futures | Market + * + */ +⋮---- +export interface FuturesMergeDepthRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + precision?: 'scale0' | 'scale1' | 'scale2' | 'scale3'; + limit?: '1' | '5' | '15' | '50' | 'max'; } ⋮---- -export interface LoanRepayResponseV3 { - loanCoin: string; - pledgeCoin: string; - repayAmount: string; - payInterest: string; - repayLoanAmount: string; - repayUnlockAmount: string; +export interface FuturesOiLimitRequestV2 { + productType: FuturesProductTypeV2; + symbol?: string; } ⋮---- -export interface LoanRepayHistoryItemV3 { - orderId: string; - loanCoin: string; - pledgeCoin: string; - repayAmount: string; - payInterest: string; - repayLoanAmount: string; - repayUnlockAmount: string; - repayTime: string; +export interface FuturesPositionAdlRankRequestV2 { + productType: FuturesProductTypeV2; } ⋮---- -export interface LoanRevisePledgeResponseV3 { - loanCoin: string; - pledgeCoin: string; - afterPledgeRate: string; +export interface FuturesRecentTradesRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + limit?: string; } ⋮---- -export interface LoanPledgeRateHistoryItemV3 { - loanCoin: string; - pledgeCoin: string; - orderId: string; - reviseTime: string; - reviseSide: string; - reviseAmount: string; - afterPledgeRate: string; - beforePledgeRate: string; +export interface FuturesHistoricTradesRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + limit?: string; + idLessThan?: string; + startTime?: string; + endTime?: string; } ⋮---- -export interface LoanDebtInfoV3 { - coin: string; - amount: string; - amountUsdt: string; +export interface FuturesCandlesRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + granularity: FuturesKlineInterval; + startTime?: string; + endTime?: string; + kLineType?: FuturesKlineTypeV2; + limit?: string; } ⋮---- -export interface GetLoanDebtsResponseV3 { - pledgeInfos: LoanDebtInfoV3[]; - loanInfos: LoanDebtInfoV3[]; +/** + * + * * Futures | Account + * + */ +⋮---- +export interface FuturesSingleAccountRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + marginCoin: string; } ⋮---- -export interface LoanReduceItemV3 { - orderId: string; - loanCoin: string; - pledgeCoin: string; - reduceTime: string; - pledgeRate: string; - pledgePrice: string; - status: string; - pledgeAmount: string; - reduceFee: string; - residueAmount: string; - runlockAmount: string; - repayLoanAmount: string; +export interface FuturesInterestHistoryRequestV2 { + productType: 'USDT-FUTURES' | 'SUSDT-FUTURES'; + coin?: string; + idLessThan?: string; + startTime?: string; + endTime?: string; + limit?: string; } - -================ -File: src/types/response/v3/trade.ts -================ -export interface BatchModifyOrderResponseV3 { - orderId: string; - clientOid: string; +⋮---- +export interface FuturesOpenCountRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + marginCoin: string; + openAmount: string; + openPrice: string; + leverage?: string; } ⋮---- -export interface CancelAllOrdersResponseV3 { - list: { - orderId: string; - clientOid: string; - code: string; - msg: string; - }[]; +export interface FuturesSetAutoMarginRequestV2 { + symbol: string; + autoMargin: 'on' | 'off'; + marginCoin: string; + amount: string; + holdSide?: 'long' | 'short'; } ⋮---- -export interface CancelBatchOrdersResponseV3 { - orderId: string; - clientOid: string; - code?: string; - msg?: string; +export interface FuturesSetLeverageRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + marginCoin: string; + leverage: string; + holdSide?: 'long' | 'short'; } ⋮---- -export interface CloseAllPositionsResponseV3 { - list: { - orderId: string; - clientOid: string; - code: string; - msg: string; - }[]; +export interface FuturesSetPositionMarginRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + marginCoin: string; + holdSide: 'long' | 'short'; + amount: string; } ⋮---- -export interface CancelOrderResponseV3 { - orderId: string; - clientOid: string; +export interface FuturesSetMarginModeRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + marginCoin: string; + marginMode: 'isolated' | 'crossed'; } ⋮---- -export interface GetMaxOpenAvailableResponseV3 { - available: string; - maxOpen: string; - buyOpenCost: string; - sellOpenCost: string; - maxBuyOpen: string; - maxSellOpen: string; +/** + * + * * Futures | Position + * + */ +⋮---- +export interface FuturesHistoricalPositionsRequestV2 { + symbol?: string; + productType?: FuturesProductTypeV2; + idLessThan?: string; + startTime?: string; + endTime?: string; + limit?: string; } ⋮---- -export interface FeeDetailV3 { - feeCoin: string; - fee: string; +/** + * + * * Futures | Trade + * + */ +⋮---- +export interface FuturesPlaceOrderRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + marginMode: 'isolated' | 'crossed'; + marginCoin: string; + size: string; + price?: string; + side: 'buy' | 'sell'; + tradeSide?: 'open' | 'close'; + orderType: 'limit' | 'market'; + force?: 'ioc' | 'fok' | 'gtc' | 'post_only'; + clientOid?: string; + reduceOnly?: 'YES' | 'NO'; + presetStopSurplusPrice?: string; + presetStopLossPrice?: string; + stpMode?: 'none' | 'cancel_taker' | 'cancel_maker' | 'cancel_both'; } ⋮---- -export interface OrderInfoV3 { - orderId: string; - clientOid: string; - category: string; +export interface FuturesReversalOrderRequestV2 { symbol: string; - orderType: string; - side: string; - price: string; - qty: string; - amount: string; - cumExecQty: string; - cumExecValue: string; - avgPrice: string; - timeInForce: string; - orderStatus: string; - posSide: string; - holdMode: string; - delegateType?: string; - reduceOnly: string; - feeDetail: FeeDetailV3[]; - cancelReason: string; - execType: string; - stpMode?: string; - createdTime: string; - updatedTime: string; + productType: FuturesProductTypeV2; + marginCoin: string; + size: string; + side?: 'buy' | 'sell'; + tradeSide?: 'open' | 'close'; + clientOid?: string; } ⋮---- -export type FillCategoryV3 = - | 'spot' - | 'margin' - | 'usdt-futures' - | 'coin-futures' - | 'usdc-futures' - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; +interface FuturesBatchOrderItem { + size: string; + price?: string; + side: 'buy' | 'sell'; + tradeSide?: 'open' | 'close'; + orderType: 'limit' | 'market'; + force?: 'ioc' | 'fok' | 'gtc' | 'post_only'; + clientOid?: string; + reduceOnly?: 'YES' | 'NO'; + presetStopSurplusPrice?: string; + presetStopLossPrice?: string; + stpMode?: 'none' | 'cancel_taker' | 'cancel_maker' | 'cancel_both'; +} ⋮---- -export interface FillV3 { - execId: string; - orderId: string; - category: FillCategoryV3; +export interface FuturesBatchOrderRequestV2 { symbol: string; - orderType: string; - side: string; - execPrice: string; - execQty: string; - execValue: string; - tradeScope: string; - feeDetail: FeeDetailV3[]; - execPnl?: string; - tradeSide?: string; - createdTime: string; - updatedTime: string; + productType: FuturesProductTypeV2; + marginCoin: string; + marginMode: 'isolated' | 'crossed'; + orderList: FuturesBatchOrderItem[]; } ⋮---- -export interface UnfilledOrderV3 { - orderId: string; - clientOid: string; - category: string; +export interface FuturesModifyOrderRequestV2 { + orderId?: string; + clientOid?: string; symbol: string; - orderType: string; - side: string; - price: string; - qty: string; - amount: string; - cumExecQty: string; - cumExecValue: string; - avgPrice: string; - timeInForce: string; - orderStatus: string; - posSide: string; - holdMode: string; - delegateType?: string; - reduceOnly: string; - feeDetail: FeeDetailV3[]; - stpMode?: string; - createdTime: string; - updatedTime: string; + productType: FuturesProductTypeV2; + newClientOid: string; + newSize?: string; + newPrice?: string; + newPresetStopSurplusPrice?: string; + newPresetStopLossPrice?: string; } ⋮---- -export interface HistoryOrderV3 { - orderId: string; - clientOid: string; - category: string; +export interface FuturesCancelOrderRequestV2 { symbol: string; - orderType: string; - side: string; - price: string; - qty: string; - amount: string; - cumExecQty: string; - cumExecValue: string; - avgPrice: string; - timeInForce: string; - orderStatus: string; - posSide: string; - holdMode: string; - delegateType?: string; - reduceOnly: string; - feeDetail: FeeDetailV3[]; - cancelReason: string; - execType: string; - stpMode?: string; - createdTime: string; - updatedTime: string; + productType: FuturesProductTypeV2; + marginCoin?: string; + orderId?: string; + clientOid?: string; } ⋮---- -export interface PositionHistoryV3 { - positionId: string; - category: string; - symbol: string; - marginCoin: string; - holdMode: string; - posSide: string; - marginMode: string; - openPriceAvg: string; - closePriceAvg: string; - openTotalPos: string; - closeTotalPos: string; - cumRealisedPnl: string; - netProfit: string; - totalFunding: string; - openFeeTotal: string; - closeFeeTotal: string; - createdTime: string; - updatedTime: string; +interface FuturesBatchCancelOrderItem { + orderId?: string; + clientOid?: string; } ⋮---- -export interface CurrentPositionV3 { - category: string; - symbol: string; - marginCoin: string; - holdMode: string; - posSide: string; - marginMode: string; - positionBalance: string; - available: string; - frozen: string; - total: string; - leverage: string; - curRealisedPnl: string; - avgPrice: string; - positionStatus: string; - unrealisedPnl: string; - liquidationPrice: string; - mmr: string; - profitRate: string; - markPrice: string; - breakEvenPrice: string; - totalFunding: string; - openFeeTotal: string; - closeFeeTotal: string; - createdTime: string; - updatedTime: string; +export interface FuturesBatchCancelOrderRequestV2 { + orderIdList?: FuturesBatchCancelOrderItem[]; + symbol?: string; + productType: FuturesProductTypeV2; + marginCoin?: string; } ⋮---- -export interface LoanDataDebtCoinV3 { - coin: string; - debt: string; - interestFreeAmount: string; - interestRateNextHour: string; +export interface FuturesFlashClosePositionsRequestV2 { + symbol?: string; + productType: FuturesProductTypeV2; + holdSide?: 'long' | 'short'; } ⋮---- -export interface LoanDataV3 { - currentLoans: string; - interestPaymentTime: string; - debtCoinList: LoanDataDebtCoinV3[]; +export interface FuturesGetOrderRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + orderId?: string; + clientOid?: string; } ⋮---- -export interface ModifyOrderResponseV3 { - orderId: string; - clientOid: string; +export interface FuturesGetOrderFillsRequestV2 { + orderId?: string; + symbol?: string; + productType: FuturesProductTypeV2; + idLessThan?: string; + startTime?: string; + endTime?: string; + limit?: string; } ⋮---- -export interface PlaceBatchOrdersResponseV3 { - orderId: string; - clientOid: string; - code?: string; - msg?: string; +export interface FuturesGetHistoricalFillsRequestV2 { + orderId?: string; + symbol?: string; + productType: FuturesProductTypeV2; + startTime?: string; + endTime?: string; + idLessThan?: string; + limit?: string; } ⋮---- -export interface PlaceOrderResponseV3 { - orderId: string; - clientOid: string; +export interface FuturesGetOpenOrdersRequestV2 { + orderId?: string; + clientOid?: string; + symbol?: string; + productType: FuturesProductTypeV2; + status?: 'live' | 'partially_filled'; + idLessThan?: string; + startTime?: string; + endTime?: string; + limit?: string; } ⋮---- -export interface PositionAdlRankV3 { - symbol: string; - marginCoin: string; - adlRank: string; - holdSide: 'long' | 'short'; -} - -================ -File: src/websocket-api-client.ts -================ -import { CancelOrderRequestV3 } from './types/request/v3/trade.js'; -import { CancelOrderResponseV3 } from './types/response/v3/trade.js'; -import { WSAPIResponse } from './types/websockets/ws-api.js'; -import { WSAPIPlaceOrderRequestV3 } from './types/websockets/ws-api-request.js'; -import { WSAPIPlaceOrderResponseV3 } from './types/websockets/ws-api-response.js'; -import { - BitgetInstTypeV3, - WSClientConfigurableOptions, -} from './types/websockets/ws-general.js'; -import { DefaultLogger } from './util/logger.js'; -import { WS_KEY_MAP } from './util/websocket-util.js'; -import { WebsocketClientV3 } from './websocket-client-v3.js'; +export type FuturesOrderSourceV2 = + | 'normal' + | 'market' + | 'profit_market' + | 'loss_market' + | 'Trader_delegate' + | 'trader_profit' + | 'trader_loss' + | 'reverse' + | 'trader_reverse' + | 'profit_limit' + | 'loss_limit' + | 'liquidation' + | 'delivery_close_long' + | 'delivery_close_short' + | 'pos_profit_limit' + | 'pos_profit_market' + | 'pos_loss_limit' + | 'pos_loss_market'; ⋮---- -/** - * Configurable options specific to only the REST-like WebsocketAPIClient - */ -export interface WSAPIClientConfigurableOptions { - /** - * Default: true - * - * Attach default event listeners, which will console log any high level - * events (opened/reconnecting/reconnected/etc). - * - * If you disable this, you should set your own event listeners - * on the embedded WS Client `wsApiClient.getWSClient().on(....)`. - */ - attachEventListeners: boolean; +export interface FuturesGetHistoryOrdersRequestV2 { + orderId?: string; + clientOid?: string; + symbol?: string; + productType: FuturesProductTypeV2; + idLessThan?: string; + orderSource?: FuturesOrderSourceV2; + startTime?: string; + endTime?: string; + limit?: string; } ⋮---- -/** - * Default: true - * - * Attach default event listeners, which will console log any high level - * events (opened/reconnecting/reconnected/etc). - * - * If you disable this, you should set your own event listeners - * on the embedded WS Client `wsApiClient.getWSClient().on(....)`. - */ +export interface FuturesCancelAllOrdersRequestV2 { + symbol?: string; + productType: FuturesProductTypeV2; + marginCoin?: string; + requestTime?: string; + receiveWindow?: string; +} ⋮---- /** - * This is a minimal Websocket API wrapper around the WebsocketClient. * - * Note: You can also directly use the sendWSAPIRequest() method to make WS API calls, but some - * may find the below methods slightly more intuitive. + * * Futures | Trigger Orders * - * Refer to the WS API promises example for a more detailed example on using sendWSAPIRequest() directly: - * https://github.com/tiagosiebler/bitget-api/blob/master/examples/V3/ws-api-trade-raw.ts */ -export class WebsocketAPIClient -⋮---- -constructor( - options?: WSClientConfigurableOptions & - Partial, - logger?: DefaultLogger, -) ⋮---- -public getWSClient(): WebsocketClientV3 +export type FuturesTriggerTypeV2 = 'fill_price' | 'mark_price'; ⋮---- -public setTimeOffsetMs(newOffset: number): void +export type FuturesStpModeV2 = + | 'none' + | 'cancel_taker' + | 'cancel_maker' + | 'cancel_both'; ⋮---- -/* - * Bitget WebSocket API Methods - * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel - */ +export interface FuturesTPSLOrderRequestV2 { + marginCoin: string; + productType: FuturesProductTypeV2; + symbol: string; + planType: FuturesPlanTypeV2; + triggerPrice: string; + triggerType?: FuturesTriggerTypeV2; + executePrice?: string; + holdSide: 'long' | 'short' | 'buy' | 'sell'; + size: string; + rangeRate?: string; + clientOid?: string; + stpMode?: FuturesStpModeV2; +} ⋮---- -/** - * Submit a new order - * - * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel - * - * @returns - */ -submitNewOrder( - category: BitgetInstTypeV3, - params: WSAPIPlaceOrderRequestV3, -): Promise> +export interface FuturesPositionTPSLOrderRequestV2 { + marginCoin: string; + productType: FuturesProductTypeV2; + symbol: string; + stopSurplusTriggerPrice?: string; + stopSurplusSize?: string; + stopSurplusTriggerType?: FuturesTriggerTypeV2; + stopSurplusExecutePrice?: string; + stopLossTriggerPrice?: string; + stopLossSize?: string; + stopLossTriggerType?: FuturesTriggerTypeV2; + stopLossExecutePrice?: string; + holdSide: 'long' | 'short' | 'buy' | 'sell'; + stpMode?: FuturesStpModeV2; + stopSurplusClientOid?: string; + stopLossClientOid?: string; +} ⋮---- -/** - * Submit a new order - * - * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel - * - * @returns - */ -placeBatchOrders( - category: BitgetInstTypeV3, - params: WSAPIPlaceOrderRequestV3[], -): Promise> +export type FuturesTriggerPriceTypeV2 = + | 'fill_price' + | 'mark_price' + | 'index_price'; ⋮---- -/* - * Bitget WebSocket API Methods - * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel - */ +export interface FuturesPlanOrderRequestV2 { + planType: 'normal_plan' | 'track_plan'; + symbol: string; + productType: FuturesProductTypeV2; + marginMode: 'isolated' | 'crossed'; + marginCoin: string; + size: string; + price?: string; + callbackRatio?: string; + triggerPrice: string; + triggerType: 'mark_price' | 'fill_price'; + side: 'buy' | 'sell'; + tradeSide?: 'open' | 'close'; + orderType: 'limit' | 'market'; + clientOid?: string; + reduceOnly?: 'YES' | 'NO'; + stopSurplusTriggerPrice?: string; + stopSurplusExecutePrice?: string; + stopSurplusTriggerType?: FuturesTriggerPriceTypeV2; + stopLossTriggerPrice?: string; + stopLossExecutePrice?: string; + stopLossTriggerType?: FuturesTriggerPriceTypeV2; + stpMode?: FuturesStpModeV2; +} ⋮---- -/** - * Cancel Order - * - * https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel - * - * @returns - */ -cancelOrder( - category: BitgetInstTypeV3, - params: CancelOrderRequestV3, -): Promise> +export interface FuturesModifyTPSLOrderRequestV2 { + orderId?: string; + clientOid?: string; + marginCoin: string; + productType: FuturesProductTypeV2; + symbol: string; + triggerPrice: string; + triggerType?: 'fill_price' | 'mark_price'; + executePrice?: string; + size: string; + rangeRate?: string; +} ⋮---- -/** - * Batch Cancel Order - * - * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Cancel-Order-Channel - * - * @returns - */ -cancelBatchOrders( - category: BitgetInstTypeV3, - params: CancelOrderRequestV3[], -): Promise> +export interface FuturesModifyPlanOrderRequestV2 { + planType: 'normal_plan' | 'track_plan'; + orderId?: string; + clientOid?: string; + symbol: string; + productType: FuturesProductTypeV2; + newSize?: string; + newPrice?: string; + newCallbackRatio?: string; + newTriggerPrice?: string; + newTriggerType?: 'fill_price' | 'mark_price'; + newStopSurplusTriggerPrice?: string; + newStopSurplusExecutePrice?: string; + newStopSurplusTriggerType?: FuturesTriggerPriceTypeV2; + newStopLossTriggerPrice?: string; + newStopLossExecutePrice?: string; + newStopLossTriggerType?: FuturesTriggerPriceTypeV2; +} ⋮---- -/** - * - * - * - * - * - * - * - * Private methods for handling some of the convenience/automation provided by the WS API Client - * - * - * - * - * - * - * - */ +export interface FuturesGetPlanOrdersRequestV2 { + orderId?: string; + clientOid?: string; + symbol?: string; + planType: 'normal_plan' | 'track_plan' | 'profit_loss'; + productType: FuturesProductTypeV2; + idLessThan?: string; + startTime?: string; + endTime?: string; + limit?: string; +} ⋮---- -private setupDefaultEventListeners() +interface FuturesCancelPlanOrderItemV2 { + orderId?: string; + clientOid?: string; +} ⋮---- -/** - * General event handlers for monitoring the WebsocketClient - */ +export type FuturesPlanOrderTypeV2 = + | 'normal_plan' + | 'profit_plan' + | 'loss_plan' + | 'pos_profit' + | 'pos_loss' + | 'moving_plan'; ⋮---- -// Blind JSON.stringify can fail on circular references +export interface FuturesCancelPlanOrderRequestV2 { + orderIdList?: FuturesCancelPlanOrderItemV2[]; + symbol?: string; + productType: FuturesProductTypeV2; + marginCoin?: string; + planType?: FuturesPlanOrderTypeV2; +} ⋮---- -// JSON.stringify({ ...data, target: 'WebSocket' }), - -================ -File: src/websocket-client-v3.ts -================ -import { - WsAPIOperationResponseMap, - WSAPIRequestBitgetV3, - WSAPIRequestFlags, - WsAPITopicRequestParamMap, - WsAPIWsKeyTopicMap, - WSOperation, - WSOperationLoginParams, - WsRequestOperationBitget, -} from './types/websockets/ws-api.js'; -import { MessageEventLike } from './types/websockets/ws-events.js'; -import { - BitgetInstTypeV3, - WsKey, - WsTopicV3, -} from './types/websockets/ws-general.js'; -import { - BaseWebsocketClient, - EmittableEvent, - MidflightWsRequestEvent, -} from './util/BaseWSClient.js'; -import { isWsPong } from './util/requestUtils.js'; -import { isWSAPIResponse } from './util/type-guards.js'; -import { SignAlgorithm, signMessage } from './util/webCryptoAPI.js'; -import { - getMaxTopicsPerSubscribeEvent, - getNormalisedTopicRequests, - getPromiseRefForWSAPIRequest, - getWsUrl, - WS_AUTH_ON_CONNECT_KEYS, - WS_KEY_MAP, - WS_LOGGER_CATEGORY, - WsTopicRequest, -} from './util/websocket-util.js'; -import { WSConnectedResult } from './util/WsStore.types.js'; +export type FuturesPlanStatusV2 = 'executed' | 'fail_trigger' | 'cancelled'; +⋮---- +export interface FuturesGetHistoryPlanOrdersRequestV2 { + orderId?: string; + clientOid?: string; + planType: 'normal_plan' | 'track_plan' | 'profit_loss'; + planStatus?: FuturesPlanStatusV2; + symbol?: string; + productType: FuturesProductTypeV2; + idLessThan?: string; + startTime?: string; + endTime?: string; + limit?: string; +} ⋮---- /** - * WebSocket client dedicated to the unified account (V3) WebSockets. * - * Your Bitget account needs to be upgraded to unified account mode, to use the account-level WebSocket topics. + * * Futures | Union Margin + * */ -export class WebsocketClientV3 extends BaseWebsocketClient< ⋮---- -WsRequestOperationBitget // subscribe requests have an "args" parameter with an object within +export interface GetUnionTransferLimitsRequestV2 { + coin: string; +} ⋮---- -/** - * Request connection of all dependent (public & private) websockets, instead of waiting for automatic connection by library - */ -public connectAll(): Promise[] +export interface UnionConvertRequestV2 { + coin: string; + amount: string; +} ⋮---- /** - * Ensures the WS API connection is active and ready. - * - * You do not need to call this, but if you call this before making any WS API requests, - * it can accelerate the first request (by preparing the connection in advance). - */ -public connectWSAPI(): Promise + * + * * Futures | Account | Max Openable Quantity + * + */ ⋮---- -/** This call automatically ensures the connection is active AND authenticated before resolving */ +export interface FuturesMaxOpenRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + marginCoin: string; + posSide: 'long' | 'short'; + orderType: 'limit' | 'market'; + openPrice?: string; +} ⋮---- /** - * Request subscription to one or more topics. Pass topics as either an array of strings, - * or array of objects (if the topic has parameters). - * - * Objects should be formatted as {topic: string, params: object, category: CategoryV5}. - * - * - Subscriptions are automatically routed to the correct websocket connection. - * - Authentication/connection is automatic. - * - Resubscribe after network issues is automatic. - * - * Call `unsubscribe(topics)` to remove topics - */ -public subscribe( - requests: - | (WsTopicRequest | WsTopicV3) - | (WsTopicRequest | WsTopicV3)[], - wsKey: WsKey, -): Promise + * + * * Futures | Account | Liquidation Price + * + */ ⋮---- -/** - * Unsubscribe from one or more topics. Similar to subscribe() but in reverse. - * - * - Requests are automatically routed to the correct websocket connection. - * - These topics will be removed from the topic cache, so they won't be subscribed to again. - */ -public unsubscribe( - requests: - | (WsTopicRequest | WsTopicV3) - | (WsTopicRequest | WsTopicV3)[], - wsKey: WsKey, -) +export interface FuturesLiquidationPriceRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + marginCoin: string; + posSide: 'long' | 'short'; + orderType: 'limit' | 'market'; + openAmount: string; + openPrice?: string; +} ⋮---- /** - * - * - * Internal methods required to integrate with the BaseWSClient - * - * - */ + * + * * Futures | Account | Isolated Symbols + * + */ ⋮---- -protected sendPingEvent(wsKey: WsKey): void +export interface FuturesIsolatedSymbolsRequestV2 { + productType: FuturesProductTypeV2; +} + +================ +File: src/types/request/v3/broker.ts +================ +export interface CreateBrokerSubAccountRequestV3 { + subaccountName: string; + label: string; +} ⋮---- -protected sendPongEvent(wsKey: WsKey): void +export interface GetBrokerSubAccountListRequestV3 { + limit?: string; + cursor?: string; + status?: 'normal' | 'freeze'; +} ⋮---- -protected isWsPing(data: any): boolean +export interface ModifyBrokerSubAccountRequestV3 { + subUid: string; + status?: 'normal' | 'freeze'; + permList?: string[]; +} ⋮---- -protected isWsPong(data: any): boolean +export interface BrokerSubWithdrawalRequestV3 { + subUid: string; + coin: string; + dest: 'on_chain' | 'internal_transfer'; + address: string; + amount: string; + chain?: string; + tag?: string; + clientOid?: string; +} ⋮---- -protected isPrivateTopicRequest( - _request: WsTopicRequest, - wsKey: WsKey, -): boolean +export interface GetBrokerSubDepositAddressRequestV3 { + subUid: string; + coin: string; + chain?: string; +} ⋮---- -protected getPrivateWSKeys(): WsKey[] +export interface GetBrokerAllSubDepositWithdrawalRequestV3 { + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; + status?: 'pending' | 'fail' | 'success'; +} ⋮---- -protected isAuthOnConnectWsKey(wsKey: WsKey): boolean +export interface GetBrokerCommissionRequestV3 { + startTime?: string; + endTime?: string; + pageSize?: string; + pageNo?: string; + bizType?: 'spot' | 'futures'; + subBizType?: + | 'spot_trade' + | 'spot_margin' + | 'usdt_futures' + | 'usdc_futures' + | 'coin_futures'; +} ⋮---- -protected async getWsUrl(wsKey: WsKey): Promise +export interface CreateBrokerSubApiKeyRequestV3 { + subUid: string; + passphrase: string; + label: string; + ipList?: string[]; + permType: 'read_write' | 'read_only'; + permList: string[]; +} ⋮---- -protected getMaxTopicsPerSubscribeEvent(wsKey: WsKey): number | null +export interface ModifyBrokerSubApiKeyRequestV3 { + subUid: string; + passphrase: string; + apiKey: string; + label?: string; + ipList?: string[]; + permType?: 'read_write' | 'read_only'; + permList?: string[]; +} ⋮---- -/** - * @returns one or more correctly structured request events for performing a operations over WS. This can vary per exchange spec. - */ -protected async getWsRequestEvents( - operation: WSOperation, - requests: WsTopicRequest[], -): Promise>[]> +export interface DeleteBrokerSubApiKeyRequestV3 { + subUid: string; + apiKey: string; +} ⋮---- -// Previously used to track topics in a request. Keeping this for subscribe/unsubscribe requests, no need for incremental values +export interface GetBrokerSubApiKeyRequestV3 { + subUid: string; +} + +================ +File: src/types/request/v3/copytrading.ts +================ +export interface GetCopyFuturesMaxTransferableRequestV3 { + coin: string; +} ⋮---- -/** - { - "op":"subscribe", - "args":[ - { - "instType":"spot", - "topic":"ticker", - "symbol":"BTCUSDT" - }, - { - "instType":"spot", - "topic":"candle5m", - "symbol":"BTCUSDT" - } - ] - } - */ +export interface CopyFuturesTransferRequestV3 { + type: 'in' | 'out'; + coin: string; + amount: string; + /** Source account type(s) for transfer-in. Comma-separated: funding, uta, otc */ + inAccountType?: string; +} ⋮---- -// const request = { -// topic: 'ticker', -// payload: { instType: 'spot', symbol: 'BTCUSDT' }, -// }; -// becomes: -// const request = { -// topic: 'ticker', -// instType: 'spot', -// symbol: 'BTCUSDT', -// }; +/** Source account type(s) for transfer-in. Comma-separated: funding, uta, otc */ ⋮---- -private async getWsAuthSignature( - wsKey: WsKey, -): Promise< +export interface GetCopyFuturesTransferRecordRequestV3 { + startTime?: string; + endTime?: string; + limit?: string; + /** Pass transferId from the previous page to paginate forward */ + cursor?: string; +} ⋮---- -private async signMessage( - paramsStr: string, - secret: string, - method: 'hex' | 'base64', - algorithm: SignAlgorithm, -): Promise +/** Pass transferId from the previous page to paginate forward */ ⋮---- -protected async getWsAuthRequestEvent( - wsKey: WsKey, -): Promise> +export interface GetCopyFuturesFollowersRequestV3 { + limit?: string; + cursor?: string; +} ⋮---- -/** - * Abstraction called to sort ws events into emittable event types (response to a request, data update, etc) - */ -protected resolveEmittableEvents( - wsKey: WsKey, - event: MessageEventLike, -): EmittableEvent[] +export interface GetCopyFuturesProfitDetailsRequestV3 { + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; +} + +================ +File: src/types/request/v3/strategy.ts +================ +export type StrategyOrderTypeV3 = 'tpsl' | 'trigger'; ⋮---- -/** - * WS API response handling - */ +export type StrategyOrderStatusV3 = + | 'pending' + | 'success' + | 'failed' + | 'cancelled' + | 'submitting'; ⋮---- -// const eg1 = { -// event: 'error', -// id: '1', -// code: '43012', -// msg: 'Insufficient balance', -// }; -⋮---- -// WS API Success -⋮---- -/** - * V3 event handling for consumers - behaves the same as V2 - */ -⋮---- -// v2 authentication event -⋮---- -// messageType: typeof msg, -// messageString: JSON.stringify(msg), -⋮---- -// Service upgrade (30033): Bitget sends this ~60s before disconnect. Log and let automatic reconnect handle when connection drops. -⋮---- -// messageType: typeof msg, -// messageString: JSON.stringify(msg), -⋮---- -// fallback emit anyway -⋮---- -/** - * V3/UTA supports order placement via WebSockets. This is the WS API: - * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel - * - * @returns a promise that resolves/rejects when a matching response arrives - */ -async sendWSAPIRequest< - TWSKey extends keyof WsAPIWsKeyTopicMap, - TWSOperation extends WsAPIWsKeyTopicMap[TWSKey], - TWSParams extends WsAPITopicRequestParamMap[TWSOperation], - TWSAPIResponse extends - WsAPIOperationResponseMap[TWSOperation] = WsAPIOperationResponseMap[TWSOperation], - >( - wsKey: WsKey, - operation: TWSOperation, - category: BitgetInstTypeV3, - params: TWSParams & { signRequest?: boolean }, - requestFlags?: WSAPIRequestFlags, -): Promise -⋮---- -// this.logger.trace('sendWSAPIRequest(): assertIsAuthenticated(${wsKey})...'); -⋮---- -// this.logger.trace('sendWSAPIRequest(): assertIsAuthenticated(${wsKey}) ok'); +export type StrategyTriggerByV3 = 'market' | 'mark'; ⋮---- -// Ensure "args" is always wrapped as array +export type StrategyTriggerOrderTypeV3 = 'limit' | 'market'; ⋮---- -// Store deferred promise, resolved within the "resolveEmittableEvents" method while parsing incoming events +export interface PlaceStrategyOrderRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol: string; + clientOid?: string; + type?: StrategyOrderTypeV3; + tpslMode?: 'full' | 'partial'; + /** Required when tpslMode=partial or for trigger orders */ + qty?: string; + side?: 'buy' | 'sell'; + posSide?: 'long' | 'short'; + reduceOnly?: 'yes' | 'no'; + tpTriggerBy?: StrategyTriggerByV3; + slTriggerBy?: StrategyTriggerByV3; + takeProfit?: string; + stopLoss?: string; + tpOrderType?: StrategyTriggerOrderTypeV3; + slOrderType?: StrategyTriggerOrderTypeV3; + tpLimitPrice?: string; + slLimitPrice?: string; + triggerBy?: StrategyTriggerByV3; + triggerPrice?: string; + triggerOrderType?: StrategyTriggerOrderTypeV3; + triggerOrderPrice?: string; +} ⋮---- -// eslint-disable-next-line @typescript-eslint/no-explicit-any +/** Required when tpslMode=partial or for trigger orders */ ⋮---- -// Enrich returned promise with request context for easier debugging +export interface ModifyStrategyOrderRequestV3 { + orderId?: string; + clientOid?: string; + qty: string; + tpTriggerBy?: StrategyTriggerByV3; + slTriggerBy?: StrategyTriggerByV3; + takeProfit?: string; + stopLoss?: string; + tpOrderType?: StrategyTriggerOrderTypeV3; + slOrderType?: StrategyTriggerOrderTypeV3; + tpLimitPrice?: string; + slLimitPrice?: string; + triggerBy?: StrategyTriggerByV3; + triggerPrice?: string; + triggerOrderType?: StrategyTriggerOrderTypeV3; + triggerOrderPrice?: string; +} ⋮---- -// throw e; +export interface CancelStrategyOrderRequestV3 { + orderId?: string; + clientOid?: string; +} ⋮---- -// Send event +export interface GetUnfilledStrategyOrdersRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + type?: StrategyOrderTypeV3; +} ⋮---- -// Return deferred promise, so caller can await this call +export interface GetHistoryStrategyOrdersRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + type?: StrategyOrderTypeV3; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; +} ================ -File: examples/V3 - UTA/WS-API/ws-api-client-trade.ts +File: src/types/response/v2/spot.ts ================ -import { DefaultLogger, WebsocketAPIClient } from '../../../src/index.js'; +/** + * + * * Spot | Market + * + */ ⋮---- -// or -// import { DefaultLogger, WS_KEY_MAP, WebsocketAPIClient } from 'bitget-api'; +export interface SpotCoinChainV2 { + chain: string; + needTag: boolean; + withdrawable: boolean; + rechargeable: boolean; + withdrawFee: string; + extraWithdrawFee: string; + depositConfirm: string; + withdrawConfirm: string; + minDepositAmount: string; + minWithdrawAmount: string; + browserUrl: string; + contractAddress: string; + withdrawStep: string; + withdrawMinScale: string; + congestion: string; +} ⋮---- -// function attachEventHandlers( -// wsClient: TWSClient, -// ): void { -// wsClient.on('update', (data) => { -// console.log('raw message received ', JSON.stringify(data)); -// }); -// wsClient.on('open', (data) => { -// console.log('ws connected', data.wsKey); -// }); -// wsClient.on('reconnect', ({ wsKey }) => { -// console.log('ws automatically reconnecting.... ', wsKey); -// }); -// wsClient.on('reconnected', (data) => { -// console.log('ws has reconnected ', data?.wsKey); -// }); -// wsClient.on('authenticated', (data) => { -// console.log('ws has authenticated ', data?.wsKey); -// }); -// } +export interface SpotCoinInfoV2 { + coinId: string; + coin: string; + transfer: boolean; + chains: SpotCoinChainV2[]; +} ⋮---- -// 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/ws-private.ts +export interface SpotSymbolInfoV2 { + symbol: string; + baseCoin: string; + quoteCoin: string; + minTradeAmount: string; + maxTradeAmount: string; + takerFeeRate: string; + makerFeeRate: string; + pricePrecision: string; + quantityPrecision: string; + quotePrecision: string; + minTradeUSDT: string; + status: string; + buyLimitPriceRatio: string; + sellLimitPriceRatio: string; + orderQuantity: string; + areaSymbol: string; + maxLimitOrderValue?: string; + maxMarketOrderValue?: string; +} ⋮---- -// Whether to use the demo trading wss connection -// demoTrading: true, +export interface SpotVipFeeRateV2 { + level: number; + dealAmount: string; + assetAmount: string; + takerFeeRate: string; + makerFeeRate: string; + btcWithdrawAmount: string; + usdtWithdrawAmount: string; +} ⋮---- -// If you want your own event handlers instead of the default ones with logs, -// disable this setting and see the `attachEventHandlers` example below: -// attachEventListeners: false +export interface SpotTickerV2 { + symbol: string; + high24h: string; + open: string; + low24h: string; + lastPr: string; + quoteVolume: string; + baseVolume: string; + usdtVolume: string; + bidPr: string; + askPr: string; + bidSz: string; + askSz: string; + openUtc: string; + ts: string; + changeUtc24h: string; + change24h: string; +} ⋮---- -logger, // Optional: inject a custom logger +export interface SpotCallAuctionV2 { + stage: string; + stageEndTime: string; + estOpeningPrice: string | null; + matchedVolume: string | null; + auctionEndTime: string; +} ⋮---- -// Optional, see above "attachEventListeners". Attach basic event handlers, so nothing is left unhandled -// attachEventHandlers(wsClient.getWSClient()); +export interface SpotMergeDepthV2 { + asks: [string, string][]; + bids: [string, string][]; + ts: string; + scale: string; + precision: string; + isMaxPrecision: string; +} ⋮---- -// Optional: prepare the WebSocket API connection in advance. -// This happens automatically but you can do this early before making any API calls, to prevent delays from a cold start. +export interface SpotOrderBookDepthV2 { + asks: [string, string][]; + bids: [string, string][]; + ts: string; +} ⋮---- -/** - * Bitget's WebSocket API be used like a REST API, through this SDK's WebsocketAPIClient. The WebsocketAPIClient is a utility class wrapped around WebsocketClientV3's sendWSAPIRequest() capabilities. - * - * Each request sent via the WebsocketAPIClient will automatically: - * - route via the active WS API connection - * - return a Promise, which automatically resolves/rejects when a matching response is received - * - * Note: this requires V3/UTA API keys! - */ +export type SpotCandlestickV2 = [ + string, // timestamp + string, // open + string, // high + string, // low + string, // close + string, // baseVolume + string, // usdtVolume + string, // quoteVolume +]; ⋮---- -/** - * Place Order - * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters - */ +string, // timestamp +string, // open +string, // high +string, // low +string, // close +string, // baseVolume +string, // usdtVolume +string, // quoteVolume ⋮---- -/** - const res = { - "event": "trade", - "id": "1750034396082", - "category": "spot", - "topic": "place-order", - "args": [ - { - "symbol": "BTCUSDT", - "orderId": "xxxxxxxx", - "clientOid": "xxxxxxxx", - "cTime": "1750034397008" - } - ], - "code": "0", - "msg": "success", - "ts": "1750034397076" - }; - */ +export interface SpotTradeV2 { + symbol: string; + tradeId: string; + side: string; + price: string; + size: string; + ts: string; +} ⋮---- /** - * Batch Place Order Channel - * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel - */ + * + * * Spot | Trade + * + */ ⋮---- -/** - * Note: batch place will never reject the request, even if all orders were rejected. Check the "code" and "msg" properties for individual orders in the response, to detect batch place errors. - */ +export interface CancelAndSubmitSpotOrderResponseV2 { + orderId: string; + clientOid: string | null; + success: string; + msg: string | null; +} ⋮---- -/** - const res = { - "event": "trade", - "id": "1750035029506", - "category": "spot", - "topic": "batch-place", - "args": [ - { - "code": "0", - "msg": "Success", - "symbol": "BTCUSDT", - "orderId": "xxxxxxxx", - "clientOid": "xxxxxxxx" - }, - { - "code": "0", - "msg": "Success", - "symbol": "BTCUSDT", - "orderId": "xxxxxxxx", - "clientOid": "xxxxxxxx" - } - ], - "code": "0", - "msg": "Success", - "ts": "1750035029925" - } - */ +export interface SubmitSpotBatchOrdersResponseV2 { + successList: { + orderId: string; + clientOid: string; + }[]; + failureList: { + orderId: string; + clientOid: string; + errorMsg: string; + errorCode?: string; + }[]; +} ⋮---- -/** - * Cancel Order - * https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel - */ +export interface SpotOrderInfoV2 { + userId: string; + symbol: string; + orderId: string; + clientOid: string; + price: string; + size: string; + orderType: string; + side: string; + status: string; + priceAvg: string; + baseVolume: string; + quoteVolume: string; + enterPointSource: string; + feeDetail: { + BGB?: { + deduction: boolean; + feeCoinCode: string; + totalDeductionFee: string; + totalFee: string; + }; + newFees?: { + c: number; + d: number; + deduction: boolean; + r: string; + t: string; + totalDeductionFee: number; + }; + }; + orderSource: string; + cancelReason: string; + cTime: string; + uTime: string; +} ⋮---- -/** - const res = { - "event": "trade", - "id": "1750034870205", - "topic": "cancel-order", - "args": [ - { - "orderId": "xxxxxxxx", - "clientOid": "xxxxxxxx" - } - ], - "code": "0", - "msg": "Success", - "ts": "1750034870597" - } - */ +export interface SpotOpenOrderV2 { + userId: string; + symbol: string; + orderId: string; + clientOid: string; + priceAvg: string; + size: string; + orderType: string; + side: string; + status: string; + basePrice: string; + baseVolume: string; + quoteVolume: string; + enterPointSource: string; + orderSource?: string; + presetTakeProfitPrice: string; + executeTakeProfitPrice: string; + presetStopLossPrice: string; + executeStopLossPrice: string; + cTime: string; + uTime?: string; + tpslType: string; + triggerPrice: string | null; +} ⋮---- -/** - * Batch Cancel Order - * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Cancel-Order-Channel - */ +export interface SpotFillV2 { + userId: string; + symbol: string; + orderId: string; + tradeId: string; + orderType: string; + side: string; + priceAvg: string; + size: string; + amount: string; + feeDetail: { + deduction: string; + feeCoin: string; + totalDeductionFee: string; + totalFee: string; + }; + tradeScope: string; + cTime: string; + uTime: string; +} ⋮---- -/** - const res = { - "event": "trade", - "id": "bb553cc0-c1fa-454e-956d-c96c8d715760", - "topic": "batch-cancel", - "args": [ - { - "code": "0", - "msg": "Success", - "orderId": "xxxxxxxxxxxxx" - }, - { - "code": "25204", - "msg": "Order does not exist", - "orderId": "xxxxxxxxxxxxx" - } - ], - "code": "0", - "msg": "Success", - "ts": "1751980011084" - } - */ - -================ -File: src/types/request/v2/broker.ts -================ /** * - * * Broker | Subaccount + * * Spot | Trigger Orders * */ ⋮---- -export interface GetSubAccountsRequestV2 { - limit?: string; - idLessThan?: string; - status?: 'normal' | 'freeze' | 'del'; - startTime?: string; - endTime?: string; -} -⋮---- -export type SubAccountPermissionV2 = - | 'withdraw' - | 'transfer' - | 'spot_trade' - | 'contract_trade' - | 'read' - | 'deposit' - | 'margin_trade'; -⋮---- -export type SubAccountLanguageV2 = - | 'en_US' - | 'zh_CN' - | 'ja_JP' - | 'vi_VN' - | 'zh_TW' - | 'ru_RU' - | 'es_ES' - | 'tr_TR' - | 'fr_FR' - | 'de_DE' - | 'pt_PT' - | 'th_TH'; -⋮---- -export type SubAccountStatusV2 = 'normal' | 'freeze'; -⋮---- -export interface ModifySubRequestV2 { - subUid: string; - permList: SubAccountPermissionV2[]; - status: SubAccountStatusV2; - language?: SubAccountLanguageV2; +export interface SpotCurrentPlanOrderV2 { + orderId: string; + clientOid: string; + symbol: string; + size: string; + executePrice: string; + triggerPrice: string; + status: string; + orderType: string; + side: string; + planType: string; + triggerType: string; + enterPointSource: string; + uTime: string; + cTime: string; } ⋮---- -export interface SubWithdrawalRequestV2 { - subUid: string; - coin: string; - dest: 'on_chain' | 'internal_transfer'; - chain?: string; - address: string; - amount: string; - tag?: string; - clientOid?: string; +export interface SpotHistoryPlanOrderV2 { + orderId: string; + clientOid: string; + symbol: string; + size: string; + executePrice: string; + triggerPrice: string; + status: string; + orderType: string; + side: string; + planType: string; + triggerType: string; + enterPointSource: string; + uTime: string; + cTime: string; } ⋮---- -export interface SubDepositRecordsRequestV2 { - orderId?: string; - userId?: string; - startTime?: string; - endTime?: string; - limit?: string; - idLessThan?: string; +export interface SpotPlanSubOrderV2 { + orderId: string; + price: string; + type: string; + status: string; } ⋮---- -export interface SubWithdrawalRecordsRequestV2 { - orderId?: string; - userId?: string; - startTime?: string; - endTime?: string; - limit?: string; - idLessThan?: string; +export interface SpotCancelPlanOrdersV2 { + successList: { + orderId: string; + clientOid: string; + }[]; + failureList: { + orderId: string; + clientOid: string; + errorMsg: string; + }[]; } ⋮---- /** * - * * Broker | Subaccount + * * Spot | Account * */ ⋮---- -export interface CreateSubAccountApiKeyRequestV2 { - subUid: string; - passphrase: string; - label?: string; - ipList: string[]; - permType: string; - permList: string[]; +export interface SpotAccountInfoV2 { + userId: string; + inviterId: string; + ips: string; + authorities: string[]; + parentId: number; + traderType: string; + channelCode: string; + channel: string; + regisTime: string; } ⋮---- -export interface ModifySubAccountApiKeyRequestV2 { - subUid: string; - apiKey: string; - label?: string; - passphrase: string; - ipList?: string[]; - permType?: string; - permList: string[]; +export interface SpotAccountAssetV2 { + coin: string; + available: string; + frozen: string; + locked: string; + limitAvailable: string; + uTime: string; } ⋮---- -/** - * - * * Broker | All Sub-accounts Deposit and Withdrawal Records - * - */ -⋮---- -export interface GetAllSubDepositWithdrawalRequestV2 { - startTime?: string; - endTime?: string; - limit?: string; - idLessThan?: string; - type?: 'all' | 'deposit' | 'withdrawal'; +export interface SpotSubAccountAssetV2 { + coin: string; + available: string; + limitAvailable: string; + frozen: string; + locked: string; + uTime: string; } -⋮---- -/** - * - * * Broker | Subaccounts - * - */ -⋮---- -export interface GetBrokerSubaccountsRequestV2 { - startTime?: string; - endTime?: string; - pageSize?: string; - pageNo?: string; +export interface SpotSubAccountAssetsV2 { + userId: number; + assetsList: SpotSubAccountAssetV2[]; } ⋮---- -/** - * - * * Broker | Commissions - * - */ -⋮---- -export interface GetBrokerCommissionsRequestV2 { - startTime?: string; - endTime?: string; - pageSize?: string; - pageNo?: string; - bizType?: 'spot' | 'futures'; - subBizType?: - | 'spot_trade' - | 'spot_margin' - | 'usdt_futures' - | 'usdc_futures' - | 'coin_futures'; +export interface SpotAccountBillV2 { + cTime: string; + coin: string; + groupType: string; + businessType: string; + size: string; + balance: string; + fees: string; + billId: string; } ⋮---- -/** - * - * * Broker | Trade Volume - * - */ -⋮---- -export interface GetBrokerTradeVolumeRequestV2 { - startTime?: string; - endTime?: string; - pageSize?: string; - pageNo?: string; +export interface SpotMainSubTransferRecordV2 { + coin: string; + status: string; + toType: string; + fromType: string; + size: string; + ts: string; + clientOid: string; + transferId: string; + fromUserId: string; + toUserId: string; } ⋮---- -/** - * - * * Broker | Total Commission - * - */ -⋮---- -export interface GetBrokerTotalCommissionRequestV2 { - startTime?: string; - endTime?: string; +export interface SpotTransferRecordV2 { + coin: string; + status: string; + toType: string; + toSymbol: string; + fromType: string; + fromSymbol: string; + size: string; + ts: string; + clientOid: string; + transferId: string; } ⋮---- -/** - * - * * Broker | Order Commission - * - */ -⋮---- -export interface GetBrokerOrderCommissionRequestV2 { - startTime?: string; - endTime?: string; - limit?: string; - uid?: string; - orderId?: string; - idLessThan?: string; +export interface SpotDepositAddressV2 { + address: string; + chain: string; + coin: string; + tag: string; + url: string; } ⋮---- -/** - * - * * Broker | Rebate Info - * - */ -⋮---- -export interface GetBrokerRebateInfoRequestV2 { - uid: string; +export interface SpotSubAccountDepositRecordV2 { + orderId: string; + tradeId: string; + coin: string; + size: string; + status: string; + toAddress: string; + dest: string; + chain: string; + fromAddress: string; + clientOid?: string; + confirm?: string; + tag?: string; + cTime: string; + uTime: string; } ⋮---- -/** - * - * * Broker | Agent (affiliate) customer APIs - * - */ -⋮---- -export interface GetAgentCustomerCommissionsRequestV2 { - startTime?: string; - endTime?: string; - idLessThan?: string; - limit?: string; - uid?: string; - coin?: string; - symbol?: string; - showSub?: 'yes' | 'no'; +export interface SpotWithdrawalRecordV2 { + orderId: string; + tradeId: string; + coin: string; + dest: string; + clientOid: string; + type: string; + tag: string; + size: string; + fee: string; + status: string; + toAddress: string; + fromAddress: string; + confirm: string; + chain: string; + cTime: string; + uTime: string; } ⋮---- -export interface GetAgentSubCustomerListRequestV2 { - startTime?: string; - endTime?: string; - idLessThan?: string; - limit?: string; - uid?: string; - showSub?: 'yes' | 'no'; +export interface SpotDepositRecordV2 { + orderId: string; + tradeId: string; + coin: string; + type: string; + size: string; + status: string; + toAddress: string; + dest: string; + chain: string; + fromAddress: string; + cTime: string; + uTime: string; } -⋮---- -export interface AgentCustomerTradeVolumeRequestV2 { - startTime?: string; - endTime?: string; - pageNo?: string; - pageSize?: string; - uid?: string; - showSub?: 'yes' | 'no'; + +================ +File: src/types/response/v3/broker.ts +================ +export interface CreateBrokerSubAccountResponseV3 { + subUid: string; + subaccountName: string; + subaccountEmail: string; + status: 'normal' | 'freeze'; + permList: string[]; + label: string; + cTime: string; } ⋮---- -export interface AgentCustomerListRequestV2 { - startTime?: string; - endTime?: string; - pageNo?: string; - pageSize?: string; - uid?: string; - referralCode?: string; - showSub?: 'yes' | 'no'; +export interface BrokerSubAccountV3 { + subUid: string; + subaccountName: string; + subaccountEmail: string | null; + status: 'normal' | 'freeze'; + permList: string[]; + label: string; + language: string; + cTime: string; + uTime: string; } ⋮---- -export interface GetAgentCustomerKycResultRequestV2 { - startTime?: string; - endTime?: string; - idLessThan?: string; - limit?: string; - uid?: string; - showSub?: 'yes' | 'no'; +export interface GetBrokerSubAccountListResponseV3 { + subList: BrokerSubAccountV3[]; } ⋮---- -export interface AgentCustomerDepositRequestV2 { - startTime?: string; - endTime?: string; - pageNo?: string; - pageSize?: string; - uid?: string; - showSub?: 'yes' | 'no'; +export interface ModifyBrokerSubAccountResponseV3 { + subUid: string; + subaccountName: string; + status: 'normal' | 'freeze'; + permList: string[]; + label: string; + cTime: string; + uTime: string; } ⋮---- -export interface AgentCustomerAssetRequestV2 { - pageNo?: string; - pageSize?: string; - uid?: string; - showSub?: 'yes' | 'no'; +export interface BrokerSubWithdrawalResponseV3 { + orderId: string; + clientOid: string; } ⋮---- -export interface GetAgentCommissionDetailRequestV2 { - startTime?: string; - endTime?: string; - limit?: string; - idLessThan?: string; +export interface BrokerSubDepositAddressV3 { + subUid: string; + coin: string; + address: string; + chain: string; + tag: string | null; + url: string; + cTime: string; } - -================ -File: src/types/request/v2/futures.ts -================ -import { FuturesPlanTypeV2, FuturesProductTypeV2 } from '../shared.js'; -⋮---- -export type FuturesKlineInterval = - | '1m' - | '3m' - | '5m' - | '15m' - | '30m' - | '1H' - | '2H' - | '4H' - | '6H' - | '12H' - | '1D' - | '3D' - | '1W' - | '1M' - | '6Hutc' - | '12Hutc' - | '1Dutc' - | '3Dutc' - | '1Wutc' - | '1Mutc'; -⋮---- -export type FuturesKlineTypeV2 = 'MARKET' | 'MARK' | 'INDEX'; ⋮---- -export interface FuturesAccountBillRequestV2 { - productType: FuturesProductTypeV2; - symbol?: string; - coin?: string; - businessType?: string; - idLessThan?: string; - startTime?: string; - endTime?: string; - limit?: string; +export interface BrokerSubDepositWithdrawalRecordV3 { + uid: string; + txId: string; + type: 'deposit' | 'withdrawal'; + subType: 'onchain' | 'internal' | 'fast'; + coin: string; + amount: string; + status: 'pending' | 'fail' | 'success'; + ts: string; } ⋮---- -/** - * - * * Futures | Market - * - */ -⋮---- -export interface FuturesMergeDepthRequestV2 { - symbol: string; - productType: FuturesProductTypeV2; - precision?: 'scale0' | 'scale1' | 'scale2' | 'scale3'; - limit?: '1' | '5' | '15' | '50' | 'max'; +export interface GetBrokerAllSubDepositWithdrawalResponseV3 { + list: BrokerSubDepositWithdrawalRecordV3[]; + endId: string; } ⋮---- -export interface FuturesRecentTradesRequestV2 { +export interface BrokerCommissionRecordV3 { + uid: string; + coin: string; symbol: string; - productType: FuturesProductTypeV2; - limit?: string; + dealtAmount: string; + totalFee: string; + deductedFee: string; + paidFee: string; + markUpFee: string; + totalCommission: string; } ⋮---- -export interface FuturesHistoricTradesRequestV2 { - symbol: string; - productType: FuturesProductTypeV2; - limit?: string; - idLessThan?: string; - startTime?: string; - endTime?: string; +export interface CreateBrokerSubApiKeyResponseV3 { + subUid: string; + label: string; + apiKey: string; + secretKey: string; + permType: 'read_write' | 'read_only'; + permList: string[]; + ipList: string[] | null; } ⋮---- -export interface FuturesCandlesRequestV2 { - symbol: string; - productType: FuturesProductTypeV2; - granularity: FuturesKlineInterval; - startTime?: string; - endTime?: string; - kLineType?: FuturesKlineTypeV2; - limit?: string; +export interface ModifyBrokerSubApiKeyResponseV3 { + subUid: string; + label: string; + apiKey: string; + permType: 'read_write' | 'read_only'; + permList: string[]; + ipList: string[]; } ⋮---- -/** - * - * * Futures | Account - * - */ -⋮---- -export interface FuturesSingleAccountRequestV2 { - symbol: string; - productType: FuturesProductTypeV2; - marginCoin: string; +export interface GetBrokerSubApiKeyResponseV3 { + subUid: string; + label: string; + apiKey: string; + secretKey: string; + permType: 'read_write' | 'read_only'; + permList: string[]; + ipList: string[] | null; } -⋮---- -export interface FuturesInterestHistoryRequestV2 { - productType: 'USDT-FUTURES' | 'SUSDT-FUTURES'; - coin?: string; - idLessThan?: string; - startTime?: string; - endTime?: string; - limit?: string; + +================ +File: src/types/response/v3/loan.ts +================ +export interface LoanTransfersV3 { + coin: string; + transfered: string; + userId: string; } ⋮---- -export interface FuturesOpenCountRequestV2 { +export interface LoanSymbolSettingV3 { symbol: string; - productType: FuturesProductTypeV2; - marginCoin: string; - openAmount: string; - openPrice: string; - leverage?: string; + leverage: string; } ⋮---- -export interface FuturesSetAutoMarginRequestV2 { - symbol: string; - autoMargin: 'on' | 'off'; - marginCoin: string; - amount: string; - holdSide?: 'long' | 'short'; +export interface LoanSymbolsV3 { + productId: string; + spotSymbols: string[]; + marginLeverage: string; + usdtContractLeverage: string; + coinContractLeverage: string; + usdcContractLeverage: string; + usdtContractSymbols: LoanSymbolSettingV3[]; + coinContractSymbols: LoanSymbolSettingV3[]; + usdcContractSymbols: LoanSymbolSettingV3[]; } ⋮---- -export interface FuturesSetLeverageRequestV2 { - symbol: string; - productType: FuturesProductTypeV2; - marginCoin: string; - leverage: string; - holdSide?: 'long' | 'short'; +export interface RepaidHistoryItemV3 { + repayOrderId: string; + businessType: 'normal' | 'liquidation'; + repayType: 'all' | 'part'; + repaidTime: string; + coin: string; + repayAmount: string; + repayInterest: string; } ⋮---- -export interface FuturesSetPositionMarginRequestV2 { - symbol: string; - productType: FuturesProductTypeV2; - marginCoin: string; - holdSide: 'long' | 'short'; - amount: string; +export interface LoanProductInfoV3 { + productId: string; + leverage: string; + supportUsdtContract: 'YES' | 'NO'; + supportCoinContract: 'YES' | 'NO'; + supportUsdcContract: 'YES' | 'NO'; + transferLine: string; + spotBuyLine: string; + usdtContractOpenLine: string; + coinContractOpenLine: string; + usdcContractOpenLine: string; + liquidationLine: string; + stopLiquidationLine: string; } ⋮---- -export interface FuturesSetMarginModeRequestV2 { - symbol: string; - productType: FuturesProductTypeV2; - marginCoin: string; - marginMode: 'isolated' | 'crossed'; +export interface LoanOrderV3 { + orderId: string; + orderProductId: string; + uid: string; + loanTime: string; + loanCoin: string; + loanAmount: string; + unpaidAmount: string; + unpaidInterest: string; + repaidAmount: string; + repaidInterest: string; + reserve: string; + status: 'not_paid_off' | 'paid_off'; } ⋮---- -/** - * - * * Futures | Position - * - */ +/** Tiered conversion rate item (when Tiered Discount Rate Model is enabled) */ +export interface ConvertRatioListItemV3 { + ladder: string; + convertRatio: string; +} ⋮---- -export interface FuturesHistoricalPositionsRequestV2 { - symbol?: string; - productType?: FuturesProductTypeV2; - idLessThan?: string; - startTime?: string; - endTime?: string; - limit?: string; +export interface CoinInfoV3 { + coin: string; + convertRatio: string; + maxConvertValue: string; + /** Tiered conversion rate (when margin mode is Tiered Discount Rate Model) */ + convertRatioList?: ConvertRatioListItemV3[]; } ⋮---- -/** - * - * * Futures | Trade - * - */ +/** Tiered conversion rate (when margin mode is Tiered Discount Rate Model) */ ⋮---- -export interface FuturesPlaceOrderRequestV2 { - symbol: string; - productType: FuturesProductTypeV2; - marginMode: 'isolated' | 'crossed'; - marginCoin: string; - size: string; - price?: string; - side: 'buy' | 'sell'; - tradeSide?: 'open' | 'close'; - orderType: 'limit' | 'market'; - force?: 'ioc' | 'fok' | 'gtc' | 'post_only'; - clientOid?: string; - reduceOnly?: 'YES' | 'NO'; - presetStopSurplusPrice?: string; - presetStopLossPrice?: string; - stpMode?: 'none' | 'cancel_taker' | 'cancel_maker' | 'cancel_both'; +export interface BindUidResponseV3 { + riskUnitId: string; + uid: string; + operate: 'bind' | 'unbind'; } ⋮---- -export interface FuturesReversalOrderRequestV2 { - symbol: string; - productType: FuturesProductTypeV2; - marginCoin: string; - size: string; - side?: 'buy' | 'sell'; - tradeSide?: 'open' | 'close'; - clientOid?: string; +export interface UnpaidInfoV3 { + coin: string; + unpaidQty: string; + unpaidInterest: string; } ⋮---- -interface FuturesBatchOrderItem { - size: string; - price?: string; - side: 'buy' | 'sell'; - tradeSide?: 'open' | 'close'; - orderType: 'limit' | 'market'; - force?: 'ioc' | 'fok' | 'gtc' | 'post_only'; - clientOid?: string; - reduceOnly?: 'YES' | 'NO'; - presetStopSurplusPrice?: string; - presetStopLossPrice?: string; - stpMode?: 'none' | 'cancel_taker' | 'cancel_maker' | 'cancel_both'; +export interface BalanceInfoV3 { + coin: string; + price: string; + amount: string; + convertedUsdtAmount: string; } ⋮---- -export interface FuturesBatchOrderRequestV2 { - symbol: string; - productType: FuturesProductTypeV2; - marginCoin: string; - marginMode: 'isolated' | 'crossed'; - orderList: FuturesBatchOrderItem[]; +export interface LTVConvertResponseV3 { + ltv: string; + subAccountUids: string[]; + unpaidUsdtAmount: string; + usdtBalance: string; + unpaidInfo: UnpaidInfoV3[]; + balanceInfo: BalanceInfoV3[]; } ⋮---- -export interface FuturesModifyOrderRequestV2 { - orderId?: string; - clientOid?: string; - symbol: string; - productType: FuturesProductTypeV2; - newClientOid: string; - newSize?: string; - newPrice?: string; - newPresetStopSurplusPrice?: string; - newPresetStopLossPrice?: string; +/* Unified Account Staking & Lending (Crypto Loans) - /api/v3/loan/* */ +⋮---- +export interface LoanCoinInfoV3 { + coin: string; + hourRateFlexible: string; + rateFlexible: string; + hourRate7D: string; + rate7D: string; + hourRate30D: string; + rate30D: string; + minBorrowAmount: string; + maxBorrowAmount: string; + minBorrowLimit: string; + maxBorrowLimit: string; } ⋮---- -export interface FuturesCancelOrderRequestV2 { - symbol: string; - productType: FuturesProductTypeV2; - marginCoin?: string; - orderId?: string; - clientOid?: string; +export interface LoanPledgeInfoV3 { + coin: string; + initRate: string; + supRate: string; + forceRate: string; + minPledgeAmount: string; + maxPledgeAmount: string; } ⋮---- -interface FuturesBatchCancelOrderItem { - orderId?: string; - clientOid?: string; +export interface GetLoanCoinsResponseV3 { + loanInfos: LoanCoinInfoV3[]; + pledgeInfos: LoanPledgeInfoV3[]; } ⋮---- -export interface FuturesBatchCancelOrderRequestV2 { - orderIdList?: FuturesBatchCancelOrderItem[]; - symbol?: string; - productType: FuturesProductTypeV2; - marginCoin?: string; +export interface GetLoanInterestResponseV3 { + hourInterest: string; + loanAmount: string; } ⋮---- -export interface FuturesFlashClosePositionsRequestV2 { - symbol?: string; - productType: FuturesProductTypeV2; - holdSide?: 'long' | 'short'; +export interface LoanBorrowResponseV3 { + orderId: string; } ⋮---- -export interface FuturesGetOrderRequestV2 { - symbol: string; - productType: FuturesProductTypeV2; - orderId?: string; - clientOid?: string; +export interface LoanBorrowOngoingItemV3 { + orderId: string; + loanCoin: string; + loanAmount: string; + interestAmount: string; + hourInterestRate: string; + pledgeCoin: string; + pledgeAmount: string; + pledgeRate: string; + supRate: string; + forceRate: string; + borrowTime: string; + expireTime: string; } ⋮---- -export interface FuturesGetOrderFillsRequestV2 { - orderId?: string; - symbol?: string; - productType: FuturesProductTypeV2; - idLessThan?: string; - startTime?: string; - endTime?: string; - limit?: string; +export interface LoanBorrowHistoryItemV3 { + orderId: string; + loanCoin: string; + pledgeCoin: string; + initPledgeAmount: string; + initLoanAmount: string; + hourRate: string; + daily: string; + borrowTime: string; + status: string; } ⋮---- -export interface FuturesGetHistoricalFillsRequestV2 { - orderId?: string; - symbol?: string; - productType: FuturesProductTypeV2; - startTime?: string; - endTime?: string; - idLessThan?: string; - limit?: string; +export interface LoanRepayResponseV3 { + loanCoin: string; + pledgeCoin: string; + repayAmount: string; + payInterest: string; + repayLoanAmount: string; + repayUnlockAmount: string; } ⋮---- -export interface FuturesGetOpenOrdersRequestV2 { - orderId?: string; - clientOid?: string; - symbol?: string; - productType: FuturesProductTypeV2; - status?: 'live' | 'partially_filled'; - idLessThan?: string; - startTime?: string; - endTime?: string; - limit?: string; +export interface LoanRepayHistoryItemV3 { + orderId: string; + loanCoin: string; + pledgeCoin: string; + repayAmount: string; + payInterest: string; + repayLoanAmount: string; + repayUnlockAmount: string; + repayTime: string; } ⋮---- -export type FuturesOrderSourceV2 = - | 'normal' - | 'market' - | 'profit_market' - | 'loss_market' - | 'Trader_delegate' - | 'trader_profit' - | 'trader_loss' - | 'reverse' - | 'trader_reverse' - | 'profit_limit' - | 'loss_limit' - | 'liquidation' - | 'delivery_close_long' - | 'delivery_close_short' - | 'pos_profit_limit' - | 'pos_profit_market' - | 'pos_loss_limit' - | 'pos_loss_market'; -⋮---- -export interface FuturesGetHistoryOrdersRequestV2 { - orderId?: string; - clientOid?: string; - symbol?: string; - productType: FuturesProductTypeV2; - idLessThan?: string; - orderSource?: FuturesOrderSourceV2; - startTime?: string; - endTime?: string; - limit?: string; +export interface LoanRevisePledgeResponseV3 { + loanCoin: string; + pledgeCoin: string; + afterPledgeRate: string; } ⋮---- -export interface FuturesCancelAllOrdersRequestV2 { - symbol?: string; - productType: FuturesProductTypeV2; - marginCoin?: string; - requestTime?: string; - receiveWindow?: string; +export interface LoanPledgeRateHistoryItemV3 { + loanCoin: string; + pledgeCoin: string; + orderId: string; + reviseTime: string; + reviseSide: string; + reviseAmount: string; + afterPledgeRate: string; + beforePledgeRate: string; } ⋮---- -/** - * - * * Futures | Trigger Orders - * - */ -⋮---- -export type FuturesTriggerTypeV2 = 'fill_price' | 'mark_price'; -⋮---- -export type FuturesStpModeV2 = - | 'none' - | 'cancel_taker' - | 'cancel_maker' - | 'cancel_both'; +export interface LoanDebtInfoV3 { + coin: string; + amount: string; + amountUsdt: string; +} ⋮---- -export interface FuturesTPSLOrderRequestV2 { - marginCoin: string; - productType: FuturesProductTypeV2; - symbol: string; - planType: FuturesPlanTypeV2; - triggerPrice: string; - triggerType?: FuturesTriggerTypeV2; - executePrice?: string; - holdSide: 'long' | 'short' | 'buy' | 'sell'; - size: string; - rangeRate?: string; - clientOid?: string; - stpMode?: FuturesStpModeV2; +export interface GetLoanDebtsResponseV3 { + pledgeInfos: LoanDebtInfoV3[]; + loanInfos: LoanDebtInfoV3[]; } ⋮---- -export type FuturesTriggerPriceTypeV2 = - | 'fill_price' - | 'mark_price' - | 'index_price'; +export interface LoanReduceItemV3 { + orderId: string; + loanCoin: string; + pledgeCoin: string; + reduceTime: string; + pledgeRate: string; + pledgePrice: string; + status: string; + pledgeAmount: string; + reduceFee: string; + residueAmount: string; + runlockAmount: string; + repayLoanAmount: string; +} + +================ +File: src/types/websockets/ws-api-request.ts +================ +import type { FuturesMarginModeV3 } from '../request/v3/trade.js'; ⋮---- -export interface FuturesPlanOrderRequestV2 { - planType: 'normal_plan' | 'track_plan'; +export interface WSAPIPlaceOrderRequestV3 { symbol: string; - productType: FuturesProductTypeV2; - marginMode: 'isolated' | 'crossed'; - marginCoin: string; - size: string; + orderType: 'limit' | 'market'; + qty: string; price?: string; - callbackRatio?: string; - triggerPrice: string; - triggerType: 'mark_price' | 'fill_price'; side: 'buy' | 'sell'; - tradeSide?: 'open' | 'close'; - orderType: 'limit' | 'market'; + posSide?: 'long' | 'short'; + timeInForce?: 'gtc' | 'ioc' | 'fok' | 'post_only'; + reduceOnly?: 'YES' | 'NO'; // Note: reduceOnly is not supported for batch place WS API. Might be supported starting late Q4 2025, but not supported yet. + /** Futures only. Defaults to crossed */ + marginMode?: FuturesMarginModeV3; clientOid?: string; - reduceOnly?: 'YES' | 'NO'; - stopSurplusTriggerPrice?: string; - stopSurplusExecutePrice?: string; - stopSurplusTriggerType?: FuturesTriggerPriceTypeV2; - stopLossTriggerPrice?: string; - stopLossExecutePrice?: string; - stopLossTriggerType?: FuturesTriggerPriceTypeV2; - stpMode?: FuturesStpModeV2; + stpMode?: 'none' | 'cancel_taker' | 'cancel_maker' | 'cancel_both'; + tpTriggerBy?: 'market' | 'mark'; + slTriggerBy?: 'market' | 'mark'; + takeProfit?: string; + stopLoss?: string; + tpOrderType?: 'limit' | 'market'; + slOrderType?: 'limit' | 'market'; + tpLimitPrice?: string; + slLimitPrice?: string; + /** Order TTL in ms [10, 60000]. Only effective when requestTime is also set on the envelope */ + receiveWindow?: string; } ⋮---- -export interface FuturesModifyTPSLOrderRequestV2 { - orderId?: string; - clientOid?: string; - marginCoin: string; - productType: FuturesProductTypeV2; - symbol: string; - triggerPrice: string; - triggerType?: 'fill_price' | 'mark_price'; - executePrice?: string; - size: string; - rangeRate?: string; -} +reduceOnly?: 'YES' | 'NO'; // Note: reduceOnly is not supported for batch place WS API. Might be supported starting late Q4 2025, but not supported yet. +/** Futures only. Defaults to crossed */ ⋮---- -export interface FuturesModifyPlanOrderRequestV2 { - planType: 'normal_plan' | 'track_plan'; - orderId?: string; - clientOid?: string; - symbol: string; - productType: FuturesProductTypeV2; - newSize?: string; - newPrice?: string; - newCallbackRatio?: string; - newTriggerPrice?: string; - newTriggerType?: 'fill_price' | 'mark_price'; - newStopSurplusTriggerPrice?: string; - newStopSurplusExecutePrice?: string; - newStopSurplusTriggerType?: FuturesTriggerPriceTypeV2; - newStopLossTriggerPrice?: string; - newStopLossExecutePrice?: string; - newStopLossTriggerType?: FuturesTriggerPriceTypeV2; -} +/** Order TTL in ms [10, 60000]. Only effective when requestTime is also set on the envelope */ + +================ +File: src/types/websockets/ws-api.ts +================ +import { WS_KEY_MAP } from '../../util/websocket-util.js'; +import { CancelOrderRequestV3 } from '../request/v3/trade.js'; +import { CancelOrderResponseV3 } from '../response/v3/trade.js'; +import { WSAPIPlaceOrderRequestV3 } from './ws-api-request.js'; +import { WSAPIPlaceOrderResponseV3 } from './ws-api-response.js'; +import { BitgetInstTypeV3, WsKey } from './ws-general.js'; ⋮---- -export interface FuturesGetPlanOrdersRequestV2 { - orderId?: string; - clientOid?: string; - symbol?: string; - planType: 'normal_plan' | 'track_plan' | 'profit_loss'; - productType: FuturesProductTypeV2; - idLessThan?: string; - startTime?: string; - endTime?: string; - limit?: string; +export type WSOperation = 'subscribe' | 'unsubscribe' | 'login'; +⋮---- +// When new WS API operations are added, make sure to also update WS_API_Operations[] below +export type WSAPIOperation = + | 'place-order' + | 'batch-place' + | 'cancel-order' + | 'batch-cancel'; +⋮---- +export interface WSOperationLoginParams { + apiKey: string; + passphrase: string; + timestamp: number; + sign: string; } ⋮---- -interface FuturesCancelPlanOrderItemV2 { - orderId?: string; - clientOid?: string; +export interface WSAPIRequestBitgetV3 { + op: 'trade'; + id: string; + category: BitgetInstTypeV3; + topic: WSAPIOperation; + args: TWSParams | TWSParams[]; + /** Client-side request timestamp; required for receiveWindow on place-order */ + requestTime?: string; } ⋮---- -export type FuturesPlanOrderTypeV2 = - | 'normal_plan' - | 'profit_plan' - | 'loss_plan' - | 'pos_profit' - | 'pos_loss' - | 'moving_plan'; +/** Client-side request timestamp; required for receiveWindow on place-order */ ⋮---- -export interface FuturesCancelPlanOrderRequestV2 { - orderIdList?: FuturesCancelPlanOrderItemV2[]; - symbol?: string; - productType: FuturesProductTypeV2; - marginCoin?: string; - planType?: FuturesPlanOrderTypeV2; +export interface WSAPIRequestFlags { + /** If true, will skip auth requirement for WS API connection */ + authIsOptional?: boolean | undefined; } ⋮---- -export type FuturesPlanStatusV2 = 'executed' | 'fail_trigger' | 'cancelled'; +/** If true, will skip auth requirement for WS API connection */ ⋮---- -export interface FuturesGetHistoryPlanOrdersRequestV2 { - orderId?: string; - clientOid?: string; - planType: 'normal_plan' | 'track_plan' | 'profit_loss'; - planStatus?: FuturesPlanStatusV2; - symbol?: string; - productType: FuturesProductTypeV2; - idLessThan?: string; - startTime?: string; - endTime?: string; - limit?: string; -} +export type Exact = { + // This part says: if there's any key that's not in T, it's an error + [K: string]: never; +} & { + [K in keyof T]: T[K]; +}; +⋮---- +// This part says: if there's any key that's not in T, it's an error ⋮---- /** - * - * * Futures | Union Margin - * + +/** + * V2 request looks like this: +{ + "op":"subscribe", + "args":[ + { + "instType":"SPOT", + "channel":"ticker", + "instId":"BTCUSDT" + }, + { + "instType":"SPOT", + "channel":"candle5m", + "instId":"BTCUSDT" + } + ] +} */ -⋮---- -export interface GetUnionTransferLimitsRequestV2 { - coin: string; +export interface WsRequestOperationBitget { + op: WSOperation; + args?: (TWSRequestArg | string | number)[]; +} +export interface WSAPIRateLimitV3 { + limit: string; + remaining: string; } ⋮---- -export interface UnionConvertRequestV2 { - coin: string; - amount: string; +export interface WSAPIResponse< + TResponseData extends object = object, + TOperation extends WSAPIOperation = WSAPIOperation, +> { + wsKey: WsKey; + /** Auto-generated */ + id: string; + event: 'trade'; + category: BitgetInstTypeV3; + topic: TOperation; + args: TResponseData; + code: '0' | string; + msg: 'success' | string; + ts: string; + /** Connection ID (trade operation responses, May 2026+) */ + connId?: string; + /** Gateway receive time, Unix microseconds */ + receiveTime?: string; + /** Gateway push time, Unix microseconds */ + pushTime?: string; + rateLimit?: WSAPIRateLimitV3[]; } ⋮---- +/** Auto-generated */ +⋮---- +/** Connection ID (trade operation responses, May 2026+) */ +⋮---- +/** Gateway receive time, Unix microseconds */ +⋮---- +/** Gateway push time, Unix microseconds */ +⋮---- /** - * - * * Futures | Account | Max Openable Quantity - * + * List of operations supported for this WsKey (connection) */ -⋮---- -export interface FuturesMaxOpenRequestV2 { - symbol: string; - productType: FuturesProductTypeV2; - marginCoin: string; - posSide: 'long' | 'short'; - orderType: 'limit' | 'market'; - openPrice?: string; +export interface WsAPIWsKeyTopicMap { + [WS_KEY_MAP.v3Private]: WSAPIOperation; } ⋮---- /** - * - * * Futures | Account | Liquidation Price - * + * Request parameters expected per operation */ -⋮---- -export interface FuturesLiquidationPriceRequestV2 { - symbol: string; - productType: FuturesProductTypeV2; - marginCoin: string; - posSide: 'long' | 'short'; - orderType: 'limit' | 'market'; - openAmount: string; - openPrice?: string; +export interface WsAPITopicRequestParamMap { + // https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters + 'place-order': WSAPIPlaceOrderRequestV3; + // https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel + 'batch-place': WSAPIPlaceOrderRequestV3[]; + // https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel + 'cancel-order': CancelOrderRequestV3; + // https://www.bitget.com/api-doc/uta/websocket/private/Batch-Cancel-Order-Channel + 'batch-cancel': CancelOrderRequestV3[]; } ⋮---- +// https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters +⋮---- +// https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel +⋮---- +// https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel +⋮---- +// https://www.bitget.com/api-doc/uta/websocket/private/Batch-Cancel-Order-Channel +⋮---- /** - * - * * Futures | Account | Isolated Symbols - * + * Response structure expected for each operation */ -⋮---- -export interface FuturesIsolatedSymbolsRequestV2 { - productType: FuturesProductTypeV2; +export interface WsAPIOperationResponseMap { + // https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters + 'place-order': WSAPIResponse<[WSAPIPlaceOrderResponseV3], 'place-order'>; + // https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel + 'batch-place': WSAPIResponse; + // https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel + 'cancel-order': WSAPIResponse<[CancelOrderResponseV3], 'cancel-order'>; + // https://www.bitget.com/api-doc/uta/websocket/private/Batch-Cancel-Order-Channel + 'batch-cancel': WSAPIResponse; } +⋮---- +// https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters +⋮---- +// https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel +⋮---- +// https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel +⋮---- +// https://www.bitget.com/api-doc/uta/websocket/private/Batch-Cancel-Order-Channel ================ -File: src/types/request/v3/public.ts +File: src/types/websockets/ws-events.ts ================ -export interface GetPublicFillsRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol?: string; - limit?: string; +export interface MessageEventLike { + target: WebSocket; + type: 'message'; + data: string; } ⋮---- -export interface GetCandlesRequestV3 { - category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol: string; - interval: - | '1m' - | '3m' - | '5m' - | '15m' - | '30m' - | '1H' - | '4H' - | '6H' - | '12H' - | '1D'; - startTime?: string; - endTime?: string; - type?: 'MARKET' | 'MARK' | 'INDEX'; - limit?: string; +export function isMessageEvent(msg: unknown): msg is MessageEventLike +⋮---- +export interface WsBaseEvent { + action: TAction; + arg: unknown; + data: TData[]; } ⋮---- -export interface GetHistoryCandlesRequestV3 { - category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol: string; - interval: - | '1m' - | '3m' - | '5m' - | '15m' - | '30m' - | '1H' - | '4H' - | '6H' - | '12H' - | '1D'; - startTime?: string; - endTime?: string; - type?: 'MARKET' | 'MARK' | 'INDEX'; - limit?: string; +export interface WsSnapshotChannelEvent extends WsBaseEvent<'snapshot'> { + arg: { + instType: string; + channel: string; + instId: string; + }; } ⋮---- -export interface GetContractsOiRequestV3 { - symbol?: string; - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; +export interface WsSnapshotAccountEvent extends WsBaseEvent<'snapshot'> { + arg: { + instType: string; + channel: 'account'; + instId: string; + }; } ⋮---- -export interface GetCurrentFundingRateRequestV3 { - category?: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; +export interface WsSnapshotPositionsEvent extends WsBaseEvent<'snapshot'> { + arg: { + instType: string; + channel: 'positions'; + instId: string; + }; } ⋮---- -export interface GetLiquidationsRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - limit?: string; - cursor?: string; +export interface WsAccountSnapshotDataUMCBL { + marginCoin: string; + locked: string; + available: string; + maxOpenPosAvailable: string; + maxTransferOut: string; + equity: string; + usdtEquity: string; } ⋮---- -export interface GetHistoryFundingRateRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol: string; - cursor?: string; - limit?: string; +export interface WsAccountSnapshotUMCBL extends WsBaseEvent<'snapshot'> { + arg: { + instType: 'umcbl'; + channel: 'account'; + instId: string; + }; + data: WsAccountSnapshotDataUMCBL[]; } ⋮---- -export interface GetMarginLoansRequestV3 { - coin: string; +export interface WsPositionSnapshotDataUMCBL { + posId: string; + instId: string; + instName: string; + marginCoin: string; + margin: string; + marginMode: string; + holdSide: string; + holdMode: string; + total: string; + available: string; + locked: string; + averageOpenPrice: string; + leverage: number; + achievedProfits: string; + upl: string; + uplRate: string; + liqPx: string; + keepMarginRate: string; + marginRate: string; + cTime: string; + uTime: string; + markPrice: string; + /** Cash dividend, USDT (Classic V2 positions channel) */ + cashDividend?: string; } ⋮---- -export interface GetOpenInterestRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; -} +/** Cash dividend, USDT (Classic V2 positions channel) */ ⋮---- -export interface GetPositionTierRequestV3 { - category: 'MARGIN' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - coin?: string; +/** UTA reality-orderbook push (ts/seq/pseq removed July 2026) */ +export interface WsRealityOrderBookDataV3 { + a: [string, string][]; + b: [string, string][]; } ⋮---- -export interface GetRiskReserveRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol: string; - marginCoin?: string; +export interface WSPositionSnapshotUMCBL extends WsBaseEvent<'snapshot'> { + arg: { + instType: 'umcbl'; + channel: 'positions'; + instId: string; + }; + data: WsPositionSnapshotDataUMCBL[]; } ⋮---- -export interface GetRiskReserveAllRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; +/** Classic V2 depth channel push data. checksum removed May 2026 - use seq instead */ +export interface WsDepthBookDataV2 { + asks: [string, string][]; + bids: [string, string][]; + ts: string; + seq: string; + /** Futures books channel only - previous push serial number */ + pseq?: string; } ⋮---- -export interface GetInstrumentsRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol?: string; -} +/** Futures books channel only - previous push serial number */ + +================ +File: src/websocket-client-v3.ts +================ +import { + WsAPIOperationResponseMap, + WSAPIRequestBitgetV3, + WSAPIRequestFlags, + WsAPITopicRequestParamMap, + WsAPIWsKeyTopicMap, + WSOperation, + WSOperationLoginParams, + WsRequestOperationBitget, +} from './types/websockets/ws-api.js'; +import { MessageEventLike } from './types/websockets/ws-events.js'; +import { + BitgetInstTypeV3, + WsKey, + WsTopicV3, +} from './types/websockets/ws-general.js'; +import { + BaseWebsocketClient, + EmittableEvent, + MidflightWsRequestEvent, +} from './util/BaseWSClient.js'; +import { isWsPong } from './util/requestUtils.js'; +import { isWSAPIResponse } from './util/type-guards.js'; +import { SignAlgorithm, signMessage } from './util/webCryptoAPI.js'; +import { + getMaxTopicsPerSubscribeEvent, + getNormalisedTopicRequests, + getPromiseRefForWSAPIRequest, + getWsUrl, + WS_AUTH_ON_CONNECT_KEYS, + WS_KEY_MAP, + WS_LOGGER_CATEGORY, + WsTopicRequest, +} from './util/websocket-util.js'; +import { WSConnectedResult } from './util/WsStore.types.js'; ⋮---- -export interface GetMarketFeeGroupRequestV3 { - category: 'SPOT' | 'FUTURES'; - group?: 'DEFAULT' | 'GROUP_A' | 'GROUP_B' | 'GROUP_C'; -} +/** + * WebSocket client dedicated to the unified account (V3) WebSockets. + * + * Your Bitget account needs to be upgraded to unified account mode, to use the account-level WebSocket topics. + */ +export class WebsocketClientV3 extends BaseWebsocketClient< ⋮---- -export interface GetMarketScoreWeightsRequestV3 { - category?: 'SPOT' | 'FUTURES'; -} +WsRequestOperationBitget // subscribe requests have an "args" parameter with an object within ⋮---- -export interface GetOrderBookRequestV3 { - category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol: string; - limit?: string; -} +/** + * Request connection of all dependent (public & private) websockets, instead of waiting for automatic connection by library + */ +public connectAll(): Promise[] ⋮---- -export interface GetTickersRequestV3 { - category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; -} +/** + * Ensures the WS API connection is active and ready. + * + * You do not need to call this, but if you call this before making any WS API requests, + * it can accelerate the first request (by preparing the connection in advance). + */ +public connectWSAPI(): Promise ⋮---- -export interface GetIndexComponentsRequestV3 { - symbol: string; -} +/** This call automatically ensures the connection is active AND authenticated before resolving */ ⋮---- -export interface GetRpiOrderBookRequestV3 { - category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol: string; - limit?: string; -} +/** + * Request subscription to one or more topics. Pass topics as either an array of strings, + * or array of objects (if the topic has parameters). + * + * Objects should be formatted as {topic: string, params: object, category: CategoryV5}. + * + * - Subscriptions are automatically routed to the correct websocket connection. + * - Authentication/connection is automatic. + * - Resubscribe after network issues is automatic. + * + * Call `unsubscribe(topics)` to remove topics + */ +public subscribe( + requests: + | (WsTopicRequest | WsTopicV3) + | (WsTopicRequest | WsTopicV3)[], + wsKey: WsKey, +): Promise ⋮---- -export interface GetCashDividendRecordsRequestV3 { - symbol: string; - type: 'pending' | 'paid'; - cursor?: string; - limit?: string; -} +/** + * Unsubscribe from one or more topics. Similar to subscribe() but in reverse. + * + * - Requests are automatically routed to the correct websocket connection. + * - These topics will be removed from the topic cache, so they won't be subscribed to again. + */ +public unsubscribe( + requests: + | (WsTopicRequest | WsTopicV3) + | (WsTopicRequest | WsTopicV3)[], + wsKey: WsKey, +) ⋮---- -export interface GetSpotWhaleFlowRequestV3 { - symbol: string; -} +/** + * + * + * Internal methods required to integrate with the BaseWSClient + * + * + */ ⋮---- -export interface GetSpotFundFlowRequestV3 { - symbol: string; - period?: string; -} +protected sendPingEvent(wsKey: WsKey): void ⋮---- -export interface GetSpotNetFlowRequestV3 { - symbol: string; -} +protected sendPongEvent(wsKey: WsKey): void ⋮---- -export interface GetMarginLongShortRequestV3 { - symbol: string; - period?: '24h' | '30d'; - coin?: string; -} +protected isWsPing(data: any): boolean ⋮---- -export interface GetMarginLoanGrowthRequestV3 { - symbol: string; - period?: string; - coin?: string; -} +protected isWsPong(data: any): boolean ⋮---- -export interface GetMarginIsolatedBorrowRequestV3 { - symbol: string; - period?: string; -} +protected isPrivateTopicRequest( + _request: WsTopicRequest, + wsKey: WsKey, +): boolean ⋮---- -export interface GetFuturesTradingDataRequestV3 { - symbol: string; - period?: string; -} - -================ -File: src/types/response/v2/broker.ts -================ -/** - * - * * Broker | Subaccount - * - */ +protected getPrivateWSKeys(): WsKey[] ⋮---- -export interface CreateSubaccountResponseV2 { - subUid: string; - subaccountName: string; - status: string; - permList: string[]; - label: string; - cTime: string; -} +protected isAuthOnConnectWsKey(wsKey: WsKey): boolean ⋮---- -export interface BrokerSubaccountV2 { - subUid: string; - subaccountName: string; - status: string; - permList: string[]; - label: string; - language: string; - cTime: string; - uTime: string; -} +protected async getWsUrl(wsKey: WsKey): Promise ⋮---- -export interface ModifySubaccountResponseV2 { - subUid: string; - subaccountName: string; - status: string; - permList: string[]; - label: string; - language: string; - cTime: string; - uTime: string; -} +protected getMaxTopicsPerSubscribeEvent(wsKey: WsKey): number | null ⋮---- -export interface SubaccountEmailV2 { - subUid: string; - subaccountName: string; - subaccountEmail: string; - cTime: string; - uTime: string; -} +/** + * @returns one or more correctly structured request events for performing a operations over WS. This can vary per exchange spec. + */ +protected async getWsRequestEvents( + operation: WSOperation, + requests: WsTopicRequest[], +): Promise>[]> ⋮---- -export interface BrokerSubaccountSpotAssetV2 { - coin: string; - available: string; - frozen: string; - locked: string; - uTime: string; -} +// Previously used to track topics in a request. Keeping this for subscribe/unsubscribe requests, no need for incremental values ⋮---- -export interface BrokerSubaccountFutureAssetV2 { - marginCoin: string; - available: string; - frozen: string; - locked: string; - crossedMaxAvailable: string; - isolatedMaxAvailable: string; - maxTransferOut: string; - accountEquity: string; - usdtEquity: string; - btcEquity: string; - uTime: string; -} +/** + { + "op":"subscribe", + "args":[ + { + "instType":"spot", + "topic":"ticker", + "symbol":"BTCUSDT" + }, + { + "instType":"spot", + "topic":"candle5m", + "symbol":"BTCUSDT" + } + ] + } + */ ⋮---- -export interface CreateSubaccountDepositAddressV2 { - subUid: string; - coin: string; - address: string; - chain: string; - tag: string; - url: string; - cTime: string; -} +// const request = { +// topic: 'ticker', +// payload: { instType: 'spot', symbol: 'BTCUSDT' }, +// }; +// becomes: +// const request = { +// topic: 'ticker', +// instType: 'spot', +// symbol: 'BTCUSDT', +// }; ⋮---- -export interface SubaccountDepositV2 { - orderId: string; - txId: string; - coin: string; - type: string; - dest: string; - amount: string; - status: string; - fromAddress: string; - toAddress: string; - fee: string; - chain: string; - confirm: string; - tag: string; - cTime: string; - uTime: string; -} +private async getWsAuthSignature( + wsKey: WsKey, +): Promise< ⋮---- -export interface BrokerSubaccountWithdrawalV2 { - orderId: string; - txId: string; - coin: string; - type: string; - dest: string; - amount: string; - status: string; - fromAddress: string; - toAddress: string; - fee: string; - chain: string; - confirm: string; - tag: string; - userId: string; - cTime: string; - uTime: string; -} +private async signMessage( + paramsStr: string, + secret: string, + method: 'hex' | 'base64', + algorithm: SignAlgorithm, +): Promise +⋮---- +protected async getWsAuthRequestEvent( + wsKey: WsKey, +): Promise> ⋮---- /** - * - * Broker | Api Key - * - */ + * Abstraction called to sort ws events into emittable event types (response to a request, data update, etc) + */ +protected resolveEmittableEvents( + wsKey: WsKey, + event: MessageEventLike, +): EmittableEvent[] ⋮---- -export interface CreateSubaccountApiKeyResponseV2 { - subUid: string; - apiKey: string; - secretKey: string; - label: string; - ipList: string[]; - permType: string; - permList: string[]; -} +/** + * WS API response handling + */ ⋮---- -export interface SubaccountApiKeyV2 { - subUid: string; - label: string; - apiKey: string; - secretKey: string; - permType: string; - permList: string[]; - ipList: string[]; -} +// const eg1 = { +// event: 'error', +// id: '1', +// code: '43012', +// msg: 'Insufficient balance', +// }; ⋮---- -export interface ModifySubaccountApiKeyResponseV2 { - subUid: string; - apiKey: string; - label: string; - ipList: string[]; - permType: string; - permList: string[]; -} +// WS API Success ⋮---- /** - * - * * Broker | All Sub-accounts Deposit and Withdrawal Records - * - */ + * V3 event handling for consumers - behaves the same as V2 + */ ⋮---- -export interface AllSubDepositWithdrawalRecordV2 { - uid: string; - txId: string; - type: 'deposit' | 'withdrawal'; - subType: 'onchain' | 'internal' | 'fast'; - coin: string; - amount: string; - status: 'pending' | 'fail' | 'success'; - ts: string; -} +// v2 authentication event ⋮---- -/** - * - * * Broker | Subaccounts - * - */ +// messageType: typeof msg, +// messageString: JSON.stringify(msg), ⋮---- -export interface BrokerSubaccountInfoV2 { - uid: string; - asset: string; - firstTimeDeposit: string; - firstTimeTrade: string; - registerTime: string; -} +// Service upgrade (30033): Bitget sends this ~60s before disconnect. Log and let automatic reconnect handle when connection drops. +⋮---- +// messageType: typeof msg, +// messageString: JSON.stringify(msg), +⋮---- +// fallback emit anyway ⋮---- /** - * - * * Broker | Commissions - * - */ -⋮---- -export interface BrokerCommissionV2 { - uid: string; - coin: string; - symbol: string; - dealtAmount: string; - totalFee: string; - deductedFee: string; - paidFee: string; - markUpFee: string; - totalCommission: string; -} -⋮---- -/** - * - * * Broker | Trade Volume - * - */ -⋮---- -export interface BrokerTradeVolumeV2 { - uid: string; - volume: string; - spotVolume: string; - futureVolume: string; -} -⋮---- -/** - * - * * Broker | Total Commission - * - */ -⋮---- -export interface BrokerTotalCommissionV2 { - date: string; - totalTradingVolume: string; - totalActiveTraders: string; - totalCommission: string; - spot: { - spotTradingVolume: string; - spotTradingFee: string; - spotPureTradingFee: string; - spotCommission: string; - }; - futures: { - futuresTradingVolume: string; - futuresTradingFee: string; - futuresPureTradingFee: string; - futuresCommission: string; - }; -} -⋮---- -/** - * - * * Broker | Order Commission - * - */ -⋮---- -export interface BrokerOrderCommissionItemV2 { - fillId: string; - orderId: string; - ts: string; - clientOid: string; - bizType: 'spot' | 'futures'; - subBizType: - | 'spot_trade' - | 'spot_margin' - | 'usdt_futures' - | 'coin_futures' - | 'usdc_futures'; - symbol: string; - volume: string; - fee: string; - pureFee: string; - rebateAmount: string; -} -⋮---- -export interface BrokerOrderCommissionV2 { - commissionlist: BrokerOrderCommissionItemV2[]; - endId: string; -} -⋮---- -/** - * - * * Broker | Rebate Info - * - */ -⋮---- -export interface BrokerRebateInfoV2 { - affiliationType: 'affiliate' | 'official'; - userLevel: string; - clientSpotRebateRatio: string; - clientFuturesRebateRatio: string; -} -⋮---- -/** - * - * * Broker | Agent (affiliate) customer APIs - * - */ -⋮---- -export interface AgentCustomerCommissionItemV2 { - uid: string; - date: string; - coin: string; - symbol: string; - productType: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES' - | string; - dealAmount: string; - fee: string; - feeDeduction: string; - activityBonusDeduct: string; - spotCouponDeduct: string; - futuresCouponDeduct: string; - spotFeeDiscountDeduct: string; - negativeMakerFeeDeduct: string; - feePaid: string; - rebateAmount: string; - userTotalRebateAmount: string; - dayTotalRebateAmount: string; - totalRebateAmount: string; -} + * V3/UTA supports order placement via WebSockets. This is the WS API: + * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel + * + * @returns a promise that resolves/rejects when a matching response arrives + */ +async sendWSAPIRequest< + TWSKey extends keyof WsAPIWsKeyTopicMap, + TWSOperation extends WsAPIWsKeyTopicMap[TWSKey], + TWSParams extends WsAPITopicRequestParamMap[TWSOperation], + TWSAPIResponse extends + WsAPIOperationResponseMap[TWSOperation] = WsAPIOperationResponseMap[TWSOperation], + >( + wsKey: WsKey, + operation: TWSOperation, + category: BitgetInstTypeV3, + params: TWSParams & { signRequest?: boolean }, + requestFlags?: WSAPIRequestFlags, +): Promise ⋮---- -export interface AgentCustomerCommissionsV2 { - endId: string; - commissionList: AgentCustomerCommissionItemV2[]; -} +// this.logger.trace('sendWSAPIRequest(): assertIsAuthenticated(${wsKey})...'); ⋮---- -export interface AgentSubCustomerItemV2 { - uid: string; - registerTime: string; -} +// this.logger.trace('sendWSAPIRequest(): assertIsAuthenticated(${wsKey}) ok'); ⋮---- -export interface AgentSubCustomerListV2 { - list: AgentSubCustomerItemV2[]; - minId: string; -} +// Ensure "args" is always wrapped as array ⋮---- -export interface AgentCustomerTradeVolumeItemV2 { - uid: string; - /** API field name (Bitget spelling). */ - volumn: string; - spotVolume: string; - futuresVolume: string; - time: string; -} +// Store deferred promise, resolved within the "resolveEmittableEvents" method while parsing incoming events ⋮---- -/** API field name (Bitget spelling). */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any ⋮---- -export interface AgentCustomerListItemV2 { - uid: string; - registerTime: string; -} +// Enrich returned promise with request context for easier debugging ⋮---- -export interface AgentCustomerKycItemV2 { - uid: string; - kycResult: 'passed' | 'not_passed' | string; -} +// throw e; ⋮---- -export interface AgentCustomerKycResultV2 { - userList: AgentCustomerKycItemV2[]; - endId: string; -} +// Send event ⋮---- -export interface AgentCustomerDepositItemV2 { - orderId: string; - uid: string; - depositTime: string; - depositCoin: string; - depositAmount: string; -} +// Return deferred promise, so caller can await this call + +================ +File: webpack/webpack.config.cjs +================ +function generateConfig(name) ⋮---- -export interface AgentCustomerAssetItemV2 { - balance: string; - uid: string; - uTime: string; - remark: string; -} +// Add '.ts' and '.tsx' as resolvable extensions. ⋮---- -export interface AgentCommissionDetailItemV2 { - uid: string; - bizType: 'spot' | 'futures' | string; - subBizType: string; - symbol: string; - coin: string; - fee: string; - volume: string; - activityBonusDeduct: string; - spotCouponDeduct: string; - futuresCouponDeduct: string; - spotFeeDiscountDeduct: string; - negativeMakerFeeDeduct: string; - feePaid: string; - directCommission: string; - subCommission: string; - partnerCommission: string; - partnerActualCommission: string; - traderType: string; - apiType: string; - status: 'settled' | 'unsettled' | 'notIssued' | string; - startCalculationTime: string; - endCalculationTime: string; -} +// Node.js core modules not available in browsers +// The REST client's https.Agent (for keepAlive) is Node.js-only and won't work in browsers ⋮---- -export interface AgentCommissionDetailV2 { - endId: string; - commissionList: AgentCommissionDetailItemV2[]; -} +// Code is already transpiled from TypeScript, no additional loaders needed ================ -File: src/types/response/v2/futures.ts +File: docs/BITGET_SDK_QUICKSTART_GUIDE.md ================ -/** - * - * * Futures | Market - * - */ -⋮---- -export interface FuturesVipFeeRateV2 { - level: string; - dealAmount: string; - assetAmount: string; - takerFeeRate: string; - makerFeeRate: string; - btcWithdrawAmount: string; - usdtWithdrawAmount: string; -} -⋮---- -export interface FuturesHistoryInterestRateV2 { - ts: string; - annualInterestRate: string; - dailyInterestRate: string; + +# Bitget API JavaScript Tutorial for Node.js and TypeScript + + +> [!TIP] +> This tutorial is available in a more readable format on our website: [Bitget JavaScript Tutorial](https://siebly.io/sdk/bitget/javascript/tutorial) + + +This guide shows how to connect to Bitget with our [`bitget-api`](https://www.npmjs.com/package/bitget-api) package - the Bitget Node.js, JavaScript, and TypeScript SDK by Siebly.io. You'll cover REST, WebSocket streams, the WebSocket API, and HTTP, HTTPS, and SOCKS proxy configuration. + +The SDK handles signing, routing, reconnects, and resubscribes so you don't have to. Below: install, public and private REST, live streams, demo trading, WebSocket API orders, V2/Classic where you still need it, and a few production notes. + +**Key links** + +- Bitget JavaScript SDK by Siebly: [`bitget-api`](https://www.npmjs.com/package/bitget-api) +- GitHub Repository: [`tiagosiebler/bitget-api`](https://github.com/tiagosiebler/bitget-api) +- SDK function-endpoint map: [Bitget JavaScript Endpoint Reference](./endpointFunctionList.md) +- SDK examples: [Bitget SDK examples](../examples) +- Bitget UTA docs: [Unified Trading Account](https://www.bitget.com/api-doc/uta/intro) +- Bitget UTA quick start: [Quick Start](https://www.bitget.com/api-doc/uta/guide) +- Bitget Classic REST quick start: [Classic REST API](https://www.bitget.com/api-doc/classic/quickStart/intro) +- Bitget Classic WebSocket quick start: [Classic WebSocket API](https://www.bitget.com/api-doc/classic/quickStart/websocket-intro) +- More Node.js, JavaScript & TypeScript SDKs for CryptoCurrency Exchange REST APIs & WebSockets: [Siebly JavaScript SDKs for Crypto APIs](https://siebly.io) + +--- + + +## Why use the SDK + +Bitget has several API surfaces, and they don't all work the same way: + +- V3/UTA REST APIs for current Unified Trading Account market data, account reads, transfers, positions, and order management. +- V3 public WebSocket streams for live market data. +- V3 private WebSocket streams for account, position, fill, and order updates. +- V3 WebSocket API commands for order placement and cancellation over a persistent WebSocket connection. +- V2/Classic REST and WebSocket APIs for accounts and workflows that have not moved to UTA. +- Demo trading endpoints and separate demo API keys for safer order testing. + +That adds up - auth, routing, WebSocket lifecycle, topic tracking, reconnects, typed request shapes. The SDK handles those parts. You focus on the work: pull market data, check balances, place orders, subscribe to updates, reconcile after reconnects. + +The main SDK surfaces are: + +| Use case | SDK surface | Common usage | +| ------------------------------ | -------------------- | -------------------------------------------------------------------------------------------------------- | +| Current REST API | `RestClientV3` | V3/UTA public market data, account reads, transfers, positions, orders, fills, and other endpoint groups | +| Current WebSocket streams | `WebsocketClientV3` | V3/UTA public market streams and private account streams | +| Current WebSocket API commands | `WebsocketAPIClient` | Promise-driven V3 order placement, batch placement, cancellation, and batch cancellation over WebSocket | +| Classic REST API | `RestClientV2` | V2/Classic public, private, and trading workflows | +| Classic WebSocket streams | `WebsocketClientV2` | V2/Classic public and private stream topics | + +For new UTA work, start with `RestClientV3`, `WebsocketClientV3`, and `WebsocketAPIClient`. Reach for `RestClientV2` and `WebsocketClientV2` only when the account or workflow is still on Bitget Classic. + +--- + + +## Installation & API Keys + +Install the SDK with npm: + +```bash +npm install bitget-api +``` + +Or use another npm-compatible package manager: + +```bash +pnpm install bitget-api +yarn add bitget-api +``` + +Public market data does not require API keys. Private REST API calls, private WebSocket streams, and WebSocket API order commands require three Bitget API credentials: + +| SDK option | Bitget credential | +| ----------- | ---------------------------------------------- | +| `apiKey` | API key | +| `apiSecret` | API secret | +| `apiPass` | API passphrase set when the API key is created | + +`apiPass` is the Bitget API passphrase, not the account login password. + +Use separate credentials for live and demo trading. Demo trading API calls need demo API keys plus `demoTrading: true` in the SDK options. + +Our private examples use environment variables for convenience - use whatever secret store fits your setup. + +When creating API keys, grant the minimum permissions you need. Dashboards usually only need read access. Trading needs read/write on orders. Withdrawal isn't required for anything here. Whitelist IPs if your server has fixed outbound addresses. + +--- + + +## Bitget concepts in this guide + +Bitget has a few naming differences across their API: + +| Surface | Product values shown in this guide | +| ------------------------------- | ---------------------------------------------------------------- | +| V3 REST `category` | `SPOT`, `MARGIN`, `USDT-FUTURES`, `USDC-FUTURES`, `COIN-FUTURES` | +| V3 public WebSocket `instType` | `spot`, `usdt-futures`, `usdc-futures`, `coin-futures` | +| V3 private WebSocket `instType` | `UTA` | +| V3 WebSocket API category | `spot`, `usdt-futures`, `usdc-futures`, `coin-futures` | +| V2 WebSocket `instType` | `SPOT`, `USDT-FUTURES`, `USDC-FUTURES`, `COIN-FUTURES` | + +REST, WebSocket streams, and the WebSocket API are separate integration flows: + +| Flow | SDK surface | Best for | What the SDK handles | +| ------------------------- | ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | +| REST API | `RestClientV3` or `RestClientV2` | Request/response reads, writes, order reconciliation, broad endpoint coverage | Base URLs, timestamps, auth headers, signatures, response parsing | +| Public WebSocket streams | `WebsocketClientV3.subscribe` or `WebsocketClientV2.subscribeTopic` | Live market data such as tickers and order books | Connection routing, subscribe requests, heartbeats, reconnects, resubscribe | +| Private WebSocket streams | `WebsocketClientV3.subscribe` or `WebsocketClientV2.subscribeTopic` with credentials | Live account, order, fill, balance, and position updates | Authentication, private endpoint routing, reconnects, resubscribe | +| WebSocket API commands | `WebsocketAPIClient` | Awaitable order commands over a persistent V3 WebSocket connection | Connection setup, authentication, request IDs, promise resolution, response matching | + +Order option casing can differ by surface. V3 REST order requests use `reduceOnly: 'yes' | 'no'`. V3 WebSocket API and V2 futures request types use `reduceOnly: 'YES' | 'NO'`. When unsure, check the type definitions for the client you're using. + +--- + + +## Start building: first REST API calls + +Want the quickest path to something working? Start here. + +### 1. First public REST API request + +Public REST calls work without credentials. + + +```typescript +import { RestClientV3 } from 'bitget-api'; + +const client = new RestClientV3(); + +async function main() { + const serverTime = await client.getServerTime(); + const instruments = await client.getInstruments({ + category: 'SPOT', + symbol: 'BTCUSDT', + }); + const tickers = await client.getTickers({ + category: 'SPOT', + symbol: 'BTCUSDT', + }); + const orderBook = await client.getOrderBook({ + category: 'SPOT', + symbol: 'BTCUSDT', + limit: '5', + }); + const candles = await client.getCandles({ + category: 'SPOT', + symbol: 'BTCUSDT', + interval: '1m', + limit: '5', + }); + + console.log({ + serverTime: serverTime.data.serverTime, + instrument: instruments.data[0]?.symbol, + ticker: tickers.data[0], + bestBid: orderBook.data.b[0], + bestAsk: orderBook.data.a[0], + candles: candles.data, + }); } -⋮---- -export interface FuturesInterestExchangeRateV2 { - tier: string; - minAmount: string; - maxAmount: string; - exchangeRate: string; + +main().catch(console.error); +``` + +If that prints data, public REST is working. + +See also: [V3 public REST examples](../examples/V3%20-%20UTA/Rest) + +### 2. First private REST API request + +Private REST uses the same `RestClientV3` with credentials - the SDK signs requests for you. + + +```typescript +import { RestClientV3 } from 'bitget-api'; + +function readBitgetCredentials() { + const apiKey = process.env.BITGET_API_KEY; + const apiSecret = process.env.BITGET_API_SECRET; + const apiPass = process.env.BITGET_API_PASS; + + if (!apiKey || !apiSecret || !apiPass) { + throw new Error( + 'Set BITGET_API_KEY, BITGET_API_SECRET, and BITGET_API_PASS before running private examples.', + ); + } + + return { apiKey, apiSecret, apiPass }; } -⋮---- -export interface FuturesDiscountRateV2 { - tier: string; - minAmount: string; - maxAmount: string; - discountRate: string; + +const client = new RestClientV3(readBitgetCredentials()); + +async function main() { + const balances = await client.getBalances(); + const settings = await client.getAccountSettings(); + + console.log({ + assetMode: settings.data.assetMode, + holdMode: settings.data.holdMode, + usdtEquity: balances.data.usdtEquity, + assets: balances.data.assets.slice(0, 5), + }); } -⋮---- -export interface FuturesDiscountRatesV2 { - coin: string; - userLimit: string; - totalLimit: string; - discountRateList: FuturesDiscountRateV2[]; + +main().catch(console.error); +``` + +If you get balances back, auth is set up correctly. + +See also: [V3 private REST examples](../examples/V3%20-%20UTA/Rest) + +### 3. First public WebSocket stream + +`WebsocketClientV3` handles V3/UTA streams. Public ones don't need credentials. + + +```typescript +import { WebsocketClientV3, WS_KEY_MAP } from 'bitget-api'; + +const ws = new WebsocketClientV3({}); + +ws.on('open', (data) => { + console.log('connected', data.wsKey); +}); + +ws.on('response', (data) => { + console.log('response', JSON.stringify(data)); +}); + +ws.on('update', (data) => { + console.log('market update', JSON.stringify(data)); +}); + +ws.on('reconnect', ({ wsKey }) => { + console.log('reconnecting', wsKey); +}); + +ws.on('reconnected', (data) => { + console.log('reconnected', data?.wsKey); +}); + +ws.on('exception', console.error); + +ws.subscribe( + [ + { + topic: 'ticker', + payload: { + instType: 'spot', + symbol: 'BTCUSDT', + }, + }, + { + topic: 'books', + payload: { + instType: 'spot', + symbol: 'BTCUSDT', + }, + }, + ], + WS_KEY_MAP.v3Public, +); +``` + +The SDK keeps the connection up, reconnects on drops, and resubscribes automatically. + +See also: [V3 public WebSocket example](../examples/V3%20-%20UTA/Websocket/ws-public.ts) + +### 4. First private account WebSocket stream + +Private streams are where trading systems usually watch account and order changes instead of polling constantly. + + +```typescript +import { WebsocketClientV3, WS_KEY_MAP } from 'bitget-api'; + +function readBitgetCredentials() { + const apiKey = process.env.BITGET_API_KEY; + const apiSecret = process.env.BITGET_API_SECRET; + const apiPass = process.env.BITGET_API_PASS; + + if (!apiKey || !apiSecret || !apiPass) { + throw new Error( + 'Set BITGET_API_KEY, BITGET_API_SECRET, and BITGET_API_PASS before running private WebSocket examples.', + ); + } + + return { apiKey, apiSecret, apiPass }; } -⋮---- -export interface FuturesMergeDepthV2 { - asks: [number, number][]; - bids: [number, number][]; - ts: string; - scale: string; - precision: string; - isMaxPrecision: string; + +const ws = new WebsocketClientV3(readBitgetCredentials()); + +ws.on('authenticated', (data) => { + console.log('authenticated', data.wsKey); +}); + +ws.on('update', (data) => { + console.log('account update', JSON.stringify(data)); +}); + +ws.on('response', (data) => { + console.log('response', JSON.stringify(data)); +}); + +ws.on('reconnect', ({ wsKey }) => { + console.log('reconnecting', wsKey); +}); + +ws.on('reconnected', (data) => { + console.log('reconnected', data?.wsKey); + // After reconnect, use REST to reconcile balances, positions, open orders, or recent fills. +}); + +ws.on('exception', console.error); + +ws.subscribe( + [ + { topic: 'account', payload: { instType: 'UTA' } }, + { topic: 'position', payload: { instType: 'UTA' } }, + { topic: 'fill', payload: { instType: 'UTA' } }, + { topic: 'order', payload: { instType: 'UTA' } }, + ], + WS_KEY_MAP.v3Private, +); +``` + +For V3 private account streams, use `instType: 'UTA'`. + +See also: [V3 private WebSocket example](../examples/V3%20-%20UTA/Websocket/ws-private.ts) + +### 5. First REST API order in demo trading + +Test with demo keys before going live. Demo uses separate Bitget API keys. + +The snippet below sets `demoTrading: true` - leave it on while testing. A successful response means Bitget accepted the order, not that it filled. + + +```typescript +import { RestClientV3 } from 'bitget-api'; + +function readBitgetCredentials() { + const apiKey = process.env.BITGET_API_KEY; + const apiSecret = process.env.BITGET_API_SECRET; + const apiPass = process.env.BITGET_API_PASS; + + if (!apiKey || !apiSecret || !apiPass) { + throw new Error( + 'Set BITGET_API_KEY, BITGET_API_SECRET, and BITGET_API_PASS with demo API credentials before placing demo orders.', + ); + } + + return { apiKey, apiSecret, apiPass }; } -⋮---- -export interface FuturesTickerV2 { - symbol: string; - lastPr: string; - askPr: string; - bidPr: string; - bidSz: string; - askSz: string; - high24h: string; - low24h: string; - ts: string; - change24h: string; - baseVolume: string; - quoteVolume: string; - usdtVolume: string; - openUtc: string; - changeUtc24h: string; - indexPrice: string; - fundingRate: string; - holdingAmount: string; - deliveryStartTime: string; - deliveryTime: string; - deliveryStatus: string; - open24h: string; - markPrice: string; + +const credentials = readBitgetCredentials(); + +const client = new RestClientV3({ + apiKey: credentials.apiKey, + apiSecret: credentials.apiSecret, + apiPass: credentials.apiPass, + demoTrading: true, +}); + +async function main() { + const ticker = await client.getTickers({ + category: 'SPOT', + symbol: 'BTCUSDT', + }); + + const lastPrice = ticker.data[0]?.lastPrice; + + if (!lastPrice) { + throw new Error('No BTCUSDT ticker price returned.'); + } + + const orderRequest = { + category: 'SPOT', + symbol: 'BTCUSDT', + side: 'buy', + orderType: 'limit', + price: lastPrice, + qty: '0.001', + timeInForce: 'gtc', + clientOid: `demo-rest-${Date.now()}`, + } as const; + + const result = await client.submitNewOrder(orderRequest); + + console.log(result); } -⋮---- -export interface FuturesFillV2 { - tradeId: string; - price: string; - size: string; - side: string; - ts: string; - symbol: string; + +main().catch(console.error); +``` + +Check order status via private streams or REST: `getOrderInfo`, `getUnfilledOrders`, `getHistoryOrders`, or `getTradeFills`. + +See also: [V3 spot trading example](../examples/V3%20-%20UTA/Rest/rest-trade-UTA-spot.ts) + +### 6. First WebSocket API order command + +The WebSocket API sends order commands over a persistent connection and waits for a response. `WebsocketAPIClient` wraps that in promises - write orders like normal `async` calls. + +This example uses `demoTrading: true` with demo API keys. + + +```typescript +import { WebsocketAPIClient } from 'bitget-api'; + +function readBitgetCredentials() { + const apiKey = process.env.BITGET_API_KEY; + const apiSecret = process.env.BITGET_API_SECRET; + const apiPass = process.env.BITGET_API_PASS; + + if (!apiKey || !apiSecret || !apiPass) { + throw new Error( + 'Set BITGET_API_KEY, BITGET_API_SECRET, and BITGET_API_PASS with demo API credentials before placing demo orders.', + ); + } + + return { apiKey, apiSecret, apiPass }; } -⋮---- -export type FuturesCandlestickV2 = [ - string, // timestamp - string, // open - string, // high - string, // low - string, // close - string, // baseVolume - string, // usdtVolume - string, // quoteVolume -]; -⋮---- -string, // timestamp -string, // open -string, // high -string, // low -string, // close -string, // baseVolume -string, // usdtVolume -string, // quoteVolume -⋮---- -export interface FuturesOpenInterestV2 { - symbol: string; - size: string; -} -⋮---- -export interface FuturesFundingTimeV2 { - symbol: string; - nextFundingTime: string; - ratePeriod: string; -} -⋮---- -export interface FuturesSymbolPriceV2 { - symbol: string; - price: string; - indexPrice: string; - markPrice: string; - ts: string; -} -⋮---- -export interface FuturesHistoricalFundingRateV2 { - symbol: string; - fundingRate: string; - fundingTime: string; -} -⋮---- -export interface FuturesContractConfigV2 { - symbol: string; - baseCoin: string; - quoteCoin: string; - buyLimitPriceRatio: string; - sellLimitPriceRatio: string; - feeRateUpRatio: string; - makerFeeRate: string; - takerFeeRate: string; - openCostUpRatio: string; - supportMarginCoins: string[]; - minTradeNum: string; - priceEndStep: string; - volumePlace: string; - pricePlace: string; - sizeMultiplier: string; - symbolType: string; - minTradeUSDT: string; - maxSymbolOrderNum: string; - maxProductOrderNum: string; - maxPositionNum: string; - symbolStatus: string; - offTime: string; - limitOpenTime: string; - deliveryTime: string; - deliveryStartTime: string; - launchTime: string; - fundInterval: string; - minLever: string; - maxLever: string; - posLimit: string; - maintainTime: string; - isRwa: string; -} -⋮---- -/** - * - * * Futures | Account - * - */ -⋮---- -export interface FuturesAccountV2 { - marginCoin: string; - locked: string; - available: string; - crossedMaxAvailable: string; - isolatedMaxAvailable: string; - maxTransferOut: string; - accountEquity: string; - usdtEquity: string; - btcEquity: string; - crossedRiskRate: string; - crossedMarginLeverage: string; - isolatedLongLever: string; - isolatedShortLever: string; - marginMode: string; - posMode: string; - unrealizedPL: string; - coupon: string; - crossedUnrealizedPL: string; - isolatedUnrealizedPL: string; - assetMode: string; + +const credentials = readBitgetCredentials(); + +const wsApi = new WebsocketAPIClient({ + apiKey: credentials.apiKey, + apiSecret: credentials.apiSecret, + apiPass: credentials.apiPass, + demoTrading: true, +}); + +const ws = wsApi.getWSClient(); + +ws.on('open', (data) => console.log('ws open', data.wsKey)); +ws.on('authenticated', (data) => console.log('authenticated', data.wsKey)); +ws.on('exception', console.error); + +async function main() { + await ws.connectWSAPI(); + + const clientOid = `demo-wsapi-${Date.now()}`; + + const placed = await wsApi.submitNewOrder('spot', { + symbol: 'BTCUSDT', + side: 'buy', + orderType: 'limit', + price: '10000', + qty: '0.001', + timeInForce: 'gtc', + clientOid, + }); + + console.log('placed', placed); + + const cancelled = await wsApi.cancelOrder('spot', { + clientOid, + }); + + console.log('cancelled', cancelled); } -⋮---- -export interface FuturesAccountsV2 { - marginCoin: string; - locked: string; - available: string; - crossedMaxAvailable: string; - isolatedMaxAvailable: string; - maxTransferOut: string; - accountEquity: string; - usdtEquity: string; - btcEquity: string; - crossedRiskRate: string; - unrealizedPL: string; - coupon: string; - unionTotalMagin: string; - unionAvailable: string; - unionMm: string; - assetList: { - coin: string; - balance: string; - }[]; - isolatedMargin: string; - crossedMargin: string; - crossedUnrealizedPL: string; - isolatedUnrealizedPL: string; - assetMode: string; + +main().catch(console.error); +``` + +`connectWSAPI()` is optional - call it before your first command if you want the connection warm and ready. + +See also: [V3 WebSocket API client example](../examples/V3%20-%20UTA/WS-API/ws-api-client-trade.ts) + +--- + + +## V3 REST API + +`RestClientV3` is the client for current Bitget UTA REST endpoints. + +### Create public and private clients + +Public client: + +```typescript +import { RestClientV3 } from 'bitget-api'; + +const publicClient = new RestClientV3(); +``` + +Private client: + +```typescript +import { RestClientV3 } from 'bitget-api'; + +const privateClient = new RestClientV3({ + apiKey: process.env.BITGET_API_KEY!, + apiSecret: process.env.BITGET_API_SECRET!, + apiPass: process.env.BITGET_API_PASS!, +}); +``` + +Demo trading client: + +```typescript +import { RestClientV3 } from 'bitget-api'; + +const demoClient = new RestClientV3({ + apiKey: process.env.BITGET_API_KEY!, + apiSecret: process.env.BITGET_API_SECRET!, + apiPass: process.env.BITGET_API_PASS!, + demoTrading: true, +}); +``` + +### Common public market data calls + +```typescript +import { RestClientV3 } from 'bitget-api'; + +const client = new RestClientV3(); + +async function main() { + const instruments = await client.getInstruments({ + category: 'SPOT', + symbol: 'BTCUSDT', + }); + + const tickers = await client.getTickers({ + category: 'USDT-FUTURES', + symbol: 'BTCUSDT', + }); + + const orderBook = await client.getOrderBook({ + category: 'SPOT', + symbol: 'BTCUSDT', + limit: '20', + }); + + const candles = await client.getCandles({ + category: 'SPOT', + symbol: 'BTCUSDT', + interval: '1m', + limit: '20', + }); + + const openInterest = await client.getOpenInterest({ + category: 'USDT-FUTURES', + symbol: 'BTCUSDT', + }); + + const fundingRate = await client.getCurrentFundingRate({ + symbol: 'BTCUSDT', + }); + + console.log({ + instrument: instruments.data[0], + ticker: tickers.data[0], + orderBook, + candles: candles.data.length, + openInterest, + fundingRate, + }); } -⋮---- -export interface FuturesSubAccountAssetV2 { - marginCoin: string; - locked: string; - available: string; - crossedMaxAvailable: string; - isolatedMaxAvailable: string; - maxTransferOut: string; - accountEquity: string; - usdtEquity: string; - btcEquity: string; - unrealizedPL: string; - coupon: string; + +main().catch(console.error); +``` + +### Common private account calls + +```typescript +import { RestClientV3 } from 'bitget-api'; + +const client = new RestClientV3({ + apiKey: process.env.BITGET_API_KEY!, + apiSecret: process.env.BITGET_API_SECRET!, + apiPass: process.env.BITGET_API_PASS!, +}); + +async function main() { + const settings = await client.getAccountSettings(); + const balances = await client.getBalances(); + const positions = await client.getCurrentPosition({ + category: 'USDT-FUTURES', + symbol: 'BTCUSDT', + }); + const openOrders = await client.getUnfilledOrders({ + category: 'SPOT', + symbol: 'BTCUSDT', + }); + const recentFills = await client.getTradeFills({ + limit: '20', + }); + + console.log({ + settings: settings.data, + balanceCount: balances.data.assets.length, + positions: positions.data.list, + openOrders: openOrders.data.list, + recentFills: recentFills.data.list, + }); } -⋮---- -export interface FuturesInterestV2 { - coin: string; - liability: string; - interestFreeLimit: string; - interestLimit: string; - hourInterestRate: string; - interest: string; - cTime: string; + +main().catch(console.error); +``` + +### Common trading calls + +```typescript +import { RestClientV3 } from 'bitget-api'; + +const client = new RestClientV3({ + apiKey: process.env.BITGET_API_KEY!, + apiSecret: process.env.BITGET_API_SECRET!, + apiPass: process.env.BITGET_API_PASS!, + demoTrading: true, +}); + +async function main() { + const clientOid = `rest-${Date.now()}`; + + const placed = await client.submitNewOrder({ + category: 'SPOT', + symbol: 'BTCUSDT', + side: 'buy', + orderType: 'limit', + price: '10000', + qty: '0.001', + timeInForce: 'gtc', + clientOid, + }); + + const orderInfo = await client.getOrderInfo({ + clientOid, + }); + + const cancelled = await client.cancelOrder({ + clientOid, + }); + + console.log({ placed, orderInfo, cancelled }); } -export interface FuturesInterestHistoryV2 { - nextSettleTime: string; - borrowAmount: string; - borrowLimit: string; - interestList: FuturesInterestV2[]; - endId: string; + +main().catch(console.error); +``` + +For futures close-only orders, V3 REST uses lower-case `reduceOnly` values: + +```typescript +await client.submitNewOrder({ + category: 'USDT-FUTURES', + symbol: 'BTCUSDT', + side: 'sell', + orderType: 'limit', + price: '100000', + qty: '0.001', + timeInForce: 'gtc', + posSide: 'long', + reduceOnly: 'yes', +}); +``` + +--- + + +## V3 WebSocket streams + +For live market or account updates, use `WebsocketClientV3`. + +### Common events + +```typescript +import { WebsocketClientV3 } from 'bitget-api'; + +const ws = new WebsocketClientV3({}); + +ws.on('open', (data) => console.log('open', data.wsKey)); +ws.on('response', (data) => console.log('response', JSON.stringify(data))); +ws.on('update', (data) => console.log('update', JSON.stringify(data))); +ws.on('reconnect', (data) => console.log('reconnect', data.wsKey)); +ws.on('reconnected', (data) => console.log('reconnected', data?.wsKey)); +ws.on('authenticated', (data) => console.log('authenticated', data.wsKey)); +ws.on('exception', console.error); +``` + +`response` events are subscribe/control acks. `update` events carry stream data. + +### Public topics + +```typescript +import { WebsocketClientV3, WS_KEY_MAP } from 'bitget-api'; + +const ws = new WebsocketClientV3({}); + +ws.on('update', (data) => { + console.log('public update', JSON.stringify(data)); +}); + +ws.subscribe( + [ + { + topic: 'ticker', + payload: { + instType: 'spot', + symbol: 'BTCUSDT', + }, + }, + { + topic: 'books', + payload: { + instType: 'usdt-futures', + symbol: 'BTCUSDT', + }, + }, + ], + WS_KEY_MAP.v3Public, +); +``` + +V3 public `instType` values are lower-case: `spot`, `usdt-futures`, `usdc-futures`, and `coin-futures`. + +### Private topics + +```typescript +import { WebsocketClientV3, WS_KEY_MAP } from 'bitget-api'; + +const ws = new WebsocketClientV3({ + apiKey: process.env.BITGET_API_KEY!, + apiSecret: process.env.BITGET_API_SECRET!, + apiPass: process.env.BITGET_API_PASS!, +}); + +ws.on('update', (data) => { + console.log('private update', JSON.stringify(data)); +}); + +ws.subscribe( + [ + { topic: 'account', payload: { instType: 'UTA' } }, + { topic: 'position', payload: { instType: 'UTA' } }, + { topic: 'fill', payload: { instType: 'UTA' } }, + { topic: 'order', payload: { instType: 'UTA' } }, + ], + WS_KEY_MAP.v3Private, +); +``` + +V3 private account topics use `instType: 'UTA'`. + +### Unsubscribe + +```typescript +ws.unsubscribe( + { + topic: 'ticker', + payload: { + instType: 'spot', + symbol: 'BTCUSDT', + }, + }, + WS_KEY_MAP.v3Public, +); +``` + +The SDK remembers subscriptions per connection and resubscribes after reconnects. + +--- + + +## V3 WebSocket API + +`WebsocketAPIClient` sends V3 order commands over WebSocket and returns a promise for each response. + +```typescript +import { WebsocketAPIClient } from 'bitget-api'; + +const wsApi = new WebsocketAPIClient({ + apiKey: process.env.BITGET_API_KEY!, + apiSecret: process.env.BITGET_API_SECRET!, + apiPass: process.env.BITGET_API_PASS!, + demoTrading: true, +}); + +async function main() { + await wsApi.getWSClient().connectWSAPI(); + + const clientOid = `wsapi-${Date.now()}`; + + const placed = await wsApi.submitNewOrder('spot', { + symbol: 'BTCUSDT', + side: 'buy', + orderType: 'limit', + price: '10000', + qty: '0.001', + timeInForce: 'gtc', + clientOid, + }); + + const cancelled = await wsApi.cancelOrder('spot', { + clientOid, + }); + + console.log({ placed, cancelled }); } -⋮---- -export interface SetLeverageResponseV2 { - symbol: string; - marginCoin: string; - longLeverage: string; - shortLeverage: string; - crossMarginLeverage: string; - marginMode: string; + +main().catch(console.error); +``` + +The helper methods are: + +| Method | WebSocket API operation | +| ---------------------------------------- | ----------------------- | +| `submitNewOrder(category, orderRequest)` | `place-order` | +| `placeBatchOrders(category, orders)` | `batch-place` | +| `cancelOrder(category, cancelRequest)` | `cancel-order` | +| `cancelBatchOrders(category, cancels)` | `batch-cancel` | + +For batch operations, check each item in the returned `args` array - one batch can mix accepted and rejected orders. + +For futures close-only orders over the WebSocket API, use upper-case `reduceOnly` values: + +```typescript +await wsApi.submitNewOrder('usdt-futures', { + symbol: 'BTCUSDT', + side: 'sell', + orderType: 'limit', + price: '100000', + qty: '0.001', + timeInForce: 'gtc', + posSide: 'long', + reduceOnly: 'YES', +}); +``` + +--- + + +## V2/Classic APIs + +Reach for V2/Classic clients only when the account or workflow still uses Classic APIs. Don't mix V2 and V3 assumptions - category names, topics, request fields, and account modes all differ. + +### Classic public REST + +```typescript +import { RestClientV2 } from 'bitget-api'; + +const client = new RestClientV2(); + +async function main() { + const spotCandles = await client.getSpotCandles({ + symbol: 'BTCUSDT', + granularity: '1min', + limit: '100', + }); + + const futuresCandles = await client.getFuturesCandles({ + symbol: 'BTCUSDT', + productType: 'USDT-FUTURES', + granularity: '1m', + limit: '100', + }); + + console.log({ + spotCandles: spotCandles.data.length, + futuresCandles: futuresCandles.data.length, + }); } -⋮---- -export interface SetMarginModeResponseV2 { - symbol: string; - marginCoin: string; - longLeverage: string; - shortLeverage: string; - marginMode: string; + +main().catch(console.error); +``` + +See also: [V2 public REST examples](../examples/V2%20-%20Classic/Rest) + +### Classic WebSocket streams + +```typescript +import { WebsocketClientV2 } from 'bitget-api'; + +const ws = new WebsocketClientV2({}); + +ws.on('update', (data) => { + console.log('classic update', JSON.stringify(data)); +}); + +ws.on('response', (data) => { + console.log('classic response', JSON.stringify(data)); +}); + +ws.on('exception', console.error); + +ws.subscribeTopic('SPOT', 'ticker', 'BTCUSDT'); +``` + +V2 WebSocket `instType` values are upper-case, such as `SPOT`, `USDT-FUTURES`, `USDC-FUTURES`, and `COIN-FUTURES`. + +See also: [V2 WebSocket examples](../examples/V2%20-%20Classic/Websocket) + +--- + + +## Proxies for REST API and WebSocket + +Use a proxy when a deployment needs a fixed egress IP, must cross an approved corporate network, or has a controlled network failover path. A proxy does not select V3/UTA, V2/Classic, demo trading, a product category, or a WebSocket `instType`. + +The broader [Using proxy with Siebly SDKs](https://siebly.io/blog/using-proxy-with-siebly-sdks) article covers the shared constructor pattern. The examples below use the current `bitget-api` V3 clients, and the same networking positions apply to the V2 clients. + +Proxy agents are a Node.js networking feature. Browser applications cannot select a raw socket agent. + +### HTTP or HTTPS proxy + +Install the agent: + +```bash +npm install bitget-api https-proxy-agent +``` + +Set `BITGET_PROXY_URL` to the full proxy URL, including URL-encoded credentials when required. + +This public check sends one V3 REST API call and one V3 ticker subscription through the same proxy: + + + +```typescript +import { HttpsProxyAgent } from 'https-proxy-agent'; +import { RestClientV3, WebsocketClientV3, WS_KEY_MAP } from 'bitget-api'; + +const proxyUrl = process.env.BITGET_PROXY_URL; + +if (!proxyUrl) { + throw new Error('Set BITGET_PROXY_URL before running this example.'); } -⋮---- -export interface FuturesAccountBillV2 { - billId: string; - symbol: string; - amount: string; - fee: string; - feeByCoupon: string; - businessType: string; - coin: string; - balance: string; - cTime: string; + +const proxyAgent = new HttpsProxyAgent(proxyUrl); + +const rest = new RestClientV3( + {}, + { + httpsAgent: proxyAgent, + proxy: false, + }, +); + +const ws = new WebsocketClientV3({ + wsOptions: { + agent: proxyAgent, + }, +}); + +ws.on('open', ({ wsKey }) => { + console.log('WebSocket connected through proxy:', wsKey); +}); +ws.on('update', (event) => { + console.log('stream update', event); +}); +ws.on('exception', console.error); + +async function main() { + const serverTime = await rest.getServerTime(); + console.log('REST API connected through proxy:', serverTime); + + ws.subscribe( + { + topic: 'ticker', + payload: { + instType: 'spot', + symbol: 'BTCUSDT', + }, + }, + WS_KEY_MAP.v3Public, + ); } -⋮---- -/** - * - * * Futures | Position - * - */ -⋮---- -export interface FuturesPositionTierV2 { - symbol: string; - level: string; - startUnit: string; - endUnit: string; - leverage: string; - keepMarginRate: string; + +process.once('SIGINT', () => { + ws.closeAll(); +}); + +main().catch(console.error); +``` + +REST API networking options belong in the second constructor argument for both `RestClientV3` and `RestClientV2`: + +- `httpsAgent` sends the HTTPS request through the agent. +- `proxy: false` prevents Axios from applying another proxy configuration on top of that agent. + +WebSocket networking options belong in `wsOptions.agent` for `WebsocketClientV3`, `WebsocketClientV2`, and `WebsocketAPIClient`. Bitget authenticates private streams and WebSocket API commands over the socket. The WebSocket clients do not fetch a separate authentication token through REST API. + +### Private streams and WebSocket API through a proxy + +This example authenticates a V3 private stream and a V3 WebSocket API connection without placing an order: + + + +```typescript +import { + WebsocketAPIClient, + WebsocketClientV3, + WS_KEY_MAP, +} from 'bitget-api'; +import { HttpsProxyAgent } from 'https-proxy-agent'; + +const proxyUrl = process.env.BITGET_PROXY_URL; + +if (!proxyUrl) { + throw new Error('Set BITGET_PROXY_URL before running this example.'); } -⋮---- -export interface FuturesPositionV2 { - marginCoin: string; - symbol: string; - holdSide: string; - openDelegateSize: string; - marginSize: string; - available: string; - locked: string; - total: string; - leverage: string; - achievedProfits: string; - openPriceAvg: string; - marginMode: string; - posMode: string; - unrealizedPL: string; - liquidationPrice: string; - keepMarginRate: string; - markPrice: string; - breakEvenPrice: string; - totalFee: string; - deductedFee: string; - marginRatio: string; - assetMode: string; - uTime: string; - autoMargin: string; - cTime: string; + +const apiKey = process.env.BITGET_API_KEY; +const apiSecret = process.env.BITGET_API_SECRET; +const apiPass = process.env.BITGET_API_PASS; + +if (!apiKey || !apiSecret || !apiPass) { + throw new Error( + 'Set BITGET_API_KEY, BITGET_API_SECRET, and BITGET_API_PASS before running this example.', + ); } -⋮---- -export interface FuturesHistoryPositionV2 { - positionId: string; - marginCoin: string; - symbol: string; - holdSide: string; - openAvgPrice: string; - closeAvgPrice: string; - marginMode: string; - openTotalPos: string; - closeTotalPos: string; - pnl: string; - netProfit: string; - totalFunding: string; - openFee: string; - closeFee: string; - cTime: string; - uTime: string; + +const proxyAgent = new HttpsProxyAgent(proxyUrl); +const credentials = { apiKey, apiSecret, apiPass }; + +const streams = new WebsocketClientV3({ + ...credentials, + wsOptions: { + agent: proxyAgent, + }, +}); + +const wsApi = new WebsocketAPIClient({ + ...credentials, + attachEventListeners: false, + wsOptions: { + agent: proxyAgent, + }, +}); +const wsApiConnection = wsApi.getWSClient(); + +streams.on('authenticated', ({ wsKey }) => { + console.log('Private stream authenticated:', wsKey); +}); +streams.on('exception', console.error); +wsApiConnection.on('authenticated', ({ wsKey }) => { + console.log('WebSocket API authenticated:', wsKey); +}); +wsApiConnection.on('exception', console.error); + +async function main() { + streams.subscribe( + [ + { topic: 'account', payload: { instType: 'UTA' } }, + { topic: 'order', payload: { instType: 'UTA' } }, + ], + WS_KEY_MAP.v3Private, + ); + + await wsApiConnection.connectWSAPI(); + console.log('Private connections are ready'); +} + +process.once('SIGINT', () => { + streams.closeAll(); + wsApiConnection.closeAll(); +}); + +main().catch(console.error); +``` + +Add `demoTrading: true` to both clients when testing with Bitget demo keys. The proxy setting does not choose demo trading or convert V2/Classic request shapes into V3/UTA request shapes. + +### SOCKS5 proxy + +Install the SOCKS agent: + +```bash +npm install bitget-api socks-proxy-agent +``` + +Use `SocksProxyAgent` in the same REST API and WebSocket positions: + + + +```typescript +import { RestClientV3, WebsocketClientV3, WS_KEY_MAP } from 'bitget-api'; +import { SocksProxyAgent } from 'socks-proxy-agent'; + +const proxyUrl = process.env.BITGET_SOCKS_PROXY_URL; + +if (!proxyUrl) { + throw new Error('Set BITGET_SOCKS_PROXY_URL before running this example.'); +} + +const proxyAgent = new SocksProxyAgent(proxyUrl); + +const rest = new RestClientV3( + {}, + { + httpsAgent: proxyAgent, + proxy: false, + }, +); + +const ws = new WebsocketClientV3({ + wsOptions: { + agent: proxyAgent, + }, +}); + +async function main() { + const serverTime = await rest.getServerTime(); + console.log('REST API connected through SOCKS5:', serverTime); + + ws.subscribe( + { + topic: 'ticker', + payload: { + instType: 'spot', + symbol: 'BTCUSDT', + }, + }, + WS_KEY_MAP.v3Public, + ); } + +process.once('SIGINT', () => { + ws.closeAll(); +}); + +main().catch(console.error); +``` + +### Proxy checks + +- Keep proxy URLs and credentials in environment variables or a secret manager. +- URL-encode usernames and passwords when constructing a proxy URL from separate values. +- Make sure the proxy egress IP matches the Bitget API key's IP whitelist. +- Test a public REST API call and public WebSocket subscription before private authentication. +- Keep V3/UTA, V2/Classic, demo trading, category, and `instType` decisions separate from proxy configuration. +- Measure request, connection, and reconnect latency through the proxy. +- Treat repeated HTTP 407 responses, TLS errors, and WebSocket reconnect loops as network failures. +- Keep the host clock synchronized. Change `recvWindow` only after measuring timestamp failures and proxy latency. +- The SDK does not rotate proxy endpoints. Handle endpoint selection outside the client when rotation is required. + +--- + + +## Production notes + +### 1. Roll out in layers + +Public REST first, then private read-only REST, then public streams, private streams, demo trading, and finally small live tests. None of the examples here need withdrawal permissions. + +### 2. Use client-generated order IDs + +Set `clientOid` on every order and store it before you send. You'll need it to match state after retries, reconnects, or restarts. + +### 3. Reconcile after reconnects + +Reconnects happen. After a private stream comes back, hit REST for balances, positions, open orders, history, and recent fills before trusting local state. + +### 4. Check exchange acceptance + +A resolved promise means the SDK got a response - not that the trade worked. Check Bitget's `code`, per-item batch `code` values, and order status. Accepted ≠ filled. + +### 5. Keep clocks healthy + +Private requests are timestamp-sensitive. Keep the host clock synced. Only touch `recvWindow` if you know you have clock skew. + +### 6. Keep credentials scoped + +Separate live and demo keys. Read-only keys for dashboards. Trading permissions only where you actually submit orders. Never put private keys in frontend code. + +### 7. Log carefully + +`BITGETTRACE=true` is handy for local debugging - it logs raw requests and responses. Don't turn it on where logs might leak account data. + +--- + + +## FAQ + +### Do I need API keys for public market data? + +No. Public REST market data and public WebSocket streams can be used without API keys. + +### What is the Bitget API passphrase? + +The API passphrase is the passphrase set when creating the Bitget API key. In the SDK constructor it is passed as `apiPass`. + +### Which client should I use for a new project? + +Start with `RestClientV3`, `WebsocketClientV3`, and `WebsocketAPIClient` for current V3/UTA workflows. + +### When should I use V2/Classic clients? + +Use `RestClientV2` and `WebsocketClientV2` when the account or endpoint is still on Bitget Classic. Do not mix V2 and V3 request assumptions in the same snippet. + +### Why do category names have different casing? + +Bitget isn't consistent. V3 REST uses upper-case categories. V3 public WebSocket uses lower-case `instType`. Private account streams use `UTA`. V2 WebSocket uses upper-case `instType`. + +### What is the difference between WebSocket streams and the WebSocket API? + +Streams push updates - market data, account changes, fills. The WebSocket API is for sending commands (place/cancel orders) and getting a direct response. Watch state on streams; send orders on the WebSocket API. + +### Can I use this SDK from plain JavaScript? + +Yes. The SDK works in JavaScript and TypeScript. TypeScript users also get request and response types from the package. + +### Does the SDK support RSA keys? + +Yes. Pass your RSA private key as `apiSecret`; the SDK auto-detects RSA vs HMAC signing. See the [GitHub repository](https://github.com/tiagosiebler/bitget-api). + +### What should I do after a WebSocket reconnect? + +Normal - let the SDK reconnect and resubscribe. Then reconcile balances, orders, and fills over REST before acting on cached state. + +### Where can I find more examples? + +More in the repo: + +- [V3/UTA examples](../examples/V3%20-%20UTA) +- [V2/Classic examples](../examples/V2%20-%20Classic) +- [Auth examples](../examples/Auth) +- [Bitget JavaScript Endpoint Reference](./endpointFunctionList.md) + +--- + + +## Next steps + +- [Bitget JavaScript SDK page](https://siebly.io/sdk/bitget/javascript) +- [`bitget-api` on npm](https://www.npmjs.com/package/bitget-api) +- [GitHub repo](https://github.com/tiagosiebler/bitget-api) +- [Endpoint reference](./endpointFunctionList.md) +- Bitget docs: [UTA](https://www.bitget.com/api-doc/uta/intro) · [Classic](https://www.bitget.com/api-doc/classic/quickStart/intro) +- [More exchange SDKs on Siebly.io](https://siebly.io) + +================ +File: examples/V3 - UTA/WS-API/ws-api-client-trade.ts +================ +import { DefaultLogger, WebsocketAPIClient } from '../../../src/index.js'; ⋮---- -/** - * - * * Futures | Trade - * - */ +// or +// import { DefaultLogger, WS_KEY_MAP, WebsocketAPIClient } from 'bitget-api'; ⋮---- -export interface FuturesBatchOrderResponseV2 { - successList: { - orderId: string; - clientOid: string; - }[]; - failureList: { - orderId: string; - clientOid: string; - errorMsg: string; - errorCode: string; - }[]; -} +// function attachEventHandlers( +// wsClient: TWSClient, +// ): void { +// wsClient.on('update', (data) => { +// console.log('raw message received ', JSON.stringify(data)); +// }); +// wsClient.on('open', (data) => { +// console.log('ws connected', data.wsKey); +// }); +// wsClient.on('reconnect', ({ wsKey }) => { +// console.log('ws automatically reconnecting.... ', wsKey); +// }); +// wsClient.on('reconnected', (data) => { +// console.log('ws has reconnected ', data?.wsKey); +// }); +// wsClient.on('authenticated', (data) => { +// console.log('ws has authenticated ', data?.wsKey); +// }); +// } ⋮---- -export interface FuturesClosePositionResponseV2 { - successList: { - orderId: string; - clientOid: string; - symbol: string; - }[]; - failureList: { - orderId: string; - clientOid: string; - symbol: string; - errorMsg: string; - errorCode: string; - }[]; -} +// 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/ws-private.ts ⋮---- -export interface FuturesOrderDetailV2 { - symbol: string; - size: string; - orderId: string; - clientOid: string; - baseVolume: string; - priceAvg: string; - fee: string; - price: string; - state: string; - side: string; - force: string; - totalProfits: string; - posSide: string; - marginCoin: string; - presetStopSurplusPrice: string; - presetStopLossPrice: string; - quoteVolume: string; - orderType: string; - leverage: string; - marginMode: string; - reduceOnly: string; - enterPointSource: string; - tradeSide: string; - posMode: string; - orderSource: string; - cancelReason: string; - cTime: string; - uTime: string; -} +// Whether to use the demo trading wss connection +// demoTrading: true, ⋮---- -export interface FuturesOrderFillV2 { - tradeId: string; - symbol: string; - orderId: string; - price: string; - baseVolume: string; - feeDetail: { - deduction: string; - feeCoin: string; - totalDeductionFee: string; - totalFee: string; - }[]; - side: string; - quoteVolume: string; - profit: string; - enterPointSource: string; - tradeSide: string; - posMode: string; - tradeScope: string; - cTime: string; -} +// If you want your own event handlers instead of the default ones with logs, +// disable this setting and see the `attachEventHandlers` example below: +// attachEventListeners: false ⋮---- -export interface FuturesOpenOrderV2 { - symbol: string; - size: string; - orderId: string; - clientOid: string; - baseVolume: string; - fee: string; - price: string; - priceAvg: string; - status: string; - side: string; - force: string; - totalProfits: string; - posSide: string; - marginCoin: string; - quoteVolume: string; - leverage: string; - marginMode: string; - enterPointSource: string; - tradeSide: string; - posMode: string; - orderType: string; - orderSource: string; - cTime: string; - uTime: string; - presetStopSurplusPrice: string; - presetStopSurplusType: string; - presetStopSurplusExecutePrice: string; - presetStopLossPrice: string; - presetStopLossType: string; - presetStopLossExecutePrice: string; -} +logger, // Optional: inject a custom logger ⋮---- -export interface FuturesHistoryOrderV2 { - symbol: string; - size: string; - orderId: string; - clientOid: string; - baseVolume: string; - fee: string; - price: string; - priceAvg: string; - status: string; - side: string; - force: string; - totalProfits: string; - posSide: string; - marginCoin: string; - quoteVolume: string; - leverage: string; - marginMode: string; - enterPointSource: string; - tradeSide: string; - posMode: string; - orderType: string; - orderSource: string; - cTime: string; - uTime: string; - presetStopSurplusPrice: string; - presetStopLossPrice: string; - liqPrice: string; -} +// Optional, see above "attachEventListeners". Attach basic event handlers, so nothing is left unhandled +// attachEventHandlers(wsClient.getWSClient()); ⋮---- -export interface FuturesCancelAllOrdersV2 { - successList: { - orderId: string; - clientOid: string; - }[]; - failureList: { - orderId: string; - clientOid: string; - errorMsg: string; - errorCode: string; - }[]; -} +// Optional: prepare the WebSocket API connection in advance. +// This happens automatically but you can do this early before making any API calls, to prevent delays from a cold start. ⋮---- /** - * - * * Futures | Trigger Orders - * - */ -⋮---- -export interface FuturesTriggerSubOrderV2 { - orderId: string; - price: string; - type: string; - status: string; -} -⋮---- -export interface FuturesPendingPlanOrderV2 { - planType: string; - symbol: string; - size: string; - orderId: string; - clientOid: string; - price: string; - executePrice: string; - callbackRatio: string; - triggerPrice: string; - triggerType: string; - planStatus: string; - side: string; - posSide: string; - marginCoin: string; - marginMode: string; - enterPointSource: string; - tradeSide: string; - posMode: string; - orderType: string; - orderSource: string; - cTime: string; - uTime: string; - stopSurplusExecutePrice: string; - stopSurplusTriggerPrice: string; - stopSurplusTriggerType: string; - stopLossExecutePrice: string; - stopLossTriggerPrice: string; - stopLossTriggerType: string; -} -⋮---- -export interface FuturesCancelPlanOrderV2 { - successList: { - orderId: string; - clientOid: string; - }[]; - failureList: { - orderId: string; - clientOid: string; - errorMsg: string; - }[]; -} -⋮---- -export interface FuturesHistoryPlanOrderV2 { - planType: string; - symbol: string; - size: string; - orderId: string; - executeOrderId: string; - clientOid: string; - planStatus: string; - price: string; - executePrice: string; - priceAvg: string; - baseVolume: string; - callbackRatio: string; - triggerPrice: string; - triggerType: string; - side: string; - posSide: string; - marginCoin: string; - marginMode: string; - enterPointSource: string; - tradeSide: string; - posMode: string; - orderType: string; - cTime: string; - uTime: string; - stopSurplusExecutePrice: string; - stopSurplusTriggerPrice: string; - stopSurplusTriggerType: string; - stopLossExecutePrice: string; - stopLossTriggerPrice: string; - stopLossTriggerType: string; -} + * Bitget's WebSocket API be used like a REST API, through this SDK's WebsocketAPIClient. The WebsocketAPIClient is a utility class wrapped around WebsocketClientV3's sendWSAPIRequest() capabilities. + * + * Each request sent via the WebsocketAPIClient will automatically: + * - route via the active WS API connection + * - return a Promise, which automatically resolves/rejects when a matching response is received + * + * Note: this requires V3/UTA API keys! + */ ⋮---- /** - * - * * Futures | Union Margin - * - */ -⋮---- -export interface UnionTransferLimitsV2 { - coin: string; - maxTransferIn: string; -} -⋮---- -export interface UnionConfigV2 { - imr: string; - mmr: string; - individualLimit: string; - individualLimitRatio: string; -} -⋮---- -export interface UnionSwitchUsdtV2 { - usdtAmount: string; -} -⋮---- -export interface UnionConvertV2 { - usdtAmount: string; -} + * Place Order + * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters + */ ⋮---- /** - * - * * Futures | Account | Max Openable Quantity - * - */ + const res = { + "event": "trade", + "id": "1750034396082", + "category": "spot", + "topic": "place-order", + "args": [ + { + "symbol": "BTCUSDT", + "orderId": "xxxxxxxx", + "clientOid": "xxxxxxxx", + "cTime": "1750034397008" + } + ], + "code": "0", + "msg": "success", + "ts": "1750034397076" + }; + */ ⋮---- -export interface FuturesMaxOpenV2 { - maxOpen: string; -} +/** + * Batch Place Order Channel + * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel + */ ⋮---- /** - * - * * Futures | Account | Liquidation Price - * - */ + * Note: batch place will never reject the request, even if all orders were rejected. Check the "code" and "msg" properties for individual orders in the response, to detect batch place errors. + */ ⋮---- -export interface FuturesLiquidationPriceV2 { - liqPrice: string; -} +/** + const res = { + "event": "trade", + "id": "1750035029506", + "category": "spot", + "topic": "batch-place", + "args": [ + { + "code": "0", + "msg": "Success", + "symbol": "BTCUSDT", + "orderId": "xxxxxxxx", + "clientOid": "xxxxxxxx" + }, + { + "code": "0", + "msg": "Success", + "symbol": "BTCUSDT", + "orderId": "xxxxxxxx", + "clientOid": "xxxxxxxx" + } + ], + "code": "0", + "msg": "Success", + "ts": "1750035029925" + } + */ ⋮---- /** - * - * * Futures | Account | Isolated Symbols - * - */ + * Cancel Order + * https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel + */ ⋮---- -export interface FuturesIsolatedSymbolV2 { - symbol: string; - marginMode: 'isolated'; -} - +/** + const res = { + "event": "trade", + "id": "1750034870205", + "topic": "cancel-order", + "args": [ + { + "orderId": "xxxxxxxx", + "clientOid": "xxxxxxxx" + } + ], + "code": "0", + "msg": "Success", + "ts": "1750034870597" + } + */ +⋮---- +/** + * Batch Cancel Order + * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Cancel-Order-Channel + */ +⋮---- +/** + const res = { + "event": "trade", + "id": "bb553cc0-c1fa-454e-956d-c96c8d715760", + "topic": "batch-cancel", + "args": [ + { + "code": "0", + "msg": "Success", + "orderId": "xxxxxxxxxxxxx" + }, + { + "code": "25204", + "msg": "Order does not exist", + "orderId": "xxxxxxxxxxxxx" + } + ], + "code": "0", + "msg": "Success", + "ts": "1751980011084" + } + */ + ================ -File: src/types/response/v3/account.ts +File: src/types/response/v2/futures.ts ================ -// Account Management Response Types -import type { CollateralTypeV3 } from '../../request/v3/account.js'; +/** + * + * * Futures | Market + * + */ ⋮---- -export interface AccountSymbolConfigV3 { - category: string; - symbol: string; - marginMode: string; - leverage: string; +export interface FuturesVipFeeRateV2 { + level: string; + dealAmount: string; + assetAmount: string; + takerFeeRate: string; + makerFeeRate: string; + btcWithdrawAmount: string; + usdtWithdrawAmount: string; } ⋮---- -export interface AccountCoinConfigV3 { - coin: string; - leverage: string; +export interface FuturesHistoryInterestRateV2 { + ts: string; + annualInterestRate: string; + dailyInterestRate: string; } ⋮---- -export type AccountPermissionV3 = - | 'uta_mgt' - | 'uta_trade' - | 'withdraw' - | 'copy_futures_position' - | 'copy_futures_order'; -⋮---- -export interface AccountInfoV3 { - userId: string; - inviterId: string; - /** Only set when the calling account is a sub-account */ - parentId: string; - channelCode: string; - channel: string; - ips: string; - permType: 'read-only' | 'read-and-write'; - permissions: AccountPermissionV3[]; - regisTime: string; +export interface FuturesInterestExchangeRateV2 { + tier: string; + minAmount: string; + maxAmount: string; + exchangeRate: string; } ⋮---- -/** Only set when the calling account is a sub-account */ -⋮---- -export type AccountLevelV3 = 'basic' | 'advanced' | 'isolated' | 'delta'; -⋮---- -export interface AccountSettingsV3 { - uid: string; - accountMode: 'unified' | 'hybrid' | 'upgrading' | 'switching'; - assetMode: string; - accountLevel: AccountLevelV3; - holdMode: string; - stpMode: 'none' | 'cancel_taker' | 'cancel_maker' | 'cancel_both'; - symbolConfigList: AccountSymbolConfigV3[]; - coinConfigList: AccountCoinConfigV3[]; +export interface FuturesDiscountRateV2 { + tier: string; + minAmount: string; + maxAmount: string; + discountRate: string; } ⋮---- -export interface AccountDeltaCoinPositionV3 { +export interface FuturesDiscountRatesV2 { coin: string; - positionRatio: string; -} -⋮---- -/** Delta-neutral mode metrics. Only available when accountLevel is delta. */ -export interface AccountDeltaInfoV3 { - deltaEquityRatio: string; - deltaThreshold: string; - positionThreshold: string; - list: AccountDeltaCoinPositionV3[]; + userLimit: string; + totalLimit: string; + discountRateList: FuturesDiscountRateV2[]; } ⋮---- -export interface AccountAssetV3 { - coin: string; - equity: string; - usdValue: string; - balance: string; - available: string; - debt: string; - locked: string; - /** Position value in USD */ - positionValue?: string; - /** Account leverage (non-negative) */ - leverage?: string; +export interface FuturesMergeDepthV2 { + asks: [number, number][]; + bids: [number, number][]; + ts: string; + scale: string; + precision: string; + isMaxPrecision: string; } ⋮---- -/** Position value in USD */ -⋮---- -/** Account leverage (non-negative) */ -⋮---- -export interface AccountAssetsV3 { - accountEquity: string; - usdtEquity: string; - btcEquity: string; - unrealisedPnl: string; - usdtUnrealisedPnl: string; - btcUnrealizedPnl: string; - effEquity: string; - mmr: string; - imr: string; - mgnRatio: string; - positionMgnRatio: string; - assets: AccountAssetV3[]; +export interface FuturesTickerV2 { + symbol: string; + lastPr: string; + askPr: string; + bidPr: string; + bidSz: string; + askSz: string; + high24h: string; + low24h: string; + ts: string; + change24h: string; + baseVolume: string; + quoteVolume: string; + usdtVolume: string; + openUtc: string; + changeUtc24h: string; + indexPrice: string; + fundingRate: string; + holdingAmount: string; + deliveryStartTime: string; + deliveryTime: string; + deliveryStatus: string; + open24h: string; + markPrice: string; } ⋮---- -export interface ConvertRecordV3 { - fromCoin: string; - fromCoinSize: string; - toCoin: string; - toCoinSize: string; +export interface FuturesFillV2 { + tradeId: string; price: string; + size: string; + side: string; ts: string; -} -⋮---- -export interface FinancialRecordV3 { - category: string; - id: string; symbol: string; - coin: string; - type: string; - amount: string; - fee: string; - balance: string; - ts: string; - /** crossed | isolated */ - positionType?: string; - positionAmount?: string; - positionBalance?: string; } ⋮---- -/** crossed | isolated */ +export type FuturesCandlestickV2 = [ + string, // timestamp + string, // open + string, // high + string, // low + string, // close + string, // baseVolume + string, // usdtVolume + string, // quoteVolume +]; ⋮---- -export interface PaymentCoinV3 { - coin: string; +string, // timestamp +string, // open +string, // high +string, // low +string, // close +string, // baseVolume +string, // usdtVolume +string, // quoteVolume +⋮---- +export interface FuturesOpenInterestV2 { + symbol: string; size: string; - amount: string; } ⋮---- -export interface RepayableCoinV3 { - coin: string; - size: string; - amount: string; +export interface FuturesFundingTimeV2 { + symbol: string; + nextFundingTime: string; + ratePeriod: string; } ⋮---- -export interface RepayResponseV3 { - result: string; - repayAmount: string; +export interface FuturesSymbolPriceV2 { + symbol: string; + price: string; + indexPrice: string; + markPrice: string; + ts: string; } ⋮---- -// Sub-account Management Response Types -⋮---- -export interface CreateSubAccountApiKeyResponseV3 { - note: string; - apiKey: string; - secret: string; - type: string; - permissions: string[]; - ips: string[]; +export interface FuturesHistoricalFundingRateV2 { + symbol: string; + fundingRate: string; + fundingTime: string; } -export interface SubAccountApiKeyV3 { - apiKey: string; - note: string; - type: string; - permissions: string[]; - ips: string[]; - ts?: string; +⋮---- +export interface FuturesContractConfigV2 { + symbol: string; + baseCoin: string; + quoteCoin: string; + buyLimitPriceRatio: string; + sellLimitPriceRatio: string; + feeRateUpRatio: string; + makerFeeRate: string; + takerFeeRate: string; + openCostUpRatio: string; + supportMarginCoins: string[]; + minTradeNum: string; + priceEndStep: string; + volumePlace: string; + pricePlace: string; + sizeMultiplier: string; + symbolType: string; + minTradeUSDT: string; + maxSymbolOrderNum: string; + maxProductOrderNum: string; + maxPositionNum: string; + symbolStatus: string; + offTime: string; + limitOpenTime: string; + deliveryTime: string; + deliveryStartTime: string; + launchTime: string; + fundInterval: string; + minLever: string; + maxLever: string; + posLimit: string; + maintainTime: string; + isRwa: string; } ⋮---- -export interface UpdateSubAccountApiKeyResponseV3 { - note: string; - apiKey: string; - type: string; - permissions: string[]; - ips: string[]; +/** + * + * * Futures | Account + * + */ +⋮---- +export interface FuturesAccountV2 { + marginCoin: string; + locked: string; + available: string; + crossedMaxAvailable: string; + isolatedMaxAvailable: string; + maxTransferOut: string; + accountEquity: string; + usdtEquity: string; + btcEquity: string; + crossedRiskRate: string; + crossedMarginLeverage: string; + isolatedLongLever: string; + isolatedShortLever: string; + marginMode: string; + posMode: string; + unrealizedPL: string; + coupon: string; + crossedUnrealizedPL: string; + isolatedUnrealizedPL: string; + assetMode: string; } ⋮---- -export interface CreateSubAccountResponseV3 { - username: string; - subUid: string; - status: string; - note: string; - createdTime: string; - updatedTime: string; +export interface FuturesAccountsV2 { + marginCoin: string; + locked: string; + available: string; + crossedMaxAvailable: string; + isolatedMaxAvailable: string; + maxTransferOut: string; + accountEquity: string; + usdtEquity: string; + btcEquity: string; + crossedRiskRate: string; + unrealizedPL: string; + coupon: string; + unionTotalMagin: string; + unionAvailable: string; + unionMm: string; + assetList: { + coin: string; + balance: string; + }[]; + isolatedMargin: string; + crossedMargin: string; + crossedUnrealizedPL: string; + isolatedUnrealizedPL: string; + assetMode: string; } ⋮---- -export interface SubAccountV3 { - subUid: string; - username: string; - status: string; - accountMode: string; - type: 'normal' | 'virtual' | 'custodian'; - note: string; - createdTime: string; - updatedTime: string; +export interface FuturesSubAccountAssetV2 { + marginCoin: string; + locked: string; + available: string; + crossedMaxAvailable: string; + isolatedMaxAvailable: string; + maxTransferOut: string; + accountEquity: string; + usdtEquity: string; + btcEquity: string; + unrealizedPL: string; + coupon: string; } ⋮---- -export interface WithdrawAddressBookEntryV3 { +export interface FuturesInterestV2 { coin: string; - chain: string; - address: string; - countryCode: string; - label: string; - memo: string; - type: 'regular' | 'EVM' | 'universal' | 'internal'; - internalType: '' | 'uid' | 'mobile' | 'email'; - createdTime: string; + liability: string; + interestFreeLimit: string; + interestLimit: string; + hourInterestRate: string; + interest: string; + cTime: string; } -⋮---- -export interface WithdrawAddressBookV3 { - addressList: WithdrawAddressBookEntryV3[]; - cursor?: string; +export interface FuturesInterestHistoryV2 { + nextSettleTime: string; + borrowAmount: string; + borrowLimit: string; + interestList: FuturesInterestV2[]; + endId: string; } ⋮---- -// Transfer Response Types -⋮---- -export interface AllSymbolFeeRateV3 { +export interface SetLeverageResponseV2 { symbol: string; - makerFeeRate: string; - takerFeeRate: string; + marginCoin: string; + longLeverage: string; + shortLeverage: string; + crossMarginLeverage: string; + marginMode: string; } ⋮---- -export interface TransferResponseV3 { - transferId: string; - clientOid?: string; +export interface SetMarginModeResponseV2 { + symbol: string; + marginCoin: string; + longLeverage: string; + shortLeverage: string; + marginMode: string; } ⋮---- -export interface SubTransferRecordV3 { - transferId: string; - oldTransferId?: string; - fromType: string; - toType: string; +export interface FuturesAccountBillV2 { + billId: string; + symbol: string; amount: string; + fee: string; + feeByCoupon: string; + businessType: string; coin: string; - fromUserId: string; - toUserId: string; - status: string; - clientOid: string; - createdTime: string; - updatedTime: string; -} -⋮---- -export interface SubUnifiedAssetV3 { - coin: string; - equity: string; - usdValue: string; balance: string; - available: string; - debt: string; - locked: string; + cTime: string; } ⋮---- -export interface SubUnifiedAssetV3 { - subUid: string; - cursor: string; - assets: SubUnifiedAssetV3[]; -} +/** + * + * * Futures | Position + * + */ ⋮---- -export interface GetFeeRateResponseV3 { - makerFeeRate: string; - takerFeeRate: string; +export interface FuturesPositionTierV2 { + symbol: string; + level: string; + startUnit: string; + endUnit: string; + leverage: string; + keepMarginRate: string; } ⋮---- -export interface FundingAssetV3 { - coin: string; +export interface FuturesPositionV2 { + marginCoin: string; + symbol: string; + holdSide: string; + openDelegateSize: string; + marginSize: string; available: string; - frozen: string; - balance: string; -} -⋮---- -// Deposit Response Types -⋮---- -export interface DepositAddressV3 { - address: string; - chain: string; - coin: string; - tag: string; - url: string; -} -⋮---- -export interface DepositRecordV3 { - orderId: string; - recordId: string; - coin: string; - type: 'deposit'; - dest: 'on_chain' | 'internal_transfer'; - size: string; - status: 'pending' | 'success' | 'fail'; - fromAddress: string; - toAddress: string; - chain: string; - createdTime: string; - updatedTime: string; + locked: string; + total: string; + leverage: string; + achievedProfits: string; + openPriceAvg: string; + marginMode: string; + posMode: string; + unrealizedPL: string; + liquidationPrice: string; + keepMarginRate: string; + markPrice: string; + breakEvenPrice: string; + totalFee: string; + deductedFee: string; + marginRatio: string; + assetMode: string; + /** Cash dividend, USDT */ + cashDividend?: string; + uTime: string; + autoMargin: string; + cTime: string; } ⋮---- -// Withdraw Response Types +/** Cash dividend, USDT */ ⋮---- -export interface WithdrawResponseV3 { - orderId: string; - clientOid: string; +export interface FuturesPositionAdlRankV2 { + symbol: string; + marginCoin: string; + adlRank: string; + rank: string; + holdSide: string; } ⋮---- -export interface WithdrawRecordV3 { +export interface FuturesHistoryPositionV2 { + positionId: string; + marginCoin: string; + symbol: string; + holdSide: string; + openAvgPrice: string; + closeAvgPrice: string; + marginMode: string; + openTotalPos: string; + closeTotalPos: string; + pnl: string; + netProfit: string; + totalFunding: string; + openFee: string; + closeFee: string; + /** Cash dividend, USDT */ + cashDividend?: string; + cTime: string; + uTime: string; +} +⋮---- +/** Cash dividend, USDT */ +⋮---- +/** + * + * * Futures | Trade + * + */ +⋮---- +export interface FuturesBatchOrderResponseV2 { + successList: { + orderId: string; + clientOid: string; + }[]; + failureList: { + orderId: string; + clientOid: string; + errorMsg: string; + errorCode: string; + }[]; +} +⋮---- +export interface FuturesClosePositionResponseV2 { + successList: { + orderId: string; + clientOid: string; + symbol: string; + }[]; + failureList: { + orderId: string; + clientOid: string; + symbol: string; + errorMsg: string; + errorCode: string; + }[]; +} +⋮---- +export interface FuturesOrderDetailV2 { + symbol: string; + size: string; orderId: string; clientOid: string; - recordId: string; - coin: string; - type: 'withdraw'; - dest: 'on_chain' | 'internal_transfer'; - size: string; - status: 'pending' | 'success' | 'fail'; - fromAddress: string; - toAddress: string; - chain: string; + baseVolume: string; + priceAvg: string; fee: string; - confirm: string; - tag: string; - createdTime: string; - updatedTime: string; + price: string; + state: string; + side: string; + force: string; + totalProfits: string; + posSide: string; + marginCoin: string; + presetStopSurplusPrice: string; + presetStopLossPrice: string; + quoteVolume: string; + orderType: string; + leverage: string; + marginMode: string; + reduceOnly: string; + enterPointSource: string; + tradeSide: string; + posMode: string; + orderSource: string; + cancelReason: string; + cTime: string; + uTime: string; } ⋮---- -export interface MaxTransferableV3 { - coin: string; - maxTransfer: string; - borrowMaxTransfer: string; +export interface FuturesOrderFillV2 { + tradeId: string; + symbol: string; + orderId: string; + price: string; + baseVolume: string; + feeDetail: { + deduction: string; + feeCoin: string; + totalDeductionFee: string; + totalFee: string; + }[]; + side: string; + quoteVolume: string; + profit: string; + enterPointSource: string; + tradeSide: string; + posMode: string; + tradeScope: string; + cTime: string; } ⋮---- -export interface OpenInterestLimitV3 { +export interface FuturesOpenOrderV2 { symbol: string; - singleUserLimit: string; - masterSubLimit: string; - marketMakerLimit: string; + size: string; + orderId: string; + clientOid: string; + baseVolume: string; + fee: string; + price: string; + priceAvg: string; + status: string; + side: string; + force: string; + totalProfits: string; + posSide: string; + marginCoin: string; + quoteVolume: string; + leverage: string; + marginMode: string; + enterPointSource: string; + tradeSide: string; + posMode: string; + orderType: string; + orderSource: string; + cTime: string; + uTime: string; + presetStopSurplusPrice: string; + presetStopSurplusType: string; + presetStopSurplusExecutePrice: string; + presetStopLossPrice: string; + presetStopLossType: string; + presetStopLossExecutePrice: string; } ⋮---- -export interface TaxRecordV3 { - id: string; - coin: string; - type: string; - amount: string; +export interface FuturesHistoryOrderV2 { + symbol: string; + size: string; + orderId: string; + clientOid: string; + baseVolume: string; fee: string; - balance: string; - ts: string; + price: string; + priceAvg: string; + status: string; + side: string; + force: string; + totalProfits: string; + posSide: string; + marginCoin: string; + quoteVolume: string; + leverage: string; + marginMode: string; + enterPointSource: string; + tradeSide: string; + posMode: string; + orderType: string; + orderSource: string; + cTime: string; + uTime: string; + presetStopSurplusPrice: string; + presetStopLossPrice: string; + liqPrice: string; } ⋮---- -export interface CollateralTypeConfigV3 { - collateralType: CollateralTypeV3; - /** Returned when collateralType=custom */ - collateralCoins?: string; +export interface FuturesCancelAllOrdersV2 { + successList: { + orderId: string; + clientOid: string; + }[]; + failureList: { + orderId: string; + clientOid: string; + errorMsg: string; + errorCode: string; + }[]; } ⋮---- -/** Returned when collateralType=custom */ +/** + * + * * Futures | Trigger Orders + * + */ ⋮---- -export interface CustomCollateralCoinV3 { - collateralCoin: string; +export interface FuturesTriggerSubOrderV2 { + orderId: string; + price: string; + type: string; + status: string; } ⋮---- -export interface PreSetLeverageV3 { - estMaxOpen?: string; - estMaxBorrowable?: string; - requiredMargin: string; - marginChange: string; +export interface FuturesPendingPlanOrderV2 { + planType: string; + symbol: string; + size: string; + orderId: string; + clientOid: string; + price: string; + executePrice: string; + callbackRatio: string; + triggerPrice: string; + triggerType: string; + planStatus: string; + side: string; + posSide: string; + marginCoin: string; + marginMode: string; + enterPointSource: string; + tradeSide: string; + posMode: string; + orderType: string; + orderSource: string; + cTime: string; + uTime: string; + stopSurplusExecutePrice: string; + stopSurplusTriggerPrice: string; + stopSurplusTriggerType: string; + stopLossExecutePrice: string; + stopLossTriggerPrice: string; + stopLossTriggerType: string; } ⋮---- -export interface MaxWithdrawalV3 { - coin: string; - otcMaxWithdrawal: string; - spotMaxWithdrawal: string; - utaMaxWithdrawal: string; - totalMaxWithdrawal: string; +export interface FuturesCancelPlanOrderV2 { + successList: { + orderId: string; + clientOid: string; + }[]; + failureList: { + orderId: string; + clientOid: string; + errorMsg: string; + }[]; } - -================ -File: src/types/websockets/ws-general.ts -================ -import type { ClientRequestArgs } from 'http'; -import WebSocket from 'isomorphic-ws'; -⋮---- -import { RestClientOptions } from '../../util/requestUtils.js'; -import { WS_KEY_MAP } from '../../util/websocket-util.js'; -import { FuturesProductTypeV2 } from '../request/shared.js'; -⋮---- -export type BitgetInstType = 'SP' | 'SPBL' | 'MC' | 'UMCBL' | 'DMCBL'; -export type BitgetInstTypeV2 = 'SPOT' | FuturesProductTypeV2; -export type BitgetInstTypeV3 = - | 'UTA' // for account-level topics - | 'spot' - | 'usdt-futures' - | 'coin-futures' - | 'usdc-futures'; ⋮---- -| 'UTA' // for account-level topics +export interface FuturesHistoryPlanOrderV2 { + planType: string; + symbol: string; + size: string; + orderId: string; + executeOrderId: string; + clientOid: string; + planStatus: string; + price: string; + executePrice: string; + priceAvg: string; + baseVolume: string; + callbackRatio: string; + triggerPrice: string; + triggerType: string; + side: string; + posSide: string; + marginCoin: string; + marginMode: string; + enterPointSource: string; + tradeSide: string; + posMode: string; + orderType: string; + cTime: string; + uTime: string; + stopSurplusExecutePrice: string; + stopSurplusTriggerPrice: string; + stopSurplusTriggerType: string; + stopLossExecutePrice: string; + stopLossTriggerPrice: string; + stopLossTriggerType: string; +} ⋮---- /** * - * V1 list of topics for WebSocket consumers + * * Futures | Union Margin * */ ⋮---- -export type WsPublicSpotTopic = - | 'ticker' - | 'candle1W' - | 'candle1D' - | 'candle12H' - | 'candle4H' - | 'candle1H' - | 'candle30m' - | 'candle15m' - | 'candle5m' - | 'candle1m' - | 'books' - | 'books5' - | 'trade'; -⋮---- -// Futures currently has the same public topics as spot -export type WsPublicFuturesTopic = WsPublicSpotTopic; -export type WsPrivateSpotTopic = 'account' | 'orders'; +export interface UnionTransferLimitsV2 { + coin: string; + maxTransferIn: string; +} ⋮---- -export type WsPrivateFuturesTopic = - | 'account' - | 'positions' - | 'orders' - | 'ordersAlgo'; +export interface UnionConfigV2 { + imr: string; + mmr: string; + individualLimit: string; + individualLimitRatio: string; +} ⋮---- -export type WsPublicTopic = WsPublicSpotTopic | WsPublicFuturesTopic; +export interface UnionSwitchUsdtV2 { + usdtAmount: string; +} ⋮---- -export type WsPrivateTopic = WsPrivateSpotTopic | WsPrivateFuturesTopic; -export type WsTopic = WsPublicTopic | WsPrivateTopic; +export interface UnionConvertV2 { + usdtAmount: string; +} ⋮---- /** * - * V2 list of topics for WebSocket consumers + * * Futures | Account | Max Openable Quantity * */ ⋮---- -export type WsPublicTopicV2 = - | 'index-price' // margin only - | 'ticker' - | 'candle1m' - | 'candle5m' - | 'candle15m' - | 'candle30m' - | 'candle1H' - | 'candle4H' - | 'candle6H' - | 'candle12H' - | 'candle1D' - | 'candle3D' - | 'candle1W' - | 'candle1M' - | 'candle6Hutc' - | 'candle12Hutc' - | 'candle1Dutc' - | 'candle3Dutc' - | 'candle1Wutc' - | 'candle1Mutc' - | 'trade' - | 'books' - | 'books1' - | 'books5' - | 'books15'; -⋮---- -| 'index-price' // margin only -⋮---- -// Also update PRIVATE_TOPICS_V2 if this is updated -export type WSPrivateTopicFuturesV2 = - | 'positions' - | 'orders-algo' - | 'positions-history'; -⋮---- -// Also update PRIVATE_TOPICS_V2 if this is updated -export type WSPrivateTopicMarginV2 = - | 'orders-crossed' - | 'account-crossed' - | 'account-isolated' - | 'orders-isolated'; -⋮---- -// Also update PRIVATE_TOPICS_V2 if this is updated -export type WsPrivateTopicV2 = - | 'account' - | 'orders' - | WSPrivateTopicFuturesV2 - | WSPrivateTopicMarginV2; -⋮---- -export type WsTopicV2 = WsPublicTopicV2 | WsPrivateTopicV2; +export interface FuturesMaxOpenV2 { + maxOpen: string; +} ⋮---- /** * - * V3 / UTA list of topics for WebSocket consumers + * * Futures | Account | Liquidation Price * */ -export type WsPublicTopicV3 = 'ticker' | 'kline' | 'books' | 'publicTrade'; -// Also update PRIVATE_TOPICS_V3 if this is updated -export type WsPrivateTopicV3 = - | 'account' - | 'position' - | 'fill' - | 'order' - | 'strategy-order'; -export type WsTopicV3 = WsPublicTopicV3 | WsPrivateTopicV3; ⋮---- -/** This is used to differentiate between each of the available websocket streams */ -export type WsKey = (typeof WS_KEY_MAP)[keyof typeof WS_KEY_MAP]; +export interface FuturesLiquidationPriceV2 { + liqPrice: string; +} ⋮---- /** - * Event args for subscribing/unsubscribing + * + * * Futures | Account | Isolated Symbols + * */ ⋮---- -export interface WsTopicSubscribeEventArgs { - instType: BitgetInstType; - channel: WsTopic; - instId?: string; +export interface FuturesIsolatedSymbolV2 { + symbol: string; + marginMode: 'isolated'; } + +================ +File: src/types/response/v3/copytrading.ts +================ +/** + * + * + * Copy Trading | Futures (UTA) + * + * + */ ⋮---- -export type WsTopicSubscribePublicArgsV2 = { - instType: BitgetInstTypeV2; - channel: WsPublicTopicV2; - /** The symbol, e.g. "BTCUSDT" */ - instId: string; -}; +export interface CopyFuturesMarginDetailV3 { + marginCoin: string; + maxLongCount: string; + remainingLongCount: string; + maxShortCount: string; + remainingShortCount: string; +} ⋮---- -/** The symbol, e.g. "BTCUSDT" */ +export interface CopyFuturesTradingPairV3 { + symbol: string; + leverage: string; + marginDetails: CopyFuturesMarginDetailV3[]; +} ⋮---- -export type WsInstIdChannelsV2 = - | 'orders' - | WSPrivateTopicFuturesV2 - | 'orders-crossed' - | 'orders-isolated'; -⋮---- -export type WsTopicSubscribePrivateInstIdArgsV2 = { - instType: BitgetInstTypeV2; - channel: WsInstIdChannelsV2; - /** The symbol, e.g. "BTCUSDT" */ - instId?: string; -}; -⋮---- -/** The symbol, e.g. "BTCUSDT" */ -⋮---- -export type WsCoinChannelsV2 = - | 'account' - | 'account-crossed' - | 'account-isolated'; -⋮---- -export type WsTopicSubscribePrivateCoinArgsV2 = { - instType: BitgetInstTypeV2; - channel: WsCoinChannelsV2; - coin: 'default' | string; -}; -⋮---- -export type WsTopicSubscribePrivateArgsV2 = - | WsTopicSubscribePrivateInstIdArgsV2 - | WsTopicSubscribePrivateCoinArgsV2; -⋮---- -export type WsTopicSubscribeEventArgsV2 = - | WsTopicSubscribePublicArgsV2 - | WsTopicSubscribePrivateArgsV2; +export interface CopyFuturesPositionSummaryV3 { + unrealizedPnl: string; + realizedPnl: string; + holdSize: string; + avgPrice: string; + symbol: string; + leverage: string; + marginMode: string; + liqPrice: string; + margin: string; + holdSide: string; + roi: string; + markPrice: string; + positionValue: string; +} ⋮---- -/** General configuration for the WebsocketClient */ -export interface WSClientConfigurableOptions { - /** Your API key */ - apiKey?: string; - - /** Your API secret */ - apiSecret?: string; - - /** The passphrase you set when creating the API Key (NOT your account password) */ - apiPass?: string; - - /** - * Set to `true` to connect to Bitget's demo trading WebSockets: - * - * - V2: https://www.bitget.com/api-doc/common/demotrading/websocket - * - V3/UTA: https://www.bitget.com/api-doc/uta/guide#demo-trading - */ - demoTrading?: boolean; - - /** Define a recv window when preparing a private websocket signature. This is in milliseconds, so 5000 == 5 seconds */ - recvWindow?: number; - - // Disable ping/pong ws heartbeat mechanism (not recommended) - disableHeartbeat?: boolean; - - /** How often to check if the connection is alive */ - pingInterval?: number; - - /** How long to wait for a pong (heartbeat reply) before assuming the connection is dead */ - pongTimeout?: number; - - /** Delay in milliseconds before respawning the connection */ - reconnectTimeout?: number; - - requestOptions?: RestClientOptions; - - wsOptions?: { - protocols?: string[]; - agent?: any; - } & Partial; - - wsUrl?: string; - - /** - * Allows you to provide a custom "signMessage" function, e.g. to use node's much faster createHmac method - * - * Look in the examples folder for a demonstration on using node's createHmac instead. - */ - customSignMessageFn?: (message: string, secret: string) => Promise; +export interface CopyFuturesMaxTransferableV3 { + maxTransferable: string; + available: string; } ⋮---- -/** Your API key */ +export interface CopyFuturesTransferResponseV3 { + transferId: string; +} ⋮---- -/** Your API secret */ +/** May be a single value or comma-separated values */ +export type CopyFuturesTransferAccountTypeV3 = + | 'spot' + | 'uta' + | 'lead' + | 'otc' + | string; ⋮---- -/** The passphrase you set when creating the API Key (NOT your account password) */ +export interface CopyFuturesTransferRecordV3 { + transferId: string; + fromType: CopyFuturesTransferAccountTypeV3; + toType: CopyFuturesTransferAccountTypeV3; + amount: string; + coin: string; + status: 'Successful' | 'Failed' | 'Processing'; + createdTime: string; +} ⋮---- -/** - * Set to `true` to connect to Bitget's demo trading WebSockets: - * - * - V2: https://www.bitget.com/api-doc/common/demotrading/websocket - * - V3/UTA: https://www.bitget.com/api-doc/uta/guide#demo-trading - */ +export interface CopyFuturesTransferRecordListV3 { + list: CopyFuturesTransferRecordV3[]; +} ⋮---- -/** Define a recv window when preparing a private websocket signature. This is in milliseconds, so 5000 == 5 seconds */ +export interface CopyFuturesCurrentFollowerV3 { + followerName: string; + estimateAssets: string; + totalProfit: string; + totalShareProfit: string; + totalInvestment: string; + canRemove: 'yes' | 'no'; + followDays: string; + totalAssets: string; + startTime: string; +} ⋮---- -// Disable ping/pong ws heartbeat mechanism (not recommended) +export interface CopyFuturesCurrentFollowersV3 { + list: CopyFuturesCurrentFollowerV3[]; +} ⋮---- -/** How often to check if the connection is alive */ +export interface CopyFuturesHistoryFollowerV3 { + followerName: string; + totalProfit: string; + totalShareProfit: string; + totalInvestment: string; + startTime: string; + endTime: string; +} ⋮---- -/** How long to wait for a pong (heartbeat reply) before assuming the connection is dead */ +export interface CopyFuturesHistoryFollowersV3 { + list: CopyFuturesHistoryFollowerV3[]; +} ⋮---- -/** Delay in milliseconds before respawning the connection */ +export interface CopyFuturesProfitSummaryV3 { + totalProfit: string; + totalAllocatedProfit: string; + totalPendingProfit: string; +} ⋮---- -/** - * Allows you to provide a custom "signMessage" function, e.g. to use node's much faster createHmac method - * - * Look in the examples folder for a demonstration on using node's createHmac instead. - */ +export interface CopyFuturesProfitDetailV3 { + followerName: string; + profit: string; + allocatedPnl: string; + pendingPnl: string; + shareRatio: string; + shareProfit: string; + reason: 'period' | 'unfollow' | string; + settleTime: string; +} ⋮---- -export interface WebsocketClientOptions extends WSClientConfigurableOptions { - pingInterval: number; - pongTimeout: number; - reconnectTimeout: number; - recvWindow: number; - authPrivateConnectionsOnConnect: boolean; - authPrivateRequests: boolean; +export interface CopyFuturesProfitDetailsV3 { + list: CopyFuturesProfitDetailV3[]; + nextCursor: string; } ================ -File: src/types/request/v3/account.ts +File: src/types/request/v3/public.ts ================ -// Account Management Request Types -⋮---- -export type AccountAdjustModeV3 = 'basic' | 'advanced' | 'delta' | 'isolated'; -⋮---- -export interface AdjustAccountModeRequestV3 { - mode: AccountAdjustModeV3; - /** Sub-account UID when the master account switches mode for a sub-account */ - targetUid?: string; -} -⋮---- -/** Sub-account UID when the master account switches mode for a sub-account */ -⋮---- -export interface SetLeverageRequestV3 { - category: 'MARGIN' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - leverage: string; - coin?: string; - posSide?: 'long' | 'short'; - /** Futures only. Defaults to crossed */ - marginMode?: 'crossed' | 'isolated'; - /** Isolated two-way mode: long leverage. Takes priority over leverage when both set */ - longLeverage?: string; - /** Isolated two-way mode: short leverage. Takes priority over leverage when both set */ - shortLeverage?: string; -} -⋮---- -/** Futures only. Defaults to crossed */ -⋮---- -/** Isolated two-way mode: long leverage. Takes priority over leverage when both set */ -⋮---- -/** Isolated two-way mode: short leverage. Takes priority over leverage when both set */ -⋮---- -export interface GetAllFeeRatesRequestV3 { +export interface GetPublicFillsRequestV3 { category: | 'SPOT' | 'MARGIN' @@ -10339,1373 +11266,1404 @@ export interface GetAllFeeRatesRequestV3 { | 'COIN-FUTURES' | 'USDC-FUTURES'; symbol?: string; + limit?: string; } ⋮---- -export interface GetConvertRecordsRequestV3 { - fromCoin?: string; - toCoin?: string; +export interface GetCandlesRequestV3 { + category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol: string; + interval: + | '1m' + | '3m' + | '5m' + | '15m' + | '30m' + | '1H' + | '4H' + | '6H' + | '12H' + | '1D'; startTime?: string; endTime?: string; + type?: 'MARKET' | 'MARK' | 'INDEX'; limit?: string; - cursor?: string; } ⋮---- -export interface GetFinancialRecordsRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - coin?: string; - type?: string; +export interface GetHistoryCandlesRequestV3 { + category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol: string; + interval: + | '1m' + | '3m' + | '5m' + | '15m' + | '30m' + | '1H' + | '4H' + | '6H' + | '12H' + | '1D'; startTime?: string; endTime?: string; + type?: 'MARKET' | 'MARK' | 'INDEX'; limit?: string; - cursor?: string; } ⋮---- -export interface RepayRequestV3 { - repayableCoinList: string[]; - paymentCoinList: string[]; +export interface GetContractsOiRequestV3 { + symbol?: string; + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; } ⋮---- -// Sub-account Management Request Types +export interface GetCurrentFundingRateRequestV3 { + category?: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; +} ⋮---- -export interface CreateSubAccountApiKeyRequestV3 { - subUid: string; - note: string; - type: 'read_write' | 'read_only'; - passphrase: string; - permissions: string[]; - ips: string[]; -} -⋮---- -export interface DeleteSubAccountApiKeyRequestV3 { - apiKey: string; -} -⋮---- -export interface GetSubAccountApiKeysRequestV3 { - subUid: string; +export interface GetLiquidationsRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; limit?: string; cursor?: string; } ⋮---- -export interface UpdateSubAccountApiKeyRequestV3 { - apiKey: string; - passphrase: string; - type?: 'read_write' | 'read_only'; - permissions?: string[]; - ips?: string[]; -} -⋮---- -export interface CreateSubAccountRequestV3 { - username: string; - accountMode?: 'classic' | 'unified'; - note?: string; -} -⋮---- -export interface FreezeSubAccountRequestV3 { - subUid: string; - operation: 'freeze' | 'unfreeze'; -} -⋮---- -export interface GetSubAccountListRequestV3 { - limit?: string; +export interface GetHistoryFundingRateRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol: string; cursor?: string; + limit?: string; } ⋮---- -// Transfer Request Types -⋮---- -export interface TransferRequestV3 { - clientOid?: string; - fromType: - | 'spot' - | 'p2p' - | 'coin-futures' - | 'usdt-futures' - | 'usdc-futures' - | 'crossed-margin' - | 'isolated-margin' - | 'uta'; - toType: - | 'spot' - | 'p2p' - | 'coin-futures' - | 'usdt-futures' - | 'usdc-futures' - | 'crossed-margin' - | 'isolated-margin' - | 'uta'; - amount: string; +export interface GetMarginLoansRequestV3 { coin: string; - symbol?: string; - /** Enable automatic margin borrowing when balance insufficient. yes | no */ - allowBorrow?: 'yes' | 'no'; } ⋮---- -/** Enable automatic margin borrowing when balance insufficient. yes | no */ -⋮---- -export interface GetTransferableCoinsRequestV3 { - fromType: - | 'spot' - | 'p2p' - | 'coin-futures' - | 'usdt-futures' - | 'usdc-futures' - | 'crossed-margin' - | 'isolated-margin' - | 'uta'; - toType: - | 'spot' - | 'p2p' - | 'coin-futures' - | 'usdt-futures' - | 'usdc-futures' - | 'crossed-margin' - | 'isolated-margin' - | 'uta'; +export interface GetOpenInterestRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; } ⋮---- -export interface GetSubTransferRecordsRequestV3 { - subUid?: string; - role?: 'initiator' | 'receiver'; +export interface GetPositionTierRequestV3 { + category: 'MARGIN' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; coin?: string; - startTime?: string; - endTime?: string; - clientOid?: string; - limit?: string; - cursor?: string; } ⋮---- -export interface SubAccountTransferRequestV3 { - fromType: - | 'spot' - | 'p2p' - | 'usdt_futures' - | 'coin_futures' - | 'usdc_futures' - | 'crossed_margin' - | 'uta'; - toType: - | 'spot' - | 'p2p' - | 'usdt_futures' - | 'coin_futures' - | 'usdc_futures' - | 'crossed_margin' - | 'uta'; - amount: string; - coin: string; - fromUserId: string; - toUserId: string; - clientOid: string; - /** Enable automatic margin borrowing when balance insufficient. yes | no */ - allowBorrow?: 'yes' | 'no'; +export interface GetRiskReserveRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol: string; + marginCoin?: string; } ⋮---- -/** Enable automatic margin borrowing when balance insufficient. yes | no */ -⋮---- -export interface GetSubUnifiedAssetsRequestV3 { - subUid?: string; - cursor?: string; - limit?: string; +export interface GetRiskReserveAllRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; } ⋮---- -export interface GetFeeRateRequestV3 { +export interface GetInstrumentsRequestV3 { category: | 'SPOT' | 'MARGIN' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol: string; + symbol?: string; } ⋮---- -export interface GetFundingAssetsRequestV3 { - coin?: string; +export interface GetMarketFeeGroupRequestV3 { + category: 'SPOT' | 'FUTURES'; + group?: 'DEFAULT' | 'GROUP_A' | 'GROUP_B' | 'GROUP_C'; } ⋮---- -export interface SwitchDeductRequestV3 { - deduct: 'on' | 'off'; +export interface GetMarketScoreWeightsRequestV3 { + category?: 'SPOT' | 'FUTURES'; } ⋮---- -// Deposit Request Types +export interface GetOrderBookRequestV3 { + category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol: string; + limit?: string; +} ⋮---- -export interface GetDepositAddressRequestV3 { - coin: string; - chain?: string; - size?: string; +export interface GetTickersRequestV3 { + category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; } ⋮---- -export interface GetSubDepositAddressRequestV3 { - subUid: string; - coin: string; - chain?: string; - size?: string; +export interface GetIndexComponentsRequestV3 { + symbol: string; } ⋮---- -export interface GetDepositRecordsRequestV3 { - coin?: string; - orderId?: string; - startTime: string; - endTime: string; +export interface GetRpiOrderBookRequestV3 { + category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol: string; limit?: string; - cursor?: string; } ⋮---- -export interface GetSubDepositRecordsRequestV3 { - coin?: string; - subUid: string; - startTime: string; - endTime: string; - limit?: string; +export interface GetCashDividendRecordsRequestV3 { + symbol: string; + type: 'pending' | 'paid'; cursor?: string; + limit?: string; } ⋮---- -// Withdraw Request Types +export interface GetSpotWhaleFlowRequestV3 { + symbol: string; +} ⋮---- -export interface WithdrawRequestV3 { - coin: string; - chain?: string; - /** Deduct from funding, uta, and/or otc accounts (comma-separated). Order: funding -> otc -> uta */ - accountType?: string; - transferType: 'on_chain' | 'internal_transfer'; - address: string; - innerToType?: 'uid' | 'email' | 'mobile'; - areaCode?: string; - tag?: string; - size: string; - remark?: string; - clientOid?: string; - memberCode?: 'bithumb' | 'korbit' | 'coinone'; - identityType?: 'company' | 'user'; - companyName?: string; - firstName?: string; - lastName?: string; +export interface GetSpotFundFlowRequestV3 { + symbol: string; + period?: string; } ⋮---- -/** Deduct from funding, uta, and/or otc accounts (comma-separated). Order: funding -> otc -> uta */ +export interface GetSpotNetFlowRequestV3 { + symbol: string; +} ⋮---- -export interface GetWithdrawRecordsRequestV3 { +export interface GetMarginLongShortRequestV3 { + symbol: string; + period?: '24h' | '30d'; coin?: string; - orderId?: string; - clientOid?: string; - startTime: string; - endTime: string; - limit?: string; - cursor?: string; } ⋮---- -export interface GetWithdrawAddressBookRequestV3 { +export interface GetMarginLoanGrowthRequestV3 { + symbol: string; + period?: string; coin?: string; - type?: 'EVM' | 'regular' | 'universal' | 'internal'; - limit?: string; - cursor?: string; } ⋮---- -export interface CancelWithdrawalRequestV3 { - orderId?: string; - clientOid?: string; +export interface GetMarginIsolatedBorrowRequestV3 { + symbol: string; + period?: string; } ⋮---- -export interface SetDepositAccountRequestV3 { - coin: string; - accountType: 'funding' | 'unified' | 'otc'; +export interface GetFuturesTradingDataRequestV3 { + symbol: string; + period?: string; } -⋮---- -export interface GetMaxTransferableRequestV3 { - coin: string; + +================ +File: src/types/request/v3/trade.ts +================ +export interface BatchModifyOrderRequestV3 { + orderId?: string; + clientOid?: string; + qty?: string; + price?: string; + autoCancel?: 'yes' | 'no'; } ⋮---- -export interface GetOpenInterestLimitRequestV3 { - symbol: string; - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; +export interface CancelAllOrdersRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol?: string; } ⋮---- -export interface GetTaxRecordsRequestV3 { - bizType: +export interface CancelBatchOrdersRequestV3 { + orderId?: string; + clientOid?: string; + category: | 'SPOT' | 'MARGIN' | 'USDT-FUTURES' | 'COIN-FUTURES' - | 'USDC-FUTURES' - | 'OTHER'; - marginType?: 'isolated' | 'crossed'; - coin?: string; - startTime: string; - endTime: string; - limit?: string; - cursor?: string; + | 'USDC-FUTURES'; + symbol: string; } ⋮---- -export type CollateralTypeV3 = 'mainstream' | 'all' | 'custom'; -⋮---- -export interface SetCollateralTypeRequestV3 { - collateralType: CollateralTypeV3; - /** Required when collateralType=custom. Comma-separated coin names */ - collateralCoins?: string; +export interface CloseAllPositionsRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; + posSide?: 'long' | 'short'; } ⋮---- -/** Required when collateralType=custom. Comma-separated coin names */ -⋮---- -export interface PreSetLeverageRequestV3 { - category: 'MARGIN' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - coin?: string; - marginMode: 'isolated' | 'cross'; - leverage?: string; - longLeverage?: string; - shortLeverage?: string; +export interface CancelOrderRequestV3 { + orderId?: string; + clientOid?: string; + category?: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; } ⋮---- -export interface SetMarginRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; +export interface GetMaxOpenAvailableRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; symbol: string; - posSide: 'long' | 'short'; - operation: 'add' | 'remove'; - amount: string; + orderType: 'limit' | 'market'; + side: 'buy' | 'sell'; + price?: string; + size?: string; } ⋮---- -export interface GetMaxWithdrawalRequestV3 { - coin: string; -} - -================ -File: src/types/response/v3/public.ts -================ -export interface PublicFillV3 { - execId: string; - price: string; - size: string; - side: 'sell' | 'buy'; - ts: string; +export interface GetOrderInfoRequestV3 { + orderId?: string; + clientOid?: string; } ⋮---- -export interface CandlestickV3 extends Array { - 0: string; // timestamp - 1: string; // open price - 2: string; // high price - 3: string; // low price - 4: string; // close price - 5: string; // volume - 6: string; // turnover +export interface GetFillsRequestV3 { + category?: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + orderId?: string; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; } ⋮---- -0: string; // timestamp -1: string; // open price -2: string; // high price -3: string; // low price -4: string; // close price -5: string; // volume -6: string; // turnover +export interface GetUnfilledOrdersRequestV3 { + category?: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol?: string; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; +} ⋮---- -export interface ContractOiV3 { - symbol: string; - notionalValue: string; - totalNotionalValue: string; +export interface GetHistoryOrdersRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol?: string; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; } ⋮---- -export interface CurrentFundingRateV3 { - symbol: string; - fundingRate: string; - fundingRateInterval: string; - nextUpdate: string; - minFundingRate: string; - maxFundingRate: string; - cashDividend?: string; - cashDividendNextUpdate?: string; +export interface GetPositionHistoryRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; } ⋮---- -export interface DiscountRateTierV3 { - tierStartValue: string; - discountRate: string; +export interface GetCurrentPositionRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; + posSide?: 'long' | 'short'; } ⋮---- -export interface DiscountRateV3 { - coin: string; - list: DiscountRateTierV3[]; +export interface ModifyOrderRequestV3 { + orderId?: string; + clientOid?: string; + qty?: string; + price?: string; + autoCancel?: 'yes' | 'no'; + symbol?: string; + category?: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + tpTriggerBy?: 'market' | 'mark'; + slTriggerBy?: 'market' | 'mark'; + takeProfit?: string; + stopLoss?: string; + tpOrderType?: 'limit' | 'market'; + slOrderType?: 'limit' | 'market'; + tpLimitPrice?: string; + slLimitPrice?: string; } ⋮---- -export interface HistoryFundingRateV3 { +export interface PlaceRealityOrderRequestV3 { + category?: 'SPOT' | 'MARGIN'; symbol: string; - fundingRate: string; - fundingRateTimestamp: string; + side: 'buy' | 'sell'; + orderType: 'limit' | 'market'; + qty: string; + price?: string; + clientOid?: string; } ⋮---- -export interface MarginLoanV3 { - dailyInterest: string; - annualInterest: string; - limit: string; +export interface CancelRealityOrderRequestV3 { + category?: 'SPOT' | 'MARGIN'; + symbol: string; + orderId?: string; + clientOid?: string; } ⋮---- -export interface OpenInterestItemV3 { +export interface PlaceBatchOrdersRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; symbol: string; - openInterest: string; + qty: string; + price?: string; + side: 'buy' | 'sell'; + orderType: 'limit' | 'market'; + timeInForce?: 'ioc' | 'fok' | 'gtc' | 'post_only'; + posSide?: 'long' | 'short'; + clientOid?: string; + reduceOnly?: 'yes' | 'no'; } ⋮---- -export interface OpenInterestV3 { - list: OpenInterestItemV3[]; - ts: string; -} +export type FuturesMarginModeV3 = 'crossed' | 'isolated'; ⋮---- -export interface PositionTierV3 { - tier: string; - minTierValue: string; - maxTierValue: string; - leverage: string; - mmr: string; +export interface PlaceOrderRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol: string; + qty: string; + price?: string; + side: 'buy' | 'sell'; + orderType: 'limit' | 'market'; + timeInForce?: 'ioc' | 'fok' | 'gtc' | 'post_only'; + posSide?: 'long' | 'short'; + clientOid?: string; + reduceOnly?: 'yes' | 'no'; + /** Futures only. Defaults to crossed */ + marginMode?: FuturesMarginModeV3; + stpMode?: 'none' | 'cancel_taker' | 'cancel_maker' | 'cancel_both'; + tpTriggerBy?: 'market' | 'mark'; + slTriggerBy?: 'market' | 'mark'; + takeProfit?: string; + stopLoss?: string; + tpOrderType?: 'limit' | 'market'; + slOrderType?: 'limit' | 'market'; + tpLimitPrice?: string; + slLimitPrice?: string; } ⋮---- -export interface RiskReserveRecordV3 { - balance: string; - amount: string; - ts: string; - type?: string; +/** Futures only. Defaults to crossed */ +⋮---- +export interface CountdownCancelAllRequestV3 { + countdown: string; // seconds until auto-cancel (5-60, or 0 to disable) } ⋮---- -export interface RiskReserveV3 { - totalBalance?: string; - coin: string; - riskReserveRecords: RiskReserveRecordV3[]; +countdown: string; // seconds until auto-cancel (5-60, or 0 to disable) + +================ +File: src/types/response/v3/trade.ts +================ +export interface BatchModifyOrderResponseV3 { + orderId: string; + clientOid: string; } ⋮---- -export interface RiskReserveHourRecordV3 { - amount: string; - balance: string; - ts: string; +export interface CancelAllOrdersResponseV3 { + list: { + orderId: string; + clientOid: string; + code: string; + msg: string; + }[]; } ⋮---- -export interface RiskReserveHourV3 { - coin: string; - riskReserveRecords: RiskReserveHourRecordV3[]; +export interface CancelBatchOrdersResponseV3 { + orderId: string; + clientOid: string; + code?: string; + msg?: string; } ⋮---- -export interface RiskReserveAllItemV3 { - symbols: string[]; - coin: string; - balance: string; +export interface CloseAllPositionsResponseV3 { + list: { + orderId: string; + clientOid: string; + code: string; + msg: string; + }[]; } ⋮---- -export interface RiskReserveAllV3 { - list: RiskReserveAllItemV3[]; +export interface CancelOrderResponseV3 { + orderId: string; + clientOid: string; } ⋮---- -export interface InstrumentV3 { - symbol: string; - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - baseCoin: string; - quoteCoin: string; - buyLimitPriceRatio: string; - sellLimitPriceRatio: string; - feeRateUpRatio: string; - minOrderQty: string; - maxOrderQty: string; - maxMarketOrderQty: string; - pricePrecision: string; - quantityPrecision: string; - quotePrecision: string; - minOrderAmount: string; - maxSymbolOrderNum: string; - maxProductOrderNum: string; - status: - | 'listed' - | 'online' - | 'limit_open' - | 'limit_close' - | 'offline' - | 'restrictedAPI'; - offTime: string; - limitOpenTime: string; - maintainTime: string; - areaSymbol?: string; - - /** yes = Reality stock token, no = non-Reality stock token */ - isReality?: 'yes' | 'no'; - - // Futures specific fields - makerFeeRate?: string; - takerFeeRate?: string; - openCostUpRatio?: string; - priceMultiplier?: string; - quantityMultiplier?: string; - symbolType?: 'perpetual' | 'delivery'; - maxPositionNum?: string; - deliveryTime?: string; - deliveryStartTime?: string; - deliveryPeriod?: string; - /** Launch time - Unix millisecond timestamp. Null for some margin pairs. */ - launchTime?: string | null; - fundInterval?: string; - minLeverage?: string; - maxLeverage?: string; - - // Margin specific fields - isIsolatedBaseBorrowable?: 'YES' | 'NO'; - isIsolatedQuotedBorrowable?: 'YES' | 'NO'; - warningRiskRatio?: string; - liquidationRiskRatio?: string; - maxCrossedLeverage?: string; - maxIsolatedLeverage?: string; - userMinBorrow?: string; +export interface GetMaxOpenAvailableResponseV3 { + available: string; + maxOpen: string; + buyOpenCost: string; + sellOpenCost: string; + maxBuyOpen: string; + maxSellOpen: string; } ⋮---- -/** yes = Reality stock token, no = non-Reality stock token */ -⋮---- -// Futures specific fields -⋮---- -/** Launch time - Unix millisecond timestamp. Null for some margin pairs. */ -⋮---- -// Margin specific fields -⋮---- -export interface MarketFeeGroupLabelV3 { - weight: string; - label: string; - symbols: string[]; +export interface FeeDetailV3 { + feeCoin: string; + fee: string; } ⋮---- -export interface MarketFeeGroupTierV3 { - level: string; - makerFeeRate: string; - /** PRO1~PRO6 only. Taker fee rate in decimal form */ - takerFeeRate?: string; +export interface OrderInfoV3 { + orderId: string; + clientOid: string; + category: string; + symbol: string; + orderType: string; + side: string; + price: string; + qty: string; + amount: string; + cumExecQty: string; + cumExecValue: string; + avgPrice: string; + timeInForce: string; + orderStatus: string; + posSide: string; + holdMode: string; + delegateType?: string; + reduceOnly: string; + feeDetail: FeeDetailV3[]; + cancelReason: string; + execType: string; + stpMode?: string; + createdTime: string; + updatedTime: string; } ⋮---- -/** PRO1~PRO6 only. Taker fee rate in decimal form */ +export type FillCategoryV3 = + | 'spot' + | 'margin' + | 'usdt-futures' + | 'coin-futures' + | 'usdc-futures' + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; ⋮---- -export interface MarketFeeGroupV3 { - category: string; - group: string; - labelList: MarketFeeGroupLabelV3[]; - tierList: MarketFeeGroupTierV3[]; +export interface FillV3 { + execId: string; + orderId: string; + category: FillCategoryV3; + symbol: string; + orderType: string; + side: string; + execPrice: string; + execQty: string; + execValue: string; + tradeScope: string; + feeDetail: FeeDetailV3[]; + execPnl?: string; + tradeSide?: string; + createdTime: string; + updatedTime: string; } ⋮---- -export interface MarketScoreWeightV3 { +export interface UnfilledOrderV3 { + orderId: string; + clientOid: string; category: string; - label: string; symbol: string; - requiredSpread: string; - minMakerVolume: string; - weight: string; + orderType: string; + side: string; + price: string; + qty: string; + amount: string; + cumExecQty: string; + cumExecValue: string; + avgPrice: string; + timeInForce: string; + orderStatus: string; + posSide: string; + holdMode: string; + delegateType?: string; + reduceOnly: string; + feeDetail: FeeDetailV3[]; + stpMode?: string; + createdTime: string; + updatedTime: string; } ⋮---- -export interface LiquidationV3 { +export interface HistoryOrderV3 { + orderId: string; + clientOid: string; + category: string; symbol: string; - side: 'buy' | 'sell'; + orderType: string; + side: string; price: string; + qty: string; amount: string; - ts: string; -} -⋮---- -export interface LiquidationsV3 { - list: LiquidationV3[]; - cursor?: string; -} -⋮---- -export interface OrderBookV3 { - a: string[][]; // asks - [price, size] - b: string[][]; // bids - [price, size] - ts: string; + cumExecQty: string; + cumExecValue: string; + avgPrice: string; + timeInForce: string; + orderStatus: string; + posSide: string; + holdMode: string; + delegateType?: string; + reduceOnly: string; + feeDetail: FeeDetailV3[]; + cancelReason: string; + execType: string; + stpMode?: string; + createdTime: string; + updatedTime: string; } ⋮---- -a: string[][]; // asks - [price, size] -b: string[][]; // bids - [price, size] -⋮---- -export interface TickerV3 { - category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; +export interface PositionHistoryV3 { + positionId: string; + category: string; symbol: string; - lastPrice: string; - openPrice24h: string; - highPrice24h: string; - lowPrice24h: string; - ask1Price: string; - bid1Price: string; - bid1Size: string; - ask1Size: string; - price24hPcnt: string; - volume24h: string; - turnover24h: string; - - // Futures specific fields - indexPrice?: string; - markPrice?: string; - fundingRate?: string; - openInterest?: string; - deliveryStartTime?: string; - deliveryTime?: string; - deliveryStatus?: string; + marginCoin: string; + holdMode: string; + posSide: string; + marginMode: string; + openPriceAvg: string; + closePriceAvg: string; + openTotalPos: string; + closeTotalPos: string; + cumRealisedPnl: string; + netProfit: string; + totalFunding: string; + openFeeTotal: string; + closeFeeTotal: string; + /** Cash dividend, USDT */ + cashDividend?: string; + createdTime: string; + updatedTime: string; } ⋮---- -// Futures specific fields +/** Cash dividend, USDT */ ⋮---- -export interface ProofOfReservesV3 { - merkleRootHash: string; - totalReserveRatio: string; - list: { - coin: string; - userAssets: string; - platformAssets: string; - reserveRatio: string; - }[]; +export interface CurrentPositionV3 { + category: string; + symbol: string; + marginCoin: string; + holdMode: string; + posSide: string; + marginMode: string; + positionBalance: string; + available: string; + frozen: string; + total: string; + leverage: string; + curRealisedPnl: string; + avgPrice: string; + positionStatus: string; + unrealisedPnl: string; + liquidationPrice: string; + mmr: string; + profitRate: string; + markPrice: string; + breakEvenPrice: string; + totalFunding: string; + openFeeTotal: string; + closeFeeTotal: string; + /** Cash dividend, USDT */ + cashDividend?: string; + createdTime: string; + updatedTime: string; } ⋮---- -export interface IndexComponentV3 { - exchange: string; - spotPair: string; - equivalentPrice: string; - weight: string; +/** Cash dividend, USDT */ +⋮---- +export interface LoanDataDebtCoinV3 { + coin: string; + debt: string; + interestFreeAmount: string; + interestRateNextHour: string; } ⋮---- -export interface IndexPriceComponentsV3 { - symbol: string; - componentList: IndexComponentV3[]; +export interface LoanDataV3 { + currentLoans: string; + interestPaymentTime: string; + debtCoinList: LoanDataDebtCoinV3[]; } ⋮---- -export interface RpiSymbolV3 { - category: 'spot' | 'usdt-futures' | 'coin-futures' | 'usdc-futures'; - symbol: string; +export interface ModifyOrderResponseV3 { + orderId: string; + clientOid: string; } ⋮---- -/** RPI order book depth: [price, nonRpiQty, rpiQty] */ -export interface RpiOrderBookV3 { - a: [string, string, string][]; - b: [string, string, string][]; - ts: string; +export interface PlaceBatchOrdersResponseV3 { + orderId: string; + clientOid: string; + code?: string; + msg?: string; } ⋮---- -export interface CashDividendRecordV3 { +export interface PlaceOrderResponseV3 { + orderId: string; + clientOid: string; +} +⋮---- +export interface PositionAdlRankV3 { symbol: string; - exDividendDate: string; - cashDividendPerShare: string; - cashDividendTimestamp: string; + marginCoin: string; + adlRank: string; + holdSide: 'long' | 'short'; } + +================ +File: src/types/response/v3/account.ts +================ +// Account Management Response Types +import type { CollateralTypeV3 } from '../../request/v3/account.js'; ⋮---- -export interface SpotWhaleFlowV3 { - volume: string; - date: string; +export interface AccountSymbolConfigV3 { + category: string; + symbol: string; + marginMode: string; + leverage: string; } ⋮---- -export interface SpotNetFlowV3 { - netFlow: string; - ts: string; +export interface AccountCoinConfigV3 { + coin: string; + leverage: string; } ⋮---- -export interface SpotFundFlowV3 { - whaleBuyVolume: string; - dolphinBuyVolume: string; - fishBuyVolume: string; - whaleSellVolume: string; - dolphinSellVolume: string; - fishSellVolume: string; - whaleBuyRatio: string; - dolphinBuyRatio: string; - fishBuyRatio: string; - whaleSellRatio: string; - dolphinSellRatio: string; - fishSellRatio: string; +export type AccountPermissionV3 = + | 'uta_mgt' + | 'uta_trade' + | 'withdraw' + | 'copy_futures_position' + | 'copy_futures_order'; +⋮---- +export interface AccountInfoV3 { + userId: string; + inviterId: string; + /** Only set when the calling account is a sub-account */ + parentId: string; + channelCode: string; + channel: string; + ips: string; + permType: 'read-only' | 'read-and-write'; + permissions: AccountPermissionV3[]; + regisTime: string; } ⋮---- -export interface MarginLongShortV3 { - longShortRatio: string; - ts: string; +/** Only set when the calling account is a sub-account */ +⋮---- +export type AccountLevelV3 = 'basic' | 'advanced' | 'isolated' | 'delta'; +⋮---- +export interface AccountSettingsV3 { + uid: string; + accountMode: 'unified' | 'hybrid' | 'upgrading' | 'switching'; + assetMode: string; + accountLevel: AccountLevelV3; + holdMode: string; + stpMode: 'none' | 'cancel_taker' | 'cancel_maker' | 'cancel_both'; + symbolConfigList: AccountSymbolConfigV3[]; + coinConfigList: AccountCoinConfigV3[]; } ⋮---- -export interface MarginLoanGrowthV3 { - growthRate: string; - ts: string; +export interface AccountDeltaCoinPositionV3 { + coin: string; + positionRatio: string; } ⋮---- -export interface MarginIsolatedBorrowV3 { - borrowRate: string; - ts: string; +/** Delta-neutral mode metrics. Only available when accountLevel is delta. */ +export interface AccountDeltaInfoV3 { + deltaEquityRatio: string; + deltaThreshold: string; + positionThreshold: string; + list: AccountDeltaCoinPositionV3[]; } ⋮---- -export interface FuturesActiveBuySellV3 { - buyVolume: string; - sellVolume: string; - ts: string; +export interface AccountAssetV3 { + coin: string; + equity: string; + usdValue: string; + balance: string; + available: string; + debt: string; + locked: string; + /** Position value in USD */ + positionValue?: string; + /** Account leverage (non-negative) */ + leverage?: string; + /** USDT bonus amount */ + bonus?: string; } ⋮---- -export interface FuturesLongShortV3 { - longRatio: string; - shortRatio: string; - longShortRatio: string; - ts: string; +/** Position value in USD */ +⋮---- +/** Account leverage (non-negative) */ +⋮---- +/** USDT bonus amount */ +⋮---- +export interface AccountAssetsV3 { + accountEquity: string; + usdtEquity: string; + btcEquity: string; + unrealisedPnl: string; + usdtUnrealisedPnl: string; + btcUnrealizedPnl: string; + effEquity: string; + mmr: string; + imr: string; + mgnRatio: string; + positionMgnRatio: string; + assets: AccountAssetV3[]; } ⋮---- -export interface FuturesPositionLongShortV3 { - longPositionRatio: string; - shortPositionRatio: string; - longShortPositionRatio: string; +export interface ConvertRecordV3 { + fromCoin: string; + fromCoinSize: string; + toCoin: string; + toCoinSize: string; + price: string; ts: string; } ⋮---- -export interface FuturesAccountLongShortV3 { - longAccountRatio: string; - shortAccountRatio: string; - longShortAccountRatio: string; +export interface FinancialRecordV3 { + category: string; + id: string; + symbol: string; + coin: string; + type: string; + amount: string; + fee: string; + balance: string; ts: string; + /** crossed | isolated */ + positionType?: string; + positionAmount?: string; + positionBalance?: string; } - -================ -File: src/index.ts -================ - - -================ -File: README.md -================ -# Node.js & Typescript Bitget API SDK - -[![Build & Test](https://github.com/tiagosiebler/bitget-api/actions/workflows/e2etests.yml/badge.svg?branch=master)](https://github.com/tiagosiebler/bitget-api/actions/workflows/e2etests.yml) -[![npm version](https://img.shields.io/npm/v/bitget-api)][1] -[![npm size](https://img.shields.io/bundlephobia/min/bitget-api/latest)][1] -[![npm downloads](https://img.shields.io/npm/dt/bitget-api)][1] -[![last commit](https://img.shields.io/github/last-commit/tiagosiebler/bitget-api)][1] -[![CodeFactor](https://www.codefactor.io/repository/github/tiagosiebler/bitget-api/badge)](https://www.codefactor.io/repository/github/tiagosiebler/bitget-api) -[![Telegram](https://img.shields.io/badge/chat-on%20telegram-blue.svg)](https://t.me/nodetraders) -[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/tiagosiebler/bitget-api) - -

- - - - SDK Logo - - -

- -[1]: https://www.npmjs.com/package/bitget-api - -> [!TIP] -> Upcoming change: As part of the [Siebly.io](https://siebly.io/) brand, this SDK will soon be hosted under the [Siebly.io GitHub organisation](https://github.com/sieblyio). The migration is seamless and requires no user changes. - -Updated & performant JavaScript & Node.js SDK for the Bitget V2 REST APIs and WebSockets: - -- Professional, robust & performant Bitget SDK with extensive production use in live trading environments. -- Complete integration with all Bitget APIs. - - [x] Supports V2 REST APIs & WebSockets - - [x] Supports V3/UTA REST APIs & WebSockets (latest) - - [x] Supports order placement via V3 WebSocket API -- Complete TypeScript support (with type declarations for all API requests & responses). - - Strongly typed requests and responses. - - Automated end-to-end tests on most API calls, ensuring no breaking changes are released to npm. -- Actively maintained with a modern, promise-driven interface. -- Over 100 integration tests making real API calls & WebSocket connections, validating any changes before they reach npm. -- Robust WebSocket integration with configurable connection heartbeats & automatic reconnect then resubscribe workflows. - - Event driven messaging. - - Smart WebSocket persistence with automatic reconnection handling. - - Emit `reconnected` event when dropped connection is restored. - - Optional beautification of WebSocket events for improved readability. -- Officially listed Node.js SDK in [Bitget API docs](https://bitgetlimited.github.io/apidoc/en/spot/#sdk-code-example). -- Browser support (via webpack bundle - see "Browser Usage" below). -- Support all authentication methods supported by Bitget: - - [x] HMAC - - [x] RSA -- Heavy automated end-to-end testing with real API calls. - - End-to-end testing before any release. - - Real API calls in e2e tests. -- Proxy support via axios integration. -- Active community support & collaboration in telegram: [Node.js Algo Traders](https://t.me/nodetraders). -- QuickStart Guide: https://siebly.io/sdk/bitget/javascript - -## Table of Contents - -- [Installation](#installation) -- [Examples](#examples) -- [Issues & Discussion](#issues--discussion) -- [Related Projects](#related-projects) -- [Documentation](#documentation) -- [Structure](#structure) -- [Usage](#usage) - - [REST API Clients](#rest-api-clients) - - [V3 REST APIs (Unified Trading Account)](#v3-rest-apis) - - [V2 REST APIs](#v2-rest-apis) - - [WebSockets](#websockets) - - [V3 Unified Trading Account](#v3-unified-trading-account) - - [Sending Orders via WebSockets](#sending-orders-via-websockets) - - [Receiving Realtime Data](#receiving-realtime-data) - - [V2 WebSockets](#v2-websockets) - - [Customise Logging](#logging) - - [Custom Logger](#customise-logging) - - [Debug HTTP Requests](#debug-http-requests) - - [Frontend Usage](#browser-usage) - - [Import](#import) - - [Webpack](#webpack) -- [LLMs & AI](#use-with-llms--ai) -- [Used By](#used-by) -- [Contributions & Thanks](#contributions--thanks) - -## Installation - -`npm install --save bitget-api` - -## Examples - -Refer to the [examples](./examples) folder for implementation demos. - -## Issues & Discussion - -- Issues? Check the [issues tab](https://github.com/tiagosiebler/bitget-api/issues). -- Discuss & collaborate with other node devs? Join our [Node.js Algo Traders](https://t.me/nodetraders) engineering community on telegram. -- Follow our announcement channel for real-time updates on [X/Twitter](https://x.com/sieblyio) - - - -## Related Projects - -Check out our JavaScript/TypeScript/Node.js SDKs & Projects: - -- Visit our website: [https://Siebly.io](https://siebly.io/) -- Try our REST API & WebSocket SDKs published on npmjs: - - [Bybit Node.js SDK: bybit-api](https://www.npmjs.com/package/bybit-api) - - [Kraken Node.js SDK: @siebly/kraken-api](https://www.npmjs.com/package/@siebly/kraken-api) - - [OKX Node.js SDK: okx-api](https://www.npmjs.com/package/okx-api) - - [Binance Node.js SDK: binance](https://www.npmjs.com/package/binance) - - [Gate (gate.com) Node.js SDK: gateio-api](https://www.npmjs.com/package/gateio-api) - - [Bitget Node.js SDK: bitget-api](https://www.npmjs.com/package/bitget-api) - - [Kucoin Node.js SDK: kucoin-api](https://www.npmjs.com/package/kucoin-api) - - [Coinbase Node.js SDK: coinbase-api](https://www.npmjs.com/package/coinbase-api) - - [Bitmart Node.js SDK: bitmart-api](https://www.npmjs.com/package/bitmart-api) -- Try my misc utilities: - - [OrderBooks Node.js: orderbooks](https://www.npmjs.com/package/orderbooks) - - [Crypto Exchange Account State Cache: accountstate](https://www.npmjs.com/package/accountstate) -- Check out my examples: - - [awesome-crypto-examples Node.js](https://github.com/tiagosiebler/awesome-crypto-examples) - - -## Documentation - -Most methods accept JS objects. These can be populated using parameters specified by Bitget's API documentation, or check the type definition in each class within this repository (see table below for convenient links to each class). - -- Bitget API Documentation - - [V3/UTA API Documentation](https://www.bitget.com/api-doc/uta/intro) (Latest - Unified Trading Account) - - [V2 API Documentation](https://www.bitget.com/api-doc/common/intro) -- [REST Endpoint Function List](./docs/endpointFunctionList.md) -- [TSDoc Documentation (autogenerated using typedoc)](https://tsdocs.dev/docs/bitget-api) - -## Structure - -This connector is fully compatible with both TypeScript and pure JavaScript projects, while the connector is written in TypeScript. A pure JavaScript version can be built using `npm run build`, which is also the version published to [npm](https://www.npmjs.com/package/bitget-api). - -The version on npm is the output from the `build` command and can be used in projects without TypeScript (although TypeScript is definitely recommended). - -- [src](./src) - the whole connector written in TypeScript -- [lib](./lib) - the JavaScript version of the project (built from TypeScript). This should not be edited directly, as it will be overwritten with each release. -- [dist](./dist) - the webpack bundle of the project for use in browser environments (see guidance on webpack below). -- [examples](./examples) - some implementation examples & demonstrations. Contributions are welcome! - ---- - -# Usage - -Create API credentials at Bitget: - -- [Livenet API Management](https://www.bitget.com/en/support/articles/360011132814-How-to-create-API) -- [Demo Trading Environment](https://www.bitget.com/en/demo-trading) - -## REST API Clients - -Each REST API group has a dedicated REST client. To avoid confusion, here are the available REST clients and the corresponding API groups: -| Class | Description | -|:------------------------------------: |:---------------------------------------------------------------------------------------------: | -| [RestClientV3](src/rest-client-v3.ts) | [V3/UTA REST APIs for Bitget's Unified Trading Account](https://www.bitget.com/api-doc/uta/intro) | -| [WebsocketClientV3](src/websocket-client-v3.ts) | Universal WS client for Bitget's V3/UTA WebSockets | -| [WebsocketAPIClient](src/websocket-api-client.ts) | Websocket API Client, for RESTlike order placement via Bitget's V3/UTA WebSocket API | -| [RestClientV2](src/rest-client-v2.ts) | [V2 REST APIs](https://www.bitget.com/api-doc/common/intro) | -| [WebsocketClientV2](src/websocket-client-v2.ts) | Universal WS client for all Bitget's V2 WebSockets | - -Examples for using each client can be found in: - -- the [examples](./examples) folder. -- the [awesome-crypto-examples](https://github.com/tiagosiebler/awesome-crypto-examples) repository. - -If you're missing an example, you're welcome to request one. Priority will be given to [github sponsors](https://github.com/sponsors/tiagosiebler). - -### Getting Started - -All REST APIs are integrated in each dedicated Rest Client class. See the above table for which REST client to use. If you've upgraded to the Unified Trading Account, you should use the V3 REST APIs and WebSockets. - -There are several REST API modules as there are some differences in each API group: - -1. `RestClientV3` for the latest V3/UTA APIs (Unified Trading Account) - recommended for new projects. -2. `RestClientV2` for V2 APIs - use if you haven't upgraded to UTA yet. - -More Node.js & JavaScript examples for Bitget's REST APIs & WebSockets can be found in the [examples](./examples) folder on GitHub. - -#### V3 REST APIs - -These are only available if you have upgraded to the Unified Trading Account. If not, use the V2 APIs instead. - -```javascript -import { RestClientV3 } from 'bitget-api'; -// or if you prefer require: -// const { RestClientV3 } = require('bitget-api'); - -// note the single quotes, preventing special characters such as $ from being incorrectly passed -const client = new RestClientV3({ - apiKey: process.env.API_KEY_COM || 'insert_api_key_here', - apiSecret: process.env.API_SECRET_COM || 'insert_api_secret_here', - apiPass: process.env.API_PASS_COM || 'insert_api_pass_here', -}); - -(async () => { - try { - console.log(await client.getBalances()); - - const newOrder = await client.submitNewOrder({ - category: 'USDT-FUTURES', - orderType: 'market', - side: 'buy', - qty: '0.001', - symbol: 'BTCUSDT', - }); - - console.log('Order submitted: ', newOrder); - } catch (e) { - console.error('request failed: ', e); - } -})(); -``` - -#### V2 REST APIs - -Not sure which function to call or which parameters to use? Click the class name in the table above to look at all the function names (they are in the same order as the official API docs), and check the API docs for a list of endpoints/parameters/responses. - -If you found the method you're looking for in the API docs, you can also search for the endpoint in the [RestClientV2](src/rest-client-v2.ts) class. This class has all V2 endpoints available. - -```javascript -import { RestClientV2 } from 'bitget-api'; -// or if you prefer require: -// const { RestClientV2 } = require('bitget-api'); - -const API_KEY = 'xxx'; -const API_SECRET = 'yyy'; -const API_PASS = 'zzz'; - -const client = new RestClientV2({ - apiKey: API_KEY, - apiSecret: API_SECRET, - apiPass: API_PASS, -}); - -// For public-only API calls, simply don't provide a key & secret or set them to undefined -// const client = new RestClientV2(); - -client - .getSpotAccount() - .then((result) => { - console.log('getSpotAccount result: ', result); - }) - .catch((err) => { - console.error('getSpotAccount error: ', err); - }); - -client - .getSpotCandles({ - symbol: 'BTCUSDT', - granularity: '1min', - limit: '1000', - }) - .then((result) => { - console.log('getCandles result: ', result); - }) - .catch((err) => { - console.error('getCandles error: ', err); - }); -``` - -## WebSockets - -All WebSocket functionality is supported via the WebsocketClient. Since there are currently 2 generations of Bitget's API, there are 2 WebsocketClient classes in this Node.js, JavaScript & TypeScript SDK for Bitget. - -Use the following guidance to decide which one to use: - -- **Unified Trading Account / V3** (latest generation): - - For receiving data, use the [WebsocketClientV3](./src/websocket-client-v3.ts). - - For sending orders via WebSockets, use the [WebsocketAPIClient](./src/websocket-api-client.ts). -- **V2** (not upgraded to Unified Trading Account yet) - - Use the [WebsocketClientV2](./src/websocket-client-v2.ts). - -All WebSocket clients support: - -- Event driven messaging -- Smart WebSocket persistence with automatic reconnection -- Heartbeat mechanisms to detect disconnections -- Automatic resubscription after reconnection -- Error handling and connection monitoring -- Optional data beautification - -Higher level examples below, while more thorough examples can be found in the examples folder on GitHub. - -##### V3 Unified Trading Account - -###### Sending orders via WebSockets - -The V3 / Unified Trading Account APIs introduce order placement via a persisted WebSocket connection. This Bitget Node.js, JavaScript & TypeScript SDK supports Bitget's full V3 API offering, including the WebSocket API. - -There are two approaches to placing orders via the Bitget WebSocket APIs. The recommended route is to use the dedicated WebsocketAPIClient class, included with this SDK. - -This integration looks & feels like a REST API client, but uses WebSockets, via the WebsocketClient's sendWSAPIRequest method. It returns promises and has end to end types. - -A simple example is below, but for a more thorough example, check the example here: [./examples/V3/ws-api-client-trade.ts](./examples/V3/ws-api-client-trade.ts) - -```typescript -import { WebsocketAPIClient } from 'bitget-api'; -// or if you prefer require: -// const { WebsocketAPIClient } = require("bitget-api"); - -// Make an instance of the WS API Client class with your API keys -const wsClient = new WebsocketAPIClient({ - apiKey: API_KEY, - apiSecret: API_SECRET, - apiPass: API_PASS, - - // Whether to use the demo trading wss connection - // demoTrading: true, -}); - -async function start() { - // Start using it like a REST API. All actions are sent via a persisted WebSocket connection. - - /** - * Place Order - * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters - */ - try { - const res = await wsClient.submitNewOrder('spot', { - orderType: 'limit', - price: '100', - qty: '0.1', - side: 'buy', - symbol: 'BTCUSDT', - timeInForce: 'gtc', - }); - - console.log(new Date(), 'WS API "submitNewOrder()" result: ', res); - } catch (e) { - console.error(new Date(), 'Exception with WS API "submitNewOrder()": ', e); - } +⋮---- +/** crossed | isolated */ +⋮---- +export interface PaymentCoinV3 { + coin: string; + size: string; + amount: string; +} +⋮---- +export interface RepayableCoinV3 { + coin: string; + size: string; + amount: string; +} +⋮---- +export interface RepayResponseV3 { + result: string; + repayAmount: string; +} +⋮---- +// Sub-account Management Response Types +⋮---- +export interface CreateSubAccountApiKeyResponseV3 { + note: string; + apiKey: string; + secret: string; + type: string; + permissions: string[]; + ips: string[]; +} +export interface SubAccountApiKeyV3 { + apiKey: string; + note: string; + type: string; + permissions: string[]; + ips: string[]; + ts?: string; +} +⋮---- +export interface UpdateSubAccountApiKeyResponseV3 { + note: string; + apiKey: string; + type: string; + permissions: string[]; + ips: string[]; +} +⋮---- +export interface CreateSubAccountResponseV3 { + username: string; + subUid: string; + status: string; + note: string; + createdTime: string; + updatedTime: string; +} +⋮---- +export interface CreateAgentSubAccountResponseV3 { + username: string; + subUid: string; + apiKey: string; + secret: string; + note: string; + createdTime: string; +} +⋮---- +export interface SubAccountV3 { + subUid: string; + username: string; + status: string; + accountMode: string; + type: 'normal' | 'virtual' | 'custodian'; + note: string; + createdTime: string; + updatedTime: string; +} +⋮---- +export interface WithdrawAddressBookEntryV3 { + coin: string; + chain: string; + address: string; + countryCode: string; + label: string; + memo: string; + type: 'regular' | 'EVM' | 'universal' | 'internal'; + internalType: '' | 'uid' | 'mobile' | 'email'; + createdTime: string; +} +⋮---- +export interface WithdrawAddressBookV3 { + addressList: WithdrawAddressBookEntryV3[]; + cursor?: string; +} +⋮---- +// Transfer Response Types +⋮---- +export interface AllSymbolFeeRateV3 { + symbol: string; + makerFeeRate: string; + takerFeeRate: string; +} +⋮---- +export interface TransferResponseV3 { + transferId: string; + clientOid?: string; +} +⋮---- +export interface SubTransferRecordV3 { + transferId: string; + oldTransferId?: string; + fromType: string; + toType: string; + amount: string; + coin: string; + fromUserId: string; + toUserId: string; + status: string; + clientOid: string; + createdTime: string; + updatedTime: string; +} +⋮---- +export interface SubUnifiedAssetV3 { + coin: string; + equity: string; + usdValue: string; + balance: string; + available: string; + debt: string; + locked: string; +} +⋮---- +export interface SubUnifiedAssetV3 { + subUid: string; + cursor: string; + assets: SubUnifiedAssetV3[]; +} +⋮---- +export interface GetFeeRateResponseV3 { + makerFeeRate: string; + takerFeeRate: string; +} +⋮---- +export interface FundingAssetV3 { + coin: string; + available: string; + frozen: string; + balance: string; +} +⋮---- +// Deposit Response Types +⋮---- +export interface DepositAddressV3 { + address: string; + chain: string; + coin: string; + tag: string; + url: string; +} +⋮---- +export interface DepositRecordV3 { + orderId: string; + recordId: string; + coin: string; + type: 'deposit'; + dest: 'on_chain' | 'internal_transfer'; + size: string; + status: 'pending' | 'success' | 'fail'; + fromAddress: string; + toAddress: string; + chain: string; + createdTime: string; + updatedTime: string; +} +⋮---- +// Withdraw Response Types +⋮---- +export interface WithdrawResponseV3 { + orderId: string; + clientOid: string; +} +⋮---- +export interface WithdrawRecordV3 { + orderId: string; + clientOid: string; + recordId: string; + coin: string; + type: 'withdraw'; + dest: 'on_chain' | 'internal_transfer'; + size: string; + status: 'pending' | 'success' | 'fail'; + fromAddress: string; + toAddress: string; + chain: string; + fee: string; + confirm: string; + tag: string; + createdTime: string; + updatedTime: string; +} +⋮---- +export interface MaxTransferableV3 { + coin: string; + maxTransfer: string; + borrowMaxTransfer: string; +} +⋮---- +export interface OpenInterestLimitV3 { + symbol: string; + singleUserLimit: string; + masterSubLimit: string; + marketMakerLimit: string; +} +⋮---- +export interface TaxRecordV3 { + id: string; + coin: string; + type: string; + amount: string; + fee: string; + balance: string; + ts: string; +} +⋮---- +export interface CollateralTypeConfigV3 { + collateralType: CollateralTypeV3; + /** Returned when collateralType=custom */ + collateralCoins?: string; +} +⋮---- +/** Returned when collateralType=custom */ +⋮---- +export interface CustomCollateralCoinV3 { + collateralCoin: string; +} +⋮---- +export interface PreSetLeverageV3 { + estMaxOpen?: string; + estMaxBorrowable?: string; + requiredMargin: string; + marginChange: string; +} +⋮---- +export interface MaxWithdrawalV3 { + coin: string; + otcMaxWithdrawal: string; + spotMaxWithdrawal: string; + utaMaxWithdrawal: string; + totalMaxWithdrawal: string; +} +⋮---- +export interface MovePositionOrderResultV3 { + orderId: string; + clientOid: string; + code: string; + msg: string; +} +⋮---- +export interface MovePositionsResponseV3 { + closePosition: MovePositionOrderResultV3[]; + openPosition: MovePositionOrderResultV3[]; +} +⋮---- +export interface MovePositionHistoryV3 { + category: string; + fromUid: string; + toUid: string; + orderId: string; + openExecId: string; + closeExecId: string; + symbol: string; + posSide: 'long' | 'short'; + qty: string; + price: string; + status: 'processing' | 'completed' | 'failed'; + createdTime: string; + updatedTime: string; +} +⋮---- +export interface EligibleSymbolV3 { + symbol: string; + category: string; + baseCoin: string; + quoteCoin: string; + symbolType?: string; + buyLimitPriceRatio: string; + sellLimitPriceRatio: string; + minOrderQty: string; + maxOrderQty: string; + pricePrecision: string; + quantityPrecision: string; + quotePrecision: string; + minOrderAmount: string; + maxSymbolOrderNum: string; + maxProductOrderNum: string; + status: string; + maintainTime: string; + areaSymbol?: string; + maxPositionNum?: string; + isReality?: string; + launchTime?: string; +} +⋮---- +export interface EligibleMarginTierItemV3 { + tier: string; + minTierValue: string; + maxTierValue: string; + leverage: string; + mmr: string; +} +⋮---- +export interface EligibleMarginTierV3 { + coin: string; + tiers: EligibleMarginTierItemV3[]; +} +⋮---- +export interface EligibleLoanInfoV3 { + limit: string; + masterSubLimit: string; + /** Bitget spelling */ + platformRemaingQuota: string; +} +⋮---- +/** Bitget spelling */ +⋮---- +export interface RateLimitQuotaItemV3 { + uid: string; + quota: string; +} +⋮---- +export interface RateLimitQuotaV3 { + category: 'spot' | 'futures' | string; + quotaList: RateLimitQuotaItemV3[]; + masterSubQuota: string; + masterSubCap: string; + cursor: string; } -start().catch((e) => console.error('Exception in example: '.e)); -``` - -###### Receiving realtime data - -Use the WebsocketClientV3 to receive data via the V3 WebSockets - -```typescript -import { WebsocketClientV3 } from "bitget-api"; -// or if you prefer require: -// const { WebsocketClientV3 } = require("bitget-api"); - -const API_KEY = "yourAPIKeyHere"; -const API_SECRET = "yourAPISecretHere; -const API_PASS = "yourAPIPassHere"; - -const wsClient = new WebsocketClientV3( - { - // Only necessary if you plan on using private/account websocket topics - apiKey: API_KEY, - apiSecret: API_SECRET, - apiPass: API_PASS, - } -); - -// Connect event handlers to process incoming events -wsClient.on('update', (data) => { - console.log('WS raw message received ', data); - // console.log('WS raw message received ', JSON.stringify(data, null, 2)); -}); - -wsClient.on('open', (data) => { - console.log('WS connection opened:', data.wsKey); -}); -wsClient.on('response', (data) => { - console.log('WS response: ', JSON.stringify(data, null, 2)); -}); -wsClient.on('reconnect', ({ wsKey }) => { - console.log('WS automatically reconnecting.... ', wsKey); -}); -wsClient.on('reconnected', (data) => { - console.log('WS reconnected ', data?.wsKey); -}); -wsClient.on('exception', (data) => { - console.log('WS error', data); -}); - -/** - * Subscribe to topics as you wish - */ - -// You can subscribe to one topic at a time -wsClient.subscribe( - { - topic: 'account', - payload: { - instType: 'UTA', // Note: all account events go on the UTA instType - }, - }, - WS_KEY_MAP.v3Private, // This parameter points to private or public -); - -// Note: all account events go on the UTA instType -const ACCOUNT_INST_TYPE = 'UTA'; -const ACCOUNT_WS_KEY = WS_KEY_MAP.v3Private; - -// Or multiple at once: -wsClient.subscribe( - [ - { - topic: 'account', - payload: { - instType: ACCOUNT_INST_TYPE, - }, - }, - { - topic: 'position', - payload: { - instType: ACCOUNT_INST_TYPE, - }, - }, - { - topic: 'fill', - payload: { - instType: ACCOUNT_INST_TYPE, - }, - }, - { - topic: 'order', - payload: { - instType: ACCOUNT_INST_TYPE, - }, - }, - ], - ACCOUNT_WS_KEY, -); - -// Example public events -wsClient.subscribe( - [ - { - topic: 'ticker', - payload: { - instType: 'spot', - symbol: 'BTCUSDT', - }, - }, - { - topic: 'ticker', - payload: { - instType: 'spot', - symbol: 'ETHUSDT', - }, - }, - { - topic: 'ticker', - payload: { - instType: 'spot', - symbol: 'XRPUSDT', - }, - }, - { - topic: 'ticker', - payload: { - instType: 'usdt-futures', - symbol: 'BTCUSDT', - }, - }, - { - topic: 'ticker', - payload: { - instType: 'usdt-futures', - symbol: 'BTCUSDT', - }, - }, - ], - WS_KEY_MAP.v3Public, -); -``` - -For more examples, including how to use websockets with Bitget, check the [examples](./examples/) and [test](./test/) folders. - -### V2 WebSockets - -If you haven't upgraded to the Unified Trading Account, use the V2 WebSocket client: - -```javascript -import { WebsocketClientV2 } from 'bitget-api'; -// or if you prefer require: -// const { WebsocketClientV2 } = require('bitget-api'); - -const API_KEY = 'xxx'; -const API_SECRET = 'yyy'; -const API_PASS = 'zzz'; - -const wsClient = new WebsocketClientV2({ - apiKey: API_KEY, - apiSecret: API_SECRET, - apiPass: API_PASS, - // Optional: connect to demo trading environment - // demoTrading: true, -}); - -// Handle incoming messages -wsClient.on('update', (data) => { - console.log('WS update received: ', data); -}); - -wsClient.on('open', (data) => { - console.log('WS connection opened: ', data.wsKey); -}); - -wsClient.on('reconnected', (data) => { - console.log('WS reconnected: ', data?.wsKey); -}); - -wsClient.on('exception', (data) => { - console.log('WS error: ', data); -}); - -// Subscribe to public data streams -wsClient.subscribeTopic('SPOT', 'ticker', symbol); - -// Subscribe to private data streams (requires authentication) -wsClient.subscribeTopic('SPOT', 'account'); -``` - ---- - -## Logging - -### Customise logging - -Pass a custom logger which supports the log methods `trace`, `info` and `error`, or override methods from the default logger as desired. - -```javascript -import { WebsocketClientV2, DefaultLogger } from 'bitget-api'; -// or if you prefer require: -// const { WebsocketClientV2, DefaultLogger } = require('bitget-api'); - -// Disable all logging on the trace level (less console logs) -const customLogger = { - ...DefaultLogger, - trace: () => {}, -}; - -const ws = new WebsocketClientV2( - { - apiKey: 'API_KEY', - apiSecret: 'API_SECRET', - apiPass: 'API_PASS', - }, - customLogger, -); -``` - -### Debug HTTP requests - -In rare situations, you may want to see the raw HTTP requets being built as well as the API response. These can be enabled by setting the `BITGETTRACE` env var to `true`. - -## Browser Usage - -### Import - -This is the "modern" way, allowing the package to be directly imported into frontend projects with full typescript support. - -1. Install these dependencies - ```sh - npm install crypto-browserify stream-browserify - ``` -2. Add this to your `tsconfig.json` - ```json - { - "compilerOptions": { - "paths": { - "crypto": [ - "./node_modules/crypto-browserify" - ], - "stream": [ - "./node_modules/stream-browserify" - ] - } - ``` -3. Declare this in the global context of your application (ex: in polyfills for angular) - ```js - (window as any).global = window; - ``` - -### Webpack - -This is the "old" way of using this package on webpages. This will build a minified js bundle that can be pulled in using a script tag on a website. - -Build a bundle using webpack: - -- `npm install` -- `npm build` -- `npm pack` - -The bundle can be found in `dist/`. Altough usage should be largely consistent, smaller differences will exist. Documentation is still TODO - contributions welcome. - -## Use with LLMs & AI - -This SDK includes a bundled `llms.txt` file in the root of the repository. If you're developing with LLMs, use the included `llms.txt` with your LLM - it will significantly improve the LLMs understanding of how to correctly use this SDK. - -This file contains AI optimised structure of all the functions in this package, and their parameters for easier use with any learning models or artificial intelligence. - ---- - -## Used By +================ +File: src/types/websockets/ws-general.ts +================ +import type { ClientRequestArgs } from 'http'; +import WebSocket from 'isomorphic-ws'; +⋮---- +import { RestClientOptions } from '../../util/requestUtils.js'; +import { WS_KEY_MAP } from '../../util/websocket-util.js'; +import { FuturesProductTypeV2 } from '../request/shared.js'; +⋮---- +export type BitgetInstType = 'SP' | 'SPBL' | 'MC' | 'UMCBL' | 'DMCBL'; +export type BitgetInstTypeV2 = 'SPOT' | FuturesProductTypeV2; +export type BitgetInstTypeV3 = + | 'UTA' // for account-level topics + | 'spot' + | 'usdt-futures' + | 'coin-futures' + | 'usdc-futures'; +⋮---- +| 'UTA' // for account-level topics +⋮---- +/** + * + * V1 list of topics for WebSocket consumers + * + */ +⋮---- +export type WsPublicSpotTopic = + | 'ticker' + | 'candle1W' + | 'candle1D' + | 'candle12H' + | 'candle4H' + | 'candle1H' + | 'candle30m' + | 'candle15m' + | 'candle5m' + | 'candle1m' + | 'books' + | 'books5' + | 'trade'; +⋮---- +// Futures currently has the same public topics as spot +export type WsPublicFuturesTopic = WsPublicSpotTopic; +export type WsPrivateSpotTopic = 'account' | 'orders'; +⋮---- +export type WsPrivateFuturesTopic = + | 'account' + | 'positions' + | 'orders' + | 'ordersAlgo'; +⋮---- +export type WsPublicTopic = WsPublicSpotTopic | WsPublicFuturesTopic; +⋮---- +export type WsPrivateTopic = WsPrivateSpotTopic | WsPrivateFuturesTopic; +export type WsTopic = WsPublicTopic | WsPrivateTopic; +⋮---- +/** + * + * V2 list of topics for WebSocket consumers + * + */ +⋮---- +export type WsPublicTopicV2 = + | 'index-price' // margin only + | 'ticker' + | 'candle1m' + | 'candle5m' + | 'candle15m' + | 'candle30m' + | 'candle1H' + | 'candle4H' + | 'candle6H' + | 'candle12H' + | 'candle1D' + | 'candle3D' + | 'candle1W' + | 'candle1M' + | 'candle6Hutc' + | 'candle12Hutc' + | 'candle1Dutc' + | 'candle3Dutc' + | 'candle1Wutc' + | 'candle1Mutc' + | 'trade' + | 'books' + | 'books1' + | 'books5' + | 'books15'; +⋮---- +| 'index-price' // margin only +⋮---- +// Also update PRIVATE_TOPICS_V2 if this is updated +export type WSPrivateTopicFuturesV2 = + | 'positions' + | 'orders-algo' + | 'positions-history'; +⋮---- +// Also update PRIVATE_TOPICS_V2 if this is updated +export type WSPrivateTopicMarginV2 = + | 'orders-crossed' + | 'account-crossed' + | 'account-isolated' + | 'orders-isolated'; +⋮---- +// Also update PRIVATE_TOPICS_V2 if this is updated +export type WsPrivateTopicV2 = + | 'account' + | 'orders' + | WSPrivateTopicFuturesV2 + | WSPrivateTopicMarginV2; +⋮---- +export type WsTopicV2 = WsPublicTopicV2 | WsPrivateTopicV2; +⋮---- +/** + * + * V3 / UTA list of topics for WebSocket consumers + * + */ +export type WsPublicTopicV3 = 'ticker' | 'kline' | 'books' | 'publicTrade'; +// Also update PRIVATE_TOPICS_V3 if this is updated +export type WsPrivateTopicV3 = + | 'account' + | 'position' + | 'fill' + | 'order' + | 'strategy-order' + | 'reality-orderbook'; +export type WsTopicV3 = WsPublicTopicV3 | WsPrivateTopicV3; +⋮---- +/** This is used to differentiate between each of the available websocket streams */ +export type WsKey = (typeof WS_KEY_MAP)[keyof typeof WS_KEY_MAP]; +⋮---- +/** + * Event args for subscribing/unsubscribing + */ +⋮---- +export interface WsTopicSubscribeEventArgs { + instType: BitgetInstType; + channel: WsTopic; + instId?: string; +} +⋮---- +export type WsTopicSubscribePublicArgsV2 = { + instType: BitgetInstTypeV2; + channel: WsPublicTopicV2; + /** The symbol, e.g. "BTCUSDT" */ + instId: string; +}; +⋮---- +/** The symbol, e.g. "BTCUSDT" */ +⋮---- +export type WsInstIdChannelsV2 = + | 'orders' + | WSPrivateTopicFuturesV2 + | 'orders-crossed' + | 'orders-isolated'; +⋮---- +export type WsTopicSubscribePrivateInstIdArgsV2 = { + instType: BitgetInstTypeV2; + channel: WsInstIdChannelsV2; + /** The symbol, e.g. "BTCUSDT" */ + instId?: string; +}; +⋮---- +/** The symbol, e.g. "BTCUSDT" */ +⋮---- +export type WsCoinChannelsV2 = + | 'account' + | 'account-crossed' + | 'account-isolated'; +⋮---- +export type WsTopicSubscribePrivateCoinArgsV2 = { + instType: BitgetInstTypeV2; + channel: WsCoinChannelsV2; + coin: 'default' | string; +}; +⋮---- +export type WsTopicSubscribePrivateArgsV2 = + | WsTopicSubscribePrivateInstIdArgsV2 + | WsTopicSubscribePrivateCoinArgsV2; +⋮---- +export type WsTopicSubscribeEventArgsV2 = + | WsTopicSubscribePublicArgsV2 + | WsTopicSubscribePrivateArgsV2; +⋮---- +/** General configuration for the WebsocketClient */ +export interface WSClientConfigurableOptions { + /** Your API key */ + apiKey?: string; -[![Repository Users Preview Image](https://dependents.info/tiagosiebler/bitget-api/image)](https://github.com/tiagosiebler/bitget-api/network/dependents) + /** Your API secret */ + apiSecret?: string; ---- + /** The passphrase you set when creating the API Key (NOT your account password) */ + apiPass?: string; - + /** + * Set to `true` to connect to Bitget's demo trading WebSockets: + * + * - V2: https://www.bitget.com/api-doc/common/demotrading/websocket + * - V3/UTA: https://www.bitget.com/api-doc/uta/guide#demo-trading + */ + demoTrading?: boolean; -### Contributions & Thanks + /** Define a recv window when preparing a private websocket signature. This is in milliseconds, so 5000 == 5 seconds */ + recvWindow?: number; -Have my projects helped you? Share the love, there are many ways you can show your thanks: + // Disable ping/pong ws heartbeat mechanism (not recommended) + disableHeartbeat?: boolean; -- Star & share my projects. -- Are my projects useful? Sponsor me on Github and support my effort to maintain & improve them: https://github.com/sponsors/tiagosiebler -- Have an interesting project? Get in touch & invite me to it. -- Or buy me all the coffee: - - ETH(ERC20): `0xA3Bda8BecaB4DCdA539Dc16F9C54a592553Be06C` -- Sign up with my referral links: - - OKX (receive a 20% fee discount!): https://www.okx.com/join/42013004 - - Binance (receive a 20% fee discount!): https://accounts.binance.com/register?ref=OKFFGIJJ - - HyperLiquid (receive a 4% fee discount!): https://app.hyperliquid.xyz/join/SDK - - Gate: https://www.gate.io/signup/NODESDKS?ref_type=103 + /** How often to check if the connection is alive */ + pingInterval?: number; - - + /** Delay in milliseconds before respawning the connection */ + reconnectTimeout?: number; -### Contributions & Pull Requests + requestOptions?: RestClientOptions; -Contributions are encouraged, I will review any incoming pull requests. See the issues tab for todo items. + wsOptions?: { + protocols?: string[]; + agent?: any; + } & ( + | Omit, 'agent'> + | Omit, 'agent'> + ); - + wsUrl?: string; -## Star History + /** + * Allows you to provide a custom "signMessage" function, e.g. to use node's much faster createHmac method + * + * Look in the examples folder for a demonstration on using node's createHmac instead. + */ + customSignMessageFn?: (message: string, secret: string) => Promise; +} +⋮---- +/** Your API key */ +⋮---- +/** Your API secret */ +⋮---- +/** The passphrase you set when creating the API Key (NOT your account password) */ +⋮---- +/** + * Set to `true` to connect to Bitget's demo trading WebSockets: + * + * - V2: https://www.bitget.com/api-doc/common/demotrading/websocket + * - V3/UTA: https://www.bitget.com/api-doc/uta/guide#demo-trading + */ +⋮---- +/** Define a recv window when preparing a private websocket signature. This is in milliseconds, so 5000 == 5 seconds */ +⋮---- +// Disable ping/pong ws heartbeat mechanism (not recommended) +⋮---- +/** How often to check if the connection is alive */ +⋮---- +/** How long to wait for a pong (heartbeat reply) before assuming the connection is dead */ +⋮---- +/** Delay in milliseconds before respawning the connection */ +⋮---- +/** + * Allows you to provide a custom "signMessage" function, e.g. to use node's much faster createHmac method + * + * Look in the examples folder for a demonstration on using node's createHmac instead. + */ +⋮---- +export interface WebsocketClientOptions extends WSClientConfigurableOptions { + pingInterval: number; + pongTimeout: number; + reconnectTimeout: number; + recvWindow: number; + authPrivateConnectionsOnConnect: boolean; + authPrivateRequests: boolean; +} -[![Star History Chart](https://api.star-history.com/svg?repos=tiagosiebler/bybit-api,tiagosiebler/okx-api,tiagosiebler/binance,tiagosiebler/bitget-api,tiagosiebler/bitmart-api,tiagosiebler/gateio-api,tiagosiebler/kucoin-api,tiagosiebler/coinbase-api,tiagosiebler/orderbooks,tiagosiebler/accountstate,tiagosiebler/awesome-crypto-examples&type=Date)](https://star-history.com/#tiagosiebler/bybit-api&tiagosiebler/okx-api&tiagosiebler/binance&tiagosiebler/bitget-api&tiagosiebler/bitmart-api&tiagosiebler/gateio-api&tiagosiebler/kucoin-api&tiagosiebler/coinbase-api&tiagosiebler/orderbooks&tiagosiebler/accountstate&tiagosiebler/awesome-crypto-examples&Date) +================ +File: src/index.ts +================ - ================ File: src/rest-client-v2.ts @@ -11717,6 +12675,7 @@ import { AgentCustomerListRequestV2, AgentCustomerTradeVolumeRequestV2, CreateSubAccountApiKeyRequestV2, + DeleteSubAccountApiKeyRequestV2, GetAgentCommissionDetailRequestV2, GetAgentCustomerCommissionsRequestV2, GetAgentCustomerKycResultRequestV2, @@ -11741,6 +12700,7 @@ import { CreateAgentSubaccountRequestV2, CreateVirtualSubApiKeyRequestV2, CreateVirtualSubRequestV2, + GetAllTradeRatesRequestV2, GetAnnouncementsRequestV2, GetConvertBGBHistoryRequestV2, GetConvertHistoryRequestV2, @@ -11824,9 +12784,12 @@ import { FuturesModifyOrderRequestV2, FuturesModifyPlanOrderRequestV2, FuturesModifyTPSLOrderRequestV2, + FuturesOiLimitRequestV2, FuturesOpenCountRequestV2, FuturesPlaceOrderRequestV2, FuturesPlanOrderRequestV2, + FuturesPositionAdlRankRequestV2, + FuturesPositionTPSLOrderRequestV2, FuturesRecentTradesRequestV2, FuturesReversalOrderRequestV2, FuturesSetAutoMarginRequestV2, @@ -11838,6 +12801,14 @@ import { GetUnionTransferLimitsRequestV2, UnionConvertRequestV2, } from './types/request/v2/futures.js'; +import { + GetInstLoanLTVConvertRequestV2, + GetInstLoanMarginCoinInfoRequestV2, + GetInstLoanOrderRequestV2, + GetInstLoanProductInfoRequestV2, + GetInstLoanRepaidHistoryRequestV2, + GetInstLoanSymbolsRequestV2, +} from './types/request/v2/instloan.js'; import { GetBorrowHistoryRequestV2, GetFinancialHistoryRequestV2, @@ -11866,6 +12837,7 @@ import { SpotAccountTypeV2, SpotBatchCancelOrderRequestV2, SpotBatchOrderRequestV2, + SpotCallAuctionRequestV2, SpotCancelandSubmitOrderRequestV2, SpotCancelOrderRequestV2, SpotCandlesRequestV2, @@ -12025,6 +12997,7 @@ import { FuturesOrderDetailV2, FuturesOrderFillV2, FuturesPendingPlanOrderV2, + FuturesPositionAdlRankV2, FuturesPositionTierV2, FuturesPositionV2, FuturesSubAccountAssetV2, @@ -12039,6 +13012,14 @@ import { UnionSwitchUsdtV2, UnionTransferLimitsV2, } from './types/response/v2/futures.js'; +import { + InstLoanCoinInfoV2, + InstLoanLTVConvertV2, + InstLoanOrderV2, + InstLoanProductInfoV2, + InstLoanRepaidHistoryItemV2, + InstLoanSymbolsV2, +} from './types/response/v2/instloan.js'; import { CrossInterestRateAndLimitResponseV2, CrossMaxBorrowableResponseV2, @@ -12066,6 +13047,7 @@ import { SpotAccountAssetV2, SpotAccountBillV2, SpotAccountInfoV2, + SpotCallAuctionV2, SpotCancelPlanOrdersV2, SpotCandlestickV2, SpotCoinInfoV2, @@ -12096,2209 +13078,3812 @@ import { REST_CLIENT_TYPE_ENUM } from './util/requestUtils.js'; import { assertMarginType } from './util/type-guards.js'; ⋮---- /** - * REST API client for all V2 endpoints - */ -export class RestClientV2 extends BaseRestClient + * REST API client for all V2 endpoints + */ +export class RestClientV2 extends BaseRestClient +⋮---- +getClientType() +⋮---- +/** + * + * Custom SDK functions + * + */ +⋮---- +/** + * This method is used to get the latency and time sync between the client and the server. + * This is not official API endpoint and is only used for internal testing purposes. + * Use this method to check the latency and time sync between the client and the server. + * Final values might vary slightly, but it should be within few ms difference. + * If you have any suggestions or improvements to this measurement, please create an issue or pull request on GitHub. + */ +async fetchLatencySummary(): Promise +⋮---- +// Adjust server time by adding estimated one-way latency +⋮---- +// Calculate time difference between adjusted server time and local time +⋮---- +async fetchServerTime(): Promise +⋮---- +/** + * + * Bitget misc functions + * + */ +⋮---- +/** + * + * + * Common + * + * + */ +⋮---- +/** + * + * * Common | Notice + * + */ +⋮---- +getAnnouncements( + params?: GetAnnouncementsRequestV2, +): Promise> +⋮---- +/** + * + * * Common | Public + * + */ +⋮---- +getServerTime(): Promise< + APIResponse<{ + serverTime: string; + }> + > { + return this.get('/api/v2/public/time'); +⋮---- +getTradeRate(params: GetTradeRateRequestV2): Promise< + APIResponse<{ + makerFeeRate: string; + takerFeeRate: string; + }> + > { + return this.getPrivate('/api/v2/common/trade-rate', params); +⋮---- +getAllTradeRates(params: GetAllTradeRatesRequestV2): Promise< + APIResponse< + { + symbol: string; + makerFeeRate: string; + takerFeeRate: string; + }[] + > + > { + return this.getPrivate('/api/v2/common/all-trade-rate', params); +⋮---- +/** + * + * * Common | Tax + * + */ +⋮---- +getSpotTransactionRecords( + params: GetSpotTransactionsRequestV2, +): Promise> +⋮---- +getFuturesTransactionRecords( + params: GetFuturesTransactionsRequestV2, +): Promise> +⋮---- +getMarginTransactionRecords( + params: GetMarginTransactionsRequestV2, +): Promise> +⋮---- +getP2PTransactionRecords( + params: GetP2PTransactionsRequestV2, +): Promise> +⋮---- +/** + * + * * Common | P2P + * + */ +⋮---- +getP2PMerchantList(params?: GetP2PMerchantsRequestV2): Promise< + APIResponse<{ + merchantList: P2PMerchantV2[]; + minMerchantId: string; + }> + > { + return this.getPrivate('/api/v2/p2p/merchantList', params); +⋮---- +getP2PMerchantInfo(): Promise> +⋮---- +getP2PMerchantOrders(params: GetMerchantP2POrdersRequestV2): Promise< + APIResponse<{ + orderList: P2PMerchantOrderV2[]; + minOrderId: string; + }> + > { + return this.getPrivate('/api/v2/p2p/orderList', params); +⋮---- +getP2PMerchantAdvertisementList( + params: GetMerchantAdvertisementsRequestV2, + ): Promise< + APIResponse<{ + advList: P2PMerchantAdvertismentV2[]; + minAdvId: string; + }> + > { + return this.getPrivate('/api/v2/p2p/advList', params); +⋮---- +/** + * + * * Common | Trading insights + * + */ +⋮---- +getSpotWhaleNetFlowData(params: { + symbol: string; +}): Promise> +⋮---- +getFuturesActiveTakerBuySellVolumeData(params: { + symbol: string; + period?: string; +}): Promise> +⋮---- +getFuturesActiveLongShortPositionData(params: { + symbol: string; + period?: string; +}): Promise> +⋮---- +getFuturesLongShortRatio(params: { + symbol: string; + period?: string; + coin?: string; +}): Promise> +⋮---- +getMarginLoanGrowthRate(params: { + symbol: string; + period?: string; + coin?: string; +}): Promise> +⋮---- +getIsolatedMarginBorrowingRatio(params: { + symbol: string; + period?: string; +}): Promise> +⋮---- +getFuturesActiveBuySellVolumeData(params: { + symbol: string; + period?: string; +}): Promise> +⋮---- +getSpotFundFlow(params: { + symbol: string; + period?: string; +}): Promise> +⋮---- +getTradeDataSupportSymbols(): Promise< + APIResponse<{ + spotList: string[]; + futureList: string[]; + }> + > { + return this.get('/api/v2/spot/market/support-symbols'); +⋮---- +getSpotFundNetFlowData(params: { symbol: string }): Promise< + APIResponse< + { + netFlow: string; + ts: string; + }[] + > + > { + return this.get('/api/v2/spot/market/fund-net-flow', params); +⋮---- +getFuturesActiveLongShortAccountData(params: { + symbol: string; + period?: string; +}): Promise> +⋮---- +/** + * + * * Common | Virtual Subaccount + * + */ +⋮---- +createVirtualSubaccount(params: { + subAccountList: string[]; +}): Promise> +⋮---- +modifyVirtualSubaccount(params: ModifyVirtualSubRequestV2): Promise< + APIResponse<{ + result: string; + }> + > { + return this.postPrivate('/api/v2/user/modify-virtual-subaccount', params); +⋮---- +batchCreateVirtualSubaccountAndAPIKey( + params: CreateVirtualSubRequestV2, +): Promise> +⋮---- +getVirtualSubaccounts(params?: { + limit?: string; + idLessThan?: string; + status?: 'normal' | 'freeze'; + }): Promise< + APIResponse<{ + endId: string; + subAccountList: VirtualSubAccountV2[]; + }> + > { + return this.getPrivate('/api/v2/user/virtual-subaccount-list', params); +⋮---- +createVirtualSubaccountAPIKey( + params: CreateVirtualSubApiKeyRequestV2, +): Promise> +⋮---- +modifyVirtualSubaccountAPIKey( + params: ModifyVirtualSubApiKeyRequestV2, +): Promise> +⋮---- +getVirtualSubaccountAPIKeys(params: { + subAccountUid: string; +}): Promise> +⋮---- +/** + * Create a dedicated sub-account for an AI Agent instance. + * Frequency limit: 1/s per UID. Agent sub-accounts cannot be edited after creation. + */ +createAgentSubaccount( + params: CreateAgentSubaccountRequestV2, +): Promise> +⋮---- +/** + * + * * Common | Assets + * + */ +getFundingAssets(params?: { + coin?: string; +}): Promise> +⋮---- +getBotAccount(params?: { + accountType?: string; +}): Promise> +⋮---- +/** Get assets overview */ +getBalances(): Promise< + APIResponse< + { + accountType: string; + usdtBalance: string; + }[] + > + > { + return this.getPrivate('/api/v2/account/all-account-balance'); +⋮---- +/** + * + * * Common | Convert + * + */ +⋮---- +getConvertCoins(): Promise> +⋮---- +getConvertQuotedPrice( + params: ConvertQuoteRequestV2, +): Promise> +⋮---- +convert( + params: ConvertRequestV2, +): Promise> +⋮---- +getConvertHistory(params: GetConvertHistoryRequestV2): Promise< + APIResponse<{ + dataList: ConvertRecordV2[]; + endId: string; + }> + > { + return this.getPrivate('/api/v2/convert/convert-record', params); +⋮---- +/** + * + * * Common | BGB Convert + * + */ +⋮---- +getConvertBGBCoins(): Promise< + APIResponse<{ + coinList: BGBConvertCoinV2[]; + }> + > { + return this.getPrivate('/api/v2/convert/bgb-convert-coin-list'); +⋮---- +convertBGB(params: { + coinList: string; +}): Promise> +⋮---- +getConvertBGBHistory( + params: GetConvertBGBHistoryRequestV2, +): Promise> +⋮---- +/** + * + * + * Spot + * + * + */ +⋮---- +/** + * + * * Spot | Market + * + */ +⋮---- +getSpotCoinInfo(params?: { + coin?: string; +}): Promise> +⋮---- +getSpotSymbolInfo(params?: { + symbol?: string; +}): Promise> +⋮---- +getSpotVIPFeeRate(): Promise> +⋮---- +getSpotTicker(params?: { + symbol?: string; +}): Promise> +⋮---- +getSpotMergeDepth(params: { + symbol: string; + precision?: string; + limit?: string; +}): Promise> +⋮---- +getSpotOrderBookDepth(params: { + symbol: string; + type?: string; + limit?: string; +}): Promise> +⋮---- +getSpotCandles( + params: SpotCandlesRequestV2, +): Promise> +⋮---- +getSpotHistoricCandles( + params: SpotHistoricCandlesRequestV2, +): Promise> +⋮---- +getSpotRecentTrades(params: { + symbol: string; + limit?: string; +}): Promise> +⋮---- +getSpotHistoricTrades( + params: SpotHistoricTradesRequestV2, +): Promise> +⋮---- +getSpotCallAuction( + params: SpotCallAuctionRequestV2, +): Promise> +⋮---- +/** + * + * * Spot | Trade + * + */ +⋮---- +spotSubmitOrder(params: SpotOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v2/spot/trade/place-order', params); +⋮---- +spotCancelandSubmitOrder( + params: SpotCancelandSubmitOrderRequestV2, +): Promise> +⋮---- +spotBatchCancelandSubmitOrder(params: { + orderList: SpotCancelandSubmitOrderRequestV2[]; +}): Promise> +⋮---- +spotCancelOrder(params: SpotCancelOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v2/spot/trade/cancel-order', params); +⋮---- +spotBatchSubmitOrders( + params: SpotBatchOrderRequestV2, +): Promise> +⋮---- +spotBatchCancelOrders( + params: SpotBatchCancelOrderRequestV2, +): Promise> +⋮---- +spotCancelSymbolOrder(params: { symbol: string }): Promise< + APIResponse<{ + symbol: string; + }> + > { + return this.postPrivate('/api/v2/spot/trade/cancel-symbol-order', params); +⋮---- +getSpotOrder( + params?: GetSpotOrderInfoRequestV2, +): Promise> +⋮---- +getSpotOpenOrders( + params?: GetSpotOpenOrdersRequestV2, +): Promise> +⋮---- +getSpotHistoricOrders( + params?: GetSpotHistoryOrdersRequestV2, +): Promise> +⋮---- +getSpotFills( + params: GetSpotFillsRequestV2, +): Promise> +⋮---- +/** + * + * * Spot | Trigger Orders + * + */ +⋮---- +spotSubmitPlanOrder(params: SpotPlanOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v2/spot/trade/place-plan-order', params); +⋮---- +spotModifyPlanOrder(params: SpotModifyPlanOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v2/spot/trade/modify-plan-order', params); +⋮---- +spotCancelPlanOrder(params: { + clientOid?: string; + orderId?: string; + }): Promise< + APIResponse<{ + result: string; + }> + > { + return this.postPrivate('/api/v2/spot/trade/cancel-plan-order', params); +⋮---- +getSpotCurrentPlanOrders(params: GetSpotCurrentPlanOrdersRequestV2): Promise< + APIResponse<{ + nextFlag: boolean; + idLessThan: string; + orderList: SpotCurrentPlanOrderV2[]; + }> + > { + return this.getPrivate('/api/v2/spot/trade/current-plan-order', params); +⋮---- +getSpotPlanSubOrder(params: { + planOrderId: string; +}): Promise> +⋮---- +getSpotHistoricPlanOrders(params: GetSpotHistoryPlanOrdersRequestV2): Promise< + APIResponse<{ + nextFlag: boolean; + idLessThan: string; + orderList: SpotHistoryPlanOrderV2[]; + }> + > { + return this.getPrivate('/api/v2/spot/trade/history-plan-order', params); +⋮---- +spotCancelPlanOrders(params?: { + symbolList?: string[]; +}): Promise> +⋮---- +/** + * + * * Spot | Account + * + */ +⋮---- +getSpotAccount(): Promise> +⋮---- +getSpotAccountAssets(params?: { + coin?: string; + assetType?: string; +}): Promise> +⋮---- +getSpotSubAccountAssets(): Promise> +⋮---- +spotModifyDepositAccount(params: { + accountType: string; + coin: string; +}): Promise> +⋮---- +getSpotAccountBills( + params?: GetSpotAccountBillsRequestV2, +): Promise> +⋮---- +spotTransfer(params: SpotTransferRequestV2): Promise< + APIResponse<{ + transferId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v2/spot/wallet/transfer', params); +⋮---- +getSpotTransferableCoins(params: { + fromType: SpotAccountTypeV2; + toType: SpotAccountTypeV2; +}): Promise> +⋮---- +spotSubTransfer(params: SpotSubAccountTransferRequestV2): Promise< + APIResponse<{ + transferId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v2/spot/wallet/subaccount-transfer', params); +⋮---- +spotWithdraw(params: SpotWithdrawalRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v2/spot/wallet/withdrawal', params); +⋮---- +getSpotMainSubTransferRecord( + params: SpotMainSubTransferRecordRequestV2, +): Promise> +⋮---- +getSpotTransferHistory( + params: GetSpotTransferRecordRequestV2, +): Promise> +⋮---- +spotSwitchBGBDeduct(params: { + deduct: boolean; +}): Promise> +⋮---- +getSpotDepositAddress(params: { + coin: string; + chain?: string; + size: string; +}): Promise> +⋮---- +getSpotSubDepositAddress(params: { + subUid: string; + coin: string; + chain?: string; + size: string; +}): Promise> +⋮---- +getSpotBGBDeductInfo(): Promise< + APIResponse<{ + deduct: string; + }> + > { + return this.getPrivate('/api/v2/spot/account/deduct-info'); +⋮---- +spotCancelWithdrawal(params: { + orderId: string; +}): Promise> +⋮---- +getSubAccountDepositRecords( + params: GetSpotSubAccountDepositRecordRequestV2, +): Promise> +⋮---- +getSpotWithdrawalHistory( + params: GetSpotWithdrawalRecordRequestV2, +): Promise> +⋮---- +getSpotDepositHistory( + params: GetSpotDepositRecordRequestV2, +): Promise> +⋮---- +/** + * Upgrade Account - Upgrade to unified account mode + * No account type restrictions; both parent and sub-accounts are supported. + * This interface is only used for upgrading to the unified account mode. + * Please note that as the account upgrade process takes approximately 1 minute, + * the successful response you receive only indicates that the request has been received, + * and does not mean that the account has been successfully upgraded to a unified account. + * Please use the query upgrade status interface to confirm whether the account upgrade is successful. + */ +upgradeToUnifiedAccount(params?: { + subUid?: string; +}): Promise> +⋮---- +/** + * Get Upgrade Status - Get account upgrade status + * No account type restrictions; both parent and sub-accounts are supported. + */ +getUnifiedAccountSwitchStatus(params?: { subUid?: string }): Promise< + APIResponse<{ + status: 'processProcessing' | 'successSuccess' | 'failFailed'; + }> + > { + return this.getPrivate('/api/v2/spot/account/upgrade-status', params); +⋮---- +/** + * + * + * Futures + * + * + */ +⋮---- +/** + * + * * Futures | Market + * + */ +⋮---- +getFuturesVIPFeeRate(): Promise> +⋮---- +getFuturesInterestRateHistory(params: { coin: string }): Promise< + APIResponse<{ + coin: string; + historyInterestRateList: FuturesHistoryInterestRateV2[]; + }> + > { + return this.get('/api/v2/mix/market/union-interest-rate-history', params); +⋮---- +getFuturesInterestExchangeRate(): Promise< + APIResponse< + { + coin: string; + exchangeRateList: FuturesInterestExchangeRateV2[]; + }[] + > + > { + return this.get('/api/v2/mix/market/exchange-rate'); +⋮---- +getFuturesDiscountRate(): Promise> +⋮---- +getFuturesMergeDepth( + params: FuturesMergeDepthRequestV2, +): Promise> +⋮---- +getFuturesTicker(params: { + symbol: string; + productType: FuturesProductTypeV2; +}): Promise> +⋮---- +getFuturesAllTickers(params: { + productType: FuturesProductTypeV2; +}): Promise> +⋮---- +getFuturesRecentTrades( + params: FuturesRecentTradesRequestV2, +): Promise> +⋮---- +getFuturesHistoricTrades( + params: FuturesHistoricTradesRequestV2, +): Promise> +⋮---- +getFuturesCandles( + params: FuturesCandlesRequestV2, +): Promise> +⋮---- +getFuturesHistoricCandles( + params: FuturesCandlesRequestV2, +): Promise> +⋮---- +getFuturesHistoricIndexPriceCandles( + params: FuturesCandlesRequestV2, +): Promise> +⋮---- +getFuturesHistoricMarkPriceCandles( + params: FuturesCandlesRequestV2, +): Promise> +⋮---- +getFuturesOpenInterest(params: { + symbol: string; + productType: FuturesProductTypeV2; + }): Promise< + APIResponse<{ + openInterestList: FuturesOpenInterestV2[]; + ts: string; + }> + > { + return this.get('/api/v2/mix/market/open-interest', params); +⋮---- +getFuturesNextFundingTime(params: { + symbol: string; + productType: FuturesProductTypeV2; +}): Promise> +⋮---- +getFuturesSymbolPrice(params: { + symbol: string; + productType: FuturesProductTypeV2; +}): Promise> +⋮---- +getFuturesHistoricFundingRates(params: { + symbol: string; + productType: FuturesProductTypeV2; + pageSize?: string; + pageNo?: string; +}): Promise> +⋮---- +getFuturesCurrentFundingRate(params: { + symbol?: string; + productType: FuturesProductTypeV2; + }): Promise< + APIResponse< + { + symbol: string; + fundingRate: string; // '0.0001'; + fundingRateInterval: string; // hours, example: '1' | '2' | '4' | '8'; + nextUpdate: string; // timestamp in milliseconds + minFundingRate: string; + maxFundingRate: string; + }[] + > + > { + return this.get('/api/v2/mix/market/current-fund-rate', params); +⋮---- +fundingRate: string; // '0.0001'; +fundingRateInterval: string; // hours, example: '1' | '2' | '4' | '8'; +nextUpdate: string; // timestamp in milliseconds +⋮---- +getFuturesContractConfig(params: { + symbol?: string; + productType: FuturesProductTypeV2; +}): Promise> +⋮---- +getFuturesOiLimit(params: FuturesOiLimitRequestV2): Promise< + APIResponse< + { + symbol: string; + notionalValue: string; + totalNotionalValue: string; + }[] + > + > { + return this.get('/api/v2/mix/market/oi-limit', params); +⋮---- +/** + * + * * Futures | Account + * + */ ⋮---- -getClientType() +getFuturesAccountAsset( + params: FuturesSingleAccountRequestV2, +): Promise> +⋮---- +getFuturesAccountAssets(params: { + productType: FuturesProductTypeV2; +}): Promise> +⋮---- +getFuturesSubAccountAssets(params: { + productType: FuturesProductTypeV2; + }): Promise< + APIResponse< + { + userId: number; + assetList: FuturesSubAccountAssetV2[]; + }[] + > + > { + return this.getPrivate('/api/v2/mix/account/sub-account-assets', params); +⋮---- +getFuturesInterestHistory( + params: FuturesInterestHistoryRequestV2, +): Promise> +⋮---- +getFuturesOpenCount(params: FuturesOpenCountRequestV2): Promise< + APIResponse<{ + size: string; + }> + > { + return this.getPrivate('/api/v2/mix/account/open-count', params); +⋮---- +setFuturesPositionAutoMargin( + params: FuturesSetAutoMarginRequestV2, +): Promise> +⋮---- +setFuturesLeverage( + params: FuturesSetLeverageRequestV2, +): Promise> +⋮---- +setFuturesPositionMargin( + params: FuturesSetPositionMarginRequestV2, +): Promise> +⋮---- +setFuturesAssetMode(params: { + productType: 'USDT-FUTURES' | 'SUSDT-FUTURES'; + assetMode: 'single' | 'union'; +}): Promise> +⋮---- +setFuturesMarginMode( + params: FuturesSetMarginModeRequestV2, +): Promise> +⋮---- +setFuturesPositionMode(params: { + productType: FuturesProductTypeV2; + posMode: 'one_way_mode' | 'hedge_mode'; + }): Promise< + APIResponse<{ + posMode: 'one_way_mode' | 'hedge_mode'; + }> + > { + return this.postPrivate('/api/v2/mix/account/set-position-mode', params); +⋮---- +getFuturesAccountBills(params: FuturesAccountBillRequestV2): Promise< + APIResponse<{ + bills: FuturesAccountBillV2[]; + endId: string; + }> + > { + return this.getPrivate('/api/v2/mix/account/bill', params); ⋮---- /** + * Get Union Transfer Limits * - * Custom SDK functions + * - Rate limit: 1 time/1s (uid) + * - Get union margin currency transfer limits + */ +getUnionTransferLimits( + params: GetUnionTransferLimitsRequestV2, +): Promise> +⋮---- +/** + * Get Union Config * + * - Rate limit: 1 time/1s (uid) + * - Get API for union margin configuration parameters (Liability Initial Margin Rate, Liability Maintenance Margin Rate, Personal Liability Limit, Personal Liability Limit Ratio) */ +getUnionConfig(): Promise> ⋮---- /** - * This method is used to get the latency and time sync between the client and the server. - * This is not official API endpoint and is only used for internal testing purposes. - * Use this method to check the latency and time sync between the client and the server. - * Final values might vary slightly, but it should be within few ms difference. - * If you have any suggestions or improvements to this measurement, please create an issue or pull request on GitHub. + * Get Switch Union USDT + * + * - Rate limit: 1 time/1s (uid) + * - Get USDT quota for switching from union margin to single margin */ -async fetchLatencySummary(): Promise +getSwitchUnionUsdt(): Promise> ⋮---- -// Adjust server time by adding estimated one-way latency +/** + * Union Convert + * + * - Rate limit: 1 time/1s (uid) + * - Union margin exchange + */ +unionConvert( + params: UnionConvertRequestV2, +): Promise> ⋮---- -// Calculate time difference between adjusted server time and local time +/** + * Get Max Openable Quantity + * + * - Rate limit: 20 req/sec/UID + * - Get Max Openable Quantity + */ +getFuturesMaxOpenableQuantity( + params: FuturesMaxOpenRequestV2, +): Promise> +⋮---- +/** + * Get Liquidation Price + * + * - Rate limit: 20 req/sec/UID + * - Get Liquidation Price + */ +getFuturesLiquidationPrice( + params: FuturesLiquidationPriceRequestV2, +): Promise> +⋮---- +/** + * Get Isolated Symbols + * + * - Rate limits: 10 time/1s (uid) + * - Retrieve trading pairs with isolated margin mode under the account. + */ +getFuturesIsolatedSymbols( + params: FuturesIsolatedSymbolsRequestV2, +): Promise> +⋮---- +/** + * + * * Futures | Position + * + */ +⋮---- +getFuturesPositionTier(params: { + productType: FuturesProductTypeV2; + symbol: string; +}): Promise> +⋮---- +getFuturesPosition(params: { + productType: FuturesProductTypeV2; + symbol: string; + marginCoin: string; +}): Promise> +⋮---- +getFuturesPositions(params: { + productType: FuturesProductTypeV2; + marginCoin?: string; +}): Promise> ⋮---- -async fetchServerTime(): Promise +getFuturesHistoricPositions( + params?: FuturesHistoricalPositionsRequestV2, + ): Promise< + APIResponse<{ + list: FuturesHistoryPositionV2[]; + endId: string; + }> + > { + return this.getPrivate('/api/v2/mix/position/history-position', params); ⋮---- -/** - * - * Bitget misc functions - * - */ +getFuturesPositionAdlRank( + params: FuturesPositionAdlRankRequestV2, +): Promise> ⋮---- /** * - * - * Common - * + * * Futures | Trade * */ ⋮---- -/** - * - * * Common | Notice - * - */ +futuresSubmitOrder(params: FuturesPlaceOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v2/mix/order/place-order', params); ⋮---- -getAnnouncements( - params?: GetAnnouncementsRequestV2, -): Promise> +futuresSubmitReversal(params: FuturesReversalOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v2/mix/order/click-backhand', params); ⋮---- -/** - * - * * Common | Public - * - */ +futuresBatchSubmitOrders( + params: FuturesBatchOrderRequestV2, +): Promise> ⋮---- -getServerTime(): Promise< +futuresModifyOrder(params: FuturesModifyOrderRequestV2): Promise< APIResponse<{ - serverTime: string; + orderId: string; + clientOid: string; }> > { - return this.get('/api/v2/public/time'); + return this.postPrivate('/api/v2/mix/order/modify-order', params); ⋮---- -getTradeRate(params: GetTradeRateRequestV2): Promise< +futuresCancelOrder(params: FuturesCancelOrderRequestV2): Promise< APIResponse<{ - makerFeeRate: string; - takerFeeRate: string; + orderId: string; + clientOid: string; }> > { - return this.getPrivate('/api/v2/common/trade-rate', params); + return this.postPrivate('/api/v2/mix/order/cancel-order', params); ⋮---- -/** - * - * * Common | Tax - * - */ +futuresBatchCancelOrders( + params: FuturesBatchCancelOrderRequestV2, +): Promise> ⋮---- -getSpotTransactionRecords( - params: GetSpotTransactionsRequestV2, -): Promise> +futuresFlashClosePositions( + params: FuturesFlashClosePositionsRequestV2, +): Promise> ⋮---- -getFuturesTransactionRecords( - params: GetFuturesTransactionsRequestV2, -): Promise> +getFuturesOrder( + params: FuturesGetOrderRequestV2, +): Promise> ⋮---- -getMarginTransactionRecords( - params: GetMarginTransactionsRequestV2, -): Promise> +getFuturesFills(params: FuturesGetOrderFillsRequestV2): Promise< + APIResponse<{ + fillList: FuturesOrderFillV2[]; + endId: string; + }> + > { + return this.getPrivate('/api/v2/mix/order/fills', params); ⋮---- -getP2PTransactionRecords( - params: GetP2PTransactionsRequestV2, -): Promise> +getFuturesHistoricOrderFills( + params: FuturesGetHistoricalFillsRequestV2, + ): Promise< + APIResponse<{ + fillList: FuturesOrderFillV2[]; + endId: string; + }> + > { + return this.getPrivate('/api/v2/mix/order/fill-history', params); +⋮---- +getFuturesOpenOrders(params: FuturesGetOpenOrdersRequestV2): Promise< + APIResponse<{ + entrustedList: FuturesOpenOrderV2[]; + endId: string; + }> + > { + return this.getPrivate('/api/v2/mix/order/orders-pending', params); +⋮---- +getFuturesHistoricOrders(params: FuturesGetHistoryOrdersRequestV2): Promise< + APIResponse<{ + entrustedList: FuturesHistoryOrderV2[]; + endId: string; + }> + > { + return this.getPrivate('/api/v2/mix/order/orders-history', params); +⋮---- +futuresCancelAllOrders( + params: FuturesCancelAllOrdersRequestV2, +): Promise> ⋮---- /** * - * * Common | P2P + * * Futures | Trigger Orders * */ ⋮---- -getP2PMerchantList(params?: GetP2PMerchantsRequestV2): Promise< +getFuturesTriggerSubOrder(params: { + planType: 'normal_plan' | 'track_plan'; + planOrderId: string; + productType: FuturesProductTypeV2; +}): Promise> +⋮---- +futuresSubmitTPSLOrder(params: FuturesTPSLOrderRequestV2): Promise< APIResponse<{ - merchantList: P2PMerchantV2[]; - minMerchantId: string; + orderId: string; + clientOid: string; }> > { - return this.getPrivate('/api/v2/p2p/merchantList', params); + return this.postPrivate('/api/v2/mix/order/place-tpsl-order', params); ⋮---- -getP2PMerchantInfo(): Promise> +futuresSubmitPositionTPSL(params: FuturesPositionTPSLOrderRequestV2): Promise< + APIResponse< + { + orderId: string; + stopSurplusClientOid: string; + stopLossClientOid: string; + }[] + > + > { + return this.postPrivate('/api/v2/mix/order/place-pos-tpsl', params); ⋮---- -getP2PMerchantOrders(params: GetMerchantP2POrdersRequestV2): Promise< +futuresSubmitPlanOrder(params: FuturesPlanOrderRequestV2): Promise< APIResponse<{ - orderList: P2PMerchantOrderV2[]; - minOrderId: string; + orderId: string; + clientOid: string; }> > { - return this.getPrivate('/api/v2/p2p/orderList', params); + return this.postPrivate('/api/v2/mix/order/place-plan-order', params); ⋮---- -getP2PMerchantAdvertisementList( - params: GetMerchantAdvertisementsRequestV2, +futuresModifyTPSLPOrder(params: FuturesModifyTPSLOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v2/mix/order/modify-tpsl-order', params); +⋮---- +futuresModifyPlanOrder(params: FuturesModifyPlanOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v2/mix/order/modify-plan-order', params); +⋮---- +getFuturesPlanOrders(params: FuturesGetPlanOrdersRequestV2): Promise< + APIResponse<{ + entrustedList: FuturesPendingPlanOrderV2[]; + endId: string; + }> + > { + return this.getPrivate('/api/v2/mix/order/orders-plan-pending', params); +⋮---- +futuresCancelPlanOrder( + params: FuturesCancelPlanOrderRequestV2, +): Promise> +⋮---- +getFuturesHistoricPlanOrders( + params: FuturesGetHistoryPlanOrdersRequestV2, ): Promise< APIResponse<{ - advList: P2PMerchantAdvertismentV2[]; - minAdvId: string; + entrustedList: FuturesHistoryPlanOrderV2[]; + endId: string; }> > { - return this.getPrivate('/api/v2/p2p/advList', params); + return this.getPrivate('/api/v2/mix/order/orders-plan-history', params); ⋮---- /** * - * * Common | Trading insights + * + * Broker + * * */ ⋮---- -getSpotWhaleNetFlowData(params: { - symbol: string; -}): Promise> +/** + * + * * Broker | Subaccount + * + */ ⋮---- -getFuturesActiveTakerBuySellVolumeData(params: { - symbol: string; - period?: string; -}): Promise> +modifySubaccountEmail(params: { + subUid: string; + subaccountEmail: string; +}): Promise> ⋮---- -getFuturesActiveLongShortPositionData(params: { - symbol: string; - period?: string; -}): Promise> +getBrokerInfo(): Promise< + APIResponse<{ + subAccountSize: string; + maxSubAccountSize: string; + uTime: string; + }> + > { + return this.getPrivate('/api/v2/broker/account/info'); ⋮---- -getFuturesLongShortRatio(params: { - symbol: string; - period?: string; - coin?: string; -}): Promise> +createSubaccount(params: { + subaccountName: string; + label: string; +}): Promise> ⋮---- -getMarginLoanGrowthRate(params: { - symbol: string; - period?: string; - coin?: string; -}): Promise> +getSubaccounts(params?: GetSubAccountsRequestV2): Promise< + APIResponse<{ + hasNextPage: boolean; + idLessThan: number; + subList: BrokerSubaccountV2[]; + }> + > { + return this.getPrivate('/api/v2/broker/account/subaccount-list', params); ⋮---- -getIsolatedMarginBorrowingRatio(params: { - symbol: string; - period?: string; -}): Promise> +modifySubaccount( + params: ModifySubRequestV2, +): Promise> ⋮---- -getFuturesActiveBuySellVolumeData(params: { - symbol: string; - period?: string; -}): Promise> +getSubaccountEmail(params: { + subUid: string; +}): Promise> ⋮---- -getSpotFundFlow(params: { - symbol: string; - period?: string; -}): Promise> +getSubaccountSpotAssets(params: { + subUid: string; + coin?: string; + assetType?: 'hold_only' | 'all'; + }): Promise< + APIResponse<{ + assetsList: BrokerSubaccountSpotAssetV2[]; + }> + > { + return this.getPrivate( + '/api/v2/broker/account/subaccount-spot-assets', + params, + ); ⋮---- -getTradeDataSupportSymbols(): Promise< +getSubaccountFuturesAssets(params: { + subUid: string; + productType: FuturesProductTypeV2; + }): Promise< APIResponse<{ - spotList: string[]; - futureList: string[]; + assetsList: BrokerSubaccountFutureAssetV2[]; }> > { - return this.get('/api/v2/spot/market/support-symbols'); + return this.getPrivate( + '/api/v2/broker/account/subaccount-future-assets', + params, + ); ⋮---- -getSpotFundNetFlowData(params: { symbol: string }): Promise< - APIResponse< - { - netFlow: string; - ts: string; - }[] - > +createSubaccountDepositAddress(params: { + subUid: string; + coin: string; + chain?: string; +}): Promise> +⋮---- +subaccountWithdrawal(params: SubWithdrawalRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> > { - return this.get('/api/v2/spot/market/fund-net-flow', params); + return this.postPrivate( + '/api/v2/broker/account/subaccount-withdrawal', + params, + ); ⋮---- -getFuturesActiveLongShortAccountData(params: { - symbol: string; - period?: string; -}): Promise> +subaccountSetAutoTransfer(params: { + subUid: string; + coin: string; + toAccountType: string; +}): Promise> ⋮---- /** + * Sub Deposit Records * - * * Common | Virtual Subaccount - * + * - Only applicable for ND broker main-account to get ND sub-accounts deposit record */ +subaccountDepositRecords( + params: SubDepositRecordsRequestV2, +): Promise> ⋮---- -createVirtualSubaccount(params: { - subAccountList: string[]; -}): Promise> -⋮---- -modifyVirtualSubaccount(params: ModifyVirtualSubRequestV2): Promise< +/** + * Sub Withdrawal Records + * + * - Only applicable for ND broker main-account + */ +subaccountWithdrawalRecords(params: SubWithdrawalRecordsRequestV2): Promise< APIResponse<{ - result: string; + resultList: BrokerSubaccountWithdrawalV2[]; + endId: string; }> > { - return this.postPrivate('/api/v2/user/modify-virtual-subaccount', params); + return this.getPrivate('/api/v2/broker/subaccount-withdrawal', params); ⋮---- -batchCreateVirtualSubaccountAndAPIKey( - params: CreateVirtualSubRequestV2, -): Promise> +/** + * + * Broker | Api Key + * + */ ⋮---- -getVirtualSubaccounts(params?: { - limit?: string; - idLessThan?: string; - status?: 'normal' | 'freeze'; - }): Promise< +createSubaccountApiKey( + params: CreateSubAccountApiKeyRequestV2, +): Promise> +⋮---- +getSubaccountApiKey(params: { + subUid: string; +}): Promise> +⋮---- +modifySubaccountApiKey( + params: ModifySubAccountApiKeyRequestV2, +): Promise> +⋮---- +deleteSubaccountApiKey( + params: DeleteSubAccountApiKeyRequestV2, +): Promise> +⋮---- +/** + * Get All Sub-accounts Deposit and Withdrawal Records + * + * - Only applicable for ND broker main-account + * - Rate limit: 5 req/sec/UID + * - Able to get ND sub-accounts deposit and withdrawal records within 90 days + */ +getAllSubDepositWithdrawalRecords( + params?: GetAllSubDepositWithdrawalRequestV2, + ): Promise< APIResponse<{ + list: AllSubDepositWithdrawalRecordV2[]; endId: string; - subAccountList: VirtualSubAccountV2[]; }> > { - return this.getPrivate('/api/v2/user/virtual-subaccount-list', params); -⋮---- -createVirtualSubaccountAPIKey( - params: CreateVirtualSubApiKeyRequestV2, -): Promise> -⋮---- -modifyVirtualSubaccountAPIKey( - params: ModifyVirtualSubApiKeyRequestV2, -): Promise> + return this.getPrivate('/api/v2/broker/all-sub-deposit-withdrawal', params); ⋮---- -getVirtualSubaccountAPIKeys(params: { - subAccountUid: string; -}): Promise> +/** + * Get Broker Subaccounts + * + * - Rate limit: 5 req/sec/UID + * - Please contact your BD or RM to apply for access permissions + */ +getBrokerSubaccounts( + params?: GetBrokerSubaccountsRequestV2, +): Promise> ⋮---- /** - * Create a dedicated sub-account for an AI Agent instance. - * Frequency limit: 1/s per UID. Agent sub-accounts cannot be edited after creation. + * Get Broker Subaccounts Commissions + * + * - Rate limit: 5 req/sec/UID + * - Please contact your BD or RM to apply for access permissions */ -createAgentSubaccount( - params: CreateAgentSubaccountRequestV2, -): Promise> +getBrokerCommissions( + params?: GetBrokerCommissionsRequestV2, +): Promise> ⋮---- /** + * Get Broker Trade Volume * - * * Common | Assets + * - Rate limit: 5 req/sec/UID + * - Please contact your BD or RM to apply for access permissions + */ +getBrokerTradeVolume( + params?: GetBrokerTradeVolumeRequestV2, +): Promise> +⋮---- +/** + * Get Total Commission * + * - Rate limit: 20 req/sec/UID + * - Data retention: 365 days + * - Historical data available from: 2025/6/1 + * - Data granularity: daily + * - Data update granularity: daily, previous day's data is updated on the current day + * - Time zone: UTC+8 + * - startTime and endTime should either both be set or both left unset + * - This API supports retrieving data within the past 365 days (data is available starting from 2025/6/1 at the earliest) + * - If startTime and endTime are not set in the request, the default returned information will be for yesterday (00:00-23:59 UTC+8) + * - Data update frequency: T+1 (UTC+8) */ -getFundingAssets(params?: { - coin?: string; -}): Promise> +getBrokerTotalCommission( + params?: GetBrokerTotalCommissionRequestV2, +): Promise> ⋮---- -getBotAccount(params?: { - accountType?: string; -}): Promise> +/** + * Get Order Commission + * + * - Rate limit: 20 req/sec/UID + * - Data storage: 30 days + * - Historical data backtracking: 2025/9/1 + * - Data granularity: daily + * - Data update frequency: daily, previous day's data is updated on the current day + * - Time zone: UTC+8 + * - startTime and endTime should either both be set or both not set + * - The maximum time span supported for startTime and endTime is 30 days + * - This API supports retrieving data within the past 30 days + * - If startTime and endTime are not set in the request, the default return will be information for yesterday (00:00-23:59 UTC+8) + * - This API data is updated on a T+1 basis + * - Transaction details only show those marked with broker channel id + */ +getBrokerOrderCommission( + params?: GetBrokerOrderCommissionRequestV2, +): Promise> ⋮---- -/** Get assets overview */ -getBalances(): Promise< - APIResponse< - { - accountType: string; - usdtBalance: string; - }[] - > - > { - return this.getPrivate('/api/v2/account/all-account-balance'); +/** + * Get Rebate Info + * + * - Rate limit: 20 req/sec/UID + * - Data retention: 30 days + * - Real-time data + */ +getBrokerRebateInfo( + params: GetBrokerRebateInfoRequestV2, +): Promise> ⋮---- /** * - * * Common | Convert + * * Broker | Agent (affiliate) customer APIs * */ ⋮---- -getConvertCoins(): Promise> -⋮---- -getConvertQuotedPrice( - params: ConvertQuoteRequestV2, -): Promise> -⋮---- -convert( - params: ConvertRequestV2, -): Promise> +getAgentCustomerCommissions( + params?: GetAgentCustomerCommissionsRequestV2, +): Promise> ⋮---- -getConvertHistory(params: GetConvertHistoryRequestV2): Promise< - APIResponse<{ - dataList: ConvertRecordV2[]; - endId: string; - }> - > { - return this.getPrivate('/api/v2/convert/convert-record', params); +/** + * Without startTime/endTime, returns all registered sub-customers (no time restriction). + */ +getAgentSubCustomerList( + params?: GetAgentSubCustomerListRequestV2, +): Promise> +⋮---- +getAgentCustomerTradeVolume( + params?: AgentCustomerTradeVolumeRequestV2, +): Promise> ⋮---- /** - * - * * Common | BGB Convert - * + * Without startTime/endTime, returns all registered customers (no time restriction). */ +getAgentCustomerList( + params?: AgentCustomerListRequestV2, +): Promise> ⋮---- -getConvertBGBCoins(): Promise< - APIResponse<{ - coinList: BGBConvertCoinV2[]; - }> - > { - return this.getPrivate('/api/v2/convert/bgb-convert-coin-list'); +getAgentCustomerKycResult( + params?: GetAgentCustomerKycResultRequestV2, +): Promise> ⋮---- -convertBGB(params: { - coinList: string; -}): Promise> +getAgentCustomerDeposits( + params?: AgentCustomerDepositRequestV2, +): Promise> ⋮---- -getConvertBGBHistory( - params: GetConvertBGBHistoryRequestV2, -): Promise> +getAgentCustomerAssets( + params?: AgentCustomerAssetRequestV2, +): Promise> +⋮---- +getAgentCommissionDetail( + params?: GetAgentCommissionDetailRequestV2, +): Promise> ⋮---- /** * * - * Spot + * Margin * * */ ⋮---- /** * - * * Spot | Market + * * Margin | Common * */ ⋮---- -getSpotCoinInfo(params?: { - coin?: string; -}): Promise> -⋮---- -getSpotSymbolInfo(params?: { - symbol?: string; -}): Promise> -⋮---- -getSpotVIPFeeRate(): Promise> -⋮---- -getSpotTicker(params?: { - symbol?: string; -}): Promise> -⋮---- -getSpotMergeDepth(params: { - symbol: string; - precision?: string; - limit?: string; -}): Promise> -⋮---- -getSpotOrderBookDepth(params: { - symbol: string; - type?: string; - limit?: string; -}): Promise> -⋮---- -getSpotCandles( - params: SpotCandlesRequestV2, -): Promise> -⋮---- -getSpotHistoricCandles( - params: SpotHistoricCandlesRequestV2, -): Promise> -⋮---- -getSpotRecentTrades(params: { - symbol: string; - limit?: string; -}): Promise> -⋮---- -getSpotHistoricTrades( - params: SpotHistoricTradesRequestV2, -): Promise> +getMarginCurrencies(): Promise> ⋮---- /** * - * * Spot | Trade + * * Margin | Cross/Isolated | Order Record * */ ⋮---- -spotSubmitOrder(params: SpotOrderRequestV2): Promise< +getMarginBorrowHistory( + marginType: MarginType, + params: GetBorrowHistoryRequestV2, + ): Promise< APIResponse<{ - orderId: string; - clientOid: string; + resultList: MarginBorrowHistoryItemV2[]; + maxId: string; + minId: string; }> > { - return this.postPrivate('/api/v2/spot/trade/place-order', params); -⋮---- -spotCancelandSubmitOrder( - params: SpotCancelandSubmitOrderRequestV2, -): Promise> -⋮---- -spotBatchCancelandSubmitOrder(params: { - orderList: SpotCancelandSubmitOrderRequestV2[]; -}): Promise> + assertMarginType(marginType); ⋮---- -spotCancelOrder(params: SpotCancelOrderRequestV2): Promise< +getMarginRepayHistory( + marginType: MarginType, + params: GetRepayHistoryRequestV2, + ): Promise< APIResponse<{ - orderId: string; - clientOid: string; + resultList: MarginRepaymentHistoryItemV2[]; + maxId: string; + minId: string; }> > { - return this.postPrivate('/api/v2/spot/trade/cancel-order', params); -⋮---- -spotBatchSubmitOrders( - params: SpotBatchOrderRequestV2, -): Promise> -⋮---- -spotBatchCancelOrders( - params: SpotBatchCancelOrderRequestV2, -): Promise> + assertMarginType(marginType); ⋮---- -spotCancelSymbolOrder(params: { symbol: string }): Promise< +getMarginInterestHistory( + marginType: MarginType, + params: GetInterestHistoryRequestV2, + ): Promise< APIResponse<{ - symbol: string; + resultList: MarginInterestHistoryItemV2[]; + maxId: string; + minId: string; }> > { - return this.postPrivate('/api/v2/spot/trade/cancel-symbol-order', params); -⋮---- -getSpotOrder( - params?: GetSpotOrderInfoRequestV2, -): Promise> -⋮---- -getSpotOpenOrders( - params?: GetSpotOpenOrdersRequestV2, -): Promise> + assertMarginType(marginType); ⋮---- -getSpotHistoricOrders( - params?: GetSpotHistoryOrdersRequestV2, -): Promise> +getMarginLiquidationHistory( + marginType: MarginType, + params: GetLiquidationHistoryRequestV2, + ): Promise< + APIResponse<{ + resultList: MarginLiquidationHistoryItemV2[]; + maxId: string; + minId: string; + }> + > { + assertMarginType(marginType); ⋮---- -getSpotFills( - params: GetSpotFillsRequestV2, -): Promise> +getMarginFinancialHistory( + marginType: MarginType, + params: GetFinancialHistoryRequestV2, + ): Promise< + APIResponse<{ + resultList: MarginFinancialHistoryItemV2[]; + maxId: string; + minId: string; + }> + > { + assertMarginType(marginType); ⋮---- /** * - * * Spot | Trigger Orders + * * Margin | Cross/Isolated | Account * */ ⋮---- -spotSubmitPlanOrder(params: SpotPlanOrderRequestV2): Promise< +getMarginAccountAssets( + marginType: MarginType, + params?: { coin?: string }, +): Promise> +⋮---- +marginBorrow( + marginType: MarginType, + params: { + loanId: string; + symbol: string; + coin: string; + borrowAmount: string; + }, + ): Promise< APIResponse<{ - orderId: string; - clientOid: string; + loanId: string; + symbol: string; + coin: string; + borrowAmount: string; }> > { - return this.postPrivate('/api/v2/spot/trade/place-plan-order', params); + assertMarginType(marginType); ⋮---- -spotModifyPlanOrder(params: SpotModifyPlanOrderRequestV2): Promise< +marginRepay( + marginType: MarginType, + params: { + remainDebtAmount: string; + symbol: string; + repayId: string; + coin: string; + repayAmount: string; + }, + ): Promise< APIResponse<{ - orderId: string; - clientOid: string; + symbol: string; + coin: string; + repayId: string; + remainDebtAmount: string; + repayAmount: string; }> > { - return this.postPrivate('/api/v2/spot/trade/modify-plan-order', params); + assertMarginType(marginType); ⋮---- -spotCancelPlanOrder(params: { - clientOid?: string; - orderId?: string; - }): Promise< - APIResponse<{ - result: string; - }> +getMarginRiskRate(marginType: MarginType): Promise< + APIResponse< + { + symbol: string; + riskRateRatio: string; + }[] + > > { - return this.postPrivate('/api/v2/spot/trade/cancel-plan-order', params); + assertMarginType(marginType); +⋮---- +getMarginMaxBorrowable( + marginType: MarginType, + params: { coin: string }, + ): Promise< + APIResponse + > { + assertMarginType(marginType); +⋮---- +getMarginMaxTransferable( + marginType: MarginType, + params: { coin: string }, + ): Promise< + APIResponse< + CrossMaxTransferableResponseV2 | IsolatedMaxTransferableResponseV2 + > + > { + assertMarginType(marginType); ⋮---- -getSpotCurrentPlanOrders(params: GetSpotCurrentPlanOrdersRequestV2): Promise< - APIResponse<{ - nextFlag: boolean; - idLessThan: string; - orderList: SpotCurrentPlanOrderV2[]; - }> +getMarginInterestRateAndMaxBorrowable( + marginType: MarginType, + params: { coin: string }, + ): Promise< + APIResponse< + | IsolatedInterestRateAndLimitResponseV2[] + | CrossInterestRateAndLimitResponseV2[] + > > { - return this.getPrivate('/api/v2/spot/trade/current-plan-order', params); + assertMarginType(marginType); ⋮---- -getSpotPlanSubOrder(params: { - planOrderId: string; -}): Promise> +getMarginTierConfiguration( + marginType: MarginType, + params: { coin: string }, + ): Promise< + APIResponse< + CrossTierConfigurationResponseV2[] | IsolatedTierConfigurationResponseV2[] + > + > { + assertMarginType(marginType); ⋮---- -getSpotHistoricPlanOrders(params: GetSpotHistoryPlanOrdersRequestV2): Promise< +marginFlashRepay( + marginType: MarginType, + params: { coin: string }, + ): Promise< APIResponse<{ - nextFlag: boolean; - idLessThan: string; - orderList: SpotHistoryPlanOrderV2[]; + repayId: string; + coin?: string; + symbol?: string; + result?: string; }> > { - return this.getPrivate('/api/v2/spot/trade/history-plan-order', params); + assertMarginType(marginType); ⋮---- -spotCancelPlanOrders(params?: { - symbolList?: string[]; -}): Promise> +getMarginFlashRepayResult( + marginType: MarginType, + params: { idList: string }, + ): Promise< + APIResponse< + { + repayId: string; + status: string; + }[] + > + > { + assertMarginType(marginType); ⋮---- /** * - * * Spot | Account + * * Margin | Cross/Isolated | Trade * */ ⋮---- -getSpotAccount(): Promise> -⋮---- -getSpotAccountAssets(params?: { - coin?: string; - assetType?: string; -}): Promise> -⋮---- -getSpotSubAccountAssets(): Promise> -⋮---- -spotModifyDepositAccount(params: { - accountType: string; - coin: string; -}): Promise> -⋮---- -getSpotAccountBills( - params?: GetSpotAccountBillsRequestV2, -): Promise> -⋮---- -spotTransfer(params: SpotTransferRequestV2): Promise< +marginSubmitOrder( + marginType: MarginType, + params: MarginPlaceOrderRequestV2, + ): Promise< APIResponse<{ - transferId: string; + orderId: string; clientOid: string; }> > { - return this.postPrivate('/api/v2/spot/wallet/transfer', params); -⋮---- -getSpotTransferableCoins(params: { - fromType: SpotAccountTypeV2; - toType: SpotAccountTypeV2; -}): Promise> + assertMarginType(marginType); ⋮---- -spotSubTransfer(params: SpotSubAccountTransferRequestV2): Promise< - APIResponse<{ - transferId: string; - clientOid: string; - }> - > { - return this.postPrivate('/api/v2/spot/wallet/subaccount-transfer', params); +marginBatchSubmitOrders( + marginType: MarginType, + params: MarginBatchOrdersRequestV2, +): Promise> ⋮---- -spotWithdraw(params: SpotWithdrawalRequestV2): Promise< +marginCancelOrder( + marginType: MarginType, + params: { + symbol: string; + orderId?: string; + clientOid?: string; + }, + ): Promise< APIResponse<{ orderId: string; clientOid: string; }> > { - return this.postPrivate('/api/v2/spot/wallet/withdrawal', params); -⋮---- -getSpotMainSubTransferRecord( - params: SpotMainSubTransferRecordRequestV2, -): Promise> -⋮---- -getSpotTransferHistory( - params: GetSpotTransferRecordRequestV2, -): Promise> -⋮---- -spotSwitchBGBDeduct(params: { - deduct: boolean; -}): Promise> -⋮---- -getSpotDepositAddress(params: { - coin: string; - chain?: string; - size: string; -}): Promise> + assertMarginType(marginType); ⋮---- -getSpotSubDepositAddress(params: { - subUid: string; - coin: string; - chain?: string; - size: string; -}): Promise> +marginBatchCancelOrders( + marginType: MarginType, + params: { + symbol: string; + orderIdList: string[]; + }, +): Promise> ⋮---- -getSpotBGBDeductInfo(): Promise< +getMarginOpenOrders( + marginType: MarginType, + params: GetMarginCurrentOrdersRequestV2, + ): Promise< APIResponse<{ - deduct: string; + orderList: MarginCurrentOrderV2[]; + maxId: string; + minId: string; }> > { - return this.getPrivate('/api/v2/spot/account/deduct-info'); -⋮---- -spotCancelWithdrawal(params: { - orderId: string; -}): Promise> -⋮---- -getSubAccountDepositRecords( - params: GetSpotSubAccountDepositRecordRequestV2, -): Promise> -⋮---- -getSpotWithdrawalHistory( - params: GetSpotWithdrawalRecordRequestV2, -): Promise> -⋮---- -getSpotDepositHistory( - params: GetSpotDepositRecordRequestV2, -): Promise> -⋮---- -/** - * Upgrade Account - Upgrade to unified account mode - * No account type restrictions; both parent and sub-accounts are supported. - * This interface is only used for upgrading to the unified account mode. - * Please note that as the account upgrade process takes approximately 1 minute, - * the successful response you receive only indicates that the request has been received, - * and does not mean that the account has been successfully upgraded to a unified account. - * Please use the query upgrade status interface to confirm whether the account upgrade is successful. - */ -upgradeToUnifiedAccount(params?: { - subUid?: string; -}): Promise> + assertMarginType(marginType); ⋮---- -/** - * Get Upgrade Status - Get account upgrade status - * No account type restrictions; both parent and sub-accounts are supported. - */ -getUnifiedAccountSwitchStatus(params?: { subUid?: string }): Promise< +getMarginHistoricOrders( + marginType: MarginType, + params: GetHistoryOrdersRequestV2, + ): Promise< APIResponse<{ - status: 'processProcessing' | 'successSuccess' | 'failFailed'; + orderList: MarginHistoryOrderV2[]; + maxId: string; + minId: string; }> > { - return this.getPrivate('/api/v2/spot/account/upgrade-status', params); -⋮---- -/** - * - * - * Futures - * - * - */ -⋮---- -/** - * - * * Futures | Market - * - */ -⋮---- -getFuturesVIPFeeRate(): Promise> + assertMarginType(marginType); ⋮---- -getFuturesInterestRateHistory(params: { coin: string }): Promise< +getMarginHistoricOrderFills( + marginType: MarginType, + params: GetMarginOrderFillsRequestV2, + ): Promise< APIResponse<{ - coin: string; - historyInterestRateList: FuturesHistoryInterestRateV2[]; + fills: MarginOrderFillV2[]; + minId: string; + maxId: string; }> > { - return this.get('/api/v2/mix/market/union-interest-rate-history', params); -⋮---- -getFuturesInterestExchangeRate(): Promise< - APIResponse< - { - coin: string; - exchangeRateList: FuturesInterestExchangeRateV2[]; - }[] - > - > { - return this.get('/api/v2/mix/market/exchange-rate'); -⋮---- -getFuturesDiscountRate(): Promise> -⋮---- -getFuturesMergeDepth( - params: FuturesMergeDepthRequestV2, -): Promise> -⋮---- -getFuturesTicker(params: { - symbol: string; - productType: FuturesProductTypeV2; -}): Promise> + assertMarginType(marginType); ⋮---- -getFuturesAllTickers(params: { - productType: FuturesProductTypeV2; -}): Promise> +getMarginLiquidationOrders( + marginType: MarginType, + params: GetMarginLiquidationOrdersRequestV2, + ): Promise< + APIResponse<{ + resultList: MarginLiquidationOrderV2[]; + idLessThan: string; + }> + > { + assertMarginType(marginType); ⋮---- -getFuturesRecentTrades( - params: FuturesRecentTradesRequestV2, -): Promise> +/** + * + * + * Copy Trading + * + * + */ ⋮---- -getFuturesHistoricTrades( - params: FuturesHistoricTradesRequestV2, -): Promise> +/** + * + * + * Copy Trading | Future copy trading | Trader Api + * + * + */ ⋮---- -getFuturesCandles( - params: FuturesCandlesRequestV2, -): Promise> +getFuturesTraderCurrentOrder( + params: GetFuturesTraderCurrentOrdersRequestV2, +): Promise> ⋮---- -getFuturesHistoricCandles( - params: FuturesCandlesRequestV2, -): Promise> +getFuturesTraderHistoryOrders( + params: GetFuturesTraderHistoryOrdersRequestV2, +): Promise> ⋮---- -getFuturesHistoricIndexPriceCandles( - params: FuturesCandlesRequestV2, -): Promise> +modifyFuturesTraderOrderTPSL( + params: ModifyFuturesTraderOrderTPSLRequestV2, +): Promise> ⋮---- -getFuturesHistoricMarkPriceCandles( - params: FuturesCandlesRequestV2, -): Promise> +getFuturesTraderOrder(): Promise< + APIResponse + > { + return this.getPrivate('/api/v2/copy/mix-trader/order-total-detail'); ⋮---- -getFuturesOpenInterest(params: { - symbol: string; - productType: FuturesProductTypeV2; - }): Promise< - APIResponse<{ - openInterestList: FuturesOpenInterestV2[]; - ts: string; - }> +getFuturesTraderProfitHistory(): Promise< + APIResponse > { - return this.get('/api/v2/mix/market/open-interest', params); + return this.getPrivate('/api/v2/copy/mix-trader/profit-history-summarys'); ⋮---- -getFuturesNextFundingTime(params: { - symbol: string; - productType: FuturesProductTypeV2; -}): Promise> +getFuturesTraderProfitShareHistory( + params: GetFuturesTraderProfitShareDetailRequestV2, +): Promise> ⋮---- -getFuturesSymbolPrice(params: { +closeFuturesTraderOrder(params: { + trackingNo: string; symbol: string; - productType: FuturesProductTypeV2; -}): Promise> + productType: CopyTradingProductTypeV2; + }): Promise< + APIResponse< + { + trackingNo: string; + symbol: string; + productType: string; + }[] + > + > { + return this.postPrivate( + '/api/v2/copy/mix-trader/order-close-positions', + params, + ); ⋮---- -getFuturesHistoricFundingRates(params: { - symbol: string; - productType: FuturesProductTypeV2; +getFuturesTraderProfitShare(params?: { + coin?: string; pageSize?: string; pageNo?: string; -}): Promise> -⋮---- -getFuturesCurrentFundingRate(params: { - symbol?: string; - productType: FuturesProductTypeV2; }): Promise< APIResponse< { - symbol: string; - fundingRate: string; // '0.0001'; - fundingRateInterval: string; // hours, example: '1' | '2' | '4' | '8'; - nextUpdate: string; // timestamp in milliseconds - minFundingRate: string; - maxFundingRate: string; + coin: string; + profit: string; + nickName: string; }[] > > { - return this.get('/api/v2/mix/market/current-fund-rate', params); -⋮---- -fundingRate: string; // '0.0001'; -fundingRateInterval: string; // hours, example: '1' | '2' | '4' | '8'; -nextUpdate: string; // timestamp in milliseconds -⋮---- -getFuturesContractConfig(params: { - symbol?: string; - productType: FuturesProductTypeV2; -}): Promise> -⋮---- -/** - * - * * Futures | Account - * - */ -⋮---- -getFuturesAccountAsset( - params: FuturesSingleAccountRequestV2, -): Promise> -⋮---- -getFuturesAccountAssets(params: { - productType: FuturesProductTypeV2; -}): Promise> + return this.getPrivate('/api/v2/copy/mix-trader/profit-details', params); ⋮---- -getFuturesSubAccountAssets(params: { - productType: FuturesProductTypeV2; +getFuturesTraderProfitShareGroup(params?: { + pageSize?: string; + pageNo?: string; }): Promise< APIResponse< { - userId: number; - assetList: FuturesSubAccountAssetV2[]; + coin: string; + profit: string; + profitTime: string; }[] > > { - return this.getPrivate('/api/v2/mix/account/sub-account-assets', params); + return this.getPrivate( + '/api/v2/copy/mix-trader/profits-group-coin-date', + params, + ); ⋮---- -getFuturesInterestHistory( - params: FuturesInterestHistoryRequestV2, -): Promise> +getFuturesTraderSymbolSettings(params: { + productType: CopyTradingProductTypeV2; +}): Promise> ⋮---- -getFuturesOpenCount(params: FuturesOpenCountRequestV2): Promise< - APIResponse<{ - size: string; - }> - > { - return this.getPrivate('/api/v2/mix/account/open-count', params); +updateFuturesTraderSymbolSettings(params: { + settingList: FuturesTraderSymbolSettingRequestV2[]; +}): Promise> ⋮---- -setFuturesPositionAutoMargin( - params: FuturesSetAutoMarginRequestV2, -): Promise> +updateFuturesTraderGlobalSettings(params?: { + enable?: 'YES' | 'NO'; + showTotalEquity?: 'YES' | 'NO'; + showTpsl?: 'YES' | 'NO'; +}): Promise> ⋮---- -setFuturesLeverage( - params: FuturesSetLeverageRequestV2, -): Promise> +getFuturesTraderFollowers( + params?: GetFuturesTraderFollowersRequestV2, +): Promise> ⋮---- -setFuturesPositionMargin( - params: FuturesSetPositionMarginRequestV2, +removeFuturesTraderFollower(params: { + followerUid: string; +}): Promise> +⋮---- +/** + * + * + * Copy Trading | Future copy trading | Follower Api + * + * + */ +⋮---- +getFuturesFollowerCurrentOrders( + params: GetFollowerFuturesCurrentTrackingOrdersRequestV2, +): Promise> +⋮---- +getFuturesFollowerHistoryOrders( + params: GetFollowerFuturesHistoryTrackingOrdersRequestV2, +): Promise> +⋮---- +updateFuturesFollowerTPSL( + params: UpdateFuturesFollowerTPSLRequestV2, ): Promise> ⋮---- -setFuturesAssetMode(params: { - productType: 'USDT-FUTURES' | 'SUSDT-FUTURES'; - assetMode: 'single' | 'union'; -}): Promise> +updateFuturesFollowerSettings( + params: UpdateFuturesFollowerSettingsRequestV2, +): Promise> ⋮---- -setFuturesMarginMode( - params: FuturesSetMarginModeRequestV2, -): Promise> +getFuturesFollowerSettings(params: { + traderId: string; +}): Promise> ⋮---- -setFuturesPositionMode(params: { - productType: FuturesProductTypeV2; - posMode: 'one_way_mode' | 'hedge_mode'; - }): Promise< +closeFuturesFollowerPositions( + params: CloseFuturesFollowerPositionsRequestV2, + ): Promise< APIResponse<{ - posMode: 'one_way_mode' | 'hedge_mode'; + orderIdList: string[]; }> > { - return this.postPrivate('/api/v2/mix/account/set-position-mode', params); + return this.postPrivate( + '/api/v2/copy/mix-follower/close-positions', + params, + ); ⋮---- -getFuturesAccountBills(params: FuturesAccountBillRequestV2): Promise< - APIResponse<{ - bills: FuturesAccountBillV2[]; - endId: string; - }> +getFuturesFollowerTraders( + params: GetFuturesFollowerTradersRequestV2, +): Promise> +⋮---- +getFuturesFollowerFollowLimit(params: { + symbol: string; + productType: CopyTradingProductTypeV2; + }): Promise< + APIResponse< + { + maxFollowSize: string; + minFollowSize: string; + symbol: string; + }[] + > > { - return this.getPrivate('/api/v2/mix/account/bill', params); + return this.getPrivate( + '/api/v2/copy/mix-follower/query-quantity-limit', + params, + ); +⋮---- +unfollowFuturesTrader(params: { + traderId: string; +}): Promise> ⋮---- /** - * Get Union Transfer Limits * - * - Rate limit: 1 time/1s (uid) - * - Get union margin currency transfer limits - */ -getUnionTransferLimits( - params: GetUnionTransferLimitsRequestV2, -): Promise> -⋮---- -/** - * Get Union Config * - * - Rate limit: 1 time/1s (uid) - * - Get API for union margin configuration parameters (Liability Initial Margin Rate, Liability Maintenance Margin Rate, Personal Liability Limit, Personal Liability Limit Ratio) - */ -getUnionConfig(): Promise> -⋮---- -/** - * Get Switch Union USDT + * Copy Trading | Future copy trading | Broker api * - * - Rate limit: 1 time/1s (uid) - * - Get USDT quota for switching from union margin to single margin - */ -getSwitchUnionUsdt(): Promise> -⋮---- -/** - * Union Convert * - * - Rate limit: 1 time/1s (uid) - * - Union margin exchange */ -unionConvert( - params: UnionConvertRequestV2, -): Promise> ⋮---- -/** - * Get Max Openable Quantity - * - * - Rate limit: 20 req/sec/UID - * - Get Max Openable Quantity - */ -getFuturesMaxOpenableQuantity( - params: FuturesMaxOpenRequestV2, -): Promise> +getBrokerTraders(params: object): Promise> ⋮---- -/** - * Get Liquidation Price - * - * - Rate limit: 20 req/sec/UID - * - Get Liquidation Price - */ -getFuturesLiquidationPrice( - params: FuturesLiquidationPriceRequestV2, -): Promise> +getBrokerTradersHistoricalOrders(params: object): Promise> ⋮---- -/** - * Get Isolated Symbols - * - * - Rate limits: 10 time/1s (uid) - * - Retrieve trading pairs with isolated margin mode under the account. - */ -getFuturesIsolatedSymbols( - params: FuturesIsolatedSymbolsRequestV2, -): Promise> +getBrokerTradersPendingOrders(params: object): Promise> ⋮---- /** * - * * Futures | Position + * + * Copy Trading | Spot copy trading | Trader api + * * */ ⋮---- -getFuturesPositionTier(params: { - productType: FuturesProductTypeV2; - symbol: string; -}): Promise> +getSpotTraderProfit(): Promise> ⋮---- -getFuturesPosition(params: { - productType: FuturesProductTypeV2; +getSpotTraderHistoryProfit( + params: GetSpotTraderHistoryProfitRequestV2, +): Promise> +⋮---- +getSpotTraderUnrealizedProfit(params?: { + coin?: string; + pageNo?: string; + pageSize?: string; +}): Promise> +⋮---- +getSpotTraderOrder(): Promise> +⋮---- +modifySpotTraderOrderTPSL(params: { + trackingNo: string; + stopSurplusPrice?: string; + stopLossPrice?: string; +}): Promise> +⋮---- +getSpotTraderHistoryOrders( + params: GetSpotTraderHistoryOrdersRequestV2, +): Promise> +⋮---- +getSpotTraderCurrentOrders( + params: GetSpotTraderCurrentOrdersRequestV2, +): Promise> +⋮---- +sellSpotTrader(params: { + trackingNoList: string[]; symbol: string; - marginCoin: string; -}): Promise> +}): Promise> ⋮---- -getFuturesPositions(params: { - productType: FuturesProductTypeV2; - marginCoin?: string; -}): Promise> +getSpotTraderSymbolSettings(params: { + symbolList: string[]; + settingType: 'add' | 'delete'; +}): Promise> ⋮---- -getFuturesHistoricPositions( - params?: FuturesHistoricalPositionsRequestV2, - ): Promise< - APIResponse<{ - list: FuturesHistoryPositionV2[]; - endId: string; - }> - > { - return this.getPrivate('/api/v2/mix/position/history-position', params); +removeSpotTraderFollowers(params: { + followerUid: string; +}): Promise> +⋮---- +getSpotTraderConfiguration(): Promise> +⋮---- +getSpotTraderFollowers( + params: GetSpotTraderFollowersRequestV2, +): Promise> ⋮---- /** * - * * Futures | Trade + * + * Copy Trading | Spot copy trading | Follower api + * * */ ⋮---- -futuresSubmitOrder(params: FuturesPlaceOrderRequestV2): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > { - return this.postPrivate('/api/v2/mix/order/place-order', params); +cancelSpotFollowerOrder(params: { + trackingNoList: string[]; +}): Promise> ⋮---- -futuresSubmitReversal(params: FuturesReversalOrderRequestV2): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > { - return this.postPrivate('/api/v2/mix/order/click-backhand', params); +updateSpotFollowerSettings(params: { + traderId: string; + autoCopy?: 'on' | 'off'; + mode?: 'basic' | 'advanced'; + settings: SpotFollowerCopyTradeSettingV2[]; +}): Promise> ⋮---- -futuresBatchSubmitOrders( - params: FuturesBatchOrderRequestV2, -): Promise> +updateSpotFollowerTPSL(params: { + trackingNo: string; + stopSurplusPrice?: string; + stopLossPrice?: string; +}): Promise> ⋮---- -futuresModifyOrder(params: FuturesModifyOrderRequestV2): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > { - return this.postPrivate('/api/v2/mix/order/modify-order', params); +getSpotFollowerTraders(params?: { + pageNo?: string; + pageSize?: string; + startTime?: string; + endTime?: string; +}): Promise> ⋮---- -futuresCancelOrder(params: FuturesCancelOrderRequestV2): Promise< +getSpotFollowerCurrentTraderSymbols(params: { traderId: string }): Promise< APIResponse<{ - orderId: string; - clientOid: string; + currentTradingList: string[]; }> > { - return this.postPrivate('/api/v2/mix/order/cancel-order', params); + return this.getPrivate( + '/api/v2/copy/spot-follower/query-trader-symbols', + params, + ); ⋮---- -futuresBatchCancelOrders( - params: FuturesBatchCancelOrderRequestV2, -): Promise> +getSpotFollowerSettings(params: { + traderId: string; +}): Promise> ⋮---- -futuresFlashClosePositions( - params: FuturesFlashClosePositionsRequestV2, -): Promise> +getSpotFollowerHistoryOrders( + params: GetSpotFollowerHistoryOrdersRequestV2, +): Promise> ⋮---- -getFuturesOrder( - params: FuturesGetOrderRequestV2, -): Promise> +getSpotFollowerOpenOrders( + params: GetSpotFollowerOpenOrdersRequestV2, +): Promise> ⋮---- -getFuturesFills(params: FuturesGetOrderFillsRequestV2): Promise< - APIResponse<{ - fillList: FuturesOrderFillV2[]; - endId: string; - }> - > { - return this.getPrivate('/api/v2/mix/order/fills', params); +sellSpotFollower(params: { + trackingNoList: string[]; + symbol: string; +}): Promise> ⋮---- -getFuturesHistoricOrderFills( - params: FuturesGetHistoricalFillsRequestV2, - ): Promise< - APIResponse<{ - fillList: FuturesOrderFillV2[]; - endId: string; - }> - > { - return this.getPrivate('/api/v2/mix/order/fill-history', params); +unfollowSpotTrader(params: { + traderId: string; +}): Promise> ⋮---- -getFuturesOpenOrders(params: FuturesGetOpenOrdersRequestV2): Promise< - APIResponse<{ - entrustedList: FuturesOpenOrderV2[]; - endId: string; - }> - > { - return this.getPrivate('/api/v2/mix/order/orders-pending', params); +/** + * + * + * Earn | Savings + * + * + */ ⋮---- -getFuturesHistoricOrders(params: FuturesGetHistoryOrdersRequestV2): Promise< - APIResponse<{ - entrustedList: FuturesHistoryOrderV2[]; - endId: string; - }> - > { - return this.getPrivate('/api/v2/mix/order/orders-history', params); +getEarnSavingsProducts(params?: { + coin?: string; + filter?: string; +}): Promise> ⋮---- -futuresCancelAllOrders( - params: FuturesCancelAllOrdersRequestV2, -): Promise> +getEarnSavingsAccount(): Promise> ⋮---- -/** - * - * * Futures | Trigger Orders - * - */ +getEarnSavingsAssets( + params: GetEarnSavingsAssetsRequestV2, +): Promise> ⋮---- -getFuturesTriggerSubOrder(params: { - planType: 'normal_plan' | 'track_plan'; - planOrderId: string; - productType: FuturesProductTypeV2; -}): Promise> +getEarnSavingsRecords( + params: GetEarnSavingsRecordsRequestV2, +): Promise> ⋮---- -futuresSubmitTPSLOrder(params: FuturesTPSLOrderRequestV2): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > { - return this.postPrivate('/api/v2/mix/order/place-tpsl-order', params); +getEarnSavingsSubscription(params: { + productId: string; + periodType: string; +}): Promise> ⋮---- -futuresSubmitPlanOrder(params: FuturesPlanOrderRequestV2): Promise< +earnSubscribeSavings(params: { + productId: string; + periodType: string; + amount: string; + }): Promise< APIResponse<{ orderId: string; - clientOid: string; + status: string; }> > { - return this.postPrivate('/api/v2/mix/order/place-plan-order', params); + return this.postPrivate('/api/v2/earn/savings/subscribe', params); ⋮---- -futuresModifyTPSLPOrder(params: FuturesModifyTPSLOrderRequestV2): Promise< +getEarnSavingsSubscriptionResult(params: { + productId: string; + periodType: string; + }): Promise< APIResponse<{ - orderId: string; - clientOid: string; + result: 'success' | 'fail'; + msg: string; }> > { - return this.postPrivate('/api/v2/mix/order/modify-tpsl-order', params); + return this.getPrivate('/api/v2/earn/savings/subscribe-result', params); ⋮---- -futuresModifyPlanOrder(params: FuturesModifyPlanOrderRequestV2): Promise< +earnRedeemSavings(params: RedeemSavingsRequestV2): Promise< APIResponse<{ orderId: string; - clientOid: string; + status: string; }> > { - return this.postPrivate('/api/v2/mix/order/modify-plan-order', params); + return this.postPrivate('/api/v2/earn/savings/redeem', params); ⋮---- -getFuturesPlanOrders(params: FuturesGetPlanOrdersRequestV2): Promise< +getEarnSavingsRedemptionResult(params: { + orderId: string; + periodType: string; + }): Promise< APIResponse<{ - entrustedList: FuturesPendingPlanOrderV2[]; - endId: string; + result: 'success' | 'fail'; + msg: string; }> > { - return this.getPrivate('/api/v2/mix/order/orders-plan-pending', params); + return this.getPrivate('/api/v2/earn/savings/redeem-result', params); ⋮---- -futuresCancelPlanOrder( - params: FuturesCancelPlanOrderRequestV2, -): Promise> +/** + * + * + * Earn | Earn Account + * + * + */ ⋮---- -getFuturesHistoricPlanOrders( - params: FuturesGetHistoryPlanOrdersRequestV2, - ): Promise< - APIResponse<{ - entrustedList: FuturesHistoryPlanOrderV2[]; - endId: string; - }> +getEarnAccount(params?: { coin?: string }): Promise< + APIResponse< + { + coin: string; + amount: string; + }[] + > > { - return this.getPrivate('/api/v2/mix/order/orders-plan-history', params); + return this.getPrivate('/api/v2/earn/account/assets', params); ⋮---- /** * * - * Broker + * Earn | On-Chain Elite * * */ ⋮---- +getEarnEliteProducts(): Promise> +⋮---- +getEarnEliteAssets(): Promise> +⋮---- +getEarnEliteRecords( + params: GetEarnEliteRecordsRequestV2, +): Promise> +⋮---- +getEarnEliteSubscribeInfo( + params: GetEarnEliteSubscribeInfoRequestV2, +): Promise> +⋮---- +subscribeEarnElite( + params: EarnEliteSubscribeRequestV2, +): Promise> +⋮---- +getEarnEliteSubscribeResult( + params: GetEarnEliteSubscribeResultRequestV2, +): Promise> +⋮---- +getEarnEliteRedeemInfo( + params: GetEarnEliteRedeemInfoRequestV2, +): Promise> +⋮---- +redeemEarnElite( + params: RedeemEarnEliteRequestV2, +): Promise> +⋮---- /** * - * * Broker | Subaccount + * + * Earn | Shark Fin + * * */ ⋮---- -modifySubaccountEmail(params: { - subUid: string; - subaccountEmail: string; -}): Promise> +getSharkfinProducts(params: { + coin: string; + limit?: string; + idLessThan?: string; +}): Promise> ⋮---- -getBrokerInfo(): Promise< +getSharkfinAccount(): Promise> +⋮---- +getSharkfinAssets( + params: GetSharkfinAssetsRequestV2, +): Promise> +⋮---- +getSharkfinRecords( + params: GetSharkfinRecordsRequestV2, +): Promise> +⋮---- +getSharkfinSubscription(params: { + productId: string; +}): Promise> +⋮---- +subscribeSharkfin(params: { productId: string; amount: string }): Promise< APIResponse<{ - subAccountSize: string; - maxSubAccountSize: string; - uTime: string; + orderId: string; + status: string; }> > { - return this.getPrivate('/api/v2/broker/account/info'); -⋮---- -createSubaccount(params: { - subaccountName: string; - label: string; -}): Promise> + return this.postPrivate('/api/v2/earn/sharkfin/subscribe', params); ⋮---- -getSubaccounts(params?: GetSubAccountsRequestV2): Promise< +getSharkfinSubscriptionResult(params: { orderId: string }): Promise< APIResponse<{ - hasNextPage: boolean; - idLessThan: number; - subList: BrokerSubaccountV2[]; + result: 'success' | 'fail'; + msg: string; }> > { - return this.getPrivate('/api/v2/broker/account/subaccount-list', params); -⋮---- -modifySubaccount( - params: ModifySubRequestV2, -): Promise> + return this.getPrivate('/api/v2/earn/sharkfin/subscribe-result', params); ⋮---- -getSubaccountEmail(params: { - subUid: string; -}): Promise> +/** + * + * + * Earn | Loan + * + * + */ ⋮---- -getSubaccountSpotAssets(params: { - subUid: string; +getLoanCurrencies(params?: { coin?: string; - assetType?: 'hold_only' | 'all'; - }): Promise< - APIResponse<{ - assetsList: BrokerSubaccountSpotAssetV2[]; - }> - > { - return this.getPrivate( - '/api/v2/broker/account/subaccount-spot-assets', - params, - ); +}): Promise> ⋮---- -getSubaccountFuturesAssets(params: { - subUid: string; - productType: FuturesProductTypeV2; - }): Promise< +getLoanEstInterestAndBorrowable( + params: GetLoanEstInterestAndBorrowableRequestV2, + ): Promise< APIResponse<{ - assetsList: BrokerSubaccountFutureAssetV2[]; + hourInterest: string; + loanAmount: string; }> > { - return this.getPrivate( - '/api/v2/broker/account/subaccount-future-assets', - params, - ); -⋮---- -createSubaccountDepositAddress(params: { - subUid: string; - coin: string; - chain?: string; -}): Promise> + return this.get('/api/v2/earn/loan/public/hour-interest', params); ⋮---- -subaccountWithdrawal(params: SubWithdrawalRequestV2): Promise< +borrowLoan(params: BorrowLoanRequestV2): Promise< APIResponse<{ orderId: string; - clientOid: string; }> > { - return this.postPrivate( - '/api/v2/broker/account/subaccount-withdrawal', - params, - ); -⋮---- -subaccountSetAutoTransfer(params: { - subUid: string; - coin: string; - toAccountType: string; -}): Promise> + return this.postPrivate('/api/v2/earn/loan/borrow', params); ⋮---- -/** - * Sub Deposit Records - * - * - Only applicable for ND broker main-account to get ND sub-accounts deposit record - */ -subaccountDepositRecords( - params: SubDepositRecordsRequestV2, -): Promise> +getOngoingLoanOrders(params?: { + orderId?: string; + loanCoin?: string; + pledgeCoin?: string; +}): Promise> ⋮---- -/** - * Sub Withdrawal Records - * - * - Only applicable for ND broker main-account - */ -subaccountWithdrawalRecords(params: SubWithdrawalRecordsRequestV2): Promise< +repayLoan( + params: RepayLoanRequestV2, +): Promise> +⋮---- +getRepayHistory( + params: GetLoanRepayHistoryRequestV2, +): Promise> +⋮---- +updateLoanPledgeRate(params: ModifyLoanPledgeRateRequestV2): Promise< APIResponse<{ - resultList: BrokerSubaccountWithdrawalV2[]; - endId: string; + loanCoin: string; + pledgeCoin: string; + afterPledgeRate: string; }> > { - return this.getPrivate('/api/v2/broker/subaccount-withdrawal', params); + return this.postPrivate('/api/v2/earn/loan/revise-pledge', params); ⋮---- -/** - * - * Broker | Api Key - * - */ +getLoanPledgeRateHistory( + params: GetLoanPledgeRateHistoryRequestV2, +): Promise> ⋮---- -createSubaccountApiKey( - params: CreateSubAccountApiKeyRequestV2, -): Promise> +getLoanHistory( + params: GetLoanHistoryRequestV2, +): Promise> ⋮---- -getSubaccountApiKey(params: { - subUid: string; -}): Promise> +getLoanDebts(): Promise> ⋮---- -modifySubaccountApiKey( - params: ModifySubAccountApiKeyRequestV2, -): Promise> +getLoanLiquidationRecords( + params: GetLiquidationRecordsRequestV2, +): Promise> ⋮---- /** - * Get All Sub-accounts Deposit and Withdrawal Records * - * - Only applicable for ND broker main-account - * - Rate limit: 5 req/sec/UID - * - Able to get ND sub-accounts deposit and withdrawal records within 90 days + * * Inst Loan | Product Info + * */ -getAllSubDepositWithdrawalRecords( - params?: GetAllSubDepositWithdrawalRequestV2, - ): Promise< +⋮---- +getLoanProductInfo( + params: GetInstLoanProductInfoRequestV2, +): Promise> +⋮---- +getLoanSymbols( + params: GetInstLoanSymbolsRequestV2, +): Promise> +⋮---- +getLoanMarginCoinInfo(params: GetInstLoanMarginCoinInfoRequestV2): Promise< APIResponse<{ - list: AllSubDepositWithdrawalRecordV2[]; - endId: string; + productId: string; + coinInfo: InstLoanCoinInfoV2[]; }> > { - return this.getPrivate('/api/v2/broker/all-sub-deposit-withdrawal', params); -⋮---- -/** - * Get Broker Subaccounts - * - * - Rate limit: 5 req/sec/UID - * - Please contact your BD or RM to apply for access permissions - */ -getBrokerSubaccounts( - params?: GetBrokerSubaccountsRequestV2, -): Promise> -⋮---- -/** - * Get Broker Subaccounts Commissions - * - * - Rate limit: 5 req/sec/UID - * - Please contact your BD or RM to apply for access permissions - */ -getBrokerCommissions( - params?: GetBrokerCommissionsRequestV2, -): Promise> + return this.getPrivate( + '/api/v2/spot/ins-loan/ensure-coins-convert', + params, + ); ⋮---- /** - * Get Broker Trade Volume * - * - Rate limit: 5 req/sec/UID - * - Please contact your BD or RM to apply for access permissions - */ -getBrokerTradeVolume( - params?: GetBrokerTradeVolumeRequestV2, -): Promise> -⋮---- -/** - * Get Total Commission + * * Inst Loan | Account * - * - Rate limit: 20 req/sec/UID - * - Data retention: 365 days - * - Historical data available from: 2025/6/1 - * - Data granularity: daily - * - Data update granularity: daily, previous day's data is updated on the current day - * - Time zone: UTC+8 - * - startTime and endTime should either both be set or both left unset - * - This API supports retrieving data within the past 365 days (data is available starting from 2025/6/1 at the earliest) - * - If startTime and endTime are not set in the request, the default returned information will be for yesterday (00:00-23:59 UTC+8) - * - Data update frequency: T+1 (UTC+8) */ -getBrokerTotalCommission( - params?: GetBrokerTotalCommissionRequestV2, -): Promise> ⋮---- -/** - * Get Order Commission - * - * - Rate limit: 20 req/sec/UID - * - Data storage: 30 days - * - Historical data backtracking: 2025/9/1 - * - Data granularity: daily - * - Data update frequency: daily, previous day's data is updated on the current day - * - Time zone: UTC+8 - * - startTime and endTime should either both be set or both not set - * - The maximum time span supported for startTime and endTime is 30 days - * - This API supports retrieving data within the past 30 days - * - If startTime and endTime are not set in the request, the default return will be information for yesterday (00:00-23:59 UTC+8) - * - This API data is updated on a T+1 basis - * - Transaction details only show those marked with broker channel id - */ -getBrokerOrderCommission( - params?: GetBrokerOrderCommissionRequestV2, -): Promise> +getLoanRiskUnit(): Promise< + APIResponse<{ + riskUnitId: string[]; + }> + > { + return this.getPrivate('/api/v2/spot/ins-loan/risk-unit'); ⋮---- -/** - * Get Rebate Info - * - * - Rate limit: 20 req/sec/UID - * - Data retention: 30 days - * - Real-time data - */ -getBrokerRebateInfo( - params: GetBrokerRebateInfoRequestV2, -): Promise> +getLoanLTVConvert( + params?: GetInstLoanLTVConvertRequestV2, +): Promise> ⋮---- /** * - * * Broker | Agent (affiliate) customer APIs + * * Inst Loan | Orders * */ ⋮---- -getAgentCustomerCommissions( - params?: GetAgentCustomerCommissionsRequestV2, -): Promise> +getLoanRepaidHistory( + params?: GetInstLoanRepaidHistoryRequestV2, +): Promise> ⋮---- -/** - * Without startTime/endTime, returns all registered sub-customers (no time restriction). - */ -getAgentSubCustomerList( - params?: GetAgentSubCustomerListRequestV2, -): Promise> +getLoanOrder( + params?: GetInstLoanOrderRequestV2, +): Promise> + +================ +File: src/types/request/v3/account.ts +================ +// Account Management Request Types ⋮---- -getAgentCustomerTradeVolume( - params?: AgentCustomerTradeVolumeRequestV2, -): Promise> +export type AccountAdjustModeV3 = 'basic' | 'advanced' | 'delta' | 'isolated'; ⋮---- -/** - * Without startTime/endTime, returns all registered customers (no time restriction). - */ -getAgentCustomerList( - params?: AgentCustomerListRequestV2, -): Promise> +export interface AdjustAccountModeRequestV3 { + mode: AccountAdjustModeV3; + /** Sub-account UID when the master account switches mode for a sub-account */ + targetUid?: string; +} ⋮---- -getAgentCustomerKycResult( - params?: GetAgentCustomerKycResultRequestV2, -): Promise> +/** Sub-account UID when the master account switches mode for a sub-account */ ⋮---- -getAgentCustomerDeposits( - params?: AgentCustomerDepositRequestV2, -): Promise> +export interface SetLeverageRequestV3 { + category: 'MARGIN' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; + leverage: string; + coin?: string; + posSide?: 'long' | 'short'; + /** Futures only. Defaults to crossed */ + marginMode?: 'crossed' | 'isolated'; + /** Isolated two-way mode: long leverage. Takes priority over leverage when both set */ + longLeverage?: string; + /** Isolated two-way mode: short leverage. Takes priority over leverage when both set */ + shortLeverage?: string; +} ⋮---- -getAgentCustomerAssets( - params?: AgentCustomerAssetRequestV2, -): Promise> +/** Futures only. Defaults to crossed */ ⋮---- -getAgentCommissionDetail( - params?: GetAgentCommissionDetailRequestV2, -): Promise> +/** Isolated two-way mode: long leverage. Takes priority over leverage when both set */ ⋮---- -/** - * - * - * Margin - * - * - */ +/** Isolated two-way mode: short leverage. Takes priority over leverage when both set */ ⋮---- -/** - * - * * Margin | Common - * - */ +export interface GetAllFeeRatesRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol?: string; +} ⋮---- -getMarginCurrencies(): Promise> +export interface GetConvertRecordsRequestV3 { + fromCoin?: string; + toCoin?: string; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; +} ⋮---- -/** - * - * * Margin | Cross/Isolated | Order Record - * - */ +export interface GetFinancialRecordsRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + coin?: string; + type?: string; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; +} ⋮---- -getMarginBorrowHistory( - marginType: MarginType, - params: GetBorrowHistoryRequestV2, - ): Promise< - APIResponse<{ - resultList: MarginBorrowHistoryItemV2[]; - maxId: string; - minId: string; - }> - > { - assertMarginType(marginType); +export interface RepayRequestV3 { + repayableCoinList: string[]; + paymentCoinList: string[]; +} ⋮---- -getMarginRepayHistory( - marginType: MarginType, - params: GetRepayHistoryRequestV2, - ): Promise< - APIResponse<{ - resultList: MarginRepaymentHistoryItemV2[]; - maxId: string; - minId: string; - }> - > { - assertMarginType(marginType); +// Sub-account Management Request Types ⋮---- -getMarginInterestHistory( - marginType: MarginType, - params: GetInterestHistoryRequestV2, - ): Promise< - APIResponse<{ - resultList: MarginInterestHistoryItemV2[]; - maxId: string; - minId: string; - }> - > { - assertMarginType(marginType); +export interface CreateSubAccountApiKeyRequestV3 { + subUid: string; + note: string; + type: 'read_write' | 'read_only'; + passphrase: string; + permissions: string[]; + ips: string[]; +} ⋮---- -getMarginLiquidationHistory( - marginType: MarginType, - params: GetLiquidationHistoryRequestV2, - ): Promise< - APIResponse<{ - resultList: MarginLiquidationHistoryItemV2[]; - maxId: string; - minId: string; - }> - > { - assertMarginType(marginType); +export interface DeleteSubAccountApiKeyRequestV3 { + apiKey: string; +} ⋮---- -getMarginFinancialHistory( - marginType: MarginType, - params: GetFinancialHistoryRequestV2, - ): Promise< - APIResponse<{ - resultList: MarginFinancialHistoryItemV2[]; - maxId: string; - minId: string; - }> - > { - assertMarginType(marginType); +export interface GetSubAccountApiKeysRequestV3 { + subUid: string; + limit?: string; + cursor?: string; +} ⋮---- -/** - * - * * Margin | Cross/Isolated | Account - * - */ +export interface UpdateSubAccountApiKeyRequestV3 { + apiKey: string; + passphrase: string; + type?: 'read_write' | 'read_only'; + permissions?: string[]; + ips?: string[]; +} ⋮---- -getMarginAccountAssets( - marginType: MarginType, - params?: { coin?: string }, -): Promise> +export interface CreateSubAccountRequestV3 { + username: string; + accountMode?: 'classic' | 'unified'; + note?: string; +} ⋮---- -marginBorrow( - marginType: MarginType, - params: { - loanId: string; - symbol: string; - coin: string; - borrowAmount: string; - }, - ): Promise< - APIResponse<{ - loanId: string; - symbol: string; - coin: string; - borrowAmount: string; - }> - > { - assertMarginType(marginType); +export interface FreezeSubAccountRequestV3 { + subUid: string; + operation: 'freeze' | 'unfreeze'; +} ⋮---- -marginRepay( - marginType: MarginType, - params: { - remainDebtAmount: string; - symbol: string; - repayId: string; - coin: string; - repayAmount: string; - }, - ): Promise< - APIResponse<{ - symbol: string; - coin: string; - repayId: string; - remainDebtAmount: string; - repayAmount: string; - }> - > { - assertMarginType(marginType); +export interface GetSubAccountListRequestV3 { + limit?: string; + cursor?: string; +} ⋮---- -getMarginRiskRate(marginType: MarginType): Promise< - APIResponse< - { - symbol: string; - riskRateRatio: string; - }[] - > - > { - assertMarginType(marginType); +// Transfer Request Types ⋮---- -getMarginMaxBorrowable( - marginType: MarginType, - params: { coin: string }, - ): Promise< - APIResponse - > { - assertMarginType(marginType); +export interface TransferRequestV3 { + clientOid?: string; + fromType: + | 'spot' + | 'p2p' + | 'coin_futures' + | 'usdt_futures' + | 'usdc_futures' + | 'crossed_margin' + | 'isolated_margin' + | 'uta'; + toType: + | 'spot' + | 'p2p' + | 'coin_futures' + | 'usdt_futures' + | 'usdc_futures' + | 'crossed_margin' + | 'isolated_margin' + | 'uta'; + amount: string; + coin: string; + symbol?: string; + /** Enable automatic margin borrowing when balance insufficient. yes | no */ + allowBorrow?: 'yes' | 'no'; +} ⋮---- -getMarginMaxTransferable( - marginType: MarginType, - params: { coin: string }, - ): Promise< - APIResponse< - CrossMaxTransferableResponseV2 | IsolatedMaxTransferableResponseV2 - > - > { - assertMarginType(marginType); +/** Enable automatic margin borrowing when balance insufficient. yes | no */ ⋮---- -getMarginInterestRateAndMaxBorrowable( - marginType: MarginType, - params: { coin: string }, - ): Promise< - APIResponse< - | IsolatedInterestRateAndLimitResponseV2[] - | CrossInterestRateAndLimitResponseV2[] - > - > { - assertMarginType(marginType); +export interface GetTransferableCoinsRequestV3 { + fromType: + | 'spot' + | 'p2p' + | 'coin_futures' + | 'usdt_futures' + | 'usdc_futures' + | 'crossed_margin' + | 'isolated_margin' + | 'uta'; + toType: + | 'spot' + | 'p2p' + | 'coin_futures' + | 'usdt_futures' + | 'usdc_futures' + | 'crossed_margin' + | 'isolated_margin' + | 'uta'; +} ⋮---- -getMarginTierConfiguration( - marginType: MarginType, - params: { coin: string }, - ): Promise< - APIResponse< - CrossTierConfigurationResponseV2[] | IsolatedTierConfigurationResponseV2[] - > - > { - assertMarginType(marginType); +export interface GetSubTransferRecordsRequestV3 { + subUid?: string; + role?: 'initiator' | 'receiver'; + coin?: string; + startTime?: string; + endTime?: string; + clientOid?: string; + limit?: string; + cursor?: string; +} +⋮---- +export interface SubAccountTransferRequestV3 { + fromType: + | 'spot' + | 'p2p' + | 'usdt_futures' + | 'coin_futures' + | 'usdc_futures' + | 'crossed_margin' + | 'uta'; + toType: + | 'spot' + | 'p2p' + | 'usdt_futures' + | 'coin_futures' + | 'usdc_futures' + | 'crossed_margin' + | 'uta'; + amount: string; + coin: string; + fromUserId: string; + toUserId: string; + clientOid: string; + /** Enable automatic margin borrowing when balance insufficient. yes | no */ + allowBorrow?: 'yes' | 'no'; +} +⋮---- +/** Enable automatic margin borrowing when balance insufficient. yes | no */ ⋮---- -marginFlashRepay( - marginType: MarginType, - params: { coin: string }, - ): Promise< - APIResponse<{ - repayId: string; - coin?: string; - symbol?: string; - result?: string; - }> - > { - assertMarginType(marginType); +export interface GetSubUnifiedAssetsRequestV3 { + subUid?: string; + cursor?: string; + limit?: string; +} ⋮---- -getMarginFlashRepayResult( - marginType: MarginType, - params: { idList: string }, - ): Promise< - APIResponse< - { - repayId: string; - status: string; - }[] - > - > { - assertMarginType(marginType); +export interface GetFeeRateRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol: string; +} ⋮---- -/** - * - * * Margin | Cross/Isolated | Trade - * - */ +export interface GetFundingAssetsRequestV3 { + coin?: string; +} ⋮---- -marginSubmitOrder( - marginType: MarginType, - params: MarginPlaceOrderRequestV2, - ): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > { - assertMarginType(marginType); +export interface SwitchDeductRequestV3 { + deduct: 'on' | 'off'; +} ⋮---- -marginBatchSubmitOrders( - marginType: MarginType, - params: MarginBatchOrdersRequestV2, -): Promise> +// Deposit Request Types ⋮---- -marginCancelOrder( - marginType: MarginType, - params: { - symbol: string; - orderId?: string; - clientOid?: string; - }, - ): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > { - assertMarginType(marginType); +export interface GetDepositAddressRequestV3 { + coin: string; + chain?: string; + size?: string; +} ⋮---- -marginBatchCancelOrders( - marginType: MarginType, - params: { - symbol: string; - orderIdList: string[]; - }, -): Promise> +export interface GetSubDepositAddressRequestV3 { + subUid: string; + coin: string; + chain?: string; + size?: string; +} ⋮---- -getMarginOpenOrders( - marginType: MarginType, - params: GetMarginCurrentOrdersRequestV2, - ): Promise< - APIResponse<{ - orderList: MarginCurrentOrderV2[]; - maxId: string; - minId: string; - }> - > { - assertMarginType(marginType); +export interface GetDepositRecordsRequestV3 { + coin?: string; + orderId?: string; + startTime: string; + endTime: string; + limit?: string; + cursor?: string; +} ⋮---- -getMarginHistoricOrders( - marginType: MarginType, - params: GetHistoryOrdersRequestV2, - ): Promise< - APIResponse<{ - orderList: MarginHistoryOrderV2[]; - maxId: string; - minId: string; - }> - > { - assertMarginType(marginType); +export interface GetSubDepositRecordsRequestV3 { + coin?: string; + subUid: string; + startTime: string; + endTime: string; + limit?: string; + cursor?: string; +} ⋮---- -getMarginHistoricOrderFills( - marginType: MarginType, - params: GetMarginOrderFillsRequestV2, - ): Promise< - APIResponse<{ - fills: MarginOrderFillV2[]; - minId: string; - maxId: string; - }> - > { - assertMarginType(marginType); +// Withdraw Request Types ⋮---- -getMarginLiquidationOrders( - marginType: MarginType, - params: GetMarginLiquidationOrdersRequestV2, - ): Promise< - APIResponse<{ - resultList: MarginLiquidationOrderV2[]; - idLessThan: string; - }> - > { - assertMarginType(marginType); +export interface WithdrawRequestV3 { + coin: string; + chain?: string; + /** Deduct from funding, uta, and/or otc accounts (comma-separated). Order: funding -> otc -> uta */ + accountType?: string; + transferType: 'on_chain' | 'internal_transfer'; + address: string; + innerToType?: 'uid' | 'email' | 'mobile'; + areaCode?: string; + tag?: string; + size: string; + remark?: string; + clientOid?: string; + memberCode?: 'bithumb' | 'korbit' | 'coinone'; + identityType?: 'company' | 'user'; + companyName?: string; + firstName?: string; + lastName?: string; +} ⋮---- -/** - * - * - * Copy Trading - * - * - */ +/** Deduct from funding, uta, and/or otc accounts (comma-separated). Order: funding -> otc -> uta */ ⋮---- -/** - * - * - * Copy Trading | Future copy trading | Trader Api - * - * - */ +export interface GetWithdrawRecordsRequestV3 { + coin?: string; + orderId?: string; + clientOid?: string; + startTime: string; + endTime: string; + limit?: string; + cursor?: string; +} ⋮---- -getFuturesTraderCurrentOrder( - params: GetFuturesTraderCurrentOrdersRequestV2, -): Promise> +export interface GetWithdrawAddressBookRequestV3 { + coin?: string; + type?: 'EVM' | 'regular' | 'universal' | 'internal'; + limit?: string; + cursor?: string; +} ⋮---- -getFuturesTraderHistoryOrders( - params: GetFuturesTraderHistoryOrdersRequestV2, -): Promise> +export interface CancelWithdrawalRequestV3 { + orderId?: string; + clientOid?: string; +} ⋮---- -modifyFuturesTraderOrderTPSL( - params: ModifyFuturesTraderOrderTPSLRequestV2, -): Promise> +export interface SetDepositAccountRequestV3 { + coin: string; + accountType: 'funding' | 'unified' | 'otc'; +} ⋮---- -getFuturesTraderOrder(): Promise< - APIResponse - > { - return this.getPrivate('/api/v2/copy/mix-trader/order-total-detail'); +export interface GetMaxTransferableRequestV3 { + coin: string; +} ⋮---- -getFuturesTraderProfitHistory(): Promise< - APIResponse - > { - return this.getPrivate('/api/v2/copy/mix-trader/profit-history-summarys'); +export interface GetOpenInterestLimitRequestV3 { + symbol: string; + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; +} ⋮---- -getFuturesTraderProfitShareHistory( - params: GetFuturesTraderProfitShareDetailRequestV2, -): Promise> +export interface GetTaxRecordsRequestV3 { + bizType: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES' + | 'OTHER'; + marginType?: 'isolated' | 'crossed'; + coin?: string; + startTime: string; + endTime: string; + limit?: string; + cursor?: string; +} +⋮---- +export type CollateralTypeV3 = 'mainstream' | 'all' | 'custom'; ⋮---- -closeFuturesTraderOrder(params: { - trackingNo: string; - symbol: string; - productType: CopyTradingProductTypeV2; - }): Promise< - APIResponse< - { - trackingNo: string; - symbol: string; - productType: string; - }[] - > - > { - return this.postPrivate( - '/api/v2/copy/mix-trader/order-close-positions', - params, - ); +export interface SetCollateralTypeRequestV3 { + collateralType: CollateralTypeV3; + /** Required when collateralType=custom. Comma-separated coin names */ + collateralCoins?: string; +} ⋮---- -getFuturesTraderProfitShare(params?: { - coin?: string; - pageSize?: string; - pageNo?: string; - }): Promise< - APIResponse< - { - coin: string; - profit: string; - nickName: string; - }[] - > - > { - return this.getPrivate('/api/v2/copy/mix-trader/profit-details', params); +/** Required when collateralType=custom. Comma-separated coin names */ ⋮---- -getFuturesTraderProfitShareGroup(params?: { - pageSize?: string; - pageNo?: string; - }): Promise< - APIResponse< - { - coin: string; - profit: string; - profitTime: string; - }[] - > - > { - return this.getPrivate( - '/api/v2/copy/mix-trader/profits-group-coin-date', - params, - ); +export interface PreSetLeverageRequestV3 { + category: 'MARGIN' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; + coin?: string; + marginMode: 'isolated' | 'cross'; + leverage?: string; + longLeverage?: string; + shortLeverage?: string; +} ⋮---- -getFuturesTraderSymbolSettings(params: { - productType: CopyTradingProductTypeV2; -}): Promise> +export interface SetMarginRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol: string; + posSide: 'long' | 'short'; + operation: 'add' | 'remove'; + amount: string; +} ⋮---- -updateFuturesTraderSymbolSettings(params: { - settingList: FuturesTraderSymbolSettingRequestV2[]; -}): Promise> +export interface GetMaxWithdrawalRequestV3 { + coin: string; +} ⋮---- -updateFuturesTraderGlobalSettings(params?: { - enable?: 'YES' | 'NO'; - showTotalEquity?: 'YES' | 'NO'; - showTpsl?: 'YES' | 'NO'; -}): Promise> +export interface GetRealityOrderBookRequestV3 { + symbol: string; +} ⋮---- -getFuturesTraderFollowers( - params?: GetFuturesTraderFollowersRequestV2, -): Promise> +export interface GetRealityFillsRequestV3 { + symbol: string; + limit?: string; +} ⋮---- -removeFuturesTraderFollower(params: { - followerUid: string; -}): Promise> +export interface SubMasterTransferRequestV3 { + fromType: 'spot' | 'uta'; + toType: 'spot' | 'p2p' | 'uta'; + amount: string; + coin: string; + clientOid?: string; +} ⋮---- -/** - * - * - * Copy Trading | Future copy trading | Follower Api - * - * - */ +export interface CreateAgentSubAccountRequestV3 { + username: string; + passphrase: string; + note?: string; +} ⋮---- -getFuturesFollowerCurrentOrders( - params: GetFollowerFuturesCurrentTrackingOrdersRequestV2, -): Promise> +export interface MovePositionItemRequestV3 { + symbol: string; + side: 'buy' | 'sell'; + qty: string; +} ⋮---- -getFuturesFollowerHistoryOrders( - params: GetFollowerFuturesHistoryTrackingOrdersRequestV2, -): Promise> +export interface MovePositionsRequestV3 { + fromUid: string; + toUid: string; + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + positionList: MovePositionItemRequestV3[]; +} ⋮---- -updateFuturesFollowerTPSL( - params: UpdateFuturesFollowerTPSLRequestV2, -): Promise> +export interface GetMovePositionHistoryRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; + startTime?: string; + endTime?: string; + cursor?: string; + limit?: string; +} ⋮---- -updateFuturesFollowerSettings( - params: UpdateFuturesFollowerSettingsRequestV2, -): Promise> +export interface GetEligibleSymbolsRequestV3 { + symbol?: string; +} ⋮---- -getFuturesFollowerSettings(params: { - traderId: string; -}): Promise> +export interface GetEligibleMarginTierRequestV3 { + coin?: string; +} ⋮---- -closeFuturesFollowerPositions( - params: CloseFuturesFollowerPositionsRequestV2, - ): Promise< - APIResponse<{ - orderIdList: string[]; - }> - > { - return this.postPrivate( - '/api/v2/copy/mix-follower/close-positions', - params, - ); +export interface GetEligibleLoanInfoRequestV3 { + coin?: string; +} ⋮---- -getFuturesFollowerTraders( - params: GetFuturesFollowerTradersRequestV2, -): Promise> +export interface GetRateLimitQuotaRequestV3 { + category: 'spot' | 'futures'; + uid?: string; + cursor?: string; + limit?: string; +} ⋮---- -getFuturesFollowerFollowLimit(params: { - symbol: string; - productType: CopyTradingProductTypeV2; - }): Promise< - APIResponse< - { - maxFollowSize: string; - minFollowSize: string; - symbol: string; - }[] - > - > { - return this.getPrivate( - '/api/v2/copy/mix-follower/query-quantity-limit', - params, - ); +export interface SetRateLimitQuotaRequestV3 { + category: 'spot' | 'futures'; + uids: string[]; + quota: string; +} + +================ +File: src/types/response/v3/public.ts +================ +export interface PublicFillV3 { + execId: string; + price: string; + size: string; + side: 'sell' | 'buy'; + ts: string; +} ⋮---- -unfollowFuturesTrader(params: { - traderId: string; -}): Promise> +export interface CandlestickV3 extends Array { + 0: string; // timestamp + 1: string; // open price + 2: string; // high price + 3: string; // low price + 4: string; // close price + 5: string; // volume + 6: string; // turnover +} ⋮---- -/** - * - * - * Copy Trading | Future copy trading | Broker api - * - * - */ +0: string; // timestamp +1: string; // open price +2: string; // high price +3: string; // low price +4: string; // close price +5: string; // volume +6: string; // turnover ⋮---- -getBrokerTraders(params: object): Promise> +export interface ContractOiV3 { + symbol: string; + notionalValue: string; + totalNotionalValue: string; +} ⋮---- -getBrokerTradersHistoricalOrders(params: object): Promise> +export interface CurrentFundingRateV3 { + symbol: string; + fundingRate: string; + fundingRateInterval: string; + nextUpdate: string; + minFundingRate: string; + maxFundingRate: string; + cashDividend?: string; + cashDividendNextUpdate?: string; +} ⋮---- -getBrokerTradersPendingOrders(params: object): Promise> +export interface DiscountRateTierV3 { + tierStartValue: string; + discountRate: string; +} ⋮---- -/** - * - * - * Copy Trading | Spot copy trading | Trader api - * - * - */ +export interface DiscountRateV3 { + coin: string; + list: DiscountRateTierV3[]; +} ⋮---- -getSpotTraderProfit(): Promise> +export interface HistoryFundingRateV3 { + symbol: string; + fundingRate: string; + fundingRateTimestamp: string; +} +⋮---- +export interface MarginLoanV3 { + dailyInterest: string; + annualInterest: string; + limit: string; + masterSubLimit?: string; + /** Bitget spelling */ + platformRemaingQuota?: string; +} ⋮---- -getSpotTraderHistoryProfit( - params: GetSpotTraderHistoryProfitRequestV2, -): Promise> +/** Bitget spelling */ ⋮---- -getSpotTraderUnrealizedProfit(params?: { - coin?: string; - pageNo?: string; - pageSize?: string; -}): Promise> +export interface OpenInterestItemV3 { + symbol: string; + openInterest: string; +} ⋮---- -getSpotTraderOrder(): Promise> +export interface OpenInterestV3 { + list: OpenInterestItemV3[]; + ts: string; +} ⋮---- -modifySpotTraderOrderTPSL(params: { - trackingNo: string; - stopSurplusPrice?: string; - stopLossPrice?: string; -}): Promise> +export interface PositionTierV3 { + tier: string; + minTierValue: string; + maxTierValue: string; + leverage: string; + mmr: string; +} ⋮---- -getSpotTraderHistoryOrders( - params: GetSpotTraderHistoryOrdersRequestV2, -): Promise> +export interface RiskReserveRecordV3 { + balance: string; + amount: string; + ts: string; + type?: string; +} ⋮---- -getSpotTraderCurrentOrders( - params: GetSpotTraderCurrentOrdersRequestV2, -): Promise> +export interface RiskReserveV3 { + totalBalance?: string; + coin: string; + riskReserveRecords: RiskReserveRecordV3[]; +} ⋮---- -sellSpotTrader(params: { - trackingNoList: string[]; - symbol: string; -}): Promise> +export interface RiskReserveHourRecordV3 { + amount: string; + balance: string; + ts: string; +} ⋮---- -getSpotTraderSymbolSettings(params: { - symbolList: string[]; - settingType: 'add' | 'delete'; -}): Promise> +export interface RiskReserveHourV3 { + coin: string; + riskReserveRecords: RiskReserveHourRecordV3[]; +} ⋮---- -removeSpotTraderFollowers(params: { - followerUid: string; -}): Promise> +export interface RiskReserveAllItemV3 { + symbols: string[]; + coin: string; + balance: string; +} ⋮---- -getSpotTraderConfiguration(): Promise> +export interface RiskReserveAllV3 { + list: RiskReserveAllItemV3[]; +} ⋮---- -getSpotTraderFollowers( - params: GetSpotTraderFollowersRequestV2, -): Promise> +export interface InstrumentV3 { + symbol: string; + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + baseCoin: string; + quoteCoin: string; + buyLimitPriceRatio: string; + sellLimitPriceRatio: string; + feeRateUpRatio: string; + minOrderQty: string; + maxOrderQty: string; + maxMarketOrderQty: string; + pricePrecision: string; + quantityPrecision: string; + quotePrecision: string; + minOrderAmount: string; + maxSymbolOrderNum: string; + maxProductOrderNum: string; + status: + | 'listed' + | 'online' + | 'limit_open' + | 'limit_close' + | 'offline' + | 'restrictedAPI'; + offTime: string; + limitOpenTime: string; + maintainTime: string; + areaSymbol?: string; + + isRwa?: 'YES' | 'NO'; + /** yes = Reality stock token, no = non-Reality stock token */ + isReality?: 'yes' | 'no'; + + // Futures specific fields + makerFeeRate?: string; + takerFeeRate?: string; + openCostUpRatio?: string; + priceMultiplier?: string; + quantityMultiplier?: string; + type?: 'perpetual' | 'delivery'; + symbolType?: 'crypto' | 'metal' | 'stock' | 'commodity'; + maxPositionNum?: string; + deliveryTime?: string; + deliveryStartTime?: string; + deliveryPeriod?: string; + /** Launch time - Unix millisecond timestamp. Null for some margin pairs. */ + launchTime?: string | null; + fundInterval?: string; + minLeverage?: string; + maxLeverage?: string; + + // Margin specific fields + isIsolatedBaseBorrowable?: 'YES' | 'NO'; + isIsolatedQuotedBorrowable?: 'YES' | 'NO'; + warningRiskRatio?: string; + liquidationRiskRatio?: string; + maxCrossedLeverage?: string; + maxIsolatedLeverage?: string; + userMinBorrow?: string; +} ⋮---- -/** - * - * - * Copy Trading | Spot copy trading | Follower api - * - * - */ +/** yes = Reality stock token, no = non-Reality stock token */ ⋮---- -cancelSpotFollowerOrder(params: { - trackingNoList: string[]; -}): Promise> +// Futures specific fields ⋮---- -updateSpotFollowerSettings(params: { - traderId: string; - autoCopy?: 'on' | 'off'; - mode?: 'basic' | 'advanced'; - settings: SpotFollowerCopyTradeSettingV2[]; -}): Promise> +/** Launch time - Unix millisecond timestamp. Null for some margin pairs. */ ⋮---- -updateSpotFollowerTPSL(params: { - trackingNo: string; - stopSurplusPrice?: string; - stopLossPrice?: string; -}): Promise> +// Margin specific fields ⋮---- -getSpotFollowerTraders(params?: { - pageNo?: string; - pageSize?: string; - startTime?: string; - endTime?: string; -}): Promise> +export interface MarketFeeGroupLabelV3 { + weight: string; + label: string; + symbols: string[]; +} ⋮---- -getSpotFollowerCurrentTraderSymbols(params: { traderId: string }): Promise< - APIResponse<{ - currentTradingList: string[]; - }> - > { - return this.getPrivate( - '/api/v2/copy/spot-follower/query-trader-symbols', - params, - ); +export interface MarketFeeGroupTierV3 { + level: string; + makerFeeRate: string; + /** PRO1~PRO6 only. Taker fee rate in decimal form */ + takerFeeRate?: string; +} ⋮---- -getSpotFollowerSettings(params: { - traderId: string; -}): Promise> +/** PRO1~PRO6 only. Taker fee rate in decimal form */ ⋮---- -getSpotFollowerHistoryOrders( - params: GetSpotFollowerHistoryOrdersRequestV2, -): Promise> +export interface MarketFeeGroupV3 { + category: string; + group: string; + labelList: MarketFeeGroupLabelV3[]; + tierList: MarketFeeGroupTierV3[]; +} ⋮---- -getSpotFollowerOpenOrders( - params: GetSpotFollowerOpenOrdersRequestV2, -): Promise> +export interface MarketScoreWeightV3 { + category: string; + label: string; + symbol: string; + requiredSpread: string; + minMakerVolume: string; + weight: string; +} ⋮---- -sellSpotFollower(params: { - trackingNoList: string[]; - symbol: string; -}): Promise> +export interface LiquidationV3 { + symbol: string; + side: 'buy' | 'sell'; + price: string; + amount: string; + ts: string; +} ⋮---- -unfollowSpotTrader(params: { - traderId: string; -}): Promise> +export interface LiquidationsV3 { + list: LiquidationV3[]; + cursor?: string; +} ⋮---- -/** - * - * - * Earn | Savings - * - * - */ +export interface OrderBookV3 { + a: string[][]; // asks - [price, size] + b: string[][]; // bids - [price, size] + ts: string; +} ⋮---- -getEarnSavingsProducts(params?: { - coin?: string; - filter?: string; -}): Promise> +a: string[][]; // asks - [price, size] +b: string[][]; // bids - [price, size] ⋮---- -getEarnSavingsAccount(): Promise> +export interface RealityOrderBookV3 { + symbol: string; + a: string[][]; + b: string[][]; + ts: string; +} ⋮---- -getEarnSavingsAssets( - params: GetEarnSavingsAssetsRequestV2, -): Promise> +export interface RealityFillV3 { + execId: string; + price: string; + size: string; + side: 'buy' | 'sell'; + ts: string; +} ⋮---- -getEarnSavingsRecords( - params: GetEarnSavingsRecordsRequestV2, -): Promise> +export interface TickerV3 { + category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol: string; + lastPrice: string; + openPrice24h: string; + highPrice24h: string; + lowPrice24h: string; + ask1Price: string; + bid1Price: string; + bid1Size: string; + ask1Size: string; + price24hPcnt: string; + volume24h: string; + turnover24h: string; + /** 24h platform turnover; only available for rtoken */ + platformTurnover24h?: string; + + // Futures specific fields + indexPrice?: string; + markPrice?: string; + fundingRate?: string; + openInterest?: string; + deliveryStartTime?: string; + deliveryTime?: string; + deliveryStatus?: string; +} ⋮---- -getEarnSavingsSubscription(params: { - productId: string; - periodType: string; -}): Promise> +/** 24h platform turnover; only available for rtoken */ ⋮---- -earnSubscribeSavings(params: { - productId: string; - periodType: string; - amount: string; - }): Promise< - APIResponse<{ - orderId: string; - status: string; - }> - > { - return this.postPrivate('/api/v2/earn/savings/subscribe', params); +// Futures specific fields ⋮---- -getEarnSavingsSubscriptionResult(params: { - productId: string; - periodType: string; - }): Promise< - APIResponse<{ - result: 'success' | 'fail'; - msg: string; - }> - > { - return this.getPrivate('/api/v2/earn/savings/subscribe-result', params); +export interface ProofOfReservesV3 { + merkleRootHash: string; + totalReserveRatio: string; + list: { + coin: string; + userAssets: string; + platformAssets: string; + reserveRatio: string; + }[]; +} ⋮---- -earnRedeemSavings(params: RedeemSavingsRequestV2): Promise< - APIResponse<{ - orderId: string; - status: string; - }> - > { - return this.postPrivate('/api/v2/earn/savings/redeem', params); +export interface IndexComponentV3 { + exchange: string; + spotPair: string; + equivalentPrice: string; + weight: string; +} ⋮---- -getEarnSavingsRedemptionResult(params: { - orderId: string; - periodType: string; - }): Promise< - APIResponse<{ - result: 'success' | 'fail'; - msg: string; - }> - > { - return this.getPrivate('/api/v2/earn/savings/redeem-result', params); +export interface IndexPriceComponentsV3 { + symbol: string; + componentList: IndexComponentV3[]; +} ⋮---- -/** - * - * - * Earn | Earn Account - * - * - */ +export interface RpiSymbolV3 { + category: 'spot' | 'usdt-futures' | 'coin-futures' | 'usdc-futures'; + symbol: string; +} ⋮---- -getEarnAccount(params?: { coin?: string }): Promise< - APIResponse< - { - coin: string; - amount: string; - }[] - > - > { - return this.getPrivate('/api/v2/earn/account/assets', params); +/** RPI order book depth: [price, nonRpiQty, rpiQty] */ +export interface RpiOrderBookV3 { + a: [string, string, string][]; + b: [string, string, string][]; + ts: string; +} ⋮---- -/** - * - * - * Earn | On-Chain Elite - * - * - */ +export interface CashDividendRecordV3 { + symbol: string; + exDividendDate: string; + cashDividendPerShare: string; + cashDividendTimestamp: string; +} ⋮---- -getEarnEliteProducts(): Promise> +export interface SpotWhaleFlowV3 { + volume: string; + date: string; +} ⋮---- -getEarnEliteAssets(): Promise> +export interface SpotNetFlowV3 { + netFlow: string; + ts: string; +} ⋮---- -getEarnEliteRecords( - params: GetEarnEliteRecordsRequestV2, -): Promise> +export interface SpotFundFlowV3 { + whaleBuyVolume: string; + dolphinBuyVolume: string; + fishBuyVolume: string; + whaleSellVolume: string; + dolphinSellVolume: string; + fishSellVolume: string; + whaleBuyRatio: string; + dolphinBuyRatio: string; + fishBuyRatio: string; + whaleSellRatio: string; + dolphinSellRatio: string; + fishSellRatio: string; +} ⋮---- -getEarnEliteSubscribeInfo( - params: GetEarnEliteSubscribeInfoRequestV2, -): Promise> +export interface MarginLongShortV3 { + longShortRatio: string; + ts: string; +} ⋮---- -subscribeEarnElite( - params: EarnEliteSubscribeRequestV2, -): Promise> +export interface MarginLoanGrowthV3 { + growthRate: string; + ts: string; +} ⋮---- -getEarnEliteSubscribeResult( - params: GetEarnEliteSubscribeResultRequestV2, -): Promise> +export interface MarginIsolatedBorrowV3 { + borrowRate: string; + ts: string; +} ⋮---- -getEarnEliteRedeemInfo( - params: GetEarnEliteRedeemInfoRequestV2, -): Promise> +export interface FuturesActiveBuySellV3 { + buyVolume: string; + sellVolume: string; + ts: string; +} ⋮---- -redeemEarnElite( - params: RedeemEarnEliteRequestV2, -): Promise> +export interface FuturesLongShortV3 { + longRatio: string; + shortRatio: string; + longShortRatio: string; + ts: string; +} ⋮---- -/** - * - * - * Earn | Shark Fin - * - * +export interface FuturesPositionLongShortV3 { + longPositionRatio: string; + shortPositionRatio: string; + longShortPositionRatio: string; + ts: string; +} +⋮---- +export interface FuturesAccountLongShortV3 { + longAccountRatio: string; + shortAccountRatio: string; + longShortAccountRatio: string; + ts: string; +} + +================ +File: README.md +================ +# Node.js & Typescript Bitget API SDK + +[![Build & Test](https://github.com/sieblyio/bitget-api/actions/workflows/e2etests.yml/badge.svg?branch=master)](https://github.com/sieblyio/bitget-api/actions/workflows/e2etests.yml) +[![npm version](https://img.shields.io/npm/v/bitget-api)][1] +[![npm size](https://img.shields.io/bundlephobia/min/bitget-api/latest)][1] +[![npm downloads](https://img.shields.io/npm/dt/bitget-api)][1] +[![last commit](https://img.shields.io/github/last-commit/sieblyio/bitget-api)][1] +[![CodeFactor](https://www.codefactor.io/repository/github/sieblyio/bitget-api/badge)](https://www.codefactor.io/repository/github/sieblyio/bitget-api) +[![Telegram](https://img.shields.io/badge/chat-on%20telegram-blue.svg)](https://t.me/nodetraders) +[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/sieblyio/bitget-api) + +

+ + + + SDK Logo + + +

+ +[1]: https://www.npmjs.com/package/bitget-api + +> [!TIP] +> Upcoming change: As part of the [Siebly.io](https://siebly.io/) brand, this SDK is now hosted under our [Siebly.io GitHub organisation](https://github.com/sieblyio). The migration is seamless and requires no user changes. + +Updated & performant JavaScript & Node.js SDK for the Bitget V2 REST APIs and WebSockets: + +- Professional, robust & performant Bitget SDK with extensive production use in live trading environments. +- Complete integration with all Bitget APIs. + - [x] Supports V2 REST APIs & WebSockets + - [x] Supports V3/UTA REST APIs & WebSockets (latest) + - [x] Supports order placement via V3 WebSocket API +- Complete TypeScript support (with type declarations for all API requests & responses). + - Strongly typed requests and responses. + - Automated end-to-end tests on most API calls, ensuring no breaking changes are released to npm. +- Actively maintained with a modern, promise-driven interface. +- Over 100 integration tests making real API calls & WebSocket connections, validating any changes before they reach npm. +- Robust WebSocket integration with configurable connection heartbeats & automatic reconnect then resubscribe workflows. + - Event driven messaging. + - Smart WebSocket persistence with automatic reconnection handling. + - Emit `reconnected` event when dropped connection is restored. + - Optional beautification of WebSocket events for improved readability. +- Officially listed Node.js SDK in [Bitget API docs](https://bitgetlimited.github.io/apidoc/en/spot/#sdk-code-example). +- Browser support (via webpack bundle - see "Browser Usage" below). +- Support all authentication methods supported by Bitget: + - [x] HMAC + - [x] RSA +- Heavy automated end-to-end testing with real API calls. + - End-to-end testing before any release. + - Real API calls in e2e tests. +- Proxy support via axios integration. +- Active community support & collaboration in telegram: [Node.js Algo Traders](https://t.me/nodetraders). +- QuickStart Guide: https://siebly.io/sdk/bitget/javascript + +## Table of Contents + +- [Installation](#installation) +- [Examples](#examples) +- [Issues & Discussion](#issues--discussion) +- [Related Projects](#related-projects) +- [Documentation](#documentation) +- [Structure](#structure) +- [Usage](#usage) + - [REST API Clients](#rest-api-clients) + - [V3 REST APIs (Unified Trading Account)](#v3-rest-apis) + - [V2 REST APIs](#v2-rest-apis) + - [WebSockets](#websockets) + - [V3 Unified Trading Account](#v3-unified-trading-account) + - [Sending Orders via WebSockets](#sending-orders-via-websockets) + - [Receiving Realtime Data](#receiving-realtime-data) + - [V2 WebSockets](#v2-websockets) + - [Customise Logging](#logging) + - [Custom Logger](#customise-logging) + - [Debug HTTP Requests](#debug-http-requests) + - [Frontend Usage](#browser-usage) + - [Import](#import) + - [Webpack](#webpack) +- [LLMs & AI](#use-with-llms--ai) +- [Used By](#used-by) +- [Contributions & Thanks](#contributions--thanks) + +## Installation + +`npm install --save bitget-api` + +## Examples + +Refer to the [examples](./examples) folder for implementation demos. + +## Issues & Discussion + +- Issues? Check the [issues tab](https://github.com/sieblyio/bitget-api/issues). +- Discuss & collaborate with other node devs? Join our [Node.js Algo Traders](https://t.me/nodetraders) engineering community on telegram. +- Follow our announcement channel for real-time updates on [X/Twitter](https://x.com/sieblyio) + + + +## Related Projects + +Check out our JavaScript/TypeScript/Node.js SDKs & Projects: + +- Visit our website: [https://Siebly.io](https://siebly.io/) +- Try our REST API & WebSocket SDKs published on npmjs: + - [Bybit JavaScript SDK: bybit-api](https://www.npmjs.com/package/bybit-api) + - [Kraken JavaScript SDK: @siebly/kraken-api](https://www.npmjs.com/package/@siebly/kraken-api) + - [OKX JavaScript SDK: okx-api](https://www.npmjs.com/package/okx-api) + - [Binance JavaScript SDK: binance](https://www.npmjs.com/package/binance) + - [Gate (gate.com) JavaScript SDK: gateio-api](https://www.npmjs.com/package/gateio-api) + - [Bitget JavaScript SDK: bitget-api](https://www.npmjs.com/package/bitget-api) + - [Kucoin JavaScript SDK: kucoin-api](https://www.npmjs.com/package/kucoin-api) + - [Coinbase JavaScript SDK: coinbase-api](https://www.npmjs.com/package/coinbase-api) + - [HTX JavaScript SDK: @siebly/htx-api](https://www.npmjs.com/package/@siebly/htx-api) +- Try my misc utilities: + - [OrderBooks Node.js: orderbooks](https://www.npmjs.com/package/orderbooks) + - [Crypto Exchange Account State Cache: accountstate](https://www.npmjs.com/package/accountstate) +- Check out my examples: + - [awesome-crypto-examples Node.js](https://github.com/sieblyio/awesome-crypto-examples) + + +## Documentation + +Most methods accept JS objects. These can be populated using parameters specified by Bitget's API documentation, or check the type definition in each class within this repository (see table below for convenient links to each class). + +- Bitget API Documentation + - [V3/UTA API Documentation](https://www.bitget.com/api-doc/uta/intro) (Latest - Unified Trading Account) + - [V2 API Documentation](https://www.bitget.com/api-doc/common/intro) +- [REST Endpoint Function List](./docs/endpointFunctionList.md) +- [TSDoc Documentation (autogenerated using typedoc)](https://tsdocs.dev/docs/bitget-api) + +## Structure + +This connector is fully compatible with both TypeScript and pure JavaScript projects, while the connector is written in TypeScript. A pure JavaScript version can be built using `npm run build`, which is also the version published to [npm](https://www.npmjs.com/package/bitget-api). + +The version on npm is the output from the `build` command and can be used in projects without TypeScript (although TypeScript is definitely recommended). + +- [src](./src) - the whole connector written in TypeScript +- [lib](./lib) - the JavaScript version of the project (built from TypeScript). This should not be edited directly, as it will be overwritten with each release. +- [dist](./dist) - the webpack bundle of the project for use in browser environments (see guidance on webpack below). +- [examples](./examples) - some implementation examples & demonstrations. Contributions are welcome! + +--- + +# Usage + +Create API credentials at Bitget: + +- [Livenet API Management](https://www.bitget.com/en/support/articles/360011132814-How-to-create-API) +- [Demo Trading Environment](https://www.bitget.com/en/demo-trading) + +## REST API Clients + +Each REST API group has a dedicated REST client. To avoid confusion, here are the available REST clients and the corresponding API groups: +| Class | Description | +|:------------------------------------: |:---------------------------------------------------------------------------------------------: | +| [RestClientV3](src/rest-client-v3.ts) | [V3/UTA REST APIs for Bitget's Unified Trading Account](https://www.bitget.com/api-doc/uta/intro) | +| [WebsocketClientV3](src/websocket-client-v3.ts) | Universal WS client for Bitget's V3/UTA WebSockets | +| [WebsocketAPIClient](src/websocket-api-client.ts) | Websocket API Client, for RESTlike order placement via Bitget's V3/UTA WebSocket API | +| [RestClientV2](src/rest-client-v2.ts) | [V2 REST APIs](https://www.bitget.com/api-doc/common/intro) | +| [WebsocketClientV2](src/websocket-client-v2.ts) | Universal WS client for all Bitget's V2 WebSockets | + +Examples for using each client can be found in: + +- the [examples](./examples) folder. +- the [awesome-crypto-examples](https://github.com/tiagosiebler/awesome-crypto-examples) repository. + +If you're missing an example, you're welcome to request one. Priority will be given to [github sponsors](https://github.com/sponsors/tiagosiebler). + +### Getting Started + +All REST APIs are integrated in each dedicated Rest Client class. See the above table for which REST client to use. If you've upgraded to the Unified Trading Account, you should use the V3 REST APIs and WebSockets. + +There are several REST API modules as there are some differences in each API group: + +1. `RestClientV3` for the latest V3/UTA APIs (Unified Trading Account) - recommended for new projects. +2. `RestClientV2` for V2 APIs - use if you haven't upgraded to UTA yet. + +More Node.js & JavaScript examples for Bitget's REST APIs & WebSockets can be found in the [examples](./examples) folder on GitHub. + +#### V3 REST APIs + +These are only available if you have upgraded to the Unified Trading Account. If not, use the V2 APIs instead. + +```javascript +import { RestClientV3 } from 'bitget-api'; +// or if you prefer require: +// const { RestClientV3 } = require('bitget-api'); + +// note the single quotes, preventing special characters such as $ from being incorrectly passed +const client = new RestClientV3({ + apiKey: process.env.API_KEY_COM || 'insert_api_key_here', + apiSecret: process.env.API_SECRET_COM || 'insert_api_secret_here', + apiPass: process.env.API_PASS_COM || 'insert_api_pass_here', +}); + +(async () => { + try { + console.log(await client.getBalances()); + + const newOrder = await client.submitNewOrder({ + category: 'USDT-FUTURES', + orderType: 'market', + side: 'buy', + qty: '0.001', + symbol: 'BTCUSDT', + }); + + console.log('Order submitted: ', newOrder); + } catch (e) { + console.error('request failed: ', e); + } +})(); +``` + +#### V2 REST APIs + +Not sure which function to call or which parameters to use? Click the class name in the table above to look at all the function names (they are in the same order as the official API docs), and check the API docs for a list of endpoints/parameters/responses. + +If you found the method you're looking for in the API docs, you can also search for the endpoint in the [RestClientV2](src/rest-client-v2.ts) class. This class has all V2 endpoints available. + +```javascript +import { RestClientV2 } from 'bitget-api'; +// or if you prefer require: +// const { RestClientV2 } = require('bitget-api'); + +const API_KEY = 'xxx'; +const API_SECRET = 'yyy'; +const API_PASS = 'zzz'; + +const client = new RestClientV2({ + apiKey: API_KEY, + apiSecret: API_SECRET, + apiPass: API_PASS, +}); + +// For public-only API calls, simply don't provide a key & secret or set them to undefined +// const client = new RestClientV2(); + +client + .getSpotAccount() + .then((result) => { + console.log('getSpotAccount result: ', result); + }) + .catch((err) => { + console.error('getSpotAccount error: ', err); + }); + +client + .getSpotCandles({ + symbol: 'BTCUSDT', + granularity: '1min', + limit: '1000', + }) + .then((result) => { + console.log('getCandles result: ', result); + }) + .catch((err) => { + console.error('getCandles error: ', err); + }); +``` + +## WebSockets + +All WebSocket functionality is supported via the WebsocketClient. Since there are currently 2 generations of Bitget's API, there are 2 WebsocketClient classes in this Node.js, JavaScript & TypeScript SDK for Bitget. + +Use the following guidance to decide which one to use: + +- **Unified Trading Account / V3** (latest generation): + - For receiving data, use the [WebsocketClientV3](./src/websocket-client-v3.ts). + - For sending orders via WebSockets, use the [WebsocketAPIClient](./src/websocket-api-client.ts). +- **V2** (not upgraded to Unified Trading Account yet) + - Use the [WebsocketClientV2](./src/websocket-client-v2.ts). + +All WebSocket clients support: + +- Event driven messaging +- Smart WebSocket persistence with automatic reconnection +- Heartbeat mechanisms to detect disconnections +- Automatic resubscription after reconnection +- Error handling and connection monitoring +- Optional data beautification + +Higher level examples below, while more thorough examples can be found in the examples folder on GitHub. + +##### V3 Unified Trading Account + +###### Sending orders via WebSockets + +The V3 / Unified Trading Account APIs introduce order placement via a persisted WebSocket connection. This Bitget Node.js, JavaScript & TypeScript SDK supports Bitget's full V3 API offering, including the WebSocket API. + +There are two approaches to placing orders via the Bitget WebSocket APIs. The recommended route is to use the dedicated WebsocketAPIClient class, included with this SDK. + +This integration looks & feels like a REST API client, but uses WebSockets, via the WebsocketClient's sendWSAPIRequest method. It returns promises and has end to end types. + +A simple example is below, but for a more thorough example, check the example here: [./examples/V3/ws-api-client-trade.ts](./examples/V3/ws-api-client-trade.ts) + +```typescript +import { WebsocketAPIClient } from 'bitget-api'; +// or if you prefer require: +// const { WebsocketAPIClient } = require("bitget-api"); + +// Make an instance of the WS API Client class with your API keys +const wsClient = new WebsocketAPIClient({ + apiKey: API_KEY, + apiSecret: API_SECRET, + apiPass: API_PASS, + + // Whether to use the demo trading wss connection + // demoTrading: true, +}); + +async function start() { + // Start using it like a REST API. All actions are sent via a persisted WebSocket connection. + + /** + * Place Order + * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters */ -⋮---- -getSharkfinProducts(params: { - coin: string; - limit?: string; - idLessThan?: string; -}): Promise> -⋮---- -getSharkfinAccount(): Promise> -⋮---- -getSharkfinAssets( - params: GetSharkfinAssetsRequestV2, -): Promise> -⋮---- -getSharkfinRecords( - params: GetSharkfinRecordsRequestV2, -): Promise> -⋮---- -getSharkfinSubscription(params: { - productId: string; -}): Promise> -⋮---- -subscribeSharkfin(params: { productId: string; amount: string }): Promise< - APIResponse<{ - orderId: string; - status: string; - }> - > { - return this.postPrivate('/api/v2/earn/sharkfin/subscribe', params); -⋮---- -getSharkfinSubscriptionResult(params: { orderId: string }): Promise< - APIResponse<{ - result: 'success' | 'fail'; - msg: string; - }> - > { - return this.getPrivate('/api/v2/earn/sharkfin/subscribe-result', params); -⋮---- + try { + const res = await wsClient.submitNewOrder('spot', { + orderType: 'limit', + price: '100', + qty: '0.1', + side: 'buy', + symbol: 'BTCUSDT', + timeInForce: 'gtc', + }); + + console.log(new Date(), 'WS API "submitNewOrder()" result: ', res); + } catch (e) { + console.error(new Date(), 'Exception with WS API "submitNewOrder()": ', e); + } +} + +start().catch((e) => console.error('Exception in example: '.e)); +``` + +###### Receiving realtime data + +Use the WebsocketClientV3 to receive data via the V3 WebSockets + +```typescript +import { WebsocketClientV3 } from "bitget-api"; +// or if you prefer require: +// const { WebsocketClientV3 } = require("bitget-api"); + +const API_KEY = "yourAPIKeyHere"; +const API_SECRET = "yourAPISecretHere; +const API_PASS = "yourAPIPassHere"; + +const wsClient = new WebsocketClientV3( + { + // Only necessary if you plan on using private/account websocket topics + apiKey: API_KEY, + apiSecret: API_SECRET, + apiPass: API_PASS, + } +); + +// Connect event handlers to process incoming events +wsClient.on('update', (data) => { + console.log('WS raw message received ', data); + // console.log('WS raw message received ', JSON.stringify(data, null, 2)); +}); + +wsClient.on('open', (data) => { + console.log('WS connection opened:', data.wsKey); +}); +wsClient.on('response', (data) => { + console.log('WS response: ', JSON.stringify(data, null, 2)); +}); +wsClient.on('reconnect', ({ wsKey }) => { + console.log('WS automatically reconnecting.... ', wsKey); +}); +wsClient.on('reconnected', (data) => { + console.log('WS reconnected ', data?.wsKey); +}); +wsClient.on('exception', (data) => { + console.log('WS error', data); +}); + /** - * - * - * Earn | Loan - * - * - */ -⋮---- -getLoanCurrencies(params?: { - coin?: string; -}): Promise> -⋮---- -getLoanEstInterestAndBorrowable( - params: GetLoanEstInterestAndBorrowableRequestV2, - ): Promise< - APIResponse<{ - hourInterest: string; - loanAmount: string; - }> - > { - return this.get('/api/v2/earn/loan/public/hour-interest', params); -⋮---- -borrowLoan(params: BorrowLoanRequestV2): Promise< - APIResponse<{ - orderId: string; - }> - > { - return this.postPrivate('/api/v2/earn/loan/borrow', params); -⋮---- -getOngoingLoanOrders(params?: { - orderId?: string; - loanCoin?: string; - pledgeCoin?: string; -}): Promise> -⋮---- -repayLoan( - params: RepayLoanRequestV2, -): Promise> -⋮---- -getRepayHistory( - params: GetLoanRepayHistoryRequestV2, -): Promise> -⋮---- -updateLoanPledgeRate(params: ModifyLoanPledgeRateRequestV2): Promise< - APIResponse<{ - loanCoin: string; - pledgeCoin: string; - afterPledgeRate: string; - }> - > { - return this.postPrivate('/api/v2/earn/loan/revise-pledge', params); -⋮---- -getLoanPledgeRateHistory( - params: GetLoanPledgeRateHistoryRequestV2, -): Promise> -⋮---- -getLoanHistory( - params: GetLoanHistoryRequestV2, -): Promise> -⋮---- -getLoanDebts(): Promise> -⋮---- -getLoanLiquidationRecords( - params: GetLiquidationRecordsRequestV2, -): Promise> + * Subscribe to topics as you wish + */ + +// You can subscribe to one topic at a time +wsClient.subscribe( + { + topic: 'account', + payload: { + instType: 'UTA', // Note: all account events go on the UTA instType + }, + }, + WS_KEY_MAP.v3Private, // This parameter points to private or public +); + +// Note: all account events go on the UTA instType +const ACCOUNT_INST_TYPE = 'UTA'; +const ACCOUNT_WS_KEY = WS_KEY_MAP.v3Private; + +// Or multiple at once: +wsClient.subscribe( + [ + { + topic: 'account', + payload: { + instType: ACCOUNT_INST_TYPE, + }, + }, + { + topic: 'position', + payload: { + instType: ACCOUNT_INST_TYPE, + }, + }, + { + topic: 'fill', + payload: { + instType: ACCOUNT_INST_TYPE, + }, + }, + { + topic: 'order', + payload: { + instType: ACCOUNT_INST_TYPE, + }, + }, + ], + ACCOUNT_WS_KEY, +); + +// Example public events +wsClient.subscribe( + [ + { + topic: 'ticker', + payload: { + instType: 'spot', + symbol: 'BTCUSDT', + }, + }, + { + topic: 'ticker', + payload: { + instType: 'spot', + symbol: 'ETHUSDT', + }, + }, + { + topic: 'ticker', + payload: { + instType: 'spot', + symbol: 'XRPUSDT', + }, + }, + { + topic: 'ticker', + payload: { + instType: 'usdt-futures', + symbol: 'BTCUSDT', + }, + }, + { + topic: 'ticker', + payload: { + instType: 'usdt-futures', + symbol: 'BTCUSDT', + }, + }, + ], + WS_KEY_MAP.v3Public, +); +``` + +For more examples, including how to use websockets with Bitget, check the [examples](./examples/) and [test](./test/) folders. + +### V2 WebSockets + +If you haven't upgraded to the Unified Trading Account, use the V2 WebSocket client: + +```javascript +import { WebsocketClientV2 } from 'bitget-api'; +// or if you prefer require: +// const { WebsocketClientV2 } = require('bitget-api'); + +const API_KEY = 'xxx'; +const API_SECRET = 'yyy'; +const API_PASS = 'zzz'; + +const wsClient = new WebsocketClientV2({ + apiKey: API_KEY, + apiSecret: API_SECRET, + apiPass: API_PASS, + // Optional: connect to demo trading environment + // demoTrading: true, +}); + +// Handle incoming messages +wsClient.on('update', (data) => { + console.log('WS update received: ', data); +}); + +wsClient.on('open', (data) => { + console.log('WS connection opened: ', data.wsKey); +}); + +wsClient.on('reconnected', (data) => { + console.log('WS reconnected: ', data?.wsKey); +}); + +wsClient.on('exception', (data) => { + console.log('WS error: ', data); +}); + +// Subscribe to public data streams +wsClient.subscribeTopic('SPOT', 'ticker', symbol); + +// Subscribe to private data streams (requires authentication) +wsClient.subscribeTopic('SPOT', 'account'); +``` + +--- + +## Logging + +### Customise logging + +Pass a custom logger which supports the log methods `trace`, `info` and `error`, or override methods from the default logger as desired. + +```javascript +import { WebsocketClientV2, DefaultLogger } from 'bitget-api'; +// or if you prefer require: +// const { WebsocketClientV2, DefaultLogger } = require('bitget-api'); + +// Disable all logging on the trace level (less console logs) +const customLogger = { + ...DefaultLogger, + trace: () => {}, +}; + +const ws = new WebsocketClientV2( + { + apiKey: 'API_KEY', + apiSecret: 'API_SECRET', + apiPass: 'API_PASS', + }, + customLogger, +); +``` + +### Debug HTTP requests + +In rare situations, you may want to see the raw HTTP requets being built as well as the API response. These can be enabled by setting the `BITGETTRACE` env var to `true`. + +## Browser Usage + +### Import + +This is the "modern" way, allowing the package to be directly imported into frontend projects with full typescript support. + +1. Install these dependencies + ```sh + npm install crypto-browserify stream-browserify + ``` +2. Add this to your `tsconfig.json` + ```json + { + "compilerOptions": { + "paths": { + "crypto": [ + "./node_modules/crypto-browserify" + ], + "stream": [ + "./node_modules/stream-browserify" + ] + } + ``` +3. Declare this in the global context of your application (ex: in polyfills for angular) + ```js + (window as any).global = window; + ``` + +### Webpack + +This is the "old" way of using this package on webpages. This will build a minified js bundle that can be pulled in using a script tag on a website. + +Build a bundle using webpack: + +- `npm install` +- `npm build` +- `npm pack` + +The bundle can be found in `dist/`. Altough usage should be largely consistent, smaller differences will exist. Documentation is still TODO - contributions welcome. + +## Use with LLMs & AI + +This SDK includes a bundled `llms.txt` file in the root of the repository. If you're developing with LLMs, use the included `llms.txt` with your LLM - it will significantly improve the LLMs understanding of how to correctly use this SDK. + +This file contains AI optimised structure of all the functions in this package, and their parameters for easier use with any learning models or artificial intelligence. + +--- + +## Used By + +[![Repository Users Preview Image](https://dependents.info/sieblyio/bitget-api/image)](https://github.com/sieblyio/bitget-api/network/dependents) + +--- + + + +### Contributions & Thanks + +Have my projects helped you? Share the love, there are many ways you can show your thanks: + +- Star & share my projects. +- Are my projects useful? Sponsor me on Github and support my effort to maintain & improve them: https://github.com/sponsors/tiagosiebler +- Have an interesting project? Get in touch & invite me to it. +- Or buy me all the coffee: + - ETH(ERC20): `0xA3Bda8BecaB4DCdA539Dc16F9C54a592553Be06C` +- Sign up with my referral links: + - OKX (receive a 20% fee discount!): https://www.okx.com/join/42013004 + - Binance (receive a 20% fee discount!): https://accounts.binance.com/register?ref=OKFFGIJJ + - HyperLiquid (receive a 4% fee discount!): https://app.hyperliquid.xyz/join/SIEBLY + - Gate: https://www.gate.io/signup/NODESDKS?ref_type=103 + + + + +### Contributions & Pull Requests + +Contributions are encouraged, I will review any incoming pull requests. See the issues tab for todo items. + + + +## Star History + +[![Star History Chart](https://api.star-history.com/svg?repos=sieblyio/bybit-api,sieblyio/okx-api,sieblyio/binance,sieblyio/bitget-api,sieblyio/bitmart-api,sieblyio/gateio-api,sieblyio/kucoin-api,sieblyio/coinbase-api,sieblyio/orderbooks,sieblyio/accountstate,sieblyio/awesome-crypto-examples&type=Date)](https://star-history.com/#sieblyio/bybit-api&sieblyio/okx-api&sieblyio/binance&sieblyio/bitget-api&sieblyio/bitmart-api&sieblyio/gateio-api&sieblyio/kucoin-api&sieblyio/coinbase-api&sieblyio/orderbooks&sieblyio/accountstate&sieblyio/awesome-crypto-examples&Date) + + ================ File: src/rest-client-v3.ts @@ -14306,6 +16891,7 @@ File: src/rest-client-v3.ts import { AdjustAccountModeRequestV3, CancelWithdrawalRequestV3, + CreateAgentSubAccountRequestV3, CreateSubAccountApiKeyRequestV3, CreateSubAccountRequestV3, DeleteSubAccountApiKeyRequestV3, @@ -14314,12 +16900,19 @@ import { GetConvertRecordsRequestV3, GetDepositAddressRequestV3, GetDepositRecordsRequestV3, + GetEligibleLoanInfoRequestV3, + GetEligibleMarginTierRequestV3, + GetEligibleSymbolsRequestV3, GetFeeRateRequestV3, GetFinancialRecordsRequestV3, GetFundingAssetsRequestV3, GetMaxTransferableRequestV3, GetMaxWithdrawalRequestV3, + GetMovePositionHistoryRequestV3, GetOpenInterestLimitRequestV3, + GetRateLimitQuotaRequestV3, + GetRealityFillsRequestV3, + GetRealityOrderBookRequestV3, GetSubAccountApiKeysRequestV3, GetSubAccountListRequestV3, GetSubDepositAddressRequestV3, @@ -14330,13 +16923,16 @@ import { GetTransferableCoinsRequestV3, GetWithdrawAddressBookRequestV3, GetWithdrawRecordsRequestV3, + MovePositionsRequestV3, PreSetLeverageRequestV3, RepayRequestV3, SetCollateralTypeRequestV3, SetDepositAccountRequestV3, SetLeverageRequestV3, SetMarginRequestV3, + SetRateLimitQuotaRequestV3, SubAccountTransferRequestV3, + SubMasterTransferRequestV3, SwitchDeductRequestV3, TransferRequestV3, UpdateSubAccountApiKeyRequestV3, @@ -14357,7 +16953,9 @@ import { } from './types/request/v3/broker.js'; import { CopyFuturesTransferRequestV3, + GetCopyFuturesFollowersRequestV3, GetCopyFuturesMaxTransferableRequestV3, + GetCopyFuturesProfitDetailsRequestV3, GetCopyFuturesTransferRecordRequestV3, } from './types/request/v3/copytrading.js'; import { @@ -14433,6 +17031,32 @@ import { GetSpotWhaleFlowRequestV3, GetTickersRequestV3, } from './types/request/v3/public.js'; +import { + CancelStockPlusOrderRequestV3, + GetStockPlusAccountRequestV3, + GetStockPlusCandlestickRequestV3, + GetStockPlusCashFlowRequestV3, + GetStockPlusDepthRequestV3, + GetStockPlusHistoryCandlestickRequestV3, + GetStockPlusHistoryExecutionsRequestV3, + GetStockPlusHistoryOrdersRequestV3, + GetStockPlusIntradayRequestV3, + GetStockPlusOptionChainInfoRequestV3, + GetStockPlusOptionExpiryDateRequestV3, + GetStockPlusOptionQuoteRequestV3, + GetStockPlusOptionVolumeRequestV3, + GetStockPlusOrderDetailRequestV3, + GetStockPlusQuoteRequestV3, + GetStockPlusStaticInfoRequestV3, + GetStockPlusStockPositionRequestV3, + GetStockPlusTodayExecutionsRequestV3, + GetStockPlusTodayOrdersRequestV3, + GetStockPlusTradeDetailRequestV3, + GetStockPlusTransferRecordsRequestV3, + ModifyStockPlusOrderRequestV3, + PlaceStockPlusOrderRequestV3, + StockPlusTransferRequestV3, +} from './types/request/v3/stockplus.js'; import { CancelStrategyOrderRequestV3, GetHistoryStrategyOrdersRequestV3, @@ -14468,18 +17092,25 @@ import { AllSymbolFeeRateV3, CollateralTypeConfigV3, ConvertRecordV3, + CreateAgentSubAccountResponseV3, CreateSubAccountApiKeyResponseV3, CreateSubAccountResponseV3, CustomCollateralCoinV3, DepositAddressV3, DepositRecordV3, + EligibleLoanInfoV3, + EligibleMarginTierV3, + EligibleSymbolV3, FinancialRecordV3, FundingAssetV3, MaxTransferableV3, MaxWithdrawalV3, + MovePositionHistoryV3, + MovePositionsResponseV3, OpenInterestLimitV3, PaymentCoinV3, PreSetLeverageV3, + RateLimitQuotaV3, RepayableCoinV3, RepayResponseV3, SubAccountApiKeyV3, @@ -14506,8 +17137,12 @@ import { ModifyBrokerSubApiKeyResponseV3, } from './types/response/v3/broker.js'; import { + CopyFuturesCurrentFollowersV3, + CopyFuturesHistoryFollowersV3, CopyFuturesMaxTransferableV3, CopyFuturesPositionSummaryV3, + CopyFuturesProfitDetailsV3, + CopyFuturesProfitSummaryV3, CopyFuturesTradingPairV3, CopyFuturesTransferRecordListV3, CopyFuturesTransferResponseV3, @@ -14584,6 +17219,8 @@ import { PositionTierV3, ProofOfReservesV3, PublicFillV3, + RealityFillV3, + RealityOrderBookV3, RiskReserveAllV3, RiskReserveHourV3, RiskReserveV3, @@ -14594,6 +17231,32 @@ import { SpotWhaleFlowV3, TickerV3, } from './types/response/v3/public.js'; +import { + StockPlusAccountV3, + StockPlusCancelOrderResponseV3, + StockPlusCandlestickV3, + StockPlusCashFlowV3, + StockPlusDepthV3, + StockPlusHistoryCandlestickV3, + StockPlusHistoryExecutionsV3, + StockPlusHistoryOrdersV3, + StockPlusIntradayV3, + StockPlusModifyOrderResponseV3, + StockPlusOptionChainInfoV3, + StockPlusOptionExpiryDateV3, + StockPlusOptionQuoteV3, + StockPlusOptionVolumeV3, + StockPlusOrderDetailV3, + StockPlusOrdersV3, + StockPlusPlaceOrderResponseV3, + StockPlusQuoteV3, + StockPlusStaticInfoV3, + StockPlusStockPositionV3, + StockPlusTodayExecutionsV3, + StockPlusTradeDetailV3, + StockPlusTransferRecordsV3, + StockPlusTransferResponseV3, +} from './types/response/v3/stockplus.js'; import { ModifyStrategyOrderResponseV3, PlaceStrategyOrderResponseV3, @@ -14900,6 +17563,20 @@ getIndexComponents( params: GetIndexComponentsRequestV3, ): Promise> ⋮---- +/** + * Get Reality OrderBook + */ +getRealityOrderBook( + params: GetRealityOrderBookRequestV3, +): Promise> +⋮---- +/** + * Get Reality Fills + */ +getRealityFills( + params: GetRealityFillsRequestV3, +): Promise> +⋮---- /** * * =====Copy Trading | Futures===== @@ -14950,6 +17627,125 @@ getCopyFuturesTransferRecords( params?: GetCopyFuturesTransferRecordRequestV3, ): Promise> ⋮---- +getCopyFuturesCurrentFollowers( + params?: GetCopyFuturesFollowersRequestV3, +): Promise> +⋮---- +getCopyFuturesHistoryFollowers( + params?: GetCopyFuturesFollowersRequestV3, +): Promise> +⋮---- +getCopyFuturesProfitSummary(): Promise< + APIResponse + > { + return this.getPrivate('/api/v3/copy/futures/profit-summary'); +⋮---- +getCopyFuturesProfitDetails( + params?: GetCopyFuturesProfitDetailsRequestV3, +): Promise> +⋮---- +/** + * + * =====Stock+===== + * + */ +⋮---- +getStockPlusOptionQuote( + params: GetStockPlusOptionQuoteRequestV3, +): Promise> +⋮---- +getStockPlusOptionChainInfo( + params: GetStockPlusOptionChainInfoRequestV3, +): Promise> +⋮---- +getStockPlusOptionExpiryDate( + params: GetStockPlusOptionExpiryDateRequestV3, +): Promise> +⋮---- +getStockPlusOptionVolume( + params: GetStockPlusOptionVolumeRequestV3, +): Promise> +⋮---- +getStockPlusStaticInfo( + params: GetStockPlusStaticInfoRequestV3, +): Promise> +⋮---- +getStockPlusQuote( + params: GetStockPlusQuoteRequestV3, +): Promise> +⋮---- +getStockPlusTradeDetail( + params: GetStockPlusTradeDetailRequestV3, +): Promise> +⋮---- +getStockPlusIntraday( + params: GetStockPlusIntradayRequestV3, +): Promise> +⋮---- +getStockPlusHistoryCandlestick( + params: GetStockPlusHistoryCandlestickRequestV3, +): Promise> +⋮---- +getStockPlusCandlestick( + params: GetStockPlusCandlestickRequestV3, +): Promise> +⋮---- +getStockPlusDepth( + params: GetStockPlusDepthRequestV3, +): Promise> +⋮---- +placeStockPlusOrder( + params: PlaceStockPlusOrderRequestV3, +): Promise> +⋮---- +cancelStockPlusOrder( + params: CancelStockPlusOrderRequestV3, +): Promise> +⋮---- +modifyStockPlusOrder( + params: ModifyStockPlusOrderRequestV3, +): Promise> +⋮---- +getStockPlusTodayOrders( + params?: GetStockPlusTodayOrdersRequestV3, +): Promise> +⋮---- +getStockPlusHistoryOrders( + params?: GetStockPlusHistoryOrdersRequestV3, +): Promise> +⋮---- +getStockPlusOrderDetail( + params: GetStockPlusOrderDetailRequestV3, +): Promise> +⋮---- +getStockPlusTodayExecutions( + params?: GetStockPlusTodayExecutionsRequestV3, +): Promise> +⋮---- +getStockPlusHistoryExecutions( + params?: GetStockPlusHistoryExecutionsRequestV3, +): Promise> +⋮---- +getStockPlusAccount( + params?: GetStockPlusAccountRequestV3, +): Promise> +⋮---- +getStockPlusCashFlow( + params: GetStockPlusCashFlowRequestV3, +): Promise> +⋮---- +getStockPlusStockPosition( + params?: GetStockPlusStockPositionRequestV3, +): Promise> +⋮---- +stockPlusTransfer( + params: StockPlusTransferRequestV3, +): Promise> +⋮---- +getStockPlusTransferRecords( + params?: GetStockPlusTransferRecordsRequestV3, +): Promise> +⋮---- /** * * =====Account======= endpoints @@ -15154,6 +17950,18 @@ getOpenInterestLimit( params: GetOpenInterestLimitRequestV3, ): Promise> ⋮---- +getEligibleSymbols( + params?: GetEligibleSymbolsRequestV3, +): Promise> +⋮---- +getEligibleMarginTier( + params?: GetEligibleMarginTierRequestV3, +): Promise> +⋮---- +getEligibleLoanInfo( + params?: GetEligibleLoanInfoRequestV3, +): Promise> +⋮---- /** * Switch Account - Switch to classic account mode * Only supports parent accounts. @@ -15201,6 +18009,13 @@ createSubAccount( params: CreateSubAccountRequestV3, ): Promise> ⋮---- +/** + * Create Agent Sub-account + */ +createAgentSubAccount( + params: CreateAgentSubAccountRequestV3, +): Promise> +⋮---- /** * Freeze/Unfreeze Sub-account */ @@ -15260,6 +18075,14 @@ getSubAccountApiKeys(params: GetSubAccountApiKeysRequestV3): Promise< > { return this.getPrivate('/api/v3/user/sub-api-list', params); ⋮---- +getRateLimitQuota( + params: GetRateLimitQuotaRequestV3, +): Promise> +⋮---- +setRateLimitQuota( + params: SetRateLimitQuotaRequestV3, +): Promise>> +⋮---- /** * * =====Transfer======= endpoints @@ -15302,6 +18125,17 @@ getSubTransferRecords(params?: GetSubTransferRecordsRequestV3): Promise< > { return this.getPrivate('/api/v3/account/sub-transfer-record', params); ⋮---- +/** + * Sub-Main Account Transfer + */ +subMasterTransfer(params: SubMasterTransferRequestV3): Promise< + APIResponse<{ + transferId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v3/account/sub-master-transfer', params); +⋮---- /** * * =====Deposit======= endpoints @@ -15480,6 +18314,24 @@ getHistoryOrders(params: GetHistoryOrdersRequestV3): Promise< > { return this.getPrivate('/api/v3/trade/history-orders', params); ⋮---- +/** + * Move Positions - Transfer positions between master and sub-accounts + */ +movePositions( + params: MovePositionsRequestV3, +): Promise> +⋮---- +/** + * Get Move Position History + */ +getMovePositionHistory(params: GetMovePositionHistoryRequestV3): Promise< + APIResponse<{ + list: MovePositionHistoryV3[]; + cursor: string; + }> + > { + return this.getPrivate('/api/v3/account/move-position-history', params); +⋮---- /** * Get Fill History */ @@ -15963,7 +18815,7 @@ File: package.json ================ { "name": "bitget-api", - "version": "3.1.11", + "version": "3.2.2", "description": "Complete Node.js & JavaScript SDK for Bitget V1-V3 REST APIs & WebSockets, with TypeScript & end-to-end tests.", "scripts": { "test": "jest", @@ -15975,7 +18827,9 @@ File: package.json "build:clean": "npm run clean && npm run build", "build:watch": "npm run clean && tsc --watch", "pack": "webpack --config webpack/webpack.config.cjs", - "lint": "eslint src", + "lint": "eslint src && npm run lint:apidoc", + "lint:apidoc": "prettier --check \"examples/apidoc/**/*.js\"", + "format:apidoc": "prettier --write \"examples/apidoc/**/*.js\"", "prepublish": "npm run build:clean", "betapublish": "npm publish --tag beta" }, @@ -15997,14 +18851,14 @@ File: package.json "author": "Tiago Siebler (https://siebly.io)", "contributors": [], "dependencies": { + "@types/ws": "^8.18.1", "axios": "^1.13.2", "isomorphic-ws": "^5.0.0", - "ws": "^8.18.3" + "ws": "8.21.1" }, "devDependencies": { "@types/jest": "^29.0.3", "@types/node": "^22.10.2", - "@types/ws": "^8.18.1", "@typescript-eslint/eslint-plugin": "^8.18.0", "@typescript-eslint/parser": "^8.18.0", "eslint": "^8.24.0", @@ -16019,7 +18873,6 @@ File: package.json "source-map-loader": "^4.0.0", "ts-loader": "^9.5.4", "webpack": "^5.74.0", - "webpack-bundle-analyzer": "^5.1.1", "webpack-cli": "^4.10.0" }, "keywords": [ @@ -16051,12 +18904,12 @@ File: package.json "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/tiagosiebler/bitget-api" + "url": "git+https://github.com/sieblyio/bitget-api.git" }, "bugs": { - "url": "https://github.com/tiagosiebler/bitget-api/issues" + "url": "https://github.com/sieblyio/bitget-api/issues" }, - "homepage": "https://github.com/tiagosiebler/bitget-api#readme" + "homepage": "https://github.com/sieblyio/bitget-api#readme" } diff --git a/package-lock.json b/package-lock.json index 62fa4ee..49157d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bitget-api", - "version": "3.2.1", + "version": "3.2.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "bitget-api", - "version": "3.2.1", + "version": "3.2.2", "license": "MIT", "dependencies": { "@types/ws": "^8.18.1", diff --git a/package.json b/package.json index d8f761e..86adbce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bitget-api", - "version": "3.2.1", + "version": "3.2.2", "description": "Complete Node.js & JavaScript SDK for Bitget V1-V3 REST APIs & WebSockets, with TypeScript & end-to-end tests.", "scripts": { "test": "jest", diff --git a/src/index.ts b/src/index.ts index 66a91d2..b9e7180 100644 --- a/src/index.ts +++ b/src/index.ts @@ -16,6 +16,7 @@ export * from './types/request/v3/earn.js'; export * from './types/request/v3/loan.js'; export * from './types/request/v3/p2p.js'; export * from './types/request/v3/public.js'; +export * from './types/request/v3/stockplus.js'; export * from './types/request/v3/strategy.js'; export * from './types/request/v3/trade.js'; export * from './types/response/v2/broker.js'; @@ -32,6 +33,7 @@ export * from './types/response/v3/earn.js'; export * from './types/response/v3/loan.js'; export * from './types/response/v3/p2p.js'; export * from './types/response/v3/public.js'; +export * from './types/response/v3/stockplus.js'; export * from './types/response/v3/strategy.js'; export * from './types/response/v3/trade.js'; export * from './types/shared.js'; diff --git a/src/rest-client-v3.ts b/src/rest-client-v3.ts index 7277d5b..19b4c6b 100644 --- a/src/rest-client-v3.ts +++ b/src/rest-client-v3.ts @@ -10,6 +10,9 @@ import { GetConvertRecordsRequestV3, GetDepositAddressRequestV3, GetDepositRecordsRequestV3, + GetEligibleLoanInfoRequestV3, + GetEligibleMarginTierRequestV3, + GetEligibleSymbolsRequestV3, GetFeeRateRequestV3, GetFinancialRecordsRequestV3, GetFundingAssetsRequestV3, @@ -17,6 +20,7 @@ import { GetMaxWithdrawalRequestV3, GetMovePositionHistoryRequestV3, GetOpenInterestLimitRequestV3, + GetRateLimitQuotaRequestV3, GetRealityFillsRequestV3, GetRealityOrderBookRequestV3, GetSubAccountApiKeysRequestV3, @@ -36,6 +40,7 @@ import { SetDepositAccountRequestV3, SetLeverageRequestV3, SetMarginRequestV3, + SetRateLimitQuotaRequestV3, SubAccountTransferRequestV3, SubMasterTransferRequestV3, SwitchDeductRequestV3, @@ -58,7 +63,9 @@ import { } from './types/request/v3/broker.js'; import { CopyFuturesTransferRequestV3, + GetCopyFuturesFollowersRequestV3, GetCopyFuturesMaxTransferableRequestV3, + GetCopyFuturesProfitDetailsRequestV3, GetCopyFuturesTransferRecordRequestV3, } from './types/request/v3/copytrading.js'; import { @@ -134,6 +141,32 @@ import { GetSpotWhaleFlowRequestV3, GetTickersRequestV3, } from './types/request/v3/public.js'; +import { + CancelStockPlusOrderRequestV3, + GetStockPlusAccountRequestV3, + GetStockPlusCandlestickRequestV3, + GetStockPlusCashFlowRequestV3, + GetStockPlusDepthRequestV3, + GetStockPlusHistoryCandlestickRequestV3, + GetStockPlusHistoryExecutionsRequestV3, + GetStockPlusHistoryOrdersRequestV3, + GetStockPlusIntradayRequestV3, + GetStockPlusOptionChainInfoRequestV3, + GetStockPlusOptionExpiryDateRequestV3, + GetStockPlusOptionQuoteRequestV3, + GetStockPlusOptionVolumeRequestV3, + GetStockPlusOrderDetailRequestV3, + GetStockPlusQuoteRequestV3, + GetStockPlusStaticInfoRequestV3, + GetStockPlusStockPositionRequestV3, + GetStockPlusTodayExecutionsRequestV3, + GetStockPlusTodayOrdersRequestV3, + GetStockPlusTradeDetailRequestV3, + GetStockPlusTransferRecordsRequestV3, + ModifyStockPlusOrderRequestV3, + PlaceStockPlusOrderRequestV3, + StockPlusTransferRequestV3, +} from './types/request/v3/stockplus.js'; import { CancelStrategyOrderRequestV3, GetHistoryStrategyOrdersRequestV3, @@ -175,6 +208,9 @@ import { CustomCollateralCoinV3, DepositAddressV3, DepositRecordV3, + EligibleLoanInfoV3, + EligibleMarginTierV3, + EligibleSymbolV3, FinancialRecordV3, FundingAssetV3, MaxTransferableV3, @@ -184,6 +220,7 @@ import { OpenInterestLimitV3, PaymentCoinV3, PreSetLeverageV3, + RateLimitQuotaV3, RepayableCoinV3, RepayResponseV3, SubAccountApiKeyV3, @@ -210,8 +247,12 @@ import { ModifyBrokerSubApiKeyResponseV3, } from './types/response/v3/broker.js'; import { + CopyFuturesCurrentFollowersV3, + CopyFuturesHistoryFollowersV3, CopyFuturesMaxTransferableV3, CopyFuturesPositionSummaryV3, + CopyFuturesProfitDetailsV3, + CopyFuturesProfitSummaryV3, CopyFuturesTradingPairV3, CopyFuturesTransferRecordListV3, CopyFuturesTransferResponseV3, @@ -300,6 +341,32 @@ import { SpotWhaleFlowV3, TickerV3, } from './types/response/v3/public.js'; +import { + StockPlusAccountV3, + StockPlusCancelOrderResponseV3, + StockPlusCandlestickV3, + StockPlusCashFlowV3, + StockPlusDepthV3, + StockPlusHistoryCandlestickV3, + StockPlusHistoryExecutionsV3, + StockPlusHistoryOrdersV3, + StockPlusIntradayV3, + StockPlusModifyOrderResponseV3, + StockPlusOptionChainInfoV3, + StockPlusOptionExpiryDateV3, + StockPlusOptionQuoteV3, + StockPlusOptionVolumeV3, + StockPlusOrderDetailV3, + StockPlusOrdersV3, + StockPlusPlaceOrderResponseV3, + StockPlusQuoteV3, + StockPlusStaticInfoV3, + StockPlusStockPositionV3, + StockPlusTodayExecutionsV3, + StockPlusTradeDetailV3, + StockPlusTransferRecordsV3, + StockPlusTransferResponseV3, +} from './types/response/v3/stockplus.js'; import { ModifyStrategyOrderResponseV3, PlaceStrategyOrderResponseV3, @@ -799,6 +866,192 @@ export class RestClientV3 extends BaseRestClient { return this.getPrivate('/api/v3/copy/futures/transfer-record', params); } + getCopyFuturesCurrentFollowers( + params?: GetCopyFuturesFollowersRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/copy/futures/current-follower', params); + } + + getCopyFuturesHistoryFollowers( + params?: GetCopyFuturesFollowersRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/copy/futures/history-follower', params); + } + + getCopyFuturesProfitSummary(): Promise< + APIResponse + > { + return this.getPrivate('/api/v3/copy/futures/profit-summary'); + } + + getCopyFuturesProfitDetails( + params?: GetCopyFuturesProfitDetailsRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/copy/futures/profit-details', params); + } + + /** + * + * =====Stock+===== + * + */ + + getStockPlusOptionQuote( + params: GetStockPlusOptionQuoteRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/stockplus/market/option-quote', params); + } + + getStockPlusOptionChainInfo( + params: GetStockPlusOptionChainInfoRequestV3, + ): Promise> { + return this.getPrivate( + '/api/v3/stockplus/market/option-chain-info', + params, + ); + } + + getStockPlusOptionExpiryDate( + params: GetStockPlusOptionExpiryDateRequestV3, + ): Promise> { + return this.getPrivate( + '/api/v3/stockplus/market/option-expiry-date', + params, + ); + } + + getStockPlusOptionVolume( + params: GetStockPlusOptionVolumeRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/stockplus/market/option-volume', params); + } + + getStockPlusStaticInfo( + params: GetStockPlusStaticInfoRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/stockplus/market/static', params); + } + + getStockPlusQuote( + params: GetStockPlusQuoteRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/stockplus/market/quote', params); + } + + getStockPlusTradeDetail( + params: GetStockPlusTradeDetailRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/stockplus/market/trade', params); + } + + getStockPlusIntraday( + params: GetStockPlusIntradayRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/stockplus/market/intraday', params); + } + + getStockPlusHistoryCandlestick( + params: GetStockPlusHistoryCandlestickRequestV3, + ): Promise> { + return this.getPrivate( + '/api/v3/stockplus/market/history-candlestick', + params, + ); + } + + getStockPlusCandlestick( + params: GetStockPlusCandlestickRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/stockplus/market/candlestick', params); + } + + getStockPlusDepth( + params: GetStockPlusDepthRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/stockplus/market/depth', params); + } + + placeStockPlusOrder( + params: PlaceStockPlusOrderRequestV3, + ): Promise> { + return this.postPrivate('/api/v3/stockplus/trade/place-order', params); + } + + cancelStockPlusOrder( + params: CancelStockPlusOrderRequestV3, + ): Promise> { + return this.postPrivate('/api/v3/stockplus/trade/cancel-order', params); + } + + modifyStockPlusOrder( + params: ModifyStockPlusOrderRequestV3, + ): Promise> { + return this.postPrivate('/api/v3/stockplus/trade/modify-order', params); + } + + getStockPlusTodayOrders( + params?: GetStockPlusTodayOrdersRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/stockplus/trade/today-orders', params); + } + + getStockPlusHistoryOrders( + params?: GetStockPlusHistoryOrdersRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/stockplus/trade/history-orders', params); + } + + getStockPlusOrderDetail( + params: GetStockPlusOrderDetailRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/stockplus/trade/order-detail', params); + } + + getStockPlusTodayExecutions( + params?: GetStockPlusTodayExecutionsRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/stockplus/trade/today-executions', params); + } + + getStockPlusHistoryExecutions( + params?: GetStockPlusHistoryExecutionsRequestV3, + ): Promise> { + return this.getPrivate( + '/api/v3/stockplus/trade/history-executions', + params, + ); + } + + getStockPlusAccount( + params?: GetStockPlusAccountRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/stockplus/asset/account', params); + } + + getStockPlusCashFlow( + params: GetStockPlusCashFlowRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/stockplus/asset/cash-flow', params); + } + + getStockPlusStockPosition( + params?: GetStockPlusStockPositionRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/stockplus/asset/stock-position', params); + } + + stockPlusTransfer( + params: StockPlusTransferRequestV3, + ): Promise> { + return this.postPrivate('/api/v3/stockplus/asset/transfer', params); + } + + getStockPlusTransferRecords( + params?: GetStockPlusTransferRecordsRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/stockplus/asset/transfer-records', params); + } + /** * * =====Account======= endpoints @@ -1049,6 +1302,24 @@ export class RestClientV3 extends BaseRestClient { return this.getPrivate('/api/v3/account/open-interest-limit', params); } + getEligibleSymbols( + params?: GetEligibleSymbolsRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/account/eligible-symbols', params); + } + + getEligibleMarginTier( + params?: GetEligibleMarginTierRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/account/eligible-margin-tier', params); + } + + getEligibleLoanInfo( + params?: GetEligibleLoanInfoRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/account/eligible-loan-info', params); + } + /** * Switch Account - Switch to classic account mode * Only supports parent accounts. @@ -1183,6 +1454,18 @@ export class RestClientV3 extends BaseRestClient { return this.getPrivate('/api/v3/user/sub-api-list', params); } + getRateLimitQuota( + params: GetRateLimitQuotaRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/user/rate-limit-quota', params); + } + + setRateLimitQuota( + params: SetRateLimitQuotaRequestV3, + ): Promise>> { + return this.postPrivate('/api/v3/user/set-rate-limit-quota', params); + } + /** * * =====Transfer======= endpoints diff --git a/src/types/request/v3/account.ts b/src/types/request/v3/account.ts index 924d186..557176f 100644 --- a/src/types/request/v3/account.ts +++ b/src/types/request/v3/account.ts @@ -398,3 +398,28 @@ export interface GetMovePositionHistoryRequestV3 { cursor?: string; limit?: string; } + +export interface GetEligibleSymbolsRequestV3 { + symbol?: string; +} + +export interface GetEligibleMarginTierRequestV3 { + coin?: string; +} + +export interface GetEligibleLoanInfoRequestV3 { + coin?: string; +} + +export interface GetRateLimitQuotaRequestV3 { + category: 'spot' | 'futures'; + uid?: string; + cursor?: string; + limit?: string; +} + +export interface SetRateLimitQuotaRequestV3 { + category: 'spot' | 'futures'; + uids: string[]; + quota: string; +} diff --git a/src/types/request/v3/copytrading.ts b/src/types/request/v3/copytrading.ts index c7f298f..c30414a 100644 --- a/src/types/request/v3/copytrading.ts +++ b/src/types/request/v3/copytrading.ts @@ -6,6 +6,8 @@ export interface CopyFuturesTransferRequestV3 { type: 'in' | 'out'; coin: string; amount: string; + /** Source account type(s) for transfer-in. Comma-separated: funding, uta, otc */ + inAccountType?: string; } export interface GetCopyFuturesTransferRecordRequestV3 { @@ -15,3 +17,15 @@ export interface GetCopyFuturesTransferRecordRequestV3 { /** Pass transferId from the previous page to paginate forward */ cursor?: string; } + +export interface GetCopyFuturesFollowersRequestV3 { + limit?: string; + cursor?: string; +} + +export interface GetCopyFuturesProfitDetailsRequestV3 { + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; +} diff --git a/src/types/request/v3/stockplus.ts b/src/types/request/v3/stockplus.ts new file mode 100644 index 0000000..2817d00 --- /dev/null +++ b/src/types/request/v3/stockplus.ts @@ -0,0 +1,165 @@ +/** + * + * + * Stock+ (UTA) + * + * + */ + +export interface GetStockPlusOptionQuoteRequestV3 { + symbol: string; +} + +export interface GetStockPlusOptionChainInfoRequestV3 { + symbol: string; + expiryDate: string; +} + +export interface GetStockPlusOptionExpiryDateRequestV3 { + symbol: string; +} + +export interface GetStockPlusOptionVolumeRequestV3 { + symbol: string; +} + +export interface GetStockPlusStaticInfoRequestV3 { + symbol: string; +} + +export interface GetStockPlusQuoteRequestV3 { + symbol: string; +} + +export interface GetStockPlusTradeDetailRequestV3 { + symbol: string; + count?: string; +} + +export interface GetStockPlusIntradayRequestV3 { + symbol: string; +} + +export interface GetStockPlusHistoryCandlestickRequestV3 { + symbol: string; + period: string; + count?: string; + adjustType?: string; + forward?: boolean; + time?: string; + tradeSessions?: string; +} + +export interface GetStockPlusCandlestickRequestV3 { + symbol: string; + period: string; + count?: string; + adjustType?: string; + tradeSessions?: string; +} + +export interface GetStockPlusDepthRequestV3 { + symbol: string; +} + +export interface PlaceStockPlusOrderRequestV3 { + symbol: string; + orderType: 'LO' | 'MO' | 'LIT' | 'MIT' | 'TSLPAMT' | 'TSLPPCT'; + side: 'Buy' | 'Sell'; + submittedQuantity: string; + timeInForce: 'Day' | 'GoodTilCanceled' | 'GoodTilDate'; + submittedPrice?: string; + triggerPrice?: string; + limitOffset?: string; + trailingAmount?: string; + trailingPercent?: string; + expireDate?: string; + outsideRth?: 'RTHOnly' | 'AnyTime' | 'Overnight'; + limitDepthLevel?: number; + triggerCount?: number; + monitorPrice?: string; + remark?: string; +} + +export interface CancelStockPlusOrderRequestV3 { + symbol: string; + orderId?: string; + clientOid?: string; +} + +export interface ModifyStockPlusOrderRequestV3 { + orderId: string; + quantity: string; + price?: string; + triggerPrice?: string; + limitOffset?: string; + trailingAmount?: string; + trailingPercent?: string; + limitDepthLevel?: number; + triggerCount?: number; + monitorPrice?: string; + remark?: string; +} + +export interface GetStockPlusTodayOrdersRequestV3 { + symbol?: string; + status?: string | string[]; + side?: string; + market?: string; + orderId?: string; +} + +export interface GetStockPlusHistoryOrdersRequestV3 { + symbol?: string; + status?: string | string[]; + side?: string; + market?: string; + startAt?: string; + endAt?: string; +} + +export interface GetStockPlusOrderDetailRequestV3 { + orderId: string; +} + +export interface GetStockPlusTodayExecutionsRequestV3 { + symbol?: string; + orderId?: string; +} + +export interface GetStockPlusHistoryExecutionsRequestV3 { + symbol?: string; + startAt?: string; + endAt?: string; +} + +export interface GetStockPlusAccountRequestV3 { + currency?: string; +} + +export interface GetStockPlusCashFlowRequestV3 { + startTime: string; + endTime: string; + businessType?: string; + symbol?: string; + page?: string; + size?: string; +} + +export interface GetStockPlusStockPositionRequestV3 { + symbol?: string; +} + +export interface StockPlusTransferRequestV3 { + coin?: string; + amount?: string; + direction?: 'in' | 'out'; +} + +export interface GetStockPlusTransferRecordsRequestV3 { + transferId?: string; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; +} diff --git a/src/types/request/v3/trade.ts b/src/types/request/v3/trade.ts index 678633c..f78a34b 100644 --- a/src/types/request/v3/trade.ts +++ b/src/types/request/v3/trade.ts @@ -145,6 +145,7 @@ export interface ModifyOrderRequestV3 { } export interface PlaceRealityOrderRequestV3 { + category?: 'SPOT' | 'MARGIN'; symbol: string; side: 'buy' | 'sell'; orderType: 'limit' | 'market'; @@ -154,6 +155,7 @@ export interface PlaceRealityOrderRequestV3 { } export interface CancelRealityOrderRequestV3 { + category?: 'SPOT' | 'MARGIN'; symbol: string; orderId?: string; clientOid?: string; diff --git a/src/types/response/v2/futures.ts b/src/types/response/v2/futures.ts index f847b68..fbf8d18 100644 --- a/src/types/response/v2/futures.ts +++ b/src/types/response/v2/futures.ts @@ -310,6 +310,8 @@ export interface FuturesPositionV2 { deductedFee: string; marginRatio: string; assetMode: string; + /** Cash dividend, USDT */ + cashDividend?: string; uTime: string; autoMargin: string; cTime: string; @@ -338,6 +340,8 @@ export interface FuturesHistoryPositionV2 { totalFunding: string; openFee: string; closeFee: string; + /** Cash dividend, USDT */ + cashDividend?: string; cTime: string; uTime: string; } diff --git a/src/types/response/v3/account.ts b/src/types/response/v3/account.ts index 2cd0850..66cd86c 100644 --- a/src/types/response/v3/account.ts +++ b/src/types/response/v3/account.ts @@ -71,6 +71,8 @@ export interface AccountAssetV3 { positionValue?: string; /** Account leverage (non-negative) */ leverage?: string; + /** USDT bonus amount */ + bonus?: string; } export interface AccountAssetsV3 { @@ -385,3 +387,60 @@ export interface MovePositionHistoryV3 { createdTime: string; updatedTime: string; } + +export interface EligibleSymbolV3 { + symbol: string; + category: string; + baseCoin: string; + quoteCoin: string; + symbolType?: string; + buyLimitPriceRatio: string; + sellLimitPriceRatio: string; + minOrderQty: string; + maxOrderQty: string; + pricePrecision: string; + quantityPrecision: string; + quotePrecision: string; + minOrderAmount: string; + maxSymbolOrderNum: string; + maxProductOrderNum: string; + status: string; + maintainTime: string; + areaSymbol?: string; + maxPositionNum?: string; + isReality?: string; + launchTime?: string; +} + +export interface EligibleMarginTierItemV3 { + tier: string; + minTierValue: string; + maxTierValue: string; + leverage: string; + mmr: string; +} + +export interface EligibleMarginTierV3 { + coin: string; + tiers: EligibleMarginTierItemV3[]; +} + +export interface EligibleLoanInfoV3 { + limit: string; + masterSubLimit: string; + /** Bitget spelling */ + platformRemaingQuota: string; +} + +export interface RateLimitQuotaItemV3 { + uid: string; + quota: string; +} + +export interface RateLimitQuotaV3 { + category: 'spot' | 'futures' | string; + quotaList: RateLimitQuotaItemV3[]; + masterSubQuota: string; + masterSubCap: string; + cursor: string; +} diff --git a/src/types/response/v3/copytrading.ts b/src/types/response/v3/copytrading.ts index a6532e5..7257291 100644 --- a/src/types/response/v3/copytrading.ts +++ b/src/types/response/v3/copytrading.ts @@ -45,7 +45,13 @@ export interface CopyFuturesTransferResponseV3 { transferId: string; } -export type CopyFuturesTransferAccountTypeV3 = 'spot' | 'uta' | 'lead'; +/** May be a single value or comma-separated values */ +export type CopyFuturesTransferAccountTypeV3 = + | 'spot' + | 'uta' + | 'lead' + | 'otc' + | string; export interface CopyFuturesTransferRecordV3 { transferId: string; @@ -60,3 +66,54 @@ export interface CopyFuturesTransferRecordV3 { export interface CopyFuturesTransferRecordListV3 { list: CopyFuturesTransferRecordV3[]; } + +export interface CopyFuturesCurrentFollowerV3 { + followerName: string; + estimateAssets: string; + totalProfit: string; + totalShareProfit: string; + totalInvestment: string; + canRemove: 'yes' | 'no'; + followDays: string; + totalAssets: string; + startTime: string; +} + +export interface CopyFuturesCurrentFollowersV3 { + list: CopyFuturesCurrentFollowerV3[]; +} + +export interface CopyFuturesHistoryFollowerV3 { + followerName: string; + totalProfit: string; + totalShareProfit: string; + totalInvestment: string; + startTime: string; + endTime: string; +} + +export interface CopyFuturesHistoryFollowersV3 { + list: CopyFuturesHistoryFollowerV3[]; +} + +export interface CopyFuturesProfitSummaryV3 { + totalProfit: string; + totalAllocatedProfit: string; + totalPendingProfit: string; +} + +export interface CopyFuturesProfitDetailV3 { + followerName: string; + profit: string; + allocatedPnl: string; + pendingPnl: string; + shareRatio: string; + shareProfit: string; + reason: 'period' | 'unfollow' | string; + settleTime: string; +} + +export interface CopyFuturesProfitDetailsV3 { + list: CopyFuturesProfitDetailV3[]; + nextCursor: string; +} diff --git a/src/types/response/v3/public.ts b/src/types/response/v3/public.ts index 67d2c2b..bb55579 100644 --- a/src/types/response/v3/public.ts +++ b/src/types/response/v3/public.ts @@ -53,6 +53,9 @@ export interface MarginLoanV3 { dailyInterest: string; annualInterest: string; limit: string; + masterSubLimit?: string; + /** Bitget spelling */ + platformRemaingQuota?: string; } export interface OpenInterestItemV3 { @@ -250,6 +253,8 @@ export interface TickerV3 { price24hPcnt: string; volume24h: string; turnover24h: string; + /** 24h platform turnover; only available for rtoken */ + platformTurnover24h?: string; // Futures specific fields indexPrice?: string; diff --git a/src/types/response/v3/stockplus.ts b/src/types/response/v3/stockplus.ts new file mode 100644 index 0000000..4e94594 --- /dev/null +++ b/src/types/response/v3/stockplus.ts @@ -0,0 +1,346 @@ +/** + * + * + * Stock+ (UTA) + * + * + */ + +export interface StockPlusOptionQuoteItemV3 { + symbol: string; + lastDone: string; + prevClose: string; + open: string; + high: string; + low: string; + timestamp: string; + volume: string; + turnover: string; + tradeStatus: string; + impliedVolatility: string; + openInterest: string; + expiryDate: string; + strikePrice: string; + contractMultipier: string; + contractType: string; + contractSize: string; + direction: string; + historicalVolatility: string; + underlyingSymbol: string; +} + +export interface StockPlusOptionQuoteV3 { + secuQuote: StockPlusOptionQuoteItemV3[]; +} + +export interface StockPlusOptionStrikePriceInfoV3 { + price: string; + callSymbol: string; + putSymbol: string; + standard: boolean; +} + +export interface StockPlusOptionChainInfoV3 { + strikePriceInfo: StockPlusOptionStrikePriceInfoV3[]; +} + +export interface StockPlusOptionExpiryDateV3 { + expiryDate: string[]; +} + +export interface StockPlusOptionVolumeV3 { + c: string; + p: string; +} + +export interface StockPlusStaticInfoItemV3 { + symbol: string; + nameCn: string; + nameEn: string; + exchange: string; + currency: string; + lotSize: number | string; + totalShares: string | number; + circulatingShares: string | number; + eps: string | number; + epsTtm: string | number; + bps: string | number; + dividendYield: string | number; + stockDerivatives: string[]; + board: string; +} + +export interface StockPlusStaticInfoV3 { + list: StockPlusStaticInfoItemV3[]; +} + +export interface StockPlusSessionQuoteV3 { + lastDone: string | number; + timestamp: string; + volume: string | number; + turnover: string | number; + high: string | number; + low: string | number; + prevClose: string | number; +} + +export interface StockPlusQuoteItemV3 { + symbol: string; + lastDone: string | number; + prevClose: string | number; + open: string | number; + high: string | number; + low: string | number; + timestamp: string; + volume: string | number; + turnover: string | number; + tradeStatus: string; + preMarketQuote?: StockPlusSessionQuoteV3 | null; + postMarketQuote?: StockPlusSessionQuoteV3 | null; + overnightQuote?: StockPlusSessionQuoteV3 | null; +} + +export interface StockPlusQuoteV3 { + list: StockPlusQuoteItemV3[]; +} + +export interface StockPlusTradeDetailItemV3 { + price: string | number; + volume: string | number; + timestamp: string; + tradeType: string; + direction: string; + tradeSession: string; +} + +export type StockPlusTradeDetailV3 = StockPlusTradeDetailItemV3[]; + +export interface StockPlusIntradayItemV3 { + price: string | number; + timestamp: string; + volume: string | number; + turnover: string | number; + avgPrice: string | number; +} + +export interface StockPlusIntradayV3 { + list: StockPlusIntradayItemV3[]; +} + +export interface StockPlusCandlestickItemV3 { + close: string; + open: string; + low: string; + high: string; + volume: string; + turnover: string; + timestamp: string; + tradeSession: string; +} + +export interface StockPlusCandlestickV3 { + list: StockPlusCandlestickItemV3[]; +} + +export type StockPlusHistoryCandlestickV3 = StockPlusCandlestickV3; + +export interface StockPlusDepthLevelV3 { + position: number; + price: string; + volume: string; + orderNum: number; +} + +export interface StockPlusDepthV3 { + asks: StockPlusDepthLevelV3[]; + bids: StockPlusDepthLevelV3[]; +} + +export interface StockPlusPlaceOrderResponseV3 { + orderId: string; + clientOid: string; + symbol: string; +} + +export type StockPlusCancelOrderResponseV3 = StockPlusPlaceOrderResponseV3; +export type StockPlusModifyOrderResponseV3 = StockPlusPlaceOrderResponseV3; + +export interface StockPlusOrderV3 { + orderId: string; + status: string; + stockName: string; + quantity: string | number; + executedQuantity: string | number; + price: string | number | null; + executedPrice: string | number | null; + submittedAt: string; + side: string; + symbol: string; + orderType: string; + lastDone: string | number | null; + triggerPrice: string | number | null; + msg: string; + tag: string; + timeInForce: string; + expireDate: string | null; + updatedAt: string | null; + triggerAt: string | null; + trailingAmount: string | number | null; + trailingPercent: string | number | null; + limitOffset: string | number | null; + triggerStatus: string | null; + currency: string; + outsideRth: string; + remark?: string; + limitDepthLevel: number | null; + triggerCount: number | null; + monitorPrice: string | null; +} + +export interface StockPlusOrdersV3 { + orders: StockPlusOrderV3[]; +} + +export interface StockPlusHistoryOrdersV3 { + hasMore: boolean; + orders: StockPlusOrderV3[]; +} + +export interface StockPlusOrderHistoryItemV3 { + price: string | number; + quantity: string | number; + status: string; + msg: string; + time: string; +} + +export interface StockPlusChargeFeeItemV3 { + code: string; + name: string; + amount: number | string; + currency: string; +} + +export interface StockPlusChargeCategoryV3 { + code: string; + name: string; + fees: StockPlusChargeFeeItemV3[]; +} + +export interface StockPlusChargeDetailV3 { + totalAmount: number | string; + currency: string; + items: StockPlusChargeCategoryV3[]; +} + +export interface StockPlusOrderDetailV3 extends StockPlusOrderV3 { + freeStatus?: string; + freeAmount?: string | null; + freeCurrency?: string | null; + deductionsStatus?: string; + deductionsAmount?: string | null; + deductionsCurrency?: string | null; + platformDeductedStatus?: string; + platformDeductedAmount?: string | null; + platformDeductedCurrency?: string | null; + history?: StockPlusOrderHistoryItemV3[]; + chargeDetail?: StockPlusChargeDetailV3; +} + +export interface StockPlusExecutionV3 { + orderId: string; + tradeId: string; + symbol: string; + tradeDoneAt: string; + quantity: number | string; + price: number | string; +} + +export interface StockPlusTodayExecutionsV3 { + trades: StockPlusExecutionV3[]; +} + +export interface StockPlusHistoryExecutionsV3 { + hasMore: boolean; + trades: StockPlusExecutionV3[]; +} + +export interface StockPlusCashInfoV3 { + withdrawCash: number | string; + availableCash: number | string; + frozenCash: number | string; + settlingCash: number | string; + currency: string; +} + +export interface StockPlusFrozenTransactionFeeV3 { + currency?: string; + amount?: number | string; + [key: string]: unknown; +} + +export interface StockPlusAccountItemV3 { + totalCash: number | string; + maxFinanceAmount: number | string; + remainingFinanceAmount: number | string; + riskLevel: number | string; + marginCall: number | string; + netAssets: number | string; + initMargin: number | string; + maintenanceMargin: number | string; + currency: string; + buyPower: number | string; + cashInfos: StockPlusCashInfoV3[]; + frozenTransactionFees: StockPlusFrozenTransactionFeeV3[]; +} + +export interface StockPlusAccountV3 { + list: StockPlusAccountItemV3[]; +} + +export interface StockPlusCashFlowItemV3 { + transactionFlowName: string; + direction: string; + businessType: string; + balance: number | string; + currency: string; + businessTime: string; + symbol: string | null; + description: string; +} + +export interface StockPlusCashFlowV3 { + list: StockPlusCashFlowItemV3[]; +} + +export interface StockPlusPositionItemV3 { + symbol: string; + symbolName: string; + quantity: number | string; + availableQuantity: number | string; + currency: string; + costPrice: number | string; + market: string; + initQuantity: number | string; +} + +export interface StockPlusPositionChannelV3 { + accountChannel: string; + positions: StockPlusPositionItemV3[]; +} + +export interface StockPlusStockPositionV3 { + channels: StockPlusPositionChannelV3[]; +} + +export interface StockPlusTransferResponseV3 { + transferId: string; +} + +export interface StockPlusTransferRecordsV3 { + transferId: string; + coin: string; + amount: string; + direction: string; + cursor: string; +} diff --git a/src/types/response/v3/trade.ts b/src/types/response/v3/trade.ts index d214a6f..af0c070 100644 --- a/src/types/response/v3/trade.ts +++ b/src/types/response/v3/trade.ts @@ -173,6 +173,8 @@ export interface PositionHistoryV3 { totalFunding: string; openFeeTotal: string; closeFeeTotal: string; + /** Cash dividend, USDT */ + cashDividend?: string; createdTime: string; updatedTime: string; } @@ -201,6 +203,8 @@ export interface CurrentPositionV3 { totalFunding: string; openFeeTotal: string; closeFeeTotal: string; + /** Cash dividend, USDT */ + cashDividend?: string; createdTime: string; updatedTime: string; } diff --git a/src/types/websockets/ws-api-request.ts b/src/types/websockets/ws-api-request.ts index 7ddde9d..4fb410a 100644 --- a/src/types/websockets/ws-api-request.ts +++ b/src/types/websockets/ws-api-request.ts @@ -21,4 +21,6 @@ export interface WSAPIPlaceOrderRequestV3 { slOrderType?: 'limit' | 'market'; tpLimitPrice?: string; slLimitPrice?: string; + /** Order TTL in ms [10, 60000]. Only effective when requestTime is also set on the envelope */ + receiveWindow?: string; } diff --git a/src/types/websockets/ws-api.ts b/src/types/websockets/ws-api.ts index e428e26..c631e8b 100644 --- a/src/types/websockets/ws-api.ts +++ b/src/types/websockets/ws-api.ts @@ -34,6 +34,8 @@ export interface WSAPIRequestBitgetV3 { category: BitgetInstTypeV3; topic: WSAPIOperation; args: TWSParams | TWSParams[]; + /** Client-side request timestamp; required for receiveWindow on place-order */ + requestTime?: string; } export interface WSAPIRequestFlags { @@ -72,6 +74,11 @@ export interface WsRequestOperationBitget { op: WSOperation; args?: (TWSRequestArg | string | number)[]; } +export interface WSAPIRateLimitV3 { + limit: string; + remaining: string; +} + export interface WSAPIResponse< TResponseData extends object = object, TOperation extends WSAPIOperation = WSAPIOperation, @@ -88,6 +95,11 @@ export interface WSAPIResponse< ts: string; /** Connection ID (trade operation responses, May 2026+) */ connId?: string; + /** Gateway receive time, Unix microseconds */ + receiveTime?: string; + /** Gateway push time, Unix microseconds */ + pushTime?: string; + rateLimit?: WSAPIRateLimitV3[]; } /** diff --git a/src/types/websockets/ws-events.ts b/src/types/websockets/ws-events.ts index fe09a37..6cf66d0 100644 --- a/src/types/websockets/ws-events.ts +++ b/src/types/websockets/ws-events.ts @@ -85,6 +85,14 @@ export interface WsPositionSnapshotDataUMCBL { cTime: string; uTime: string; markPrice: string; + /** Cash dividend, USDT (Classic V2 positions channel) */ + cashDividend?: string; +} + +/** UTA reality-orderbook push (ts/seq/pseq removed July 2026) */ +export interface WsRealityOrderBookDataV3 { + a: [string, string][]; + b: [string, string][]; } export interface WSPositionSnapshotUMCBL extends WsBaseEvent<'snapshot'> { diff --git a/src/types/websockets/ws-general.ts b/src/types/websockets/ws-general.ts index 0b48d74..e723b64 100644 --- a/src/types/websockets/ws-general.ts +++ b/src/types/websockets/ws-general.ts @@ -117,7 +117,8 @@ export type WsPrivateTopicV3 = | 'position' | 'fill' | 'order' - | 'strategy-order'; + | 'strategy-order' + | 'reality-orderbook'; export type WsTopicV3 = WsPublicTopicV3 | WsPrivateTopicV3; /** This is used to differentiate between each of the available websocket streams */ diff --git a/src/util/websocket-util.ts b/src/util/websocket-util.ts index 069ebd8..fe86f67 100644 --- a/src/util/websocket-util.ts +++ b/src/util/websocket-util.ts @@ -114,6 +114,7 @@ export const PRIVATE_TOPICS_V3: WsPrivateTopicV3[] = [ 'fill', 'order', 'strategy-order', + 'reality-orderbook', ]; export async function getWsUrl(