diff --git a/docs/endpointFunctionList.md b/docs/endpointFunctionList.md index 98ded34..6b3d84d 100644 --- a/docs/endpointFunctionList.md +++ b/docs/endpointFunctionList.md @@ -361,216 +361,265 @@ This table includes all endpoints from the official Exchange API docs and corres | Function | AUTH | HTTP Method | Endpoint | | -------- | :------: | :------: | -------- | -| [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` | +| [getServerTime()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L575) | | GET | `/api/v3/public/time` | +| [getInstruments()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L592) | | GET | `/api/v3/market/instruments` | +| [getMarketFeeGroup()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L601) | | GET | `/api/v3/market/fee-group` | +| [getLiquidations()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L610) | | GET | `/api/v3/market/liquidations` | +| [getRpiSymbols()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L619) | | GET | `/api/v3/market/rpi-symbols` | +| [getRpiOrderBook()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L626) | | GET | `/api/v3/market/rpi-orderbook` | +| [getCashDividendRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L635) | | GET | `/api/v3/market/cash-dividend-records` | +| [getSplitRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L641) | | GET | `/api/v3/market/split-records` | +| [getSpotWhaleFlow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L650) | | GET | `/api/v3/market/spot-whale-flow` | +| [getSpotFundFlow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L659) | | GET | `/api/v3/market/spot-fund-flow` | +| [getSpotNetFlow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L668) | | GET | `/api/v3/market/spot-net-flow` | +| [getMarginLongShort()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L677) | | GET | `/api/v3/market/margin-long-short` | +| [getMarginLoanGrowth()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L686) | | GET | `/api/v3/market/margin-loan-growth` | +| [getMarginIsolatedBorrow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L695) | | GET | `/api/v3/market/margin-isolated-borrow` | +| [getFuturesActiveBuySell()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L704) | | GET | `/api/v3/market/futures-active-buy-sell` | +| [getFuturesLongShort()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L713) | | GET | `/api/v3/market/futures-long-short` | +| [getFuturesPositionLongShort()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L722) | | GET | `/api/v3/market/futures-position-long-short` | +| [getFuturesAccountLongShort()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L731) | | GET | `/api/v3/market/futures-account-long-short` | +| [getMarketScoreWeights()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L740) | | GET | `/api/v3/market/score-weights` | +| [getTickers()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L749) | | GET | `/api/v3/market/tickers` | +| [getOrderBook()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L756) | | GET | `/api/v3/market/orderbook` | +| [getFills()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L765) | | GET | `/api/v3/market/fills` | +| [getProofOfReserves()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L774) | | GET | `/api/v3/market/proof-of-reserves` | +| [getOpenInterest()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L781) | | GET | `/api/v3/market/open-interest` | +| [getCandles()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L791) | | GET | `/api/v3/market/candles` | +| [getHistoryCandles()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L800) | | GET | `/api/v3/market/history-candles` | +| [getCurrentFundingRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L809) | | GET | `/api/v3/market/current-fund-rate` | +| [getHistoryFundingRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L818) | | GET | `/api/v3/market/history-fund-rate` | +| [getRiskReserve()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L827) | | GET | `/api/v3/market/risk-reserve` | +| [getRiskReserveHour()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L836) | | GET | `/api/v3/market/risk-reserve-hour` | +| [getRiskReserveAll()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L845) | | GET | `/api/v3/market/risk-reserve-all` | +| [getDiscountRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L854) | | GET | `/api/v3/market/discount-rate` | +| [getMarginLoans()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L861) | | GET | `/api/v3/market/margin-loans` | +| [getPositionTier()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L870) | | GET | `/api/v3/market/position-tier` | +| [getContractsOi()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L879) | | GET | `/api/v3/market/oi-limit` | +| [getIndexComponents()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L888) | | GET | `/api/v3/market/index-components` | +| [getRealityOrderBook()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L897) | :closed_lock_with_key: | GET | `/api/v3/account/reality-orderbook` | +| [getRealityFills()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L906) | :closed_lock_with_key: | GET | `/api/v3/account/reality-fills` | +| [getRealityCompanyOverview()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L912) | | GET | `/api/v3/reality/market/company-overview` | +| [getRealityValuationIndicators()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L918) | | GET | `/api/v3/reality/market/valuation-indicators` | +| [getRealityEarningsForecast()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L924) | | GET | `/api/v3/reality/market/earnings-forecast` | +| [getRealitySuspensionResumptionInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L930) | | GET | `/api/v3/reality/market/suspension-resumption-info` | +| [getRealityDividends()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L939) | | GET | `/api/v3/reality/market/dividends` | +| [getRealityShareCapitalChange()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L945) | | GET | `/api/v3/reality/market/share-capital-change` | +| [getRealityInnerTrades()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L951) | | GET | `/api/v3/reality/market/inner-trades` | +| [getRealityExecutiveShareholdings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L957) | | GET | `/api/v3/reality/market/executive-shareholdings` | +| [getRealityShareholdDetail()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L965) | | GET | `/api/v3/reality/market/sharehold-detail` | +| [getRealityStockInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L971) | | GET | `/api/v3/reality/market/stock-info` | +| [getRealityMarketStates()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L977) | | GET | `/api/v3/reality/market/states` | +| [getRealityMarketCalendar()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L981) | | GET | `/api/v3/reality/market/calendar` | +| [getCopyFuturesTradingPairs()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L996) | :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#L1007) | :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#L1017) | :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#L1027) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/transfer` | +| [getCopyFuturesTransferRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1037) | :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#L1043) | :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#L1049) | :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#L1055) | :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#L1061) | :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#L1073) | :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#L1079) | :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#L1088) | :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#L1097) | :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#L1103) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/static` | +| [getStockPlusQuote()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1109) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/quote` | +| [getStockPlusTradeDetail()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1115) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/trade` | +| [getStockPlusIntraday()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1121) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/intraday` | +| [getStockPlusHistoryCandlestick()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1127) | :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#L1136) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/candlestick` | +| [getStockPlusDepth()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1142) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/depth` | +| [placeStockPlusOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1148) | :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#L1154) | :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#L1160) | :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#L1166) | :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#L1172) | :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#L1178) | :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#L1184) | :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#L1190) | :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#L1199) | :closed_lock_with_key: | GET | `/api/v3/stockplus/asset/account` | +| [getStockPlusCashFlow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1205) | :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#L1211) | :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#L1217) | :closed_lock_with_key: | POST | `/api/v3/stockplus/asset/transfer` | +| [getStockPlusTransferRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1223) | :closed_lock_with_key: | GET | `/api/v3/stockplus/asset/transfer-records` | +| [getCfdTickers()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1235) | :closed_lock_with_key: | GET | `/api/v3/cfd/market/tickers` | +| [getCfdHistoryCandlestick()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1241) | :closed_lock_with_key: | GET | `/api/v3/cfd/market/history-candlestick` | +| [placeCfdOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1247) | :closed_lock_with_key: | POST | `/api/v3/cfd/trade/place-order` | +| [modifyCfdOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1253) | :closed_lock_with_key: | POST | `/api/v3/cfd/trade/modify-order` | +| [cancelCfdOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1259) | :closed_lock_with_key: | POST | `/api/v3/cfd/trade/cancel-order` | +| [cancelAllCfdOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1263) | :closed_lock_with_key: | POST | `/api/v3/cfd/trade/cancel-all` | +| [closeCfdPositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1269) | :closed_lock_with_key: | POST | `/api/v3/cfd/trade/close-positions` | +| [closeAllCfdPositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1275) | :closed_lock_with_key: | POST | `/api/v3/cfd/trade/close-all-positions` | +| [getCfdUnfilledOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1281) | :closed_lock_with_key: | GET | `/api/v3/cfd/trade/unfilled-order` | +| [getCfdOrderHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1287) | :closed_lock_with_key: | GET | `/api/v3/cfd/trade/history-order` | +| [getCfdCurrentPositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1293) | :closed_lock_with_key: | GET | `/api/v3/cfd/trade/current-positions` | +| [getCfdFundDetail()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1299) | :closed_lock_with_key: | GET | `/api/v3/cfd/account/fund-detail` | +| [cfdTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1303) | :closed_lock_with_key: | POST | `/api/v3/cfd/account/transfer` | +| [getCfdTransferRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1309) | :closed_lock_with_key: | GET | `/api/v3/cfd/account/transfer-records` | +| [getCfdFinancialRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1315) | :closed_lock_with_key: | GET | `/api/v3/cfd/account/financial-records` | +| [getCfdInstruments()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1321) | :closed_lock_with_key: | GET | `/api/v3/cfd/account/instruments` | +| [getBalances()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1336) | :closed_lock_with_key: | GET | `/api/v3/account/assets` | +| [getFundingAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1343) | :closed_lock_with_key: | GET | `/api/v3/account/funding-assets` | +| [getAccountInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1353) | :closed_lock_with_key: | GET | `/api/v3/account/info` | +| [getAccountSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1361) | :closed_lock_with_key: | GET | `/api/v3/account/settings` | +| [adjustAccountMode()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1368) | :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#L1378) | :closed_lock_with_key: | GET | `/api/v3/account/delta-info` | +| [setLeverage()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1385) | :closed_lock_with_key: | POST | `/api/v3/account/set-leverage` | +| [setHoldMode()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1392) | :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#L1401) | :closed_lock_with_key: | GET | `/api/v3/account/collateral-type` | +| [setCollateralType()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1408) | :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#L1417) | | GET | `/api/v3/account/custom-collateral-coins` | +| [preSetLeverage()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1424) | :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#L1433) | :closed_lock_with_key: | POST | `/api/v3/account/set-margin` | +| [getMaxWithdrawal()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1440) | :closed_lock_with_key: | GET | `/api/v3/account/max-withdrawal` | +| [getFinancialRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1449) | :closed_lock_with_key: | GET | `/api/v3/account/financial-records` | +| [getFundingFinancialRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1458) | :closed_lock_with_key: | GET | `/api/v3/account/funding-financial-records` | +| [getRepayableCoins()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1472) | :closed_lock_with_key: | GET | `/api/v3/account/repayable-coins` | +| [getPaymentCoins()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1484) | :closed_lock_with_key: | GET | `/api/v3/account/payment-coins` | +| [submitRepay()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1496) | :closed_lock_with_key: | POST | `/api/v3/account/repay` | +| [getConvertRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1503) | :closed_lock_with_key: | GET | `/api/v3/account/convert-records` | +| [getSmallAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1512) | :closed_lock_with_key: | GET | `/api/v3/convert/small-assets` | +| [tradeSmallAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1518) | :closed_lock_with_key: | POST | `/api/v3/convert/small-assets-trade` | +| [getSmallAssetsHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1524) | :closed_lock_with_key: | GET | `/api/v3/convert/small-assets-history` | +| [setDepositAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1539) | :closed_lock_with_key: | POST | `/api/v3/account/deposit-account` | +| [switchDeduct()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1548) | :closed_lock_with_key: | POST | `/api/v3/account/switch-deduct` | +| [getDeductInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1555) | :closed_lock_with_key: | GET | `/api/v3/account/deduct-info` | +| [getFeeRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1566) | :closed_lock_with_key: | GET | `/api/v3/account/fee-rate` | +| [getAllFeeRates()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1578) | :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#L1591) | :closed_lock_with_key: | GET | `/api/v3/account/max-transferable` | +| [getOpenInterestLimit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1603) | :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#L1609) | :closed_lock_with_key: | GET | `/api/v3/account/eligible-symbols` | +| [getEligibleMarginTier()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1615) | :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#L1621) | :closed_lock_with_key: | GET | `/api/v3/account/eligible-loan-info` | +| [getEligibleDiscountRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1627) | :closed_lock_with_key: | GET | `/api/v3/account/eligible-discount-rate` | +| [downgradeAccountToClassic()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1642) | :closed_lock_with_key: | POST | `/api/v3/account/switch` | +| [getUnifiedAccountSwitchStatus()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1650) | :closed_lock_with_key: | GET | `/api/v3/account/switch-status` | +| [getTaxRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1666) | :closed_lock_with_key: | GET | `/api/v3/tax/records` | +| [createSubAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1681) | :closed_lock_with_key: | POST | `/api/v3/user/create-sub` | +| [createAgentSubAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1690) | :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#L1699) | :closed_lock_with_key: | POST | `/api/v3/user/freeze-sub` | +| [getSubUnifiedAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1708) | :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#L1717) | :closed_lock_with_key: | GET | `/api/v3/user/sub-list` | +| [createSubAccountApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1730) | :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#L1739) | :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#L1748) | :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#L1757) | :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#L1767) | :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#L1773) | :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#L1788) | :closed_lock_with_key: | GET | `/api/v3/account/transferable-coins` | +| [submitTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1797) | :closed_lock_with_key: | POST | `/api/v3/account/transfer` | +| [subAccountTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1806) | :closed_lock_with_key: | POST | `/api/v3/account/sub-transfer` | +| [getSubTransferRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1818) | :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#L1830) | :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#L1848) | :closed_lock_with_key: | GET | `/api/v3/account/deposit-address` | +| [getSubDepositAddress()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1857) | :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#L1866) | :closed_lock_with_key: | GET | `/api/v3/account/deposit-records` | +| [getSubDepositRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1875) | :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#L1890) | :closed_lock_with_key: | POST | `/api/v3/account/withdraw` | +| [getWithdrawRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1899) | :closed_lock_with_key: | GET | `/api/v3/account/withdrawal-records` | +| [getWithdrawAddressBook()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1908) | :closed_lock_with_key: | GET | `/api/v3/account/withdraw-address` | +| [cancelWithdrawal()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1917) | :closed_lock_with_key: | POST | `/api/v3/account/cancel-withdrawal` | +| [submitNewOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1932) | :closed_lock_with_key: | POST | `/api/v3/trade/place-order` | +| [modifyOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1941) | :closed_lock_with_key: | POST | `/api/v3/trade/modify-order` | +| [placeRealityOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1950) | :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#L1959) | :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#L1968) | :closed_lock_with_key: | GET | `/api/v3/trade/loan-data` | +| [cancelOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1975) | :closed_lock_with_key: | POST | `/api/v3/trade/cancel-order` | +| [placeBatchOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1984) | :closed_lock_with_key: | POST | `/api/v3/trade/place-batch` | +| [batchModifyOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1993) | :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#L2002) | :closed_lock_with_key: | POST | `/api/v3/trade/cancel-batch` | +| [cancelAllOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2011) | :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#L2020) | :closed_lock_with_key: | POST | `/api/v3/trade/close-positions` | +| [getOrderInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2029) | :closed_lock_with_key: | GET | `/api/v3/trade/order-info` | +| [getUnfilledOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2038) | :closed_lock_with_key: | GET | `/api/v3/trade/unfilled-orders` | +| [getHistoryOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2050) | :closed_lock_with_key: | GET | `/api/v3/trade/history-orders` | +| [movePositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2062) | :closed_lock_with_key: | POST | `/api/v3/account/move-positions` | +| [getMovePositionHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2071) | :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#L2083) | :closed_lock_with_key: | GET | `/api/v3/trade/fills` | +| [getCurrentPosition()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2095) | :closed_lock_with_key: | GET | `/api/v3/position/current-position` | +| [getPositionHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2106) | :closed_lock_with_key: | GET | `/api/v3/position/history-position` | +| [getMaxOpenAvailable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2118) | :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#L2127) | :closed_lock_with_key: | GET | `/api/v3/position/adlRank` | +| [countdownCancelAll()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2134) | :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#L2149) | :closed_lock_with_key: | GET | `/api/v3/ins-loan/transfered` | +| [getLoanSymbols()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2158) | :closed_lock_with_key: | GET | `/api/v3/ins-loan/symbols` | +| [getLoanRiskUnit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2167) | :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#L2178) | :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#L2187) | :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#L2196) | :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#L2205) | :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#L2214) | :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#L2226) | :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#L2241) | :closed_lock_with_key: | GET | `/api/v3/loan/coins` | +| [getLoanInterest()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2250) | :closed_lock_with_key: | GET | `/api/v3/loan/interest` | +| [loanBorrow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2259) | :closed_lock_with_key: | POST | `/api/v3/loan/borrow` | +| [getLoanBorrowOngoing()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2268) | :closed_lock_with_key: | GET | `/api/v3/loan/borrow-ongoing` | +| [getLoanBorrowHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2277) | :closed_lock_with_key: | GET | `/api/v3/loan/borrow-history` | +| [loanRepay()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2286) | :closed_lock_with_key: | POST | `/api/v3/loan/repay` | +| [getLoanRepayHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2295) | :closed_lock_with_key: | GET | `/api/v3/loan/repay-history` | +| [loanRevisePledge()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2304) | :closed_lock_with_key: | POST | `/api/v3/loan/revise-pledge` | +| [getLoanPledgeRateHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2313) | :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#L2322) | :closed_lock_with_key: | GET | `/api/v3/loan/debts` | +| [getLoanReduces()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2329) | :closed_lock_with_key: | GET | `/api/v3/loan/reduces` | +| [submitStrategyOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2344) | :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#L2353) | :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#L2362) | :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#L2371) | :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#L2380) | :closed_lock_with_key: | GET | `/api/v3/trade/history-strategy-orders` | +| [getStrategySubOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2389) | :closed_lock_with_key: | GET | `/api/v3/trade/strategy-sub-orders` | +| [validateGridBot()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2404) | :closed_lock_with_key: | POST | `/api/v3/trade/grid/validate` | +| [createGridBot()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2410) | :closed_lock_with_key: | POST | `/api/v3/trade/grid/create-bot` | +| [modifyGridBot()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2416) | :closed_lock_with_key: | POST | `/api/v3/trade/grid/modify-bot` | +| [modifyGridInterval()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2422) | :closed_lock_with_key: | POST | `/api/v3/trade/grid/modify-grid-interval` | +| [addGridInvestment()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2428) | :closed_lock_with_key: | POST | `/api/v3/trade/grid/add-investment` | +| [closeGridBot()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2434) | :closed_lock_with_key: | POST | `/api/v3/trade/grid/close-bot` | +| [getGridBotDetail()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2440) | :closed_lock_with_key: | GET | `/api/v3/trade/grid/bot-detail` | +| [getGridBotOrderDetails()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2446) | :closed_lock_with_key: | GET | `/api/v3/trade/grid/list-details` | +| [validateNeutralGridBot()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2452) | :closed_lock_with_key: | POST | `/api/v3/trade/grid/validate-neutral` | +| [createNeutralGridBot()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2458) | :closed_lock_with_key: | POST | `/api/v3/trade/grid/create-neutral-bot` | +| [modifyNeutralGridBot()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2464) | :closed_lock_with_key: | POST | `/api/v3/trade/grid/modify-neutral-bot` | +| [modifyNeutralGridInterval()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2470) | :closed_lock_with_key: | POST | `/api/v3/trade/grid/modify-neutral-grid-interval` | +| [getNeutralGridBotDetail()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2479) | :closed_lock_with_key: | GET | `/api/v3/trade/grid/neutral-bot-detail` | +| [getNeutralGridBotOrderDetails()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2485) | :closed_lock_with_key: | GET | `/api/v3/trade/grid/neutral-list-details` | +| [createBrokerSubAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2503) | :closed_lock_with_key: | POST | `/api/v3/broker/create-sub` | +| [getBrokerSubAccountList()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2515) | :closed_lock_with_key: | GET | `/api/v3/broker/sub-list` | +| [modifyBrokerSubAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2527) | :closed_lock_with_key: | POST | `/api/v3/broker/modify-sub` | +| [brokerSubWithdrawal()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2542) | :closed_lock_with_key: | POST | `/api/v3/broker/sub-withdrawal` | +| [getBrokerSubDepositAddress()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2554) | :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#L2566) | :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#L2578) | :closed_lock_with_key: | GET | `/api/v3/broker/commission` | +| [createBrokerSubApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2590) | :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#L2602) | :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#L2618) | :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#L2630) | :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#L2642) | :closed_lock_with_key: | GET | `/api/v3/p2p/ad-list` | +| [getP2pExchangeRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2648) | :closed_lock_with_key: | GET | `/api/v3/p2p/exchange-rate` | +| [simulateP2pFee()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2654) | :closed_lock_with_key: | POST | `/api/v3/p2p/fee-simulate` | +| [getP2pAdLimit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2660) | :closed_lock_with_key: | GET | `/api/v3/p2p/ad-limit` | +| [createP2pAd()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2666) | :closed_lock_with_key: | POST | `/api/v3/p2p/ad-create` | +| [updateP2pAd()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2672) | :closed_lock_with_key: | POST | `/api/v3/p2p/ad-update` | +| [operateP2pAd()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2676) | :closed_lock_with_key: | POST | `/api/v3/p2p/ad-operate` | +| [getP2pAdInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2680) | :closed_lock_with_key: | GET | `/api/v3/p2p/ad-info` | +| [getP2pMyAds()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2686) | :closed_lock_with_key: | GET | `/api/v3/p2p/my-ads` | +| [getP2pPendingOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2692) | :closed_lock_with_key: | GET | `/api/v3/p2p/pending-orders` | +| [getP2pAllOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2698) | :closed_lock_with_key: | GET | `/api/v3/p2p/all-orders` | +| [getP2pOrderInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2704) | :closed_lock_with_key: | GET | `/api/v3/p2p/order-info` | +| [confirmP2pOrderPayment()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2710) | :closed_lock_with_key: | POST | `/api/v3/p2p/order-pay` | +| [releaseP2pOrderAsset()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2716) | :closed_lock_with_key: | POST | `/api/v3/p2p/order-release` | +| [getP2pUserInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2722) | :closed_lock_with_key: | GET | `/api/v3/p2p/user-info` | +| [getP2pCurrencies()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2726) | :closed_lock_with_key: | GET | `/api/v3/p2p/currencies` | +| [getP2pPayMethods()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2730) | :closed_lock_with_key: | GET | `/api/v3/p2p/pay-method` | +| [getP2pBalance()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2734) | :closed_lock_with_key: | GET | `/api/v3/p2p/balance` | +| [getEarnEliteProducts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2746) | :closed_lock_with_key: | GET | `/api/v3/earn/elite-product` | +| [getEarnEliteAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2750) | :closed_lock_with_key: | GET | `/api/v3/earn/elite-assets` | +| [getEarnEliteRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2754) | :closed_lock_with_key: | GET | `/api/v3/earn/elite-records` | +| [getEarnEliteSubscribeInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2760) | :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#L2766) | :closed_lock_with_key: | POST | `/api/v3/earn/elite-subscribe` | +| [getEarnEliteSubscribeResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2772) | :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#L2778) | :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#L2784) | :closed_lock_with_key: | POST | `/api/v3/earn/elite-redeem` | # websocket-api-client.ts @@ -580,7 +629,9 @@ This client provides WebSocket API endpoints which allow for faster interactions | Function | AUTH | HTTP Method | Endpoint | | -------- | :------: | :------: | -------- | -| [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 +| [submitNewOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/websocket-api-client.ts#L85) | | WS | `place-order` | +| [placeBatchOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/websocket-api-client.ts#L104) | | WS | `batch-place` | +| [cancelOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/websocket-api-client.ts#L128) | | WS | `cancel-order` | +| [cancelBatchOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/websocket-api-client.ts#L147) | | WS | `batch-cancel` | +| [modifyOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/websocket-api-client.ts#L159) | | WS | `modify-order` | +| [batchModifyOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/websocket-api-client.ts#L171) | | WS | `batch-modify` | \ No newline at end of file diff --git a/examples/apidoc/RestClientV3/Account/get-account-fee-rate.js b/examples/apidoc/RestClientV3/Account/get-account-fee-rate.js index b95a3f4..bfaa5c6 100644 --- a/examples/apidoc/RestClientV3/Account/get-account-fee-rate.js +++ b/examples/apidoc/RestClientV3/Account/get-account-fee-rate.js @@ -12,6 +12,7 @@ client .getFeeRate({ category: 'SPOT', symbol: 'BTCUSDT', + rpiFlag: 'no', }) .then((response) => { console.log(response); diff --git a/examples/apidoc/RestClientV3/Account/get-eligible-discount-rate.js b/examples/apidoc/RestClientV3/Account/get-eligible-discount-rate.js new file mode 100644 index 0000000..f8687b9 --- /dev/null +++ b/examples/apidoc/RestClientV3/Account/get-eligible-discount-rate.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 + .getEligibleDiscountRate() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Account/get-funding-financial-records.js b/examples/apidoc/RestClientV3/Account/get-funding-financial-records.js new file mode 100644 index 0000000..12ad3fd --- /dev/null +++ b/examples/apidoc/RestClientV3/Account/get-funding-financial-records.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 + .getFundingFinancialRecords({ + coin: 'BTC', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Account/get-max-open-available.js b/examples/apidoc/RestClientV3/Account/get-max-open-available.js index 8a2354f..4af3e53 100644 --- a/examples/apidoc/RestClientV3/Account/get-max-open-available.js +++ b/examples/apidoc/RestClientV3/Account/get-max-open-available.js @@ -14,6 +14,7 @@ client symbol: 'BTCUSDT', orderType: 'market', side: 'sell', + autoBorrow: 'no', }) .then((response) => { console.log(response); diff --git a/examples/apidoc/RestClientV3/Account/get-small-assets-history.js b/examples/apidoc/RestClientV3/Account/get-small-assets-history.js new file mode 100644 index 0000000..46acb74 --- /dev/null +++ b/examples/apidoc/RestClientV3/Account/get-small-assets-history.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 + .getSmallAssetsHistory() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Account/get-small-assets.js b/examples/apidoc/RestClientV3/Account/get-small-assets.js new file mode 100644 index 0000000..9e8fecd --- /dev/null +++ b/examples/apidoc/RestClientV3/Account/get-small-assets.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 + .getSmallAssets() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Account/small-assets-trade.js b/examples/apidoc/RestClientV3/Account/small-assets-trade.js new file mode 100644 index 0000000..d4a7a23 --- /dev/null +++ b/examples/apidoc/RestClientV3/Account/small-assets-trade.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 + .tradeSmallAssets({ + fromCoinList: ['DOGE'], + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/CFD/Account/get-financial-records.js b/examples/apidoc/RestClientV3/CFD/Account/get-financial-records.js new file mode 100644 index 0000000..df5ea67 --- /dev/null +++ b/examples/apidoc/RestClientV3/CFD/Account/get-financial-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 + .getCfdFinancialRecords() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/CFD/Account/get-fund-detail.js b/examples/apidoc/RestClientV3/CFD/Account/get-fund-detail.js new file mode 100644 index 0000000..3726a51 --- /dev/null +++ b/examples/apidoc/RestClientV3/CFD/Account/get-fund-detail.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 + .getCfdFundDetail() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/CFD/Account/get-instruments.js b/examples/apidoc/RestClientV3/CFD/Account/get-instruments.js new file mode 100644 index 0000000..150cd7a --- /dev/null +++ b/examples/apidoc/RestClientV3/CFD/Account/get-instruments.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 + .getCfdInstruments({ + symbol: 'XAUUSD', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/CFD/Account/get-transfer-records.js b/examples/apidoc/RestClientV3/CFD/Account/get-transfer-records.js new file mode 100644 index 0000000..07a108a --- /dev/null +++ b/examples/apidoc/RestClientV3/CFD/Account/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 + .getCfdTransferRecords() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/CFD/Account/transfer.js b/examples/apidoc/RestClientV3/CFD/Account/transfer.js new file mode 100644 index 0000000..319fcea --- /dev/null +++ b/examples/apidoc/RestClientV3/CFD/Account/transfer.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 + .cfdTransfer({ + coin: 'USDT', + amount: '100', + accountType: 'uta', + direction: 'in', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/CFD/Market/get-kline-candlestick-history.js b/examples/apidoc/RestClientV3/CFD/Market/get-kline-candlestick-history.js new file mode 100644 index 0000000..a7b8db4 --- /dev/null +++ b/examples/apidoc/RestClientV3/CFD/Market/get-kline-candlestick-history.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 + .getCfdHistoryCandlestick({ + symbol: 'XAUUSD', + interval: '1m', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/CFD/Market/get-tickers.js b/examples/apidoc/RestClientV3/CFD/Market/get-tickers.js new file mode 100644 index 0000000..618ad4d --- /dev/null +++ b/examples/apidoc/RestClientV3/CFD/Market/get-tickers.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 + .getCfdTickers({ + symbol: 'XAUUSD', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/CFD/Trade/cancel-all-cfd-orders.js b/examples/apidoc/RestClientV3/CFD/Trade/cancel-all-cfd-orders.js new file mode 100644 index 0000000..fb02086 --- /dev/null +++ b/examples/apidoc/RestClientV3/CFD/Trade/cancel-all-cfd-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 + .cancelAllCfdOrders({ + symbol: 'XAUUSD', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/CFD/Trade/cancel-cfd-order.js b/examples/apidoc/RestClientV3/CFD/Trade/cancel-cfd-order.js new file mode 100644 index 0000000..1a830dd --- /dev/null +++ b/examples/apidoc/RestClientV3/CFD/Trade/cancel-cfd-order.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 + .cancelCfdOrder({ + orderId: '111111111111111111', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/CFD/Trade/close-all-cfd-positions.js b/examples/apidoc/RestClientV3/CFD/Trade/close-all-cfd-positions.js new file mode 100644 index 0000000..07ef03f --- /dev/null +++ b/examples/apidoc/RestClientV3/CFD/Trade/close-all-cfd-positions.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 + .closeAllCfdPositions({ + symbol: 'XAUUSD', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/CFD/Trade/close-cfd-positions.js b/examples/apidoc/RestClientV3/CFD/Trade/close-cfd-positions.js new file mode 100644 index 0000000..780c1ec --- /dev/null +++ b/examples/apidoc/RestClientV3/CFD/Trade/close-cfd-positions.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 + .closeCfdPositions({ + positionId: '111111111111111111', + qty: '1', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/CFD/Trade/get-cfd-current-positions.js b/examples/apidoc/RestClientV3/CFD/Trade/get-cfd-current-positions.js new file mode 100644 index 0000000..7167c7a --- /dev/null +++ b/examples/apidoc/RestClientV3/CFD/Trade/get-cfd-current-positions.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 + .getCfdCurrentPositions() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/CFD/Trade/get-cfd-order-history.js b/examples/apidoc/RestClientV3/CFD/Trade/get-cfd-order-history.js new file mode 100644 index 0000000..5aad06c --- /dev/null +++ b/examples/apidoc/RestClientV3/CFD/Trade/get-cfd-order-history.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 + .getCfdOrderHistory({ + symbol: 'XAUUSD', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/CFD/Trade/get-cfd-unfilled-orders.js b/examples/apidoc/RestClientV3/CFD/Trade/get-cfd-unfilled-orders.js new file mode 100644 index 0000000..dfc0d75 --- /dev/null +++ b/examples/apidoc/RestClientV3/CFD/Trade/get-cfd-unfilled-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 + .getCfdUnfilledOrders({ + symbol: 'XAUUSD', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/CFD/Trade/modify-cfd-order.js b/examples/apidoc/RestClientV3/CFD/Trade/modify-cfd-order.js new file mode 100644 index 0000000..e57d4ae --- /dev/null +++ b/examples/apidoc/RestClientV3/CFD/Trade/modify-cfd-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 + .modifyCfdOrder({ + orderId: '111111111111111111', + price: '2620.00', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/CFD/Trade/place-cfd-order.js b/examples/apidoc/RestClientV3/CFD/Trade/place-cfd-order.js new file mode 100644 index 0000000..9f367b2 --- /dev/null +++ b/examples/apidoc/RestClientV3/CFD/Trade/place-cfd-order.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 + .placeCfdOrder({ + symbol: 'XAUUSD', + orderType: 'market', + side: 'buy', + qty: '1', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Grid/add-investment-amount.js b/examples/apidoc/RestClientV3/Grid/add-investment-amount.js new file mode 100644 index 0000000..9ac61de --- /dev/null +++ b/examples/apidoc/RestClientV3/Grid/add-investment-amount.js @@ -0,0 +1,25 @@ +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 + .addGridInvestment({ + category: 'SPOT', + botId: 'botId', + coin: 'USDT', + size: '100', + fundsSource: ['uta'], + reinvestProfit: 'yes', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Grid/close-grid-bot.js b/examples/apidoc/RestClientV3/Grid/close-grid-bot.js new file mode 100644 index 0000000..7d17cf2 --- /dev/null +++ b/examples/apidoc/RestClientV3/Grid/close-grid-bot.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 + .closeGridBot({ + botId: 'botId', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Grid/create-grid-bot.js b/examples/apidoc/RestClientV3/Grid/create-grid-bot.js new file mode 100644 index 0000000..4ac9340 --- /dev/null +++ b/examples/apidoc/RestClientV3/Grid/create-grid-bot.js @@ -0,0 +1,32 @@ +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 + .createGridBot({ + category: 'SPOT', + symbol: 'BTCUSDT', + maxPrice: '70000', + minPrice: '60000', + gridNum: '10', + gridOrderMode: 'arithmetic', + investmentAmount: [ + { + coin: 'USDT', + amount: '1000', + }, + ], + fundsSource: ['uta'], + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Grid/create-neutral-grid-bot.js b/examples/apidoc/RestClientV3/Grid/create-neutral-grid-bot.js new file mode 100644 index 0000000..bbadc7e --- /dev/null +++ b/examples/apidoc/RestClientV3/Grid/create-neutral-grid-bot.js @@ -0,0 +1,33 @@ +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 + .createNeutralGridBot({ + category: 'USDT-FUTURES', + symbol: 'BTCUSDT', + maxPrice: '70000', + minPrice: '60000', + gridNum: '10', + gridOrderMode: 'arithmetic', + investmentAmount: [ + { + coin: 'USDT', + amount: '1000', + }, + ], + fundsSource: ['uta'], + leverage: '5', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Grid/get-grid-bot-detail.js b/examples/apidoc/RestClientV3/Grid/get-grid-bot-detail.js new file mode 100644 index 0000000..6cb9580 --- /dev/null +++ b/examples/apidoc/RestClientV3/Grid/get-grid-bot-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 + .getGridBotDetail({ + botId: 'botId', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Grid/get-grid-bot-order-details.js b/examples/apidoc/RestClientV3/Grid/get-grid-bot-order-details.js new file mode 100644 index 0000000..58a5edb --- /dev/null +++ b/examples/apidoc/RestClientV3/Grid/get-grid-bot-order-details.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 + .getGridBotOrderDetails({ + category: 'SPOT', + botId: 'botId', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Grid/get-neutral-grid-bot-detail.js b/examples/apidoc/RestClientV3/Grid/get-neutral-grid-bot-detail.js new file mode 100644 index 0000000..668f475 --- /dev/null +++ b/examples/apidoc/RestClientV3/Grid/get-neutral-grid-bot-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 + .getNeutralGridBotDetail({ + botId: 'botId', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Grid/get-neutral-grid-bot-order-details.js b/examples/apidoc/RestClientV3/Grid/get-neutral-grid-bot-order-details.js new file mode 100644 index 0000000..54e3c78 --- /dev/null +++ b/examples/apidoc/RestClientV3/Grid/get-neutral-grid-bot-order-details.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 + .getNeutralGridBotOrderDetails({ + category: 'USDT-FUTURES', + botId: 'botId', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Grid/modify-grid-bot-parameters.js b/examples/apidoc/RestClientV3/Grid/modify-grid-bot-parameters.js new file mode 100644 index 0000000..d833ac7 --- /dev/null +++ b/examples/apidoc/RestClientV3/Grid/modify-grid-bot-parameters.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 + .modifyGridBot({ + botId: 'botId', + category: 'SPOT', + takeProfit: '75000', + stopLoss: '55000', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Grid/modify-grid-interval-and-grid-number.js b/examples/apidoc/RestClientV3/Grid/modify-grid-interval-and-grid-number.js new file mode 100644 index 0000000..6dacfac --- /dev/null +++ b/examples/apidoc/RestClientV3/Grid/modify-grid-interval-and-grid-number.js @@ -0,0 +1,24 @@ +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 + .modifyGridInterval({ + category: 'SPOT', + botId: 'botId', + maxPrice: '72000', + minPrice: '58000', + gridNum: '12', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Grid/modify-neutral-grid-bot-parameters.js b/examples/apidoc/RestClientV3/Grid/modify-neutral-grid-bot-parameters.js new file mode 100644 index 0000000..c61aa70 --- /dev/null +++ b/examples/apidoc/RestClientV3/Grid/modify-neutral-grid-bot-parameters.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 + .modifyNeutralGridBot({ + botId: 'botId', + category: 'USDT-FUTURES', + takeProfit: '75000', + stopLoss: '55000', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Grid/modify-neutral-grid-interval-and-grid-number.js b/examples/apidoc/RestClientV3/Grid/modify-neutral-grid-interval-and-grid-number.js new file mode 100644 index 0000000..8f356d5 --- /dev/null +++ b/examples/apidoc/RestClientV3/Grid/modify-neutral-grid-interval-and-grid-number.js @@ -0,0 +1,24 @@ +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 + .modifyNeutralGridInterval({ + category: 'USDT-FUTURES', + botId: 'botId', + maxPrice: '72000', + minPrice: '58000', + gridNum: '12', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Grid/validate-grid-parameters.js b/examples/apidoc/RestClientV3/Grid/validate-grid-parameters.js new file mode 100644 index 0000000..b142bc4 --- /dev/null +++ b/examples/apidoc/RestClientV3/Grid/validate-grid-parameters.js @@ -0,0 +1,32 @@ +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 + .validateGridBot({ + category: 'SPOT', + symbol: 'BTCUSDT', + maxPrice: '70000', + minPrice: '60000', + gridNum: '10', + gridOrderMode: 'arithmetic', + investmentAmount: [ + { + coin: 'USDT', + amount: '1000', + }, + ], + fundsSource: ['uta'], + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Grid/validate-neutral-grid-parameters.js b/examples/apidoc/RestClientV3/Grid/validate-neutral-grid-parameters.js new file mode 100644 index 0000000..07042e4 --- /dev/null +++ b/examples/apidoc/RestClientV3/Grid/validate-neutral-grid-parameters.js @@ -0,0 +1,33 @@ +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 + .validateNeutralGridBot({ + category: 'USDT-FUTURES', + symbol: 'BTCUSDT', + maxPrice: '70000', + minPrice: '60000', + gridNum: '10', + gridOrderMode: 'arithmetic', + investmentAmount: [ + { + coin: 'USDT', + amount: '1000', + }, + ], + fundsSource: ['uta'], + leverage: '5', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Public/get-margin-loan.js b/examples/apidoc/RestClientV3/Public/get-margin-loan.js index 08eb7ed..25b7e9f 100644 --- a/examples/apidoc/RestClientV3/Public/get-margin-loan.js +++ b/examples/apidoc/RestClientV3/Public/get-margin-loan.js @@ -7,6 +7,7 @@ const client = new RestClientV3(); client .getMarginLoans({ coin: 'BTC', + level: 'vip0', }) .then((response) => { console.log(response); diff --git a/examples/apidoc/RestClientV3/Public/get-split-records.js b/examples/apidoc/RestClientV3/Public/get-split-records.js new file mode 100644 index 0000000..65ab128 --- /dev/null +++ b/examples/apidoc/RestClientV3/Public/get-split-records.js @@ -0,0 +1,14 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3(); + +client + .getSplitRecords() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Reality/get-company-overview.js b/examples/apidoc/RestClientV3/Reality/get-company-overview.js new file mode 100644 index 0000000..8c277d5 --- /dev/null +++ b/examples/apidoc/RestClientV3/Reality/get-company-overview.js @@ -0,0 +1,16 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3(); + +client + .getRealityCompanyOverview({ + code: 'MU', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Reality/get-dividends.js b/examples/apidoc/RestClientV3/Reality/get-dividends.js new file mode 100644 index 0000000..5929dae --- /dev/null +++ b/examples/apidoc/RestClientV3/Reality/get-dividends.js @@ -0,0 +1,16 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3(); + +client + .getRealityDividends({ + code: 'MU', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Reality/get-earnings-forecast.js b/examples/apidoc/RestClientV3/Reality/get-earnings-forecast.js new file mode 100644 index 0000000..86f21f9 --- /dev/null +++ b/examples/apidoc/RestClientV3/Reality/get-earnings-forecast.js @@ -0,0 +1,16 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3(); + +client + .getRealityEarningsForecast({ + code: 'MU', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Reality/get-executive-shareholdings.js b/examples/apidoc/RestClientV3/Reality/get-executive-shareholdings.js new file mode 100644 index 0000000..ce8f53f --- /dev/null +++ b/examples/apidoc/RestClientV3/Reality/get-executive-shareholdings.js @@ -0,0 +1,16 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3(); + +client + .getRealityExecutiveShareholdings({ + code: 'MU', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Reality/get-inner-trades.js b/examples/apidoc/RestClientV3/Reality/get-inner-trades.js new file mode 100644 index 0000000..4b0f56a --- /dev/null +++ b/examples/apidoc/RestClientV3/Reality/get-inner-trades.js @@ -0,0 +1,16 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3(); + +client + .getRealityInnerTrades({ + code: 'MU', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Reality/get-market-calendar.js b/examples/apidoc/RestClientV3/Reality/get-market-calendar.js new file mode 100644 index 0000000..b2fce46 --- /dev/null +++ b/examples/apidoc/RestClientV3/Reality/get-market-calendar.js @@ -0,0 +1,14 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3(); + +client + .getRealityMarketCalendar() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Reality/get-market-states.js b/examples/apidoc/RestClientV3/Reality/get-market-states.js new file mode 100644 index 0000000..0cddd84 --- /dev/null +++ b/examples/apidoc/RestClientV3/Reality/get-market-states.js @@ -0,0 +1,14 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3(); + +client + .getRealityMarketStates() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Reality/get-share-capital-change.js b/examples/apidoc/RestClientV3/Reality/get-share-capital-change.js new file mode 100644 index 0000000..964c111 --- /dev/null +++ b/examples/apidoc/RestClientV3/Reality/get-share-capital-change.js @@ -0,0 +1,16 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3(); + +client + .getRealityShareCapitalChange({ + code: 'MU', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Reality/get-sharehold-detail.js b/examples/apidoc/RestClientV3/Reality/get-sharehold-detail.js new file mode 100644 index 0000000..6f46744 --- /dev/null +++ b/examples/apidoc/RestClientV3/Reality/get-sharehold-detail.js @@ -0,0 +1,16 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3(); + +client + .getRealityShareholdDetail({ + code: 'MU', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Reality/get-stock-info.js b/examples/apidoc/RestClientV3/Reality/get-stock-info.js new file mode 100644 index 0000000..30570ab --- /dev/null +++ b/examples/apidoc/RestClientV3/Reality/get-stock-info.js @@ -0,0 +1,16 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3(); + +client + .getRealityStockInfo({ + symbol: 'RAAPLUSDT', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Reality/get-suspension-resumption-info.js b/examples/apidoc/RestClientV3/Reality/get-suspension-resumption-info.js new file mode 100644 index 0000000..f8079be --- /dev/null +++ b/examples/apidoc/RestClientV3/Reality/get-suspension-resumption-info.js @@ -0,0 +1,16 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3(); + +client + .getRealitySuspensionResumptionInfo({ + code: 'MU', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Reality/get-valuation-indicators.js b/examples/apidoc/RestClientV3/Reality/get-valuation-indicators.js new file mode 100644 index 0000000..939c87b --- /dev/null +++ b/examples/apidoc/RestClientV3/Reality/get-valuation-indicators.js @@ -0,0 +1,16 @@ +import { RestClientV3 } from 'bitget-api'; +// or, if require is preferred: +// const { RestClientV3 } = require('bitget-api'); + +const client = new RestClientV3(); + +client + .getRealityValuationIndicators({ + code: 'MU', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Strategy/get-strategy-sub-orders.js b/examples/apidoc/RestClientV3/Strategy/get-strategy-sub-orders.js new file mode 100644 index 0000000..76ed1e2 --- /dev/null +++ b/examples/apidoc/RestClientV3/Strategy/get-strategy-sub-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 + .getStrategySubOrders({ + orderId: '111111111111111111', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/RestClientV3/Strategy/place-strategy-order.js b/examples/apidoc/RestClientV3/Strategy/place-strategy-order.js index 39d77cc..2153ce2 100644 --- a/examples/apidoc/RestClientV3/Strategy/place-strategy-order.js +++ b/examples/apidoc/RestClientV3/Strategy/place-strategy-order.js @@ -12,6 +12,7 @@ client .submitStrategyOrder({ category: 'USDT-FUTURES', symbol: 'BTCUSDT', + type: 'tpsl', posSide: 'long', stopLoss: '99000', takeProfit: '100800', diff --git a/examples/apidoc/RestClientV3/Trade/batch-modify-orders.js b/examples/apidoc/RestClientV3/Trade/batch-modify-orders.js index 9aa0c4c..60e0369 100644 --- a/examples/apidoc/RestClientV3/Trade/batch-modify-orders.js +++ b/examples/apidoc/RestClientV3/Trade/batch-modify-orders.js @@ -15,12 +15,18 @@ client qty: '123', price: '123', autoCancel: 'no', + symbol: 'BTCUSDT', + category: 'SPOT', + requestId: 123456, }, { orderId: '2', qty: '123', price: '123', autoCancel: 'no', + symbol: 'BTCUSDT', + category: 'SPOT', + requestId: 123457, }, ]) .then((response) => { diff --git a/examples/apidoc/RestClientV3/Trade/modify-order.js b/examples/apidoc/RestClientV3/Trade/modify-order.js index bd31b23..324e531 100644 --- a/examples/apidoc/RestClientV3/Trade/modify-order.js +++ b/examples/apidoc/RestClientV3/Trade/modify-order.js @@ -14,6 +14,9 @@ client qty: '123', price: '123', autoCancel: 'no', + symbol: 'BTCUSDT', + category: 'SPOT', + requestId: 123456, }) .then((response) => { console.log(response); diff --git a/examples/apidoc/RestClientV3/Trade/place-order.js b/examples/apidoc/RestClientV3/Trade/place-order.js index 17fadc8..a33220f 100644 --- a/examples/apidoc/RestClientV3/Trade/place-order.js +++ b/examples/apidoc/RestClientV3/Trade/place-order.js @@ -19,6 +19,7 @@ client posSide: 'long', timeInForce: 'gtc', reduceOnly: 'no', + autoBorrow: 'no', }) .then((response) => { console.log(response); diff --git a/llms.txt b/llms.txt index 5091c9c..d551b57 100644 --- a/llms.txt +++ b/llms.txt @@ -98,11 +98,14 @@ src/ v3/ account.ts broker.ts + cfd.ts copytrading.ts earn.ts + grid.ts loan.ts p2p.ts public.ts + reality.ts stockplus.ts strategy.ts trade.ts @@ -120,11 +123,14 @@ src/ v3/ account.ts broker.ts + cfd.ts copytrading.ts earn.ts + grid.ts loan.ts p2p.ts public.ts + reality.ts stockplus.ts strategy.ts trade.ts @@ -146,6 +152,7 @@ webpack/ .eslintrc.cjs .gitignore .jshintrc +.npmrc .nvmrc .prettierrc jest.config.ts @@ -750,6 +757,319 @@ export interface GetMarginLiquidationOrdersRequestV2 { idLessThan?: string; } +================ +File: src/types/request/v3/cfd.ts +================ +export type CfdYesNoV3 = 'yes' | 'no'; +⋮---- +export type CfdOrderTypeV3 = 'limit' | 'market'; +⋮---- +export type CfdSideV3 = 'buy' | 'sell'; +⋮---- +export type CfdKlineIntervalV3 = '1m' | '15m' | '1h' | '4h' | '1d'; +⋮---- +export type CfdTransferAccountTypeV3 = 'funding' | 'uta'; +⋮---- +export type CfdTransferDirectionV3 = 'in' | 'out'; +⋮---- +export interface GetCfdTickersRequestV3 { + symbol?: string; +} +⋮---- +export interface GetCfdHistoryCandlestickRequestV3 { + symbol: string; + interval: CfdKlineIntervalV3; + side?: CfdSideV3; + startTime?: string; + endTime?: string; + limit?: string; +} +⋮---- +export interface PlaceCfdOrderRequestV3 { + symbol: string; + orderType: CfdOrderTypeV3; + side: CfdSideV3; + qty: string; + price?: string; + takeProfit?: string; + stopLoss?: string; +} +⋮---- +export interface ModifyCfdOrderRequestV3 { + orderId: string; + price?: string; + takeProfit?: string; + stopLoss?: string; +} +⋮---- +export interface CancelCfdOrderRequestV3 { + orderId: string; +} +⋮---- +export interface CancelAllCfdOrdersRequestV3 { + symbol?: string; +} +⋮---- +export interface CloseCfdPositionsRequestV3 { + positionId: string; + qty: string; +} +⋮---- +export interface CloseAllCfdPositionsRequestV3 { + symbol?: string; +} +⋮---- +export interface GetCfdUnfilledOrdersRequestV3 { + symbol?: string; + subUid?: string; +} +⋮---- +export interface GetCfdOrderHistoryRequestV3 { + symbol: string; + subUid?: string; + startTime?: string; + endTime?: string; + limit?: string; +} +⋮---- +export interface GetCfdCurrentPositionsRequestV3 { + symbol?: string; + subUid?: string; +} +⋮---- +export interface CfdTransferRequestV3 { + coin: string; + amount: string; + accountType: CfdTransferAccountTypeV3; + direction: CfdTransferDirectionV3; +} +⋮---- +export interface GetCfdTransferRecordsRequestV3 { + transferId?: string; + subUid?: string; + startTime?: string; + endTime?: string; + direction?: CfdTransferDirectionV3; + limit?: string; +} +⋮---- +export interface GetCfdFinancialRecordsRequestV3 { + type?: string; + startTime?: string; + endTime?: string; + limit?: string; +} +⋮---- +export interface GetCfdInstrumentsRequestV3 { + symbol?: string; +} + +================ +File: src/types/request/v3/grid.ts +================ +export type GridCategoryV3 = 'SPOT' | 'USDT-FUTURES' | 'USDC-FUTURES'; +⋮---- +export type NeutralGridCategoryV3 = 'USDT-FUTURES' | 'USDC-FUTURES'; +⋮---- +export type GridFundsSourceV3 = 'funding' | 'uta' | 'otc'; +⋮---- +export type GridYesNoV3 = 'yes' | 'no'; +⋮---- +export type GridOrderModeV3 = 'arithmetic' | 'geometric'; +⋮---- +export type GridTypeV3 = 'long' | 'short' | 'neutral' | 'netural'; +⋮---- +export type GridTriggerConditionV3 = 'instant' | 'price' | 'rsi' | 'boll'; +⋮---- +export type GridTerminationConditionV3 = 'rsi' | 'boll'; +⋮---- +export type GridAdjustTypeV3 = 'increase' | 'decrease'; +⋮---- +export interface GridInvestmentAmountV3 { + coin: string; + amount: string; +} +⋮---- +export interface GridIndicatorParamsV3 { + indicatorLength?: string; + threshold?: string; + multiplier?: string; + interval?: string; +} +⋮---- +export interface GridBotIdRequestV3 { + botId: string; +} +⋮---- +export interface GetGridBotDetailRequestV3 { + botId: string; +} +⋮---- +export interface GetGridBotOrderDetailsRequestV3 { + category: GridCategoryV3; + botId: string; +} +⋮---- +export interface CloseGridBotRequestV3 { + botId: string; +} +⋮---- +export interface AddGridInvestmentRequestV3 { + category: GridCategoryV3; + botId: string; + coin?: string; + size?: string; + fundsSource: GridFundsSourceV3[]; + adjustType?: GridAdjustTypeV3; + reinvestProfit?: GridYesNoV3; +} +⋮---- +export interface CreateGridBotRequestV3 { + category: GridCategoryV3; + symbol: string; + maxPrice: string; + minPrice: string; + gridNum: string; + gridOrderMode: GridOrderModeV3; + investmentAmount: GridInvestmentAmountV3[]; + fundsSource?: GridFundsSourceV3[]; + slippage?: string; + autoTransferProfits?: GridYesNoV3; + gridType?: GridTypeV3; + leverage?: string; + autoReserveMargin?: GridYesNoV3; + reservedMargin?: string; + triggerCondition?: GridTriggerConditionV3; + triggerParams?: GridIndicatorParamsV3[]; + triggerPrice?: string; + terminationCondition?: GridTerminationConditionV3; + terminationParams?: GridIndicatorParamsV3[]; + terminationSell?: GridYesNoV3; + stopLoss?: string; + takeProfit?: string; + trailingGrid?: GridYesNoV3; + movingAverageGains?: string; + stopUpwardPrice?: string; + hodlMode?: GridYesNoV3; + marketOpen?: GridYesNoV3; + lossReserve?: GridYesNoV3; +} +⋮---- +export type ValidateGridBotRequestV3 = CreateGridBotRequestV3; +⋮---- +export interface ModifyGridBotRequestV3 { + botId: string; + category: GridCategoryV3; + takeProfit?: string; + stopLoss?: string; + terminationCondition?: GridTerminationConditionV3; + terminationParams?: GridIndicatorParamsV3[]; + hodlMode?: GridYesNoV3; + autoTransferProfits?: GridYesNoV3; +} +⋮---- +export interface ModifyGridIntervalRequestV3 { + category: GridCategoryV3; + botId: string; + maxPrice: string; + minPrice: string; + gridNum: string; +} +⋮---- +export interface CreateNeutralGridBotRequestV3 { + category: NeutralGridCategoryV3; + symbol: string; + maxPrice: string; + minPrice: string; + gridNum: string; + gridOrderMode: GridOrderModeV3; + fundsSource?: GridFundsSourceV3[]; + leverage?: string; + investmentAmount: GridInvestmentAmountV3[]; + triggerPrice?: string; + stopLoss?: string; + takeProfit?: string; + autoTransferProfits?: GridYesNoV3; +} +⋮---- +export type ValidateNeutralGridBotRequestV3 = CreateNeutralGridBotRequestV3; +⋮---- +export interface ModifyNeutralGridBotRequestV3 { + botId: string; + category: NeutralGridCategoryV3; + takeProfit?: string; + stopLoss?: string; + autoTransferProfits?: GridYesNoV3; +} +⋮---- +export interface ModifyNeutralGridIntervalRequestV3 { + category: NeutralGridCategoryV3; + botId: string; + maxPrice: string; + minPrice: string; + gridNum: string; +} +⋮---- +export interface GetNeutralGridBotDetailRequestV3 { + botId: string; +} +⋮---- +export interface GetNeutralGridBotOrderDetailsRequestV3 { + category: NeutralGridCategoryV3 | GridCategoryV3; + botId: string; +} + +================ +File: src/types/request/v3/reality.ts +================ +export interface GetRealityCompanyOverviewRequestV3 { + code: string; +} +⋮---- +export interface GetRealityValuationIndicatorsRequestV3 { + code: string; +} +⋮---- +export interface GetRealityEarningsForecastRequestV3 { + code: string; +} +⋮---- +export interface GetRealitySuspensionResumptionInfoRequestV3 { + code: string; +} +⋮---- +export interface GetRealityDividendsRequestV3 { + code: string; + limit?: string; + cursor?: string; +} +⋮---- +export interface GetRealityShareCapitalChangeRequestV3 { + code: string; +} +⋮---- +export interface GetRealityInnerTradesRequestV3 { + code: string; + limit?: string; + cursor?: string; +} +⋮---- +export interface GetRealityExecutiveShareholdingsRequestV3 { + code: string; + limit?: string; + cursor?: string; +} +⋮---- +export interface GetRealityShareholdDetailRequestV3 { + code: string; + limit?: string; + cursor?: string; +} +⋮---- +export interface GetRealityStockInfoRequestV3 { + symbol?: string; +} + ================ File: src/types/request/shared.ts ================ @@ -1532,75 +1852,519 @@ export interface MarginLiquidationOrderV2 { } ================ -File: src/types/websockets/ws-api-response.ts +File: src/types/response/v3/cfd.ts ================ -export interface WSAPIPlaceOrderResponseV3 { +import type { CfdOrderTypeV3, CfdSideV3 } from '../../request/v3/cfd.js'; +⋮---- +export interface CfdTickerV3 { symbol: string; - orderId: string; - clientOid: string; - cTime: string; + openPriceChange: string; + highPrice: string; + lowPrice: string; + quoteTime: string; } - -================ -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'; ⋮---- -/** - * 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 CfdCandlestickV3 extends Array { + 0: string; + 1: string; + 2: string; + 3: string; + 4: 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 PlaceCfdOrderResponseV3 { + trxId: 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 ModifyCfdOrderResponseV3 { + orderId: string; +} ⋮---- -constructor( - options?: WSClientConfigurableOptions & - Partial, - logger?: DefaultLogger, -) +export interface CfdUnfilledOrderV3 { + symbol: string; + orderType: CfdOrderTypeV3 | string; + side: CfdSideV3 | string; + price: string; + qty: string; + takeProfit?: string; + stopLoss?: string; + trxId: string; + orderId: string; +} ⋮---- -public getWSClient(): WebsocketClientV3 +export interface CfdHistoryOrderV3 { + symbol: string; + orderType: CfdOrderTypeV3 | string; + side: CfdSideV3 | string; + price: string; + qty: string; + cumExecQty?: string; + takeProfit?: string; + stopLoss?: string; + status: string; + trxId: string; + orderId: string; +} +⋮---- +export interface CfdOrderHistoryV3 { + list: CfdHistoryOrderV3[]; +} +⋮---- +export interface CfdCurrentPositionV3 { + positionId: string; + symbol: string; + orderType: CfdOrderTypeV3 | string; + side: CfdSideV3 | string; + qty: string; + openPrice: string; + takeProfit?: string; + stopLoss?: string; + interest: string; + unrealizedPnl: string; + totalProfit: string; +} +⋮---- +export interface CfdFundDetailV3 { + leverage: string; + balance: string; + credit: string; + marginStopOut: string; + marginUsed: string; + marginCall: string; + marginFree: string; + marginLevel: string; + equity: string; + pnl: string; + status: string; + swap: string; + frozen: string; + currency: string; +} +⋮---- +export interface CfdTransferResponseV3 { + transferId: string; +} +⋮---- +export interface CfdTransferRecordV3 { + transferId: string; + coin: string; + amount: string; + direction: string; + status: string; + accountType: string; + createdTime: string; + updatedTime: string; +} +⋮---- +export interface CfdTransferRecordsV3 { + list: CfdTransferRecordV3[]; + cursor?: string; +} +⋮---- +export interface CfdFinancialRecordV3 { + id: string | number; + symbol: string; + side: string | number; + qty: string | number; + swap: string | number; + fee: string | number; + cashFlow: string | number; + balanceBefore: string | number; + balanceChange: string | number; + balanceAfter: string | number; + creditBefore: string | number; + creditChange: string | number; + creditAfter: string | number; + openPrice: string | number; + closePrice: string | number; + orderId: string | number; + ts: string | number; +} +⋮---- +export interface CfdInstrumentV3 { + symbol: string; + onlineTime: string; + currency: string; + digits: string; + spread: string; + contractSize: string; + marginCurrency: string; + profitCurrency: string; + stopLevel: string; + enable: string; + marginPercent: string; + initialMargin: string; + marginMode: string; + maintMargin: string; + maintMarginRateBuy: string; + maintMarginRateSell: string; + initialMarginRateBuy: string; + initialMarginRateSell: string; + maxVolume: string; + minVolume: string; + stepVolume: string; + priceCurrency: string; + tickSize: string; + tickValue: string; + leverage: string; + tradeTime: string; + commissionType: string; + commissionRate: string; + symbolCategory: string; + exchangeRate: string; + marginUsdRate: string; +} + +================ +File: src/types/response/v3/grid.ts +================ +import type { GridIndicatorParamsV3 } from '../../request/v3/grid.js'; +⋮---- +export interface GridBotIdResponseV3 { + botId: string; +} +⋮---- +export interface GridValidateResponseV3 { + valid: string; + reason?: string; + minInvestment?: string; +} +⋮---- +export interface GridBotOrderItemV3 { + orderId: string; + delegateCount: string; + delegatePrice: string; + changeRequired: number | string; +} +⋮---- +export interface GridBotOrderDetailsV3 { + botId: string; + symbol: string; + buyOrderList: GridBotOrderItemV3[]; + sellOrderList: GridBotOrderItemV3[]; +} +⋮---- +export interface GridBotDetailV3 { + botId: string; + symbol: string; + status: string; + totalProfit: string; + roi: string; + gridProfit: string; + gridProfitRate: string; + unpairedProfit: string; + unpairedProfitRate: string; + margin?: string; + arbitrageAPR: string; + totalAPR: string; + createdTime: string; + runningTime: string; + currentBaseBalance?: string; + currentQuoteBalance?: string; + initialBaseHoldings?: string; + initialQuoteHoldings?: string; + reservedBaseTradingFee?: string; + reservedQuoteTradingFee?: string; + gridStartPrice?: string; + gridType?: string; + maxPrice: string; + minPrice: string; + gridNum: string; + gridOrderMode: string; + baseInvestmentCoin?: string; + baseInvestmentAmount?: string; + quoteInvestmentCoin?: string; + quoteInvestmentAmount?: string; + slippage?: string; + triggerCondition?: string; + triggerParams?: GridIndicatorParamsV3[]; + triggerPrice?: string; + terminationCondition?: string; + terminationParams?: GridIndicatorParamsV3[]; + terminationSell?: string; + stopLoss?: string; + takeProfit?: string; + hodlMode?: string; + autoTransferProfits?: string; + arbitrageCount?: string; + terminationReason?: string; +} +⋮---- +export interface NeutralGridBotDetailV3 { + botId: string; + symbol: string; + status: string; + totalProfit: string; + roi: string; + gridProfit: string; + gridProfitRate: string; + unpairedProfit: string; + unpairedProfitRate: string; + margin?: string; + arbitrageAPR: string; + totalAPR: string; + createdTime: string; + runningTime: string; + gridStartPrice?: string; + maxPrice: string; + minPrice: string; + gridNum: string; + gridOrderMode: string; + triggerPrice?: string; + leverage?: string; + stopLoss?: string; + takeProfit?: string; + holdPosition?: string; + oneGridMinProfit?: string; + oneGridMaxProfit?: string; + autoTransferProfits?: string; +} + +================ +File: src/types/response/v3/reality.ts +================ +export interface RealityCompanyOverviewV3 { + peRatio: string; + pbRatio: string; + totalShares: string; + marketCap: string; + high52Week: string; + low52Week: string; + code: string; + name: string; + ListingDate: string; + employees: string; + companyAddress: string; +} +⋮---- +export interface RealityValuationIndicatorsV3 { + date: string; + pb: string; + pbEd: string; + pbPd: string; + pbMrq: string; + pe: string; + peLyr: string; + peTtmEd: string; + peTtmPd: string; + ps: string; + psLyr: string; + psTtmEd: string; + psTtmPd: string; + pcf: string; + pcfNet: string; + pcfNetTtmEd: string; + pcfNetTtmPd: string; + pcfTtmEd: string; + pcfTtmPd: string; + evEbitda: string; + equityValue: string; + grossEv: string; + netEv: string; + tmvUsd: string; + cirTmvUsd: string; + dividendYieldTtm: string; +} +⋮---- +export interface RealityEarningsForecastV3 { + fiscalYear: string; + publicationDeadline: string; + isActual: boolean; + revenue: string; + ebit: string; + netIncomeParent: string; + eps: string; + bps: string; + cfps: string; + roe: string; + roa: string; + currency: string; +} +⋮---- +export interface RealitySuspensionResumptionInfoV3 { + code: string; + name: string; + suspensionDate: string; + suspensionTime: string; + suspensionReason: string; + suspensionPrice: string; + resumptionDate: string; + resumptionQuoteTime: string; + resumptionTradingTime: string; +} +⋮---- +export interface RealityDividendItemV3 { + type: string; + announcementDate: string; + recordDate: string; + exrightDate: string; + dividendDate: string; + dividendPerShare: string; + stockDividendPerShare: string; + splitValidDate: string; + splitNumerator: string; + splitDenominator: string; +} +⋮---- +export interface RealityShareCapitalChangeV3 { + announcementDate: string; + changeDate: string; + totalShares: string; + commonShares: string; + preferredShares: string; + otherShares: string; + specialExplain: string; + changeReason: string; +} +⋮---- +export interface RealityInnerTradeItemV3 { + reporterName: string; + issueOrgName: string; + endDate: string; + announcementDate: string; + innerType: string; + position: string; + securityTitle: string; + tradeDate: string; + designatedExerciseDate: string; + innerTradeType: string; + actionType: string; + tradeVolume: string; + tradePrice: string; + holdingType: string; + indirectHoldingStatement: string; + postTradeQuantity: string; +} +⋮---- +export interface RealityExecutiveShareholdingItemV3 { + name: string; + holdingNum: string; + holdingRatio: string; + voteRatio: string; + period: string; + announcementDate: string; +} +⋮---- +export interface RealityShareholdDetailItemV3 { + name: string; + holdingNum: string; + holdingRatio: string; +} +⋮---- +export interface RealityCursorListV3 { + list: T[]; + cursor?: string; +} +⋮---- +export interface RealityStockInfoV3 { + symbol: string; + code: string; + name: string; + tradingPeriod: string[]; + weekendTradable: 'yes' | 'no' | string; +} +⋮---- +export interface RealityMarketSessionStateV3 { + state: string; + timeZone: string; + startTime: string; + endTime: string; +} +⋮---- +export interface RealityMarketStateV3 { + market: string; + daylightType: string; + stateList: RealityMarketSessionStateV3[]; +} +⋮---- +export interface RealityMarketSpecificConfigV3 { + remark: string; + startTime: string; + endTime: string; +} +⋮---- +export interface RealityMarketCalendarV3 { + timeZone: string; + specificConfig: RealityMarketSpecificConfigV3[]; + regularConfig: string[]; +} + +================ +File: src/types/websockets/ws-api-response.ts +================ +export interface WSAPIPlaceOrderResponseV3 { + symbol: string; + orderId: string; + clientOid: string; + cTime: string; +} + +================ +File: src/websocket-api-client.ts +================ +import { + CancelOrderRequestV3, + ModifyOrderRequestV3, +} from './types/request/v3/trade.js'; +import { + CancelOrderResponseV3, + ModifyOrderResponseV3, +} 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'; +⋮---- +/** + * 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; +} +⋮---- +/** + * 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(....)`. + */ +⋮---- +/** + * 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 +⋮---- +constructor( + options?: WSClientConfigurableOptions & + Partial, + logger?: DefaultLogger, +) +⋮---- +public getWSClient(): WebsocketClientV3 ⋮---- public setTimeOffsetMs(newOffset: number): void ⋮---- @@ -1662,6 +2426,16 @@ cancelBatchOrders( params: CancelOrderRequestV3[], ): Promise> ⋮---- +modifyOrder( + category: BitgetInstTypeV3, + params: ModifyOrderRequestV3, +): Promise> +⋮---- +batchModifyOrders( + category: BitgetInstTypeV3, + params: ModifyOrderRequestV3[], +): Promise> +⋮---- /** * * @@ -4948,36 +5722,275 @@ export interface RedeemEarnEliteResultV3 { } ================ -File: src/types/response/v3/p2p.ts +File: src/types/response/v3/loan.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 P2pPayMethodV3 { - payMethodId: string; - payMethodName: string; - payMethodUserName: string; - userPayMethodId: string; - payMethodInfo: P2pPayMethodInfoFieldV3[]; +export interface LoanTransfersV3 { + coin: string; + transfered: string; + userId: string; } ⋮---- -export interface P2pTokenDetailV3 { - token: string; - precision: string; +export interface LoanSymbolSettingV3 { + symbol: string; + leverage: string; } ⋮---- -export interface P2pFiatPayMethodV3 { +export interface LoanSymbolsV3 { + productId: string; + spotSymbols: string[]; + marginLeverage: string; + usdtContractLeverage: string; + coinContractLeverage: string; + usdcContractLeverage: string; + usdtContractSymbols: LoanSymbolSettingV3[]; + coinContractSymbols: LoanSymbolSettingV3[]; + usdcContractSymbols: LoanSymbolSettingV3[]; +} +⋮---- +export interface RepaidHistoryItemV3 { + repayOrderId: string; + businessType: 'normal' | 'liquidation'; + repayType: 'all' | 'part'; + repaidTime: string; + coin: string; + repayAmount: string; + repayInterest: 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 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'; +} +⋮---- +/** Tiered conversion rate item (when Tiered Discount Rate Model is enabled) */ +export interface ConvertRatioListItemV3 { + ladder: string; + convertRatio: string; +} +⋮---- +export interface CoinInfoV3 { + coin: string; + convertRatio: string; + maxConvertValue: string; + /** Tiered conversion rate (when margin mode is Tiered Discount Rate Model) */ + convertRatioList?: ConvertRatioListItemV3[]; +} +⋮---- +/** Tiered conversion rate (when margin mode is Tiered Discount Rate Model) */ +⋮---- +export interface BindUidResponseV3 { + riskUnitId: string; + uid: string; + operate: 'bind' | 'unbind'; +} +⋮---- +export interface UnpaidInfoV3 { + coin: string; + unpaidQty: string; + unpaidInterest: string; +} +⋮---- +export interface BalanceInfoV3 { + coin: string; + price: string; + amount: string; + convertedUsdtAmount: string; +} +⋮---- +export interface LTVConvertResponseV3 { + ltv: string; + subAccountUids: string[]; + unpaidUsdtAmount: string; + usdtBalance: string; + unpaidInfo: UnpaidInfoV3[]; + balanceInfo: BalanceInfoV3[]; +} +⋮---- +/* 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 LoanPledgeInfoV3 { + coin: string; + initRate: string; + supRate: string; + forceRate: string; + minPledgeAmount: string; + maxPledgeAmount: string; +} +⋮---- +export interface GetLoanCoinsResponseV3 { + loanInfos: LoanCoinInfoV3[]; + pledgeInfos: LoanPledgeInfoV3[]; +} +⋮---- +export interface GetLoanInterestResponseV3 { + hourInterest: string; + loanAmount: string; +} +⋮---- +export interface LoanBorrowResponseV3 { + orderId: 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 LoanBorrowHistoryItemV3 { + orderId: string; + loanCoin: string; + pledgeCoin: string; + initPledgeAmount: string; + initLoanAmount: string; + hourRate: string; + daily: string; + borrowTime: string; + status: string; +} +⋮---- +export interface LoanRepayResponseV3 { + loanCoin: string; + pledgeCoin: string; + repayAmount: string; + payInterest: string; + repayLoanAmount: string; + repayUnlockAmount: string; +} +⋮---- +export interface LoanRepayHistoryItemV3 { + orderId: string; + loanCoin: string; + pledgeCoin: string; + repayAmount: string; + payInterest: string; + repayLoanAmount: string; + repayUnlockAmount: string; + repayTime: string; +} +⋮---- +export interface LoanRevisePledgeResponseV3 { + loanCoin: string; + pledgeCoin: string; + afterPledgeRate: string; +} +⋮---- +export interface LoanPledgeRateHistoryItemV3 { + loanCoin: string; + pledgeCoin: string; + orderId: string; + reviseTime: string; + reviseSide: string; + reviseAmount: string; + afterPledgeRate: string; + beforePledgeRate: string; +} +⋮---- +export interface LoanDebtInfoV3 { + coin: string; + amount: string; + amountUsdt: string; +} +⋮---- +export interface GetLoanDebtsResponseV3 { + pledgeInfos: LoanDebtInfoV3[]; + loanInfos: LoanDebtInfoV3[]; +} +⋮---- +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/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 P2pPayMethodV3 { + payMethodId: string; + payMethodName: string; + payMethodUserName: string; + userPayMethodId: string; + payMethodInfo: P2pPayMethodInfoFieldV3[]; +} +⋮---- +export interface P2pTokenDetailV3 { + token: string; + precision: string; +} +⋮---- +export interface P2pFiatPayMethodV3 { payMethodName: string; iconUrl: string; payMethodId: string; @@ -5534,9 +6547,14 @@ export interface StockPlusTransferRecordsV3 { File: src/types/response/v3/strategy.ts ================ import type { + StrategyIcebergParamsV3, + StrategyOcoParamsV3, StrategyOrderStatusV3, + StrategyOrderTypeV3, + StrategyTrailingStopParamsV3, StrategyTriggerByV3, StrategyTriggerOrderTypeV3, + StrategyTwapParamsV3, } from '../../request/v3/strategy.js'; ⋮---- export interface PlaceStrategyOrderResponseV3 { @@ -5552,11 +6570,12 @@ export interface ModifyStrategyOrderResponseV3 { export interface StrategyOrderV3 { orderId: string; clientOid: string; - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES' | string; symbol: string; qty: string; posSide: 'long' | 'short'; status: StrategyOrderStatusV3; + type?: StrategyOrderTypeV3 | string; triggerType?: 'takeProfit' | 'stopLoss'; tpTriggerBy?: StrategyTriggerByV3; slTriggerBy?: StrategyTriggerByV3; @@ -5570,9 +6589,32 @@ export interface StrategyOrderV3 { triggerPrice?: string; triggerOrderType?: StrategyTriggerOrderTypeV3; triggerOrderPrice?: string; + ocoParams?: StrategyOcoParamsV3; + trailingStopParams?: StrategyTrailingStopParamsV3; + icebergParams?: StrategyIcebergParamsV3; + twapParams?: StrategyTwapParamsV3; createdTime: string; updatedTime: string; } +⋮---- +export interface StrategySubOrderV3 { + subOrderId: string; + subClientOid?: string; + orderId?: string; + clientOid?: string; + category?: string; + symbol?: string; + side?: string; + posSide?: string; + orderType?: string; + price?: string; + qty?: string; + cumExecQty?: string; + avgPrice?: string; + status?: string; + createdTime?: string; + updatedTime?: string; +} ================ File: src/types/shared.ts @@ -5615,6 +6657,12 @@ export interface APIResponse { data: T; } +================ +File: .npmrc +================ +min-release-age=30 +save-exact=true + ================ File: .nvmrc ================ @@ -7386,7 +8434,13 @@ export interface GetCopyFuturesProfitDetailsRequestV3 { ================ File: src/types/request/v3/strategy.ts ================ -export type StrategyOrderTypeV3 = 'tpsl' | 'trigger'; +export type StrategyOrderTypeV3 = + | 'tpsl' + | 'trigger' + | 'oco' + | 'trailing_stop' + | 'iceberg' + | 'twap'; ⋮---- export type StrategyOrderStatusV3 = | 'pending' @@ -7399,6 +8453,45 @@ export type StrategyTriggerByV3 = 'market' | 'mark'; ⋮---- export type StrategyTriggerOrderTypeV3 = 'limit' | 'market'; ⋮---- +export interface StrategyOcoParamsV3 { + ocoLimitPrice?: string; + ocoTriggerPrice?: string; + ocoOrderType?: StrategyTriggerOrderTypeV3; + ocoOrderPrice?: string; +} +⋮---- +export interface StrategyTrailingStopParamsV3 { + activationPrice?: string; + activationType?: string; + trailType?: string; + trailVariance?: string; + preOrderType?: StrategyTriggerOrderTypeV3; + preOrderPrice?: string; +} +⋮---- +export interface StrategyIcebergParamsV3 { + splitMode?: string; + qtyPerOrder?: string; + splitOrderNumbers?: string; + orderPreference?: string; + executionStrategy?: string; + fixedDistanceType?: string; + distance?: string; + fixedPrice?: string; + priceLimit?: string; +} +⋮---- +export interface StrategyTwapParamsV3 { + duration?: string; + interval?: string; + orderType?: StrategyTriggerOrderTypeV3; + limitOffsetType?: string; + limitOffsetPercentage?: string; + limitOffsetSpread?: string; + twapTriggerPrice?: string; + twapTerminationPrice?: string; +} +⋮---- export interface PlaceStrategyOrderRequestV3 { category: | 'SPOT' @@ -7427,6 +8520,10 @@ export interface PlaceStrategyOrderRequestV3 { triggerPrice?: string; triggerOrderType?: StrategyTriggerOrderTypeV3; triggerOrderPrice?: string; + ocoParams?: StrategyOcoParamsV3; + trailingStopParams?: StrategyTrailingStopParamsV3; + icebergParams?: StrategyIcebergParamsV3; + twapParams?: StrategyTwapParamsV3; } ⋮---- /** Required when tpslMode=partial or for trigger orders */ @@ -7477,64 +8574,25 @@ export interface GetHistoryStrategyOrdersRequestV3 { limit?: string; cursor?: string; } +⋮---- +export interface GetStrategySubOrdersRequestV3 { + orderId?: string; + clientOid?: string; + limit?: string; + cursor?: string; +} ================ -File: src/types/response/v2/spot.ts +File: src/types/response/v2/futures.ts ================ /** * - * * Spot | Market + * * Futures | Market * */ ⋮---- -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 SpotCoinInfoV2 { - coinId: string; - coin: string; - transfer: boolean; - chains: SpotCoinChainV2[]; -} -⋮---- -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 SpotVipFeeRateV2 { - level: number; +export interface FuturesVipFeeRateV2 { + level: string; dealAmount: string; assetAmount: string; takerFeeRate: string; @@ -7543,49 +8601,78 @@ export interface SpotVipFeeRateV2 { usdtWithdrawAmount: 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 FuturesHistoryInterestRateV2 { ts: string; - changeUtc24h: string; - change24h: string; + annualInterestRate: string; + dailyInterestRate: string; } ⋮---- -export interface SpotCallAuctionV2 { - stage: string; - stageEndTime: string; - estOpeningPrice: string | null; - matchedVolume: string | null; - auctionEndTime: string; +export interface FuturesInterestExchangeRateV2 { + tier: string; + minAmount: string; + maxAmount: string; + exchangeRate: string; } ⋮---- -export interface SpotMergeDepthV2 { - asks: [string, string][]; - bids: [string, string][]; +export interface FuturesDiscountRateV2 { + tier: string; + minAmount: string; + maxAmount: string; + discountRate: string; +} +⋮---- +export interface FuturesDiscountRatesV2 { + coin: string; + userLimit: string; + totalLimit: string; + discountRateList: FuturesDiscountRateV2[]; +} +⋮---- +export interface FuturesMergeDepthV2 { + asks: [number, number][]; + bids: [number, number][]; ts: string; scale: string; precision: string; isMaxPrecision: string; } ⋮---- -export interface SpotOrderBookDepthV2 { - asks: [string, string][]; - bids: [string, string][]; +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 type SpotCandlestickV2 = [ +export interface FuturesFillV2 { + tradeId: string; + price: string; + size: string; + side: string; + ts: string; + symbol: string; +} +⋮---- +export type FuturesCandlestickV2 = [ string, // timestamp string, // open string, // high @@ -7605,752 +8692,1215 @@ string, // baseVolume string, // usdtVolume string, // quoteVolume ⋮---- -export interface SpotTradeV2 { +export interface FuturesOpenInterestV2 { symbol: string; - tradeId: string; - side: string; - price: string; size: string; - ts: string; } ⋮---- -/** - * - * * Spot | Trade - * - */ -⋮---- -export interface CancelAndSubmitSpotOrderResponseV2 { - orderId: string; - clientOid: string | null; - success: string; - msg: string | null; +export interface FuturesFundingTimeV2 { + symbol: string; + nextFundingTime: string; + ratePeriod: string; } ⋮---- -export interface SubmitSpotBatchOrdersResponseV2 { - successList: { - orderId: string; - clientOid: string; - }[]; - failureList: { - orderId: string; - clientOid: string; - errorMsg: string; - errorCode?: string; - }[]; +export interface FuturesSymbolPriceV2 { + symbol: string; + price: string; + indexPrice: string; + markPrice: string; + ts: string; } ⋮---- -export interface SpotOrderInfoV2 { - userId: string; +export interface FuturesHistoricalFundingRateV2 { 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; + fundingRate: string; + fundingTime: string; } ⋮---- -export interface SpotOpenOrderV2 { - userId: string; +export interface FuturesContractConfigV2 { 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; -} -⋮---- -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; + 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; } ⋮---- /** * - * * Spot | Trigger Orders + * * Futures | Account * */ ⋮---- -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; +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 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 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 FuturesInterestV2 { + coin: string; + liability: string; + interestFreeLimit: string; + interestLimit: string; + hourInterestRate: string; + interest: string; cTime: string; } +export interface FuturesInterestHistoryV2 { + nextSettleTime: string; + borrowAmount: string; + borrowLimit: string; + interestList: FuturesInterestV2[]; + endId: string; +} ⋮---- -export interface SpotHistoryPlanOrderV2 { - orderId: string; - clientOid: string; +export interface SetLeverageResponseV2 { symbol: string; - size: string; - executePrice: string; - triggerPrice: string; - status: string; - orderType: string; - side: string; - planType: string; - triggerType: string; - enterPointSource: string; - uTime: string; - cTime: string; + marginCoin: string; + longLeverage: string; + shortLeverage: string; + crossMarginLeverage: string; + marginMode: string; } ⋮---- -export interface SpotPlanSubOrderV2 { - orderId: string; - price: string; - type: string; - status: string; +export interface SetMarginModeResponseV2 { + symbol: string; + marginCoin: string; + longLeverage: string; + shortLeverage: string; + marginMode: string; } ⋮---- -export interface SpotCancelPlanOrdersV2 { - successList: { - orderId: string; - clientOid: string; - }[]; - failureList: { - orderId: string; - clientOid: string; - errorMsg: string; - }[]; +export interface FuturesAccountBillV2 { + billId: string; + symbol: string; + amount: string; + fee: string; + feeByCoupon: string; + businessType: string; + coin: string; + balance: string; + cTime: string; } ⋮---- /** * - * * Spot | Account + * * Futures | Position * */ ⋮---- -export interface SpotAccountInfoV2 { - userId: string; - inviterId: string; - ips: string; - authorities: string[]; - parentId: number; - traderType: string; - channelCode: string; - channel: string; - regisTime: string; +export interface FuturesPositionTierV2 { + symbol: string; + level: string; + startUnit: string; + endUnit: string; + leverage: string; + keepMarginRate: string; } ⋮---- -export interface SpotAccountAssetV2 { - coin: string; +export interface FuturesPositionV2 { + marginCoin: string; + symbol: string; + holdSide: string; + openDelegateSize: string; + marginSize: string; available: string; - frozen: string; locked: string; - limitAvailable: 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; } ⋮---- -export interface SpotSubAccountAssetV2 { - coin: string; - available: string; - limitAvailable: string; - frozen: string; - locked: string; - uTime: string; -} -export interface SpotSubAccountAssetsV2 { - userId: number; - assetsList: SpotSubAccountAssetV2[]; +/** Cash dividend, USDT */ +⋮---- +export interface FuturesPositionAdlRankV2 { + symbol: string; + marginCoin: string; + adlRank: string; + rank: string; + holdSide: string; } ⋮---- -export interface SpotAccountBillV2 { +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; - coin: string; - groupType: string; - businessType: string; - size: string; - balance: string; - fees: string; - billId: string; + uTime: string; } ⋮---- -export interface SpotMainSubTransferRecordV2 { - coin: string; - status: string; - toType: string; - fromType: string; - size: string; - ts: string; - clientOid: string; - transferId: string; - fromUserId: string; - toUserId: 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 SpotTransferRecordV2 { - coin: string; - status: string; - toType: string; - toSymbol: string; - fromType: string; - fromSymbol: 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; - ts: string; + orderId: string; clientOid: string; - transferId: 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; } ⋮---- -export interface SpotDepositAddressV2 { - address: string; - chain: string; - coin: string; - tag: string; - url: 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 SpotSubAccountDepositRecordV2 { - orderId: string; - tradeId: string; - coin: string; +export interface FuturesOpenOrderV2 { + symbol: string; size: string; + orderId: string; + clientOid: string; + baseVolume: string; + fee: string; + price: string; + priceAvg: string; status: string; - toAddress: string; - dest: string; - chain: string; - fromAddress: string; - clientOid?: string; - confirm?: string; - tag?: 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 SpotWithdrawalRecordV2 { +export interface FuturesHistoryOrderV2 { + symbol: string; + size: string; orderId: string; - tradeId: string; - coin: string; - dest: string; clientOid: string; - type: string; - tag: string; - size: string; + baseVolume: string; fee: string; + price: string; + priceAvg: string; status: string; - toAddress: string; - fromAddress: string; - confirm: string; - chain: 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 SpotDepositRecordV2 { +export interface FuturesCancelAllOrdersV2 { + successList: { + orderId: string; + clientOid: string; + }[]; + failureList: { + orderId: string; + clientOid: string; + errorMsg: string; + errorCode: string; + }[]; +} +⋮---- +/** + * + * * Futures | Trigger Orders + * + */ +⋮---- +export interface FuturesTriggerSubOrderV2 { orderId: string; - tradeId: string; - coin: string; + price: string; type: string; - size: string; status: string; - toAddress: string; - dest: string; - chain: string; - fromAddress: string; - cTime: string; - uTime: 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; } ⋮---- -export interface BrokerSubAccountV3 { - subUid: string; - subaccountName: string; - subaccountEmail: string | null; - status: 'normal' | 'freeze'; - permList: string[]; - label: string; - language: 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 GetBrokerSubAccountListResponseV3 { - subList: BrokerSubAccountV3[]; +export interface FuturesCancelPlanOrderV2 { + successList: { + orderId: string; + clientOid: string; + }[]; + failureList: { + orderId: string; + clientOid: string; + errorMsg: string; + }[]; } ⋮---- -export interface ModifyBrokerSubAccountResponseV3 { - subUid: string; - subaccountName: string; - status: 'normal' | 'freeze'; - permList: string[]; - label: 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; } ⋮---- -export interface BrokerSubWithdrawalResponseV3 { - orderId: string; - clientOid: string; -} +/** + * + * * Futures | Union Margin + * + */ ⋮---- -export interface BrokerSubDepositAddressV3 { - subUid: string; +export interface UnionTransferLimitsV2 { coin: string; - address: string; - chain: string; - tag: string | null; - url: string; - cTime: string; + maxTransferIn: 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; +export interface UnionConfigV2 { + imr: string; + mmr: string; + individualLimit: string; + individualLimitRatio: string; } ⋮---- -export interface GetBrokerAllSubDepositWithdrawalResponseV3 { - list: BrokerSubDepositWithdrawalRecordV3[]; - endId: string; +export interface UnionSwitchUsdtV2 { + usdtAmount: string; } ⋮---- -export interface BrokerCommissionRecordV3 { - uid: string; - coin: string; - symbol: string; - dealtAmount: string; - totalFee: string; - deductedFee: string; - paidFee: string; - markUpFee: string; - totalCommission: string; +export interface UnionConvertV2 { + usdtAmount: string; } ⋮---- -export interface CreateBrokerSubApiKeyResponseV3 { - subUid: string; - label: string; - apiKey: string; - secretKey: string; - permType: 'read_write' | 'read_only'; - permList: string[]; - ipList: string[] | null; +/** + * + * * Futures | Account | Max Openable Quantity + * + */ +⋮---- +export interface FuturesMaxOpenV2 { + maxOpen: string; } ⋮---- -export interface ModifyBrokerSubApiKeyResponseV3 { - subUid: string; - label: string; - apiKey: string; - permType: 'read_write' | 'read_only'; - permList: string[]; - ipList: string[]; +/** + * + * * Futures | Account | Liquidation Price + * + */ +⋮---- +export interface FuturesLiquidationPriceV2 { + liqPrice: string; } ⋮---- -export interface GetBrokerSubApiKeyResponseV3 { - subUid: string; - label: string; - apiKey: string; - secretKey: string; - permType: 'read_write' | 'read_only'; - permList: string[]; - ipList: string[] | null; +/** + * + * * Futures | Account | Isolated Symbols + * + */ +⋮---- +export interface FuturesIsolatedSymbolV2 { + symbol: string; + marginMode: 'isolated'; } ================ -File: src/types/response/v3/loan.ts +File: src/types/response/v2/spot.ts ================ -export interface LoanTransfersV3 { +/** + * + * * Spot | Market + * + */ +⋮---- +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 SpotCoinInfoV2 { + coinId: string; coin: string; - transfered: string; - userId: string; + transfer: boolean; + chains: SpotCoinChainV2[]; } ⋮---- -export interface LoanSymbolSettingV3 { +export interface SpotSymbolInfoV2 { symbol: string; - leverage: 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 LoanSymbolsV3 { - productId: string; - spotSymbols: string[]; - marginLeverage: string; - usdtContractLeverage: string; - coinContractLeverage: string; - usdcContractLeverage: string; - usdtContractSymbols: LoanSymbolSettingV3[]; - coinContractSymbols: LoanSymbolSettingV3[]; - usdcContractSymbols: LoanSymbolSettingV3[]; +export interface SpotVipFeeRateV2 { + level: number; + dealAmount: string; + assetAmount: string; + takerFeeRate: string; + makerFeeRate: string; + btcWithdrawAmount: string; + usdtWithdrawAmount: string; } ⋮---- -export interface RepaidHistoryItemV3 { - repayOrderId: string; - businessType: 'normal' | 'liquidation'; - repayType: 'all' | 'part'; - repaidTime: string; - coin: string; - repayAmount: string; - repayInterest: 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 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; } ⋮---- -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 SpotCallAuctionV2 { + stage: string; + stageEndTime: string; + estOpeningPrice: string | null; + matchedVolume: string | null; + auctionEndTime: string; } ⋮---- -/** Tiered conversion rate item (when Tiered Discount Rate Model is enabled) */ -export interface ConvertRatioListItemV3 { - ladder: string; - convertRatio: string; +export interface SpotMergeDepthV2 { + asks: [string, string][]; + bids: [string, string][]; + ts: string; + scale: string; + precision: string; + isMaxPrecision: 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 SpotOrderBookDepthV2 { + asks: [string, string][]; + bids: [string, string][]; + ts: string; } ⋮---- -/** Tiered conversion rate (when margin mode is Tiered Discount Rate Model) */ -⋮---- -export interface BindUidResponseV3 { - riskUnitId: string; - uid: string; - operate: 'bind' | 'unbind'; -} +export type SpotCandlestickV2 = [ + string, // timestamp + string, // open + string, // high + string, // low + string, // close + string, // baseVolume + string, // usdtVolume + string, // quoteVolume +]; ⋮---- -export interface UnpaidInfoV3 { - coin: string; - unpaidQty: string; - unpaidInterest: string; -} +string, // timestamp +string, // open +string, // high +string, // low +string, // close +string, // baseVolume +string, // usdtVolume +string, // quoteVolume ⋮---- -export interface BalanceInfoV3 { - coin: string; +export interface SpotTradeV2 { + symbol: string; + tradeId: string; + side: string; price: string; - amount: string; - convertedUsdtAmount: string; -} -⋮---- -export interface LTVConvertResponseV3 { - ltv: string; - subAccountUids: string[]; - unpaidUsdtAmount: string; - usdtBalance: string; - unpaidInfo: UnpaidInfoV3[]; - balanceInfo: BalanceInfoV3[]; -} -⋮---- -/* 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 LoanPledgeInfoV3 { - coin: string; - initRate: string; - supRate: string; - forceRate: string; - minPledgeAmount: string; - maxPledgeAmount: string; + size: string; + ts: string; } ⋮---- -export interface GetLoanCoinsResponseV3 { - loanInfos: LoanCoinInfoV3[]; - pledgeInfos: LoanPledgeInfoV3[]; -} +/** + * + * * Spot | Trade + * + */ ⋮---- -export interface GetLoanInterestResponseV3 { - hourInterest: string; - loanAmount: string; +export interface CancelAndSubmitSpotOrderResponseV2 { + orderId: string; + clientOid: string | null; + success: string; + msg: string | null; } ⋮---- -export interface LoanBorrowResponseV3 { - orderId: string; +export interface SubmitSpotBatchOrdersResponseV2 { + successList: { + orderId: string; + clientOid: string; + }[]; + failureList: { + orderId: string; + clientOid: string; + errorMsg: string; + errorCode?: string; + }[]; } ⋮---- -export interface LoanBorrowOngoingItemV3 { +export interface SpotOrderInfoV2 { + userId: string; + symbol: string; orderId: string; - loanCoin: string; - loanAmount: string; - interestAmount: string; - hourInterestRate: string; - pledgeCoin: string; - pledgeAmount: string; - pledgeRate: string; - supRate: string; - forceRate: string; - borrowTime: string; - expireTime: 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 LoanBorrowHistoryItemV3 { +export interface SpotOpenOrderV2 { + userId: string; + symbol: string; orderId: string; - loanCoin: string; - pledgeCoin: string; - initPledgeAmount: string; - initLoanAmount: string; - hourRate: string; - daily: string; - borrowTime: 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; } ⋮---- -export interface LoanRepayResponseV3 { - loanCoin: string; - pledgeCoin: string; - repayAmount: string; - payInterest: string; - repayLoanAmount: string; - repayUnlockAmount: string; -} -⋮---- -export interface LoanRepayHistoryItemV3 { +export interface SpotFillV2 { + userId: string; + symbol: string; orderId: string; - loanCoin: string; - pledgeCoin: string; - repayAmount: string; - payInterest: string; - repayLoanAmount: string; - repayUnlockAmount: string; - repayTime: 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; } ⋮---- -export interface LoanRevisePledgeResponseV3 { - loanCoin: string; - pledgeCoin: string; - afterPledgeRate: string; -} +/** + * + * * Spot | Trigger Orders + * + */ ⋮---- -export interface LoanPledgeRateHistoryItemV3 { - loanCoin: string; - pledgeCoin: string; +export interface SpotCurrentPlanOrderV2 { orderId: string; - reviseTime: string; - reviseSide: string; - reviseAmount: string; - afterPledgeRate: string; - beforePledgeRate: string; -} -⋮---- -export interface LoanDebtInfoV3 { - coin: string; - amount: string; - amountUsdt: 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 GetLoanDebtsResponseV3 { - pledgeInfos: LoanDebtInfoV3[]; - loanInfos: LoanDebtInfoV3[]; +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 LoanReduceItemV3 { +export interface SpotPlanSubOrderV2 { orderId: string; - loanCoin: string; - pledgeCoin: string; - reduceTime: string; - pledgeRate: string; - pledgePrice: string; + price: string; + type: 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 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; - /** Order TTL in ms [10, 60000]. Only effective when requestTime is also set on the envelope */ - receiveWindow?: string; +export interface SpotCancelPlanOrdersV2 { + successList: { + orderId: string; + clientOid: string; + }[]; + failureList: { + orderId: string; + clientOid: string; + errorMsg: 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 */ -⋮---- -/** 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'; +/** + * + * * Spot | Account + * + */ ⋮---- -export type WSOperation = 'subscribe' | 'unsubscribe' | 'login'; +export interface SpotAccountInfoV2 { + userId: string; + inviterId: string; + ips: string; + authorities: string[]; + parentId: number; + traderType: string; + channelCode: string; + channel: string; + regisTime: string; +} ⋮---- -// 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 SpotAccountAssetV2 { + coin: string; + available: string; + frozen: string; + locked: string; + limitAvailable: string; + uTime: string; +} ⋮---- -export interface WSOperationLoginParams { - apiKey: string; - passphrase: string; - timestamp: number; - sign: string; +export interface SpotSubAccountAssetV2 { + coin: string; + available: string; + limitAvailable: string; + frozen: string; + locked: string; + uTime: string; +} +export interface SpotSubAccountAssetsV2 { + userId: number; + assetsList: SpotSubAccountAssetV2[]; } ⋮---- -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 interface SpotAccountBillV2 { + cTime: string; + coin: string; + groupType: string; + businessType: string; + size: string; + balance: string; + fees: string; + billId: string; } ⋮---- -/** Client-side request timestamp; required for receiveWindow on place-order */ +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 WSAPIRequestFlags { - /** If true, will skip auth requirement for WS API connection */ - authIsOptional?: boolean | undefined; +export interface SpotTransferRecordV2 { + coin: string; + status: string; + toType: string; + toSymbol: string; + fromType: string; + fromSymbol: string; + size: string; + ts: string; + clientOid: string; + transferId: string; } ⋮---- -/** If true, will skip auth requirement for WS API connection */ +export interface SpotDepositAddressV2 { + address: string; + chain: string; + coin: string; + tag: string; + url: string; +} ⋮---- -export type Exact = { - // This part says: if there's any key that's not in T, it's an error - [K: string]: never; -} & { +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; +} +⋮---- +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 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; +} + +================ +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 BrokerSubAccountV3 { + subUid: string; + subaccountName: string; + subaccountEmail: string | null; + status: 'normal' | 'freeze'; + permList: string[]; + label: string; + language: string; + cTime: string; + uTime: string; +} +⋮---- +export interface GetBrokerSubAccountListResponseV3 { + subList: BrokerSubAccountV3[]; +} +⋮---- +export interface ModifyBrokerSubAccountResponseV3 { + subUid: string; + subaccountName: string; + status: 'normal' | 'freeze'; + permList: string[]; + label: string; + cTime: string; + uTime: string; +} +⋮---- +export interface BrokerSubWithdrawalResponseV3 { + orderId: string; + clientOid: string; +} +⋮---- +export interface BrokerSubDepositAddressV3 { + subUid: string; + coin: string; + address: string; + chain: string; + tag: string | null; + url: string; + cTime: 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; +} +⋮---- +export interface GetBrokerAllSubDepositWithdrawalResponseV3 { + list: BrokerSubDepositWithdrawalRecordV3[]; + endId: string; +} +⋮---- +export interface BrokerCommissionRecordV3 { + uid: string; + coin: string; + symbol: string; + dealtAmount: string; + totalFee: string; + deductedFee: string; + paidFee: string; + markUpFee: string; + totalCommission: string; +} +⋮---- +export interface CreateBrokerSubApiKeyResponseV3 { + subUid: string; + label: string; + apiKey: string; + secretKey: string; + permType: 'read_write' | 'read_only'; + permList: string[]; + ipList: string[] | null; +} +⋮---- +export interface ModifyBrokerSubApiKeyResponseV3 { + subUid: string; + label: string; + apiKey: string; + permType: 'read_write' | 'read_only'; + permList: string[]; + ipList: string[]; +} +⋮---- +export interface GetBrokerSubApiKeyResponseV3 { + subUid: string; + label: string; + apiKey: string; + secretKey: string; + permType: 'read_write' | 'read_only'; + permList: string[]; + ipList: string[] | null; +} + +================ +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' | 'rpi'; + 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; + /** Order TTL in ms [10, 60000]. Only effective when requestTime is also set on the envelope */ + receiveWindow?: string; + /** Spot only. Default: no */ + autoBorrow?: 'yes' | 'no'; +} +⋮---- +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 */ +⋮---- +/** Order TTL in ms [10, 60000]. Only effective when requestTime is also set on the envelope */ +⋮---- +/** Spot only. Default: no */ + +================ +File: src/types/websockets/ws-api.ts +================ +import { WS_KEY_MAP } from '../../util/websocket-util.js'; +import { + CancelOrderRequestV3, + ModifyOrderRequestV3, +} from '../request/v3/trade.js'; +import { + CancelOrderResponseV3, + ModifyOrderResponseV3, +} 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'; +⋮---- +// 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' + | 'modify-order' + | 'batch-modify'; +⋮---- +export interface WSOperationLoginParams { + apiKey: string; + passphrase: string; + timestamp: number; + sign: 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; +} +⋮---- +/** Client-side request timestamp; required for receiveWindow on place-order */ +⋮---- +export interface WSAPIRequestFlags { + /** If true, will skip auth requirement for WS API connection */ + authIsOptional?: boolean | undefined; +} +⋮---- +/** 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]; }; ⋮---- @@ -8433,8 +9983,10 @@ export interface WsAPITopicRequestParamMap { '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 + // https://www.bitget.com/docs/uta/websocket/private/Batch-Cancel-Order-Channel 'batch-cancel': CancelOrderRequestV3[]; + 'modify-order': ModifyOrderRequestV3; + 'batch-modify': ModifyOrderRequestV3[]; } ⋮---- // https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters @@ -8443,7 +9995,7 @@ export interface WsAPITopicRequestParamMap { ⋮---- // 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 +// https://www.bitget.com/docs/uta/websocket/private/Batch-Cancel-Order-Channel ⋮---- /** * Response structure expected for each operation @@ -8455,8 +10007,10 @@ export interface WsAPIOperationResponseMap { '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 + // https://www.bitget.com/docs/uta/websocket/private/Batch-Cancel-Order-Channel 'batch-cancel': WSAPIResponse; + 'modify-order': WSAPIResponse<[ModifyOrderResponseV3], 'modify-order'>; + 'batch-modify': WSAPIResponse; } ⋮---- // https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters @@ -8465,7 +10019,7 @@ export interface WsAPIOperationResponseMap { ⋮---- // 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 +// https://www.bitget.com/docs/uta/websocket/private/Batch-Cancel-Order-Channel ================ File: src/types/websockets/ws-events.ts @@ -8849,8041 +10403,6905 @@ function generateConfig(name) // Code is already transpiled from TypeScript, no additional loaders needed ================ -File: docs/BITGET_SDK_QUICKSTART_GUIDE.md +File: examples/V3 - UTA/WS-API/ws-api-client-trade.ts ================ - -# 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, - }); -} - -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 }; -} - -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), - }); -} - -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 }; -} - -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 }; -} - -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); -} - -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 }; -} - -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); -} - -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, - }); -} - -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, - }); -} - -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 }); -} - -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 }); -} - -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, - }); -} - -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.'); -} - -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, - ); -} - -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.'); -} - -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.', - ); -} - -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'; -⋮---- -// or -// import { DefaultLogger, WS_KEY_MAP, WebsocketAPIClient } from 'bitget-api'; -⋮---- -// 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); -// }); -// } -⋮---- -// 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 -⋮---- -// Whether to use the demo trading wss connection -// demoTrading: true, -⋮---- -// 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 -⋮---- -logger, // Optional: inject a custom logger -⋮---- -// Optional, see above "attachEventListeners". Attach basic event handlers, so nothing is left unhandled -// attachEventHandlers(wsClient.getWSClient()); -⋮---- -// 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. -⋮---- -/** - * 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! - */ -⋮---- -/** - * Place Order - * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters - */ -⋮---- -/** - 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" - }; - */ -⋮---- -/** - * Batch Place Order Channel - * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel - */ -⋮---- -/** - * 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. - */ -⋮---- -/** - 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" - } - */ -⋮---- -/** - * Cancel Order - * https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel - */ -⋮---- -/** - 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/v2/futures.ts -================ -/** - * - * * 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; -} -⋮---- -export interface FuturesInterestExchangeRateV2 { - tier: string; - minAmount: string; - maxAmount: string; - exchangeRate: string; -} -⋮---- -export interface FuturesDiscountRateV2 { - tier: string; - minAmount: string; - maxAmount: string; - discountRate: string; -} -⋮---- -export interface FuturesDiscountRatesV2 { - coin: string; - userLimit: string; - totalLimit: string; - discountRateList: FuturesDiscountRateV2[]; -} -⋮---- -export interface FuturesMergeDepthV2 { - asks: [number, number][]; - bids: [number, number][]; - ts: string; - scale: string; - precision: string; - isMaxPrecision: string; -} -⋮---- -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 FuturesFillV2 { - tradeId: string; - price: string; - size: string; - side: string; - ts: string; - symbol: string; -} -⋮---- -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; -} -⋮---- -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 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 FuturesInterestV2 { - coin: string; - liability: string; - interestFreeLimit: string; - interestLimit: string; - hourInterestRate: string; - interest: string; - cTime: string; -} -export interface FuturesInterestHistoryV2 { - nextSettleTime: string; - borrowAmount: string; - borrowLimit: string; - interestList: FuturesInterestV2[]; - endId: string; -} -⋮---- -export interface SetLeverageResponseV2 { - symbol: string; - marginCoin: string; - longLeverage: string; - shortLeverage: string; - crossMarginLeverage: string; - marginMode: string; -} -⋮---- -export interface SetMarginModeResponseV2 { - symbol: string; - marginCoin: string; - longLeverage: string; - shortLeverage: string; - marginMode: string; -} -⋮---- -export interface FuturesAccountBillV2 { - billId: string; - symbol: string; - amount: string; - fee: string; - feeByCoupon: string; - businessType: string; - coin: string; - balance: string; - cTime: string; -} -⋮---- -/** - * - * * Futures | Position - * - */ -⋮---- -export interface FuturesPositionTierV2 { - symbol: string; - level: string; - startUnit: string; - endUnit: string; - leverage: string; - keepMarginRate: string; -} -⋮---- -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; - /** Cash dividend, USDT */ - cashDividend?: string; - uTime: string; - autoMargin: string; - cTime: string; -} -⋮---- -/** Cash dividend, USDT */ -⋮---- -export interface FuturesPositionAdlRankV2 { - symbol: string; - marginCoin: string; - adlRank: string; - rank: string; - holdSide: string; -} -⋮---- -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; - 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; -} -⋮---- -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 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; -} -⋮---- -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; -} -⋮---- -export interface FuturesCancelAllOrdersV2 { - successList: { - orderId: string; - clientOid: string; - }[]; - failureList: { - orderId: string; - clientOid: string; - errorMsg: string; - errorCode: string; - }[]; -} -⋮---- -/** - * - * * 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; -} -⋮---- -/** - * - * * 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; -} -⋮---- -/** - * - * * Futures | Account | Max Openable Quantity - * - */ -⋮---- -export interface FuturesMaxOpenV2 { - maxOpen: string; -} -⋮---- -/** - * - * * Futures | Account | Liquidation Price - * - */ -⋮---- -export interface FuturesLiquidationPriceV2 { - liqPrice: string; -} -⋮---- -/** - * - * * Futures | Account | Isolated Symbols - * - */ -⋮---- -export interface FuturesIsolatedSymbolV2 { - symbol: string; - marginMode: 'isolated'; -} - -================ -File: src/types/response/v3/copytrading.ts -================ -/** - * - * - * Copy Trading | Futures (UTA) - * - * - */ -⋮---- -export interface CopyFuturesMarginDetailV3 { - marginCoin: string; - maxLongCount: string; - remainingLongCount: string; - maxShortCount: string; - remainingShortCount: string; -} -⋮---- -export interface CopyFuturesTradingPairV3 { - symbol: string; - leverage: string; - marginDetails: CopyFuturesMarginDetailV3[]; -} -⋮---- -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; -} -⋮---- -export interface CopyFuturesMaxTransferableV3 { - maxTransferable: string; - available: string; -} -⋮---- -export interface CopyFuturesTransferResponseV3 { - transferId: string; -} -⋮---- -/** May be a single value or comma-separated values */ -export type CopyFuturesTransferAccountTypeV3 = - | 'spot' - | 'uta' - | 'lead' - | 'otc' - | string; -⋮---- -export interface CopyFuturesTransferRecordV3 { - transferId: string; - fromType: CopyFuturesTransferAccountTypeV3; - toType: CopyFuturesTransferAccountTypeV3; - amount: string; - coin: string; - status: 'Successful' | 'Failed' | 'Processing'; - createdTime: string; -} -⋮---- -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; -} - -================ -File: src/types/request/v3/public.ts -================ -export interface GetPublicFillsRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol?: string; - limit?: 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 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 GetContractsOiRequestV3 { - symbol?: string; - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; -} -⋮---- -export interface GetCurrentFundingRateRequestV3 { - category?: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; -} -⋮---- -export interface GetLiquidationsRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - limit?: string; - cursor?: string; -} -⋮---- -export interface GetHistoryFundingRateRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol: string; - cursor?: string; - limit?: string; -} -⋮---- -export interface GetMarginLoansRequestV3 { - coin: string; -} -⋮---- -export interface GetOpenInterestRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; -} -⋮---- -export interface GetPositionTierRequestV3 { - category: 'MARGIN' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - coin?: string; -} -⋮---- -export interface GetRiskReserveRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol: string; - marginCoin?: string; -} -⋮---- -export interface GetRiskReserveAllRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; -} -⋮---- -export interface GetInstrumentsRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol?: string; -} -⋮---- -export interface GetMarketFeeGroupRequestV3 { - category: 'SPOT' | 'FUTURES'; - group?: 'DEFAULT' | 'GROUP_A' | 'GROUP_B' | 'GROUP_C'; -} -⋮---- -export interface GetMarketScoreWeightsRequestV3 { - category?: 'SPOT' | 'FUTURES'; -} -⋮---- -export interface GetOrderBookRequestV3 { - category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol: string; - limit?: string; -} -⋮---- -export interface GetTickersRequestV3 { - category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; -} -⋮---- -export interface GetIndexComponentsRequestV3 { - symbol: string; -} -⋮---- -export interface GetRpiOrderBookRequestV3 { - category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol: string; - limit?: string; -} -⋮---- -export interface GetCashDividendRecordsRequestV3 { - symbol: string; - type: 'pending' | 'paid'; - cursor?: string; - limit?: string; -} -⋮---- -export interface GetSpotWhaleFlowRequestV3 { - symbol: string; -} -⋮---- -export interface GetSpotFundFlowRequestV3 { - symbol: string; - period?: string; -} -⋮---- -export interface GetSpotNetFlowRequestV3 { - symbol: string; -} -⋮---- -export interface GetMarginLongShortRequestV3 { - symbol: string; - period?: '24h' | '30d'; - coin?: string; -} -⋮---- -export interface GetMarginLoanGrowthRequestV3 { - symbol: string; - period?: string; - coin?: string; -} -⋮---- -export interface GetMarginIsolatedBorrowRequestV3 { - symbol: string; - period?: string; -} -⋮---- -export interface GetFuturesTradingDataRequestV3 { - symbol: string; - period?: string; -} - -================ -File: src/types/request/v3/trade.ts -================ -export interface BatchModifyOrderRequestV3 { - orderId?: string; - clientOid?: string; - qty?: string; - price?: string; - autoCancel?: 'yes' | 'no'; -} -⋮---- -export interface CancelAllOrdersRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol?: string; -} -⋮---- -export interface CancelBatchOrdersRequestV3 { - orderId?: string; - clientOid?: string; - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol: string; -} -⋮---- -export interface CloseAllPositionsRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - posSide?: 'long' | 'short'; -} -⋮---- -export interface CancelOrderRequestV3 { - orderId?: string; - clientOid?: string; - category?: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; -} -⋮---- -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 GetOrderInfoRequestV3 { - orderId?: string; - clientOid?: string; -} -⋮---- -export interface GetFillsRequestV3 { - category?: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - orderId?: string; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: 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 GetHistoryOrdersRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol?: string; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; -} -⋮---- -export interface GetPositionHistoryRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; -} -⋮---- -export interface GetCurrentPositionRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - posSide?: 'long' | 'short'; -} -⋮---- -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 PlaceRealityOrderRequestV3 { - category?: 'SPOT' | 'MARGIN'; - symbol: string; - side: 'buy' | 'sell'; - orderType: 'limit' | 'market'; - qty: string; - price?: string; - clientOid?: string; -} -⋮---- -export interface CancelRealityOrderRequestV3 { - category?: 'SPOT' | 'MARGIN'; - symbol: string; - orderId?: string; - clientOid?: 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 type FuturesMarginModeV3 = 'crossed' | 'isolated'; -⋮---- -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; -} -⋮---- -/** Futures only. Defaults to crossed */ -⋮---- -export interface CountdownCancelAllRequestV3 { - countdown: string; // seconds until auto-cancel (5-60, or 0 to disable) -} -⋮---- -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 CancelAllOrdersResponseV3 { - list: { - orderId: string; - clientOid: string; - code: string; - msg: string; - }[]; -} -⋮---- -export interface CancelBatchOrdersResponseV3 { - orderId: string; - clientOid: string; - code?: string; - msg?: string; -} -⋮---- -export interface CloseAllPositionsResponseV3 { - list: { - orderId: string; - clientOid: string; - code: string; - msg: string; - }[]; -} -⋮---- -export interface CancelOrderResponseV3 { - orderId: string; - clientOid: string; -} -⋮---- -export interface GetMaxOpenAvailableResponseV3 { - available: string; - maxOpen: string; - buyOpenCost: string; - sellOpenCost: string; - maxBuyOpen: string; - maxSellOpen: string; -} -⋮---- -export interface FeeDetailV3 { - feeCoin: string; - fee: 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; -} -⋮---- -export type FillCategoryV3 = - | 'spot' - | 'margin' - | 'usdt-futures' - | 'coin-futures' - | 'usdc-futures' - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; -⋮---- -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 UnfilledOrderV3 { - 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[]; - stpMode?: string; - createdTime: string; - updatedTime: string; -} -⋮---- -export interface HistoryOrderV3 { - 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; -} -⋮---- -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; - /** Cash dividend, USDT */ - cashDividend?: string; - createdTime: string; - updatedTime: string; -} -⋮---- -/** Cash dividend, USDT */ -⋮---- -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; -} -⋮---- -/** Cash dividend, USDT */ -⋮---- -export interface LoanDataDebtCoinV3 { - coin: string; - debt: string; - interestFreeAmount: string; - interestRateNextHour: string; -} -⋮---- -export interface LoanDataV3 { - currentLoans: string; - interestPaymentTime: string; - debtCoinList: LoanDataDebtCoinV3[]; -} -⋮---- -export interface ModifyOrderResponseV3 { - orderId: string; - clientOid: string; -} -⋮---- -export interface PlaceBatchOrdersResponseV3 { - orderId: string; - clientOid: string; - code?: string; - msg?: string; -} -⋮---- -export interface PlaceOrderResponseV3 { - orderId: string; - clientOid: string; -} -⋮---- -export interface PositionAdlRankV3 { - symbol: 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 AccountSymbolConfigV3 { - category: string; - symbol: string; - marginMode: string; - leverage: string; -} -⋮---- -export interface AccountCoinConfigV3 { - coin: string; - leverage: 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; -} -⋮---- -/** 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 AccountDeltaCoinPositionV3 { - 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[]; -} -⋮---- -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; -} -⋮---- -/** 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 ConvertRecordV3 { - fromCoin: string; - fromCoinSize: string; - toCoin: string; - toCoinSize: string; - price: 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 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; -} - -================ -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; - - /** 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; - } & ( - | Omit, 'agent'> - | Omit, 'agent'> - ); - - 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; -} -⋮---- -/** 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; -} - -================ -File: src/index.ts -================ - - -================ -File: src/rest-client-v2.ts -================ -import { FuturesProductTypeV2, MarginType } from './types/request/shared.js'; -import { - AgentCustomerAssetRequestV2, - AgentCustomerDepositRequestV2, - AgentCustomerListRequestV2, - AgentCustomerTradeVolumeRequestV2, - CreateSubAccountApiKeyRequestV2, - DeleteSubAccountApiKeyRequestV2, - GetAgentCommissionDetailRequestV2, - GetAgentCustomerCommissionsRequestV2, - GetAgentCustomerKycResultRequestV2, - GetAgentSubCustomerListRequestV2, - GetAllSubDepositWithdrawalRequestV2, - GetBrokerCommissionsRequestV2, - GetBrokerOrderCommissionRequestV2, - GetBrokerRebateInfoRequestV2, - GetBrokerSubaccountsRequestV2, - GetBrokerTotalCommissionRequestV2, - GetBrokerTradeVolumeRequestV2, - GetSubAccountsRequestV2, - ModifySubAccountApiKeyRequestV2, - ModifySubRequestV2, - SubDepositRecordsRequestV2, - SubWithdrawalRecordsRequestV2, - SubWithdrawalRequestV2, -} from './types/request/v2/broker.js'; -import { - ConvertQuoteRequestV2, - ConvertRequestV2, - CreateAgentSubaccountRequestV2, - CreateVirtualSubApiKeyRequestV2, - CreateVirtualSubRequestV2, - GetAllTradeRatesRequestV2, - GetAnnouncementsRequestV2, - GetConvertBGBHistoryRequestV2, - GetConvertHistoryRequestV2, - GetFuturesTransactionsRequestV2, - GetMarginTransactionsRequestV2, - GetMerchantAdvertisementsRequestV2, - GetMerchantP2POrdersRequestV2, - GetP2PMerchantsRequestV2, - GetP2PTransactionsRequestV2, - GetSpotTransactionsRequestV2, - GetTradeRateRequestV2, - ModifyVirtualSubApiKeyRequestV2, - ModifyVirtualSubRequestV2, -} from './types/request/v2/common.js'; -import { - CloseFuturesFollowerPositionsRequestV2, - CopyTradingProductTypeV2, - FuturesTraderSymbolSettingRequestV2, - GetFollowerFuturesCurrentTrackingOrdersRequestV2, - GetFollowerFuturesHistoryTrackingOrdersRequestV2, - GetFuturesFollowerTradersRequestV2, - GetFuturesTraderCurrentOrdersRequestV2, - GetFuturesTraderFollowersRequestV2, - GetFuturesTraderHistoryOrdersRequestV2, - GetFuturesTraderProfitShareDetailRequestV2, - GetSpotFollowerHistoryOrdersRequestV2, - GetSpotFollowerOpenOrdersRequestV2, - GetSpotTraderCurrentOrdersRequestV2, - GetSpotTraderFollowersRequestV2, - GetSpotTraderHistoryOrdersRequestV2, - GetSpotTraderHistoryProfitRequestV2, - ModifyFuturesTraderOrderTPSLRequestV2, - SpotFollowerCopyTradeSettingV2, - UpdateFuturesFollowerSettingsRequestV2, - UpdateFuturesFollowerTPSLRequestV2, -} from './types/request/v2/copytrading.js'; -import { - BorrowLoanRequestV2, - EarnEliteSubscribeRequestV2, - GetEarnEliteRecordsRequestV2, - GetEarnEliteRedeemInfoRequestV2, - GetEarnEliteSubscribeInfoRequestV2, - GetEarnEliteSubscribeResultRequestV2, - GetEarnSavingsAssetsRequestV2, - GetEarnSavingsRecordsRequestV2, - GetLiquidationRecordsRequestV2, - GetLoanEstInterestAndBorrowableRequestV2, - GetLoanHistoryRequestV2, - GetLoanPledgeRateHistoryRequestV2, - GetLoanRepayHistoryRequestV2, - GetSharkfinAssetsRequestV2, - GetSharkfinRecordsRequestV2, - ModifyLoanPledgeRateRequestV2, - RedeemEarnEliteRequestV2, - RedeemSavingsRequestV2, - RepayLoanRequestV2, -} from './types/request/v2/earn.js'; -import { - FuturesAccountBillRequestV2, - FuturesBatchCancelOrderRequestV2, - FuturesBatchOrderRequestV2, - FuturesCancelAllOrdersRequestV2, - FuturesCancelOrderRequestV2, - FuturesCancelPlanOrderRequestV2, - FuturesCandlesRequestV2, - FuturesFlashClosePositionsRequestV2, - FuturesGetHistoricalFillsRequestV2, - FuturesGetHistoryOrdersRequestV2, - FuturesGetHistoryPlanOrdersRequestV2, - FuturesGetOpenOrdersRequestV2, - FuturesGetOrderFillsRequestV2, - FuturesGetOrderRequestV2, - FuturesGetPlanOrdersRequestV2, - FuturesHistoricalPositionsRequestV2, - FuturesHistoricTradesRequestV2, - FuturesInterestHistoryRequestV2, - FuturesIsolatedSymbolsRequestV2, - FuturesLiquidationPriceRequestV2, - FuturesMaxOpenRequestV2, - FuturesMergeDepthRequestV2, - FuturesModifyOrderRequestV2, - FuturesModifyPlanOrderRequestV2, - FuturesModifyTPSLOrderRequestV2, - FuturesOiLimitRequestV2, - FuturesOpenCountRequestV2, - FuturesPlaceOrderRequestV2, - FuturesPlanOrderRequestV2, - FuturesPositionAdlRankRequestV2, - FuturesPositionTPSLOrderRequestV2, - FuturesRecentTradesRequestV2, - FuturesReversalOrderRequestV2, - FuturesSetAutoMarginRequestV2, - FuturesSetLeverageRequestV2, - FuturesSetMarginModeRequestV2, - FuturesSetPositionMarginRequestV2, - FuturesSingleAccountRequestV2, - FuturesTPSLOrderRequestV2, - GetUnionTransferLimitsRequestV2, - UnionConvertRequestV2, -} from './types/request/v2/futures.js'; -import { - GetInstLoanLTVConvertRequestV2, - GetInstLoanMarginCoinInfoRequestV2, - GetInstLoanOrderRequestV2, - GetInstLoanProductInfoRequestV2, - GetInstLoanRepaidHistoryRequestV2, - GetInstLoanSymbolsRequestV2, -} from './types/request/v2/instloan.js'; -import { - GetBorrowHistoryRequestV2, - GetFinancialHistoryRequestV2, - GetHistoryOrdersRequestV2, - GetInterestHistoryRequestV2, - GetLiquidationHistoryRequestV2, - GetMarginCurrentOrdersRequestV2, - GetMarginLiquidationOrdersRequestV2, - GetMarginOrderFillsRequestV2, - GetRepayHistoryRequestV2, - MarginBatchOrdersRequestV2, - MarginPlaceOrderRequestV2, -} from './types/request/v2/margin.js'; -import { - GetSpotAccountBillsRequestV2, - GetSpotCurrentPlanOrdersRequestV2, - GetSpotDepositRecordRequestV2, - GetSpotFillsRequestV2, - GetSpotHistoryOrdersRequestV2, - GetSpotHistoryPlanOrdersRequestV2, - GetSpotOpenOrdersRequestV2, - GetSpotOrderInfoRequestV2, - GetSpotSubAccountDepositRecordRequestV2, - GetSpotTransferRecordRequestV2, - GetSpotWithdrawalRecordRequestV2, - SpotAccountTypeV2, - SpotBatchCancelOrderRequestV2, - SpotBatchOrderRequestV2, - SpotCallAuctionRequestV2, - SpotCancelandSubmitOrderRequestV2, - SpotCancelOrderRequestV2, - SpotCandlesRequestV2, - SpotHistoricCandlesRequestV2, - SpotHistoricTradesRequestV2, - SpotMainSubTransferRecordRequestV2, - SpotModifyPlanOrderRequestV2, - SpotOrderRequestV2, - SpotPlanOrderRequestV2, - SpotSubAccountTransferRequestV2, - SpotTransferRequestV2, - SpotWithdrawalRequestV2, -} from './types/request/v2/spot.js'; -import { - AgentCommissionDetailV2, - AgentCustomerAssetItemV2, - AgentCustomerCommissionsV2, - AgentCustomerDepositItemV2, - AgentCustomerKycResultV2, - AgentCustomerListItemV2, - AgentCustomerTradeVolumeItemV2, - AgentSubCustomerListV2, - AllSubDepositWithdrawalRecordV2, - BrokerCommissionV2, - BrokerOrderCommissionV2, - BrokerRebateInfoV2, - BrokerSubaccountFutureAssetV2, - BrokerSubaccountInfoV2, - BrokerSubaccountSpotAssetV2, - BrokerSubaccountV2, - BrokerSubaccountWithdrawalV2, - BrokerTotalCommissionV2, - BrokerTradeVolumeV2, - CreateSubaccountApiKeyResponseV2, - CreateSubaccountDepositAddressV2, - CreateSubaccountResponseV2, - ModifySubaccountApiKeyResponseV2, - ModifySubaccountResponseV2, - SubaccountApiKeyV2, - SubaccountDepositV2, - SubaccountEmailV2, -} from './types/response/v2/broker.js'; -import { - AnnouncementV2, - BGBConvertCoinV2, - BGBConvertHistoryV2, - BotAssetV2, - ConvertBGBResponseV2, - ConvertCurrencyV2, - ConvertQuotedPriceV2, - ConvertRecordV2, - ConvertTradeResponseV2, - CreateAgentSubaccountV2, - CreateVirtualSubAccountAndApiKeyV2, - CreateVirtualSubAccountApiKeyV2, - CreateVirtualSubAccountV2, - FundingAssetV2, - FuturesActiveBuySellVolumeV2, - FuturesActiveLongShortAccountV2, - FuturesActiveLongShortPositionV2, - FuturesLongShortRatioV2, - FuturesTransactionRecordV2, - IsolatedMarginBorrowingRatioV2, - LeveragedLongShortRatioV2, - MarginLoanGrowthRateV2, - MarginTransactionRecordV2, - ModifyVirtualSubAccountApiKeyV2, - P2PMerchantAdvertismentV2, - P2PMerchantInfoV2, - P2PMerchantOrdersV2, - P2PMerchantOrderV2, - P2PMerchantV2, - SpotFundFlowV2, - SpotTransactionRecordV2, - SpotWhaleNetFlowV2, - SubAccountApiKeyItemV2, - VirtualSubAccountV2, -} from './types/response/v2/common.js'; -import { - CTFuturesFollowerCurrentOrdersV2, - CTFuturesFollowerHistoryOrdersV2, - CTFuturesFollowerMyTradersV2, - CTFuturesFollowerSettingsV2, - CTFuturesTraderCurrentOrdersV2, - CTFuturesTraderHistoryOrderV2, - CTFuturesTraderHistoryProfitSummaryV2, - CTFuturesTraderMyFollowersV2, - CTFuturesTraderProfitShareHistoryV2, - CTFuturesTraderSymbolSettingsV2, - CTFuturesTraderTotalOrderSummaryV2, - CTSpotFollowerCurrentOrdersV2, - CTSpotFollowerFollowConfigurationV2, - CTSpotFollowerHistoryOrdersV2, - CTSpotFollowerMyTradersV2, - CTSpotTraderCurrentTrackingOrdersV2, - CTSpotTraderFollowerListV2, - CTSpotTraderHistoryOrdersV2, - CTSpotTraderHistoryProfitSharingV2, - CTSpotTraderProfitSummaryV2, - CTSpotTraderTotalOrderDetailV2, - CTSpotTraderUnrealizedProfitV2, -} from './types/response/v2/copy-trading.js'; -import { - EarnEliteAssetsV2, - EarnEliteProductV2, - EarnEliteRecordsV2, - EarnEliteRedeemInfoV2, - EarnEliteSubscribeInfoV2, - EarnEliteSubscribeResultV2, - EarnEliteSubscribeStatusV2, - EarnLoanCurrenciesV2, - EarnLoanDebtsV2, - EarnLoanHistoryV2, - EarnLoanLiquidationRecordsV2, - EarnLoanOrdersV2, - EarnLoanPledgeRateHistoryV2, - EarnLoanRepayHistoryV2, - EarnLoanRepayResponseV2, - EarnSavingsAccountV2, - EarnSavingsAssetsV2, - EarnSavingsProductsV2, - EarnSavingsRecordsV2, - EarnSavingsSubscriptionDetailV2, - EarnSharkfinAccountV2, - EarnSharkfinAssetsV2, - EarnSharkfinProductsV2, - EarnSharkfinRecordsV2, - EarnSharkfinSubscriptionDetailV2, - RedeemEarnEliteResultV2, -} from './types/response/v2/earn.js'; -import { - FuturesAccountBillV2, - FuturesAccountsV2, - FuturesAccountV2, - FuturesBatchOrderResponseV2, - FuturesCancelAllOrdersV2, - FuturesCancelPlanOrderV2, - FuturesCandlestickV2, - FuturesClosePositionResponseV2, - FuturesContractConfigV2, - FuturesDiscountRatesV2, - FuturesFillV2, - FuturesFundingTimeV2, - FuturesHistoricalFundingRateV2, - FuturesHistoryInterestRateV2, - FuturesHistoryOrderV2, - FuturesHistoryPlanOrderV2, - FuturesHistoryPositionV2, - FuturesInterestExchangeRateV2, - FuturesInterestHistoryV2, - FuturesIsolatedSymbolV2, - FuturesLiquidationPriceV2, - FuturesMaxOpenV2, - FuturesMergeDepthV2, - FuturesOpenInterestV2, - FuturesOpenOrderV2, - FuturesOrderDetailV2, - FuturesOrderFillV2, - FuturesPendingPlanOrderV2, - FuturesPositionAdlRankV2, - FuturesPositionTierV2, - FuturesPositionV2, - FuturesSubAccountAssetV2, - FuturesSymbolPriceV2, - FuturesTickerV2, - FuturesTriggerSubOrderV2, - FuturesVipFeeRateV2, - SetLeverageResponseV2, - SetMarginModeResponseV2, - UnionConfigV2, - UnionConvertV2, - UnionSwitchUsdtV2, - UnionTransferLimitsV2, -} from './types/response/v2/futures.js'; -import { - InstLoanCoinInfoV2, - InstLoanLTVConvertV2, - InstLoanOrderV2, - InstLoanProductInfoV2, - InstLoanRepaidHistoryItemV2, - InstLoanSymbolsV2, -} from './types/response/v2/instloan.js'; -import { - CrossInterestRateAndLimitResponseV2, - CrossMaxBorrowableResponseV2, - CrossMaxTransferableResponseV2, - CrossTierConfigurationResponseV2, - IsolatedInterestRateAndLimitResponseV2, - IsolatedMaxBorrowableResponseV2, - IsolatedMaxTransferableResponseV2, - IsolatedTierConfigurationResponseV2, - MarginAccountAssetV2, - MarginBatchOrdersResponseV2, - MarginBorrowHistoryItemV2, - MarginCurrencyV2, - MarginCurrentOrderV2, - MarginFinancialHistoryItemV2, - MarginHistoryOrderV2, - MarginInterestHistoryItemV2, - MarginLiquidationHistoryItemV2, - MarginLiquidationOrderV2, - MarginOrderFillV2, - MarginRepaymentHistoryItemV2, -} from './types/response/v2/margin.js'; -import { - CancelAndSubmitSpotOrderResponseV2, - SpotAccountAssetV2, - SpotAccountBillV2, - SpotAccountInfoV2, - SpotCallAuctionV2, - SpotCancelPlanOrdersV2, - SpotCandlestickV2, - SpotCoinInfoV2, - SpotCurrentPlanOrderV2, - SpotDepositAddressV2, - SpotDepositRecordV2, - SpotFillV2, - SpotHistoryPlanOrderV2, - SpotMainSubTransferRecordV2, - SpotMergeDepthV2, - SpotOpenOrderV2, - SpotOrderBookDepthV2, - SpotOrderInfoV2, - SpotPlanSubOrderV2, - SpotSubAccountAssetsV2, - SpotSubAccountDepositRecordV2, - SpotSymbolInfoV2, - SpotTickerV2, - SpotTradeV2, - SpotTransferRecordV2, - SpotVipFeeRateV2, - SpotWithdrawalRecordV2, - SubmitSpotBatchOrdersResponseV2, -} from './types/response/v2/spot.js'; -import { APIResponse } from './types/shared.js'; -import BaseRestClient from './util/BaseRestClient.js'; -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 -⋮---- -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 - * - */ -⋮---- -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 - * - * - 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 - * - * - 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> -⋮---- -/** - * 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> -⋮---- -getFuturesHistoricPositions( - params?: FuturesHistoricalPositionsRequestV2, - ): Promise< - APIResponse<{ - list: FuturesHistoryPositionV2[]; - endId: string; - }> - > { - return this.getPrivate('/api/v2/mix/position/history-position', params); -⋮---- -getFuturesPositionAdlRank( - params: FuturesPositionAdlRankRequestV2, -): Promise> -⋮---- -/** - * - * * Futures | Trade - * - */ -⋮---- -futuresSubmitOrder(params: FuturesPlaceOrderRequestV2): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > { - return this.postPrivate('/api/v2/mix/order/place-order', params); -⋮---- -futuresSubmitReversal(params: FuturesReversalOrderRequestV2): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > { - return this.postPrivate('/api/v2/mix/order/click-backhand', params); -⋮---- -futuresBatchSubmitOrders( - params: FuturesBatchOrderRequestV2, -): Promise> -⋮---- -futuresModifyOrder(params: FuturesModifyOrderRequestV2): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > { - return this.postPrivate('/api/v2/mix/order/modify-order', params); -⋮---- -futuresCancelOrder(params: FuturesCancelOrderRequestV2): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > { - return this.postPrivate('/api/v2/mix/order/cancel-order', params); -⋮---- -futuresBatchCancelOrders( - params: FuturesBatchCancelOrderRequestV2, -): Promise> -⋮---- -futuresFlashClosePositions( - params: FuturesFlashClosePositionsRequestV2, -): Promise> -⋮---- -getFuturesOrder( - params: FuturesGetOrderRequestV2, -): Promise> -⋮---- -getFuturesFills(params: FuturesGetOrderFillsRequestV2): Promise< - APIResponse<{ - fillList: FuturesOrderFillV2[]; - endId: string; - }> - > { - return this.getPrivate('/api/v2/mix/order/fills', params); -⋮---- -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> -⋮---- -/** - * - * * Futures | Trigger Orders - * - */ -⋮---- -getFuturesTriggerSubOrder(params: { - planType: 'normal_plan' | 'track_plan'; - planOrderId: string; - productType: FuturesProductTypeV2; -}): Promise> -⋮---- -futuresSubmitTPSLOrder(params: FuturesTPSLOrderRequestV2): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > { - return this.postPrivate('/api/v2/mix/order/place-tpsl-order', params); -⋮---- -futuresSubmitPositionTPSL(params: FuturesPositionTPSLOrderRequestV2): Promise< - APIResponse< - { - orderId: string; - stopSurplusClientOid: string; - stopLossClientOid: string; - }[] - > - > { - return this.postPrivate('/api/v2/mix/order/place-pos-tpsl', params); -⋮---- -futuresSubmitPlanOrder(params: FuturesPlanOrderRequestV2): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > { - return this.postPrivate('/api/v2/mix/order/place-plan-order', params); -⋮---- -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<{ - entrustedList: FuturesHistoryPlanOrderV2[]; - endId: string; - }> - > { - return this.getPrivate('/api/v2/mix/order/orders-plan-history', params); -⋮---- -/** - * - * - * Broker - * - * - */ -⋮---- -/** - * - * * Broker | Subaccount - * - */ -⋮---- -modifySubaccountEmail(params: { - subUid: string; - subaccountEmail: string; -}): Promise> -⋮---- -getBrokerInfo(): Promise< - APIResponse<{ - subAccountSize: string; - maxSubAccountSize: string; - uTime: string; - }> - > { - return this.getPrivate('/api/v2/broker/account/info'); -⋮---- -createSubaccount(params: { - subaccountName: string; - label: string; -}): Promise> -⋮---- -getSubaccounts(params?: GetSubAccountsRequestV2): Promise< - APIResponse<{ - hasNextPage: boolean; - idLessThan: number; - subList: BrokerSubaccountV2[]; - }> - > { - return this.getPrivate('/api/v2/broker/account/subaccount-list', params); -⋮---- -modifySubaccount( - params: ModifySubRequestV2, -): Promise> -⋮---- -getSubaccountEmail(params: { - subUid: 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, - ); -⋮---- -getSubaccountFuturesAssets(params: { - subUid: string; - productType: FuturesProductTypeV2; - }): Promise< - APIResponse<{ - assetsList: BrokerSubaccountFutureAssetV2[]; - }> - > { - return this.getPrivate( - '/api/v2/broker/account/subaccount-future-assets', - params, - ); -⋮---- -createSubaccountDepositAddress(params: { - subUid: string; - coin: string; - chain?: string; -}): Promise> -⋮---- -subaccountWithdrawal(params: SubWithdrawalRequestV2): 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> -⋮---- -/** - * Sub Deposit Records - * - * - Only applicable for ND broker main-account to get ND sub-accounts deposit record - */ -subaccountDepositRecords( - params: SubDepositRecordsRequestV2, -): Promise> -⋮---- -/** - * Sub Withdrawal Records - * - * - Only applicable for ND broker main-account - */ -subaccountWithdrawalRecords(params: SubWithdrawalRecordsRequestV2): Promise< - APIResponse<{ - resultList: BrokerSubaccountWithdrawalV2[]; - endId: string; - }> - > { - return this.getPrivate('/api/v2/broker/subaccount-withdrawal', params); -⋮---- -/** - * - * Broker | Api Key - * - */ -⋮---- -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; - }> - > { - 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> -⋮---- -/** - * 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 - * - * - 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> -⋮---- -/** - * Get Rebate Info - * - * - Rate limit: 20 req/sec/UID - * - Data retention: 30 days - * - Real-time data - */ -getBrokerRebateInfo( - params: GetBrokerRebateInfoRequestV2, -): Promise> -⋮---- -/** - * - * * Broker | Agent (affiliate) customer APIs - * - */ -⋮---- -getAgentCustomerCommissions( - params?: GetAgentCustomerCommissionsRequestV2, -): Promise> -⋮---- -/** - * Without startTime/endTime, returns all registered sub-customers (no time restriction). - */ -getAgentSubCustomerList( - params?: GetAgentSubCustomerListRequestV2, -): Promise> -⋮---- -getAgentCustomerTradeVolume( - params?: AgentCustomerTradeVolumeRequestV2, -): Promise> -⋮---- -/** - * Without startTime/endTime, returns all registered customers (no time restriction). - */ -getAgentCustomerList( - params?: AgentCustomerListRequestV2, -): Promise> -⋮---- -getAgentCustomerKycResult( - params?: GetAgentCustomerKycResultRequestV2, -): Promise> -⋮---- -getAgentCustomerDeposits( - params?: AgentCustomerDepositRequestV2, -): Promise> -⋮---- -getAgentCustomerAssets( - params?: AgentCustomerAssetRequestV2, -): Promise> -⋮---- -getAgentCommissionDetail( - params?: GetAgentCommissionDetailRequestV2, -): Promise> -⋮---- -/** - * - * - * Margin - * - * - */ -⋮---- -/** - * - * * Margin | Common - * - */ -⋮---- -getMarginCurrencies(): Promise> -⋮---- -/** - * - * * Margin | Cross/Isolated | Order Record - * - */ -⋮---- -getMarginBorrowHistory( - marginType: MarginType, - params: GetBorrowHistoryRequestV2, - ): Promise< - APIResponse<{ - resultList: MarginBorrowHistoryItemV2[]; - maxId: string; - minId: string; - }> - > { - assertMarginType(marginType); -⋮---- -getMarginRepayHistory( - marginType: MarginType, - params: GetRepayHistoryRequestV2, - ): Promise< - APIResponse<{ - resultList: MarginRepaymentHistoryItemV2[]; - maxId: string; - minId: string; - }> - > { - assertMarginType(marginType); -⋮---- -getMarginInterestHistory( - marginType: MarginType, - params: GetInterestHistoryRequestV2, - ): Promise< - APIResponse<{ - resultList: MarginInterestHistoryItemV2[]; - maxId: string; - minId: string; - }> - > { - assertMarginType(marginType); -⋮---- -getMarginLiquidationHistory( - marginType: MarginType, - params: GetLiquidationHistoryRequestV2, - ): Promise< - APIResponse<{ - resultList: MarginLiquidationHistoryItemV2[]; - maxId: string; - minId: string; - }> - > { - assertMarginType(marginType); -⋮---- -getMarginFinancialHistory( - marginType: MarginType, - params: GetFinancialHistoryRequestV2, - ): Promise< - APIResponse<{ - resultList: MarginFinancialHistoryItemV2[]; - maxId: string; - minId: string; - }> - > { - assertMarginType(marginType); -⋮---- -/** - * - * * Margin | Cross/Isolated | Account - * - */ -⋮---- -getMarginAccountAssets( - marginType: MarginType, - params?: { coin?: string }, -): Promise> -⋮---- -marginBorrow( - marginType: MarginType, - params: { - loanId: string; - symbol: string; - coin: string; - borrowAmount: string; - }, - ): Promise< - APIResponse<{ - loanId: string; - symbol: string; - coin: string; - borrowAmount: string; - }> - > { - assertMarginType(marginType); -⋮---- -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); -⋮---- -getMarginRiskRate(marginType: MarginType): Promise< - APIResponse< - { - symbol: string; - riskRateRatio: string; - }[] - > - > { - assertMarginType(marginType); -⋮---- -getMarginMaxBorrowable( - marginType: MarginType, - params: { coin: string }, - ): Promise< - APIResponse - > { - assertMarginType(marginType); -⋮---- -getMarginMaxTransferable( - marginType: MarginType, - params: { coin: string }, - ): Promise< - APIResponse< - CrossMaxTransferableResponseV2 | IsolatedMaxTransferableResponseV2 - > - > { - assertMarginType(marginType); -⋮---- -getMarginInterestRateAndMaxBorrowable( - marginType: MarginType, - params: { coin: string }, - ): Promise< - APIResponse< - | IsolatedInterestRateAndLimitResponseV2[] - | CrossInterestRateAndLimitResponseV2[] - > - > { - assertMarginType(marginType); -⋮---- -getMarginTierConfiguration( - marginType: MarginType, - params: { coin: string }, - ): Promise< - APIResponse< - CrossTierConfigurationResponseV2[] | IsolatedTierConfigurationResponseV2[] - > - > { - assertMarginType(marginType); -⋮---- -marginFlashRepay( - marginType: MarginType, - params: { coin: string }, - ): Promise< - APIResponse<{ - repayId: string; - coin?: string; - symbol?: string; - result?: string; - }> - > { - assertMarginType(marginType); -⋮---- -getMarginFlashRepayResult( - marginType: MarginType, - params: { idList: string }, - ): Promise< - APIResponse< - { - repayId: string; - status: string; - }[] - > - > { - assertMarginType(marginType); -⋮---- -/** - * - * * Margin | Cross/Isolated | Trade - * - */ -⋮---- -marginSubmitOrder( - marginType: MarginType, - params: MarginPlaceOrderRequestV2, - ): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > { - assertMarginType(marginType); -⋮---- -marginBatchSubmitOrders( - marginType: MarginType, - params: MarginBatchOrdersRequestV2, -): Promise> -⋮---- -marginCancelOrder( - marginType: MarginType, - params: { - symbol: string; - orderId?: string; - clientOid?: string; - }, - ): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > { - assertMarginType(marginType); -⋮---- -marginBatchCancelOrders( - marginType: MarginType, - params: { - symbol: string; - orderIdList: string[]; - }, -): Promise> -⋮---- -getMarginOpenOrders( - marginType: MarginType, - params: GetMarginCurrentOrdersRequestV2, - ): Promise< - APIResponse<{ - orderList: MarginCurrentOrderV2[]; - maxId: string; - minId: string; - }> - > { - assertMarginType(marginType); -⋮---- -getMarginHistoricOrders( - marginType: MarginType, - params: GetHistoryOrdersRequestV2, - ): Promise< - APIResponse<{ - orderList: MarginHistoryOrderV2[]; - maxId: string; - minId: string; - }> - > { - assertMarginType(marginType); -⋮---- -getMarginHistoricOrderFills( - marginType: MarginType, - params: GetMarginOrderFillsRequestV2, - ): Promise< - APIResponse<{ - fills: MarginOrderFillV2[]; - minId: string; - maxId: string; - }> - > { - assertMarginType(marginType); -⋮---- -getMarginLiquidationOrders( - marginType: MarginType, - params: GetMarginLiquidationOrdersRequestV2, - ): Promise< - APIResponse<{ - resultList: MarginLiquidationOrderV2[]; - idLessThan: string; - }> - > { - assertMarginType(marginType); -⋮---- -/** - * - * - * Copy Trading - * - * - */ -⋮---- -/** - * - * - * Copy Trading | Future copy trading | Trader Api - * - * - */ -⋮---- -getFuturesTraderCurrentOrder( - params: GetFuturesTraderCurrentOrdersRequestV2, -): Promise> -⋮---- -getFuturesTraderHistoryOrders( - params: GetFuturesTraderHistoryOrdersRequestV2, -): Promise> -⋮---- -modifyFuturesTraderOrderTPSL( - params: ModifyFuturesTraderOrderTPSLRequestV2, -): Promise> -⋮---- -getFuturesTraderOrder(): Promise< - APIResponse - > { - return this.getPrivate('/api/v2/copy/mix-trader/order-total-detail'); -⋮---- -getFuturesTraderProfitHistory(): Promise< - APIResponse - > { - return this.getPrivate('/api/v2/copy/mix-trader/profit-history-summarys'); -⋮---- -getFuturesTraderProfitShareHistory( - params: GetFuturesTraderProfitShareDetailRequestV2, -): Promise> -⋮---- -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, - ); -⋮---- -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); -⋮---- -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, - ); -⋮---- -getFuturesTraderSymbolSettings(params: { - productType: CopyTradingProductTypeV2; -}): Promise> -⋮---- -updateFuturesTraderSymbolSettings(params: { - settingList: FuturesTraderSymbolSettingRequestV2[]; -}): Promise> -⋮---- -updateFuturesTraderGlobalSettings(params?: { - enable?: 'YES' | 'NO'; - showTotalEquity?: 'YES' | 'NO'; - showTpsl?: 'YES' | 'NO'; -}): Promise> -⋮---- -getFuturesTraderFollowers( - params?: GetFuturesTraderFollowersRequestV2, -): Promise> -⋮---- -removeFuturesTraderFollower(params: { - followerUid: string; -}): Promise> -⋮---- -/** - * - * - * Copy Trading | Future copy trading | Follower Api - * - * - */ -⋮---- -getFuturesFollowerCurrentOrders( - params: GetFollowerFuturesCurrentTrackingOrdersRequestV2, -): Promise> -⋮---- -getFuturesFollowerHistoryOrders( - params: GetFollowerFuturesHistoryTrackingOrdersRequestV2, -): Promise> -⋮---- -updateFuturesFollowerTPSL( - params: UpdateFuturesFollowerTPSLRequestV2, -): Promise> -⋮---- -updateFuturesFollowerSettings( - params: UpdateFuturesFollowerSettingsRequestV2, -): Promise> -⋮---- -getFuturesFollowerSettings(params: { - traderId: string; -}): Promise> -⋮---- -closeFuturesFollowerPositions( - params: CloseFuturesFollowerPositionsRequestV2, - ): Promise< - APIResponse<{ - orderIdList: string[]; - }> - > { - return this.postPrivate( - '/api/v2/copy/mix-follower/close-positions', - params, - ); -⋮---- -getFuturesFollowerTraders( - params: GetFuturesFollowerTradersRequestV2, -): Promise> -⋮---- -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, - ); -⋮---- -unfollowFuturesTrader(params: { - traderId: string; -}): Promise> -⋮---- -/** - * - * - * Copy Trading | Future copy trading | Broker api - * - * - */ -⋮---- -getBrokerTraders(params: object): Promise> -⋮---- -getBrokerTradersHistoricalOrders(params: object): Promise> -⋮---- -getBrokerTradersPendingOrders(params: object): Promise> -⋮---- -/** - * - * - * Copy Trading | Spot copy trading | Trader api - * - * - */ -⋮---- -getSpotTraderProfit(): Promise> -⋮---- -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; -}): Promise> -⋮---- -getSpotTraderSymbolSettings(params: { - symbolList: string[]; - settingType: 'add' | 'delete'; -}): Promise> -⋮---- -removeSpotTraderFollowers(params: { - followerUid: string; -}): Promise> -⋮---- -getSpotTraderConfiguration(): Promise> -⋮---- -getSpotTraderFollowers( - params: GetSpotTraderFollowersRequestV2, -): Promise> -⋮---- -/** - * - * - * Copy Trading | Spot copy trading | Follower api - * - * - */ -⋮---- -cancelSpotFollowerOrder(params: { - trackingNoList: string[]; -}): Promise> -⋮---- -updateSpotFollowerSettings(params: { - traderId: string; - autoCopy?: 'on' | 'off'; - mode?: 'basic' | 'advanced'; - settings: SpotFollowerCopyTradeSettingV2[]; -}): Promise> -⋮---- -updateSpotFollowerTPSL(params: { - trackingNo: string; - stopSurplusPrice?: string; - stopLossPrice?: string; -}): Promise> -⋮---- -getSpotFollowerTraders(params?: { - pageNo?: string; - pageSize?: string; - startTime?: string; - endTime?: string; -}): Promise> -⋮---- -getSpotFollowerCurrentTraderSymbols(params: { traderId: string }): Promise< - APIResponse<{ - currentTradingList: string[]; - }> - > { - return this.getPrivate( - '/api/v2/copy/spot-follower/query-trader-symbols', - params, - ); -⋮---- -getSpotFollowerSettings(params: { - traderId: string; -}): Promise> -⋮---- -getSpotFollowerHistoryOrders( - params: GetSpotFollowerHistoryOrdersRequestV2, -): Promise> -⋮---- -getSpotFollowerOpenOrders( - params: GetSpotFollowerOpenOrdersRequestV2, -): Promise> -⋮---- -sellSpotFollower(params: { - trackingNoList: string[]; - symbol: string; -}): Promise> -⋮---- -unfollowSpotTrader(params: { - traderId: string; -}): Promise> -⋮---- -/** - * - * - * Earn | Savings - * - * - */ -⋮---- -getEarnSavingsProducts(params?: { - coin?: string; - filter?: string; -}): Promise> -⋮---- -getEarnSavingsAccount(): Promise> -⋮---- -getEarnSavingsAssets( - params: GetEarnSavingsAssetsRequestV2, -): Promise> -⋮---- -getEarnSavingsRecords( - params: GetEarnSavingsRecordsRequestV2, -): Promise> -⋮---- -getEarnSavingsSubscription(params: { - productId: string; - periodType: string; -}): Promise> -⋮---- -earnSubscribeSavings(params: { - productId: string; - periodType: string; - amount: string; - }): Promise< - APIResponse<{ - orderId: string; - status: string; - }> - > { - return this.postPrivate('/api/v2/earn/savings/subscribe', params); -⋮---- -getEarnSavingsSubscriptionResult(params: { - productId: string; - periodType: string; - }): Promise< - APIResponse<{ - result: 'success' | 'fail'; - msg: string; - }> - > { - return this.getPrivate('/api/v2/earn/savings/subscribe-result', params); -⋮---- -earnRedeemSavings(params: RedeemSavingsRequestV2): Promise< - APIResponse<{ - orderId: string; - status: string; - }> - > { - return this.postPrivate('/api/v2/earn/savings/redeem', params); -⋮---- -getEarnSavingsRedemptionResult(params: { - orderId: string; - periodType: string; - }): Promise< - APIResponse<{ - result: 'success' | 'fail'; - msg: string; - }> - > { - return this.getPrivate('/api/v2/earn/savings/redeem-result', params); -⋮---- -/** - * - * - * Earn | Earn Account - * - * - */ -⋮---- -getEarnAccount(params?: { coin?: string }): Promise< - APIResponse< - { - coin: string; - amount: string; - }[] - > - > { - return this.getPrivate('/api/v2/earn/account/assets', params); -⋮---- -/** - * - * - * 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> -⋮---- -/** - * - * - * Earn | Shark Fin - * - * - */ -⋮---- -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); -⋮---- -/** - * - * - * 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> -⋮---- -/** - * - * * Inst Loan | Product Info - * - */ -⋮---- -getLoanProductInfo( - params: GetInstLoanProductInfoRequestV2, -): Promise> -⋮---- -getLoanSymbols( - params: GetInstLoanSymbolsRequestV2, -): Promise> -⋮---- -getLoanMarginCoinInfo(params: GetInstLoanMarginCoinInfoRequestV2): Promise< - APIResponse<{ - productId: string; - coinInfo: InstLoanCoinInfoV2[]; - }> - > { - return this.getPrivate( - '/api/v2/spot/ins-loan/ensure-coins-convert', - params, - ); -⋮---- -/** - * - * * Inst Loan | Account - * - */ -⋮---- -getLoanRiskUnit(): Promise< - APIResponse<{ - riskUnitId: string[]; - }> - > { - return this.getPrivate('/api/v2/spot/ins-loan/risk-unit'); -⋮---- -getLoanLTVConvert( - params?: GetInstLoanLTVConvertRequestV2, -): Promise> -⋮---- -/** - * - * * Inst Loan | Orders - * - */ -⋮---- -getLoanRepaidHistory( - params?: GetInstLoanRepaidHistoryRequestV2, -): Promise> -⋮---- -getLoanOrder( - params?: GetInstLoanOrderRequestV2, -): Promise> - -================ -File: src/types/request/v3/account.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 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol?: string; -} -⋮---- -export interface GetConvertRecordsRequestV3 { - fromCoin?: string; - toCoin?: string; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; -} -⋮---- -export interface GetFinancialRecordsRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - coin?: string; - type?: string; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; -} -⋮---- -export interface RepayRequestV3 { - repayableCoinList: string[]; - paymentCoinList: string[]; -} -⋮---- -// Sub-account Management Request Types -⋮---- -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; - 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; - cursor?: 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; - 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 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 */ -⋮---- -export interface GetSubUnifiedAssetsRequestV3 { - subUid?: string; - cursor?: string; - limit?: string; -} -⋮---- -export interface GetFeeRateRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol: string; -} -⋮---- -export interface GetFundingAssetsRequestV3 { - coin?: string; -} -⋮---- -export interface SwitchDeductRequestV3 { - deduct: 'on' | 'off'; -} +import { DefaultLogger, WebsocketAPIClient } from '../../../src/index.js'; ⋮---- -// Deposit Request Types +// or +// import { DefaultLogger, WS_KEY_MAP, WebsocketAPIClient } from 'bitget-api'; ⋮---- -export interface GetDepositAddressRequestV3 { - coin: string; - chain?: string; - size?: 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 GetSubDepositAddressRequestV3 { - subUid: string; - coin: string; - chain?: string; - size?: 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 GetDepositRecordsRequestV3 { - coin?: string; - orderId?: string; - startTime: string; - endTime: string; - limit?: string; - cursor?: string; -} +// Whether to use the demo trading wss connection +// demoTrading: true, ⋮---- -export interface GetSubDepositRecordsRequestV3 { - coin?: string; - subUid: string; - startTime: string; - endTime: string; - limit?: string; - cursor?: 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 ⋮---- -// Withdraw Request Types +logger, // Optional: inject a custom logger ⋮---- -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; -} +// Optional, see above "attachEventListeners". Attach basic event handlers, so nothing is left unhandled +// attachEventHandlers(wsClient.getWSClient()); ⋮---- -/** Deduct from funding, uta, and/or otc accounts (comma-separated). Order: funding -> otc -> uta */ +// 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 GetWithdrawRecordsRequestV3 { - coin?: string; - orderId?: string; - clientOid?: string; - startTime: string; - endTime: string; - limit?: string; - cursor?: 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 interface GetWithdrawAddressBookRequestV3 { - coin?: string; - type?: 'EVM' | 'regular' | 'universal' | 'internal'; - limit?: string; - cursor?: string; -} +/** + * Place Order + * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters + */ ⋮---- -export interface CancelWithdrawalRequestV3 { - orderId?: string; - clientOid?: string; -} +/** + 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 SetDepositAccountRequestV3 { - coin: string; - accountType: 'funding' | 'unified' | 'otc'; -} +/** + * Batch Place Order Channel + * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel + */ ⋮---- -export interface GetMaxTransferableRequestV3 { - coin: string; -} +/** + * 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 GetOpenInterestLimitRequestV3 { - symbol: string; - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; -} +/** + 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 GetTaxRecordsRequestV3 { - bizType: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES' - | 'OTHER'; - marginType?: 'isolated' | 'crossed'; - coin?: string; - startTime: string; - endTime: string; - limit?: string; - cursor?: string; -} +/** + * Cancel Order + * https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel + */ ⋮---- -export type CollateralTypeV3 = 'mainstream' | 'all' | 'custom'; +/** + const res = { + "event": "trade", + "id": "1750034870205", + "topic": "cancel-order", + "args": [ + { + "orderId": "xxxxxxxx", + "clientOid": "xxxxxxxx" + } + ], + "code": "0", + "msg": "Success", + "ts": "1750034870597" + } + */ ⋮---- -export interface SetCollateralTypeRequestV3 { - collateralType: CollateralTypeV3; - /** Required when collateralType=custom. Comma-separated coin names */ - collateralCoins?: string; -} +/** + * Batch Cancel Order + * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Cancel-Order-Channel + */ ⋮---- -/** Required when collateralType=custom. Comma-separated coin names */ +/** + 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/copytrading.ts +================ +/** + * + * + * Copy Trading | Futures (UTA) + * + * + */ ⋮---- -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 CopyFuturesMarginDetailV3 { + marginCoin: string; + maxLongCount: string; + remainingLongCount: string; + maxShortCount: string; + remainingShortCount: string; } ⋮---- -export interface SetMarginRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; +export interface CopyFuturesTradingPairV3 { symbol: string; - posSide: 'long' | 'short'; - operation: 'add' | 'remove'; - amount: string; + leverage: string; + marginDetails: CopyFuturesMarginDetailV3[]; } ⋮---- -export interface GetMaxWithdrawalRequestV3 { - coin: string; +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; } ⋮---- -export interface GetRealityOrderBookRequestV3 { - symbol: string; +export interface CopyFuturesMaxTransferableV3 { + maxTransferable: string; + available: string; } ⋮---- -export interface GetRealityFillsRequestV3 { - symbol: string; - limit?: string; +export interface CopyFuturesTransferResponseV3 { + transferId: string; } ⋮---- -export interface SubMasterTransferRequestV3 { - fromType: 'spot' | 'uta'; - toType: 'spot' | 'p2p' | 'uta'; +/** May be a single value or comma-separated values */ +export type CopyFuturesTransferAccountTypeV3 = + | 'spot' + | 'uta' + | 'lead' + | 'otc' + | string; +⋮---- +export interface CopyFuturesTransferRecordV3 { + transferId: string; + fromType: CopyFuturesTransferAccountTypeV3; + toType: CopyFuturesTransferAccountTypeV3; amount: string; coin: string; - clientOid?: string; + status: 'Successful' | 'Failed' | 'Processing'; + createdTime: string; } ⋮---- -export interface CreateAgentSubAccountRequestV3 { - username: string; - passphrase: string; - note?: string; +export interface CopyFuturesTransferRecordListV3 { + list: CopyFuturesTransferRecordV3[]; } ⋮---- -export interface MovePositionItemRequestV3 { - symbol: string; - side: 'buy' | 'sell'; - qty: string; +export interface CopyFuturesCurrentFollowerV3 { + followerName: string; + estimateAssets: string; + totalProfit: string; + totalShareProfit: string; + totalInvestment: string; + canRemove: 'yes' | 'no'; + followDays: string; + totalAssets: string; + startTime: string; } ⋮---- -export interface MovePositionsRequestV3 { - fromUid: string; - toUid: string; - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - positionList: MovePositionItemRequestV3[]; +export interface CopyFuturesCurrentFollowersV3 { + list: CopyFuturesCurrentFollowerV3[]; } ⋮---- -export interface GetMovePositionHistoryRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - startTime?: string; - endTime?: string; - cursor?: string; - limit?: string; +export interface CopyFuturesHistoryFollowerV3 { + followerName: string; + totalProfit: string; + totalShareProfit: string; + totalInvestment: string; + startTime: string; + endTime: string; } ⋮---- -export interface GetEligibleSymbolsRequestV3 { - symbol?: string; +export interface CopyFuturesHistoryFollowersV3 { + list: CopyFuturesHistoryFollowerV3[]; } ⋮---- -export interface GetEligibleMarginTierRequestV3 { - coin?: string; +export interface CopyFuturesProfitSummaryV3 { + totalProfit: string; + totalAllocatedProfit: string; + totalPendingProfit: string; } ⋮---- -export interface GetEligibleLoanInfoRequestV3 { - coin?: string; +export interface CopyFuturesProfitDetailV3 { + followerName: string; + profit: string; + allocatedPnl: string; + pendingPnl: string; + shareRatio: string; + shareProfit: string; + reason: 'period' | 'unfollow' | string; + settleTime: string; } ⋮---- -export interface GetRateLimitQuotaRequestV3 { - category: 'spot' | 'futures'; - uid?: string; - cursor?: string; - limit?: string; +export interface CopyFuturesProfitDetailsV3 { + list: CopyFuturesProfitDetailV3[]; + nextCursor: string; } -⋮---- -export interface SetRateLimitQuotaRequestV3 { - category: 'spot' | 'futures'; - uids: string[]; - quota: string; + +================ +File: docs/BITGET_SDK_QUICKSTART_GUIDE.md +================ + +# 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: [`sieblyio/bitget-api`](https://github.com/sieblyio/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, + }); } -================ -File: src/types/response/v3/public.ts -================ -export interface PublicFillV3 { - execId: string; - price: string; - size: string; - side: 'sell' | 'buy'; - ts: 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 -} -⋮---- -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 ContractOiV3 { - symbol: string; - notionalValue: string; - totalNotionalValue: string; -} -⋮---- -export interface CurrentFundingRateV3 { - symbol: string; - fundingRate: string; - fundingRateInterval: string; - nextUpdate: string; - minFundingRate: string; - maxFundingRate: string; - cashDividend?: string; - cashDividendNextUpdate?: string; -} -⋮---- -export interface DiscountRateTierV3 { - tierStartValue: string; - discountRate: string; -} -⋮---- -export interface DiscountRateV3 { - coin: string; - list: DiscountRateTierV3[]; -} -⋮---- -export interface HistoryFundingRateV3 { - symbol: string; - fundingRate: string; - fundingRateTimestamp: string; -} -⋮---- -export interface MarginLoanV3 { - dailyInterest: string; - annualInterest: string; - limit: string; - masterSubLimit?: string; - /** Bitget spelling */ - platformRemaingQuota?: 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 }; } -⋮---- -/** Bitget spelling */ -⋮---- -export interface OpenInterestItemV3 { - symbol: string; - openInterest: 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 OpenInterestV3 { - list: OpenInterestItemV3[]; - ts: string; + +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 PositionTierV3 { - tier: string; - minTierValue: string; - maxTierValue: string; - leverage: string; - mmr: 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 RiskReserveRecordV3 { - balance: string; - amount: string; - ts: string; - type?: 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 RiskReserveV3 { - totalBalance?: string; - coin: string; - riskReserveRecords: RiskReserveRecordV3[]; + +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 interface RiskReserveHourRecordV3 { - amount: string; - balance: string; - ts: 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 RiskReserveHourV3 { - coin: string; - riskReserveRecords: RiskReserveHourRecordV3[]; + +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 RiskReserveAllItemV3 { - symbols: string[]; - coin: string; - balance: 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 RiskReserveAllV3 { - list: RiskReserveAllItemV3[]; + +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 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'; +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, + }); - // 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; + const cancelled = await wsApi.cancelOrder('spot', { + clientOid, + }); - // Margin specific fields - isIsolatedBaseBorrowable?: 'YES' | 'NO'; - isIsolatedQuotedBorrowable?: 'YES' | 'NO'; - warningRiskRatio?: string; - liquidationRiskRatio?: string; - maxCrossedLeverage?: string; - maxIsolatedLeverage?: string; - userMinBorrow?: 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 MarketFeeGroupTierV3 { - level: string; - makerFeeRate: string; - /** PRO1~PRO6 only. Taker fee rate in decimal form */ - takerFeeRate?: string; -} -⋮---- -/** PRO1~PRO6 only. Taker fee rate in decimal form */ -⋮---- -export interface MarketFeeGroupV3 { - category: string; - group: string; - labelList: MarketFeeGroupLabelV3[]; - tierList: MarketFeeGroupTierV3[]; -} -⋮---- -export interface MarketScoreWeightV3 { - category: string; - label: string; - symbol: string; - requiredSpread: string; - minMakerVolume: string; - weight: string; -} -⋮---- -export interface LiquidationV3 { - symbol: string; - side: 'buy' | 'sell'; - price: 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; -} -⋮---- -a: string[][]; // asks - [price, size] -b: string[][]; // bids - [price, size] -⋮---- -export interface RealityOrderBookV3 { - symbol: string; - a: string[][]; - b: string[][]; - ts: string; -} -⋮---- -export interface RealityFillV3 { - execId: string; - price: string; - size: string; - side: 'buy' | 'sell'; - ts: string; + console.log({ placed, cancelled }); } -⋮---- -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; -} -⋮---- -/** 24h platform turnover; only available for rtoken */ -⋮---- -// Futures specific fields -⋮---- -export interface ProofOfReservesV3 { - merkleRootHash: string; - totalReserveRatio: string; - list: { - coin: string; - userAssets: string; - platformAssets: string; - reserveRatio: string; - }[]; -} -⋮---- -export interface IndexComponentV3 { - exchange: string; - spotPair: string; - equivalentPrice: string; - weight: string; -} -⋮---- -export interface IndexPriceComponentsV3 { - symbol: string; - componentList: IndexComponentV3[]; -} -⋮---- -export interface RpiSymbolV3 { - category: 'spot' | 'usdt-futures' | 'coin-futures' | 'usdc-futures'; - symbol: string; -} -⋮---- -/** RPI order book depth: [price, nonRpiQty, rpiQty] */ -export interface RpiOrderBookV3 { - a: [string, string, string][]; - b: [string, string, string][]; - ts: string; -} -⋮---- -export interface CashDividendRecordV3 { - symbol: string; - exDividendDate: string; - cashDividendPerShare: string; - cashDividendTimestamp: string; -} -⋮---- -export interface SpotWhaleFlowV3 { - volume: string; - date: string; -} -⋮---- -export interface SpotNetFlowV3 { - netFlow: string; - ts: 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 interface MarginLongShortV3 { - longShortRatio: string; - ts: string; -} -⋮---- -export interface MarginLoanGrowthV3 { - growthRate: string; - ts: 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 MarginIsolatedBorrowV3 { - borrowRate: string; - ts: 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 FuturesActiveBuySellV3 { - buyVolume: string; - sellVolume: string; - ts: 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, + ); } -⋮---- -export interface FuturesLongShortV3 { - longRatio: string; - shortRatio: string; - longShortRatio: string; - ts: 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 FuturesPositionLongShortV3 { - longPositionRatio: string; - shortPositionRatio: string; - longShortPositionRatio: string; - ts: 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 FuturesAccountLongShortV3 { - longAccountRatio: string; - shortAccountRatio: string; - longShortAccountRatio: string; - ts: 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'); } -================ -File: README.md -================ -# Node.js & Typescript Bitget API SDK +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'; -[![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) +const proxyUrl = process.env.BITGET_SOCKS_PROXY_URL; -

- - - - SDK Logo - - -

+if (!proxyUrl) { + throw new Error('Set BITGET_SOCKS_PROXY_URL before running this example.'); +} -[1]: https://www.npmjs.com/package/bitget-api +const proxyAgent = new SocksProxyAgent(proxyUrl); -> [!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. +const rest = new RestClientV3( + {}, + { + httpsAgent: proxyAgent, + proxy: false, + }, +); -Updated & performant JavaScript & Node.js SDK for the Bitget V2 REST APIs and WebSockets: +const ws = new WebsocketClientV3({ + wsOptions: { + agent: proxyAgent, + }, +}); -- 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 +async function main() { + const serverTime = await rest.getServerTime(); + console.log('REST API connected through SOCKS5:', serverTime); -## Table of Contents + ws.subscribe( + { + topic: 'ticker', + payload: { + instType: 'spot', + symbol: 'BTCUSDT', + }, + }, + WS_KEY_MAP.v3Public, + ); +} -- [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) +process.once('SIGINT', () => { + ws.closeAll(); +}); -## Installation +main().catch(console.error); +``` -`npm install --save bitget-api` +### Proxy checks -## Examples +- 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. -Refer to the [examples](./examples) folder for implementation demos. +--- -## Issues & Discussion + +## Production notes -- 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) +### 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. -## Related Projects +### 2. Use client-generated order IDs -Check out our JavaScript/TypeScript/Node.js SDKs & Projects: +Set `clientOid` on every order and store it before you send. You'll need it to match state after retries, reconnects, or restarts. -- 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) - +### 3. Reconcile after reconnects -## Documentation +Reconnects happen. After a private stream comes back, hit REST for balances, positions, open orders, history, and recent fills before trusting local state. -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). +### 4. Check exchange acceptance -- 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) +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. -## Structure +### 5. Keep clocks healthy -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). +Private requests are timestamp-sensitive. Keep the host clock synced. Only touch `recvWindow` if you know you have clock skew. -The version on npm is the output from the `build` command and can be used in projects without TypeScript (although TypeScript is definitely recommended). +### 6. Keep credentials scoped -- [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! +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 -# Usage +`BITGETTRACE=true` is handy for local debugging - it logs raw requests and responses. Don't turn it on where logs might leak account data. -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) + +## FAQ -## REST API Clients +### Do I need API keys for public market data? -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 | +No. Public REST market data and public WebSocket streams can be used without API keys. -Examples for using each client can be found in: +### What is the Bitget API passphrase? -- the [examples](./examples) folder. -- the [awesome-crypto-examples](https://github.com/tiagosiebler/awesome-crypto-examples) repository. +The API passphrase is the passphrase set when creating the Bitget API key. In the SDK constructor it is passed as `apiPass`. -If you're missing an example, you're welcome to request one. Priority will be given to [github sponsors](https://github.com/sponsors/tiagosiebler). +### Which client should I use for a new project? -### Getting Started +Start with `RestClientV3`, `WebsocketClientV3`, and `WebsocketAPIClient` for current V3/UTA workflows. -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. +### When should I use V2/Classic clients? -There are several REST API modules as there are some differences in each API group: +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. -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. +### Why do category names have different casing? -More Node.js & JavaScript examples for Bitget's REST APIs & WebSockets can be found in the [examples](./examples) folder on GitHub. +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`. -#### V3 REST APIs +### What is the difference between WebSocket streams and the WebSocket API? -These are only available if you have upgraded to the Unified Trading Account. If not, use the V2 APIs instead. +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. -```javascript -import { RestClientV3 } from 'bitget-api'; -// or if you prefer require: -// const { RestClientV3 } = require('bitget-api'); +### Can I use this SDK from plain JavaScript? -// 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', -}); +Yes. The SDK works in JavaScript and TypeScript. TypeScript users also get request and response types from the package. -(async () => { - try { - console.log(await client.getBalances()); +### Does the SDK support RSA keys? - const newOrder = await client.submitNewOrder({ - category: 'USDT-FUTURES', - orderType: 'market', - side: 'buy', - qty: '0.001', - symbol: 'BTCUSDT', - }); +Yes. Pass your RSA private key as `apiSecret`; the SDK auto-detects RSA vs HMAC signing. See the [GitHub repository](https://github.com/sieblyio/bitget-api). - console.log('Order submitted: ', newOrder); - } catch (e) { - console.error('request failed: ', e); - } -})(); -``` +### 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. -#### V2 REST APIs +### Where can I find more examples? -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. +More in the repo: -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. +- [V3/UTA examples](../examples/V3%20-%20UTA) +- [V2/Classic examples](../examples/V2%20-%20Classic) +- [Auth examples](../examples/Auth) +- [Bitget JavaScript Endpoint Reference](./endpointFunctionList.md) -```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'; + +## Next steps -const client = new RestClientV2({ - apiKey: API_KEY, - apiSecret: API_SECRET, - apiPass: API_PASS, -}); +- [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/sieblyio/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) -// For public-only API calls, simply don't provide a key & secret or set them to undefined -// const client = new RestClientV2(); +================ +File: src/types/request/v3/public.ts +================ +export interface GetPublicFillsRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol?: string; + limit?: 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 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 GetContractsOiRequestV3 { + symbol?: string; + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; +} +⋮---- +export interface GetCurrentFundingRateRequestV3 { + category?: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; +} +⋮---- +export interface GetLiquidationsRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; + limit?: string; + cursor?: string; +} +⋮---- +export interface GetHistoryFundingRateRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol: string; + cursor?: string; + limit?: string; +} +⋮---- +export interface GetMarginLoansRequestV3 { + coin: string; + /** User level. Default: vip0 */ + level?: + | 'vip0' + | 'vip1' + | 'vip2' + | 'vip3' + | 'vip4' + | 'vip5' + | 'vip6' + | 'vip7' + | 'pro1' + | 'pro2' + | 'pro3' + | 'pro4' + | 'pro5' + | 'pro6'; +} +⋮---- +/** User level. Default: vip0 */ +⋮---- +export interface GetSplitRecordsRequestV3 { + symbol?: string; +} +⋮---- +export interface GetOpenInterestRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; +} +⋮---- +export interface GetPositionTierRequestV3 { + category: 'MARGIN' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; + coin?: string; +} +⋮---- +export interface GetRiskReserveRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol: string; + marginCoin?: string; +} +⋮---- +export interface GetRiskReserveAllRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; +} +⋮---- +export interface GetInstrumentsRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol?: string; +} +⋮---- +export interface GetMarketFeeGroupRequestV3 { + category: 'SPOT' | 'FUTURES'; + group?: 'DEFAULT' | 'GROUP_A' | 'GROUP_B' | 'GROUP_C'; +} +⋮---- +export interface GetMarketScoreWeightsRequestV3 { + category?: 'SPOT' | 'FUTURES'; +} +⋮---- +export interface GetOrderBookRequestV3 { + category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol: string; + limit?: string; +} +⋮---- +export interface GetTickersRequestV3 { + category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; +} +⋮---- +export interface GetIndexComponentsRequestV3 { + symbol: string; +} +⋮---- +export interface GetRpiOrderBookRequestV3 { + category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol: string; + limit?: string; +} +⋮---- +export interface GetCashDividendRecordsRequestV3 { + symbol: string; + type: 'pending' | 'paid'; + cursor?: string; + limit?: string; +} +⋮---- +export interface GetSpotWhaleFlowRequestV3 { + symbol: string; +} +⋮---- +export interface GetSpotFundFlowRequestV3 { + symbol: string; + period?: string; +} +⋮---- +export interface GetSpotNetFlowRequestV3 { + symbol: string; +} +⋮---- +export interface GetMarginLongShortRequestV3 { + symbol: string; + period?: '24h' | '30d'; + coin?: string; +} +⋮---- +export interface GetMarginLoanGrowthRequestV3 { + symbol: string; + period?: string; + coin?: string; +} +⋮---- +export interface GetMarginIsolatedBorrowRequestV3 { + symbol: string; + period?: string; +} +⋮---- +export interface GetFuturesTradingDataRequestV3 { + symbol: string; + period?: string; +} -client - .getSpotAccount() - .then((result) => { - console.log('getSpotAccount result: ', result); - }) - .catch((err) => { - console.error('getSpotAccount error: ', err); - }); +================ +File: src/types/request/v3/trade.ts +================ +export interface BatchModifyOrderRequestV3 { + orderId?: string; + clientOid?: string; + qty?: string; + price?: string; + /** Custom request ID. Numbers within 18 digits. */ + requestId?: number; + autoCancel?: 'yes' | 'no'; + /** Required from 30 Sep 2026 */ + symbol?: string; + /** Required from 30 Sep 2026 */ + category?: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; +} +⋮---- +/** Custom request ID. Numbers within 18 digits. */ +⋮---- +/** Required from 30 Sep 2026 */ +⋮---- +/** Required from 30 Sep 2026 */ +⋮---- +export interface CancelAllOrdersRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol?: string; +} +⋮---- +export interface CancelBatchOrdersRequestV3 { + orderId?: string; + clientOid?: string; + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol: string; +} +⋮---- +export interface CloseAllPositionsRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; + posSide?: 'long' | 'short'; +} +⋮---- +export interface CancelOrderRequestV3 { + orderId?: string; + clientOid?: string; + category?: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; +} +⋮---- +export interface GetMaxOpenAvailableRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol: string; + orderType: 'limit' | 'market'; + side: 'buy' | 'sell'; + price?: string; + size?: string; + /** Spot only. Default: no */ + autoBorrow?: 'yes' | 'no'; +} +⋮---- +/** Spot only. Default: no */ +⋮---- +export interface GetOrderInfoRequestV3 { + orderId?: string; + clientOid?: string; +} +⋮---- +export interface GetFillsRequestV3 { + category?: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + orderId?: string; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: 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 GetHistoryOrdersRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol?: string; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; +} +⋮---- +export interface GetPositionHistoryRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; +} +⋮---- +export interface GetCurrentPositionRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; + posSide?: 'long' | 'short'; +} +⋮---- +export interface ModifyOrderRequestV3 { + orderId?: string; + clientOid?: string; + qty?: string; + price?: string; + /** Custom request ID. Numbers within 18 digits. */ + requestId?: number; + autoCancel?: 'yes' | 'no'; + /** Required from 30 Sep 2026 */ + symbol?: string; + /** Required from 30 Sep 2026 */ + 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; +} +⋮---- +/** Custom request ID. Numbers within 18 digits. */ +⋮---- +/** Required from 30 Sep 2026 */ +⋮---- +/** Required from 30 Sep 2026 */ +⋮---- +export interface PlaceRealityOrderRequestV3 { + category?: 'SPOT' | 'MARGIN'; + symbol: string; + side: 'buy' | 'sell'; + orderType: 'limit' | 'market'; + qty: string; + price?: string; + clientOid?: string; +} +⋮---- +export interface CancelRealityOrderRequestV3 { + category?: 'SPOT' | 'MARGIN'; + symbol: string; + orderId?: string; + clientOid?: 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 type FuturesMarginModeV3 = 'crossed' | 'isolated'; +⋮---- +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' | 'rpi'; + 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; + /** Spot only. Default: no */ + autoBorrow?: 'yes' | 'no'; +} +⋮---- +/** Futures only. Defaults to crossed */ +⋮---- +/** Spot only. Default: no */ +⋮---- +export interface CountdownCancelAllRequestV3 { + countdown: string; // seconds until auto-cancel (5-60, or 0 to disable) +} +⋮---- +countdown: string; // seconds until auto-cancel (5-60, or 0 to disable) -client - .getSpotCandles({ - symbol: 'BTCUSDT', - granularity: '1min', - limit: '1000', - }) - .then((result) => { - console.log('getCandles result: ', result); - }) - .catch((err) => { - console.error('getCandles error: ', err); - }); -``` +================ +File: src/types/response/v3/account.ts +================ +// Account Management Response Types +import type { CollateralTypeV3 } from '../../request/v3/account.js'; +⋮---- +export interface AccountSymbolConfigV3 { + category: string; + symbol: string; + marginMode: string; + leverage: string; +} +⋮---- +export interface AccountCoinConfigV3 { + coin: string; + leverage: 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; +} +⋮---- +/** 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'; + deltaSwitch?: 'yes' | 'no'; + symbolConfigList: AccountSymbolConfigV3[]; + coinConfigList: AccountCoinConfigV3[]; +} +⋮---- +export interface AccountDeltaCoinPositionV3 { + coin: string; + positionRatio: string; +} +⋮---- +/** Delta-neutral mode metrics. Available when deltaSwitch is enabled. */ +export interface AccountDeltaInfoV3 { + /** Deprecated, no longer used as a hedge-eligibility criterion */ + deltaEquityRatio: string; + /** Deprecated, no longer used as a hedge-eligibility criterion */ + deltaThreshold: string; + positionThreshold: string; + list: AccountDeltaCoinPositionV3[]; +} +⋮---- +/** Deprecated, no longer used as a hedge-eligibility criterion */ +⋮---- +/** Deprecated, no longer used as a hedge-eligibility criterion */ +⋮---- +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; +} +⋮---- +/** 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; + positionValue?: string; + leverage?: string; + assets: AccountAssetV3[]; +} +⋮---- +export interface ConvertRecordV3 { + fromCoin: string; + fromCoinSize: string; + toCoin: string; + toCoinSize: string; + price: 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 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' | 'fund_management'; + 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 EligibleDiscountRateTierV3 { + tierStartValue: string; + discountRate: string; +} +⋮---- +export interface EligibleDiscountRateV3 { + coin: string; + list: EligibleDiscountRateTierV3[]; +} +⋮---- +export interface FundingFinancialRecordV3 { + id: string; + coin: string; + groupType: string; + type: string; + amount: string; + balance: string; + ts: string; +} +⋮---- +export interface SmallAssetFeeDetailV3 { + feeRate?: string; + fee?: string; + feeCoin?: string; +} +⋮---- +export interface SmallAssetV3 { + coin: string; + available?: string; + estimatedCoin?: string; + estimatedAmount?: string; + feeDetail?: SmallAssetFeeDetailV3; + cTime?: string; + size?: string; + usdtValue?: string; +} +⋮---- +export interface SmallAssetsTradeResponseV3 { + fromCoin?: string; + toCoin?: string; + orderId?: string; + result?: string; +} +⋮---- +export interface SmallAssetsHistoryItemV3 { + orderId?: string; + fromCoin?: string; + fromAmount?: string; + fromCoinPrice?: string; + fromCoinSize?: string; + toCoin?: string; + toAmount?: string; + toCoinPrice?: string; + toCoinSize?: string; + feeDetail?: SmallAssetFeeDetailV3; + status?: string; + createdTime?: string; + ts?: string; +} +⋮---- +export interface RateLimitQuotaItemV3 { + uid: string; + quota: string; +} +⋮---- +export interface RateLimitQuotaV3 { + category: 'spot' | 'futures' | string; + quotaList: RateLimitQuotaItemV3[]; + masterSubQuota: string; + masterSubCap: string; + cursor: string; +} -## WebSockets +================ +File: src/types/response/v3/trade.ts +================ +export interface BatchModifyOrderResponseV3 { + orderId: string; + clientOid: string; +} +⋮---- +export interface CancelAllOrdersResponseV3 { + list: { + orderId: string; + clientOid: string; + code: string; + msg: string; + }[]; +} +⋮---- +export interface CancelBatchOrdersResponseV3 { + orderId: string; + clientOid: string; + code?: string; + msg?: string; +} +⋮---- +export interface CloseAllPositionsResponseV3 { + list: { + orderId: string; + clientOid: string; + code: string; + msg: string; + }[]; +} +⋮---- +export interface CancelOrderResponseV3 { + orderId: string; + clientOid: string; +} +⋮---- +export interface GetMaxOpenAvailableResponseV3 { + available: string; + maxOpen: string; + buyOpenCost: string; + sellOpenCost: string; + maxBuyOpen: string; + maxSellOpen: string; + maxBuyAvailable?: string; + maxSellAvailable?: string; +} +⋮---- +export interface FeeDetailV3 { + feeCoin: string; + fee: 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; +} +⋮---- +export type FillCategoryV3 = + | 'spot' + | 'margin' + | 'usdt-futures' + | 'coin-futures' + | 'usdc-futures' + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; +⋮---- +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 UnfilledOrderV3 { + 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[]; + stpMode?: string; + createdTime: string; + updatedTime: string; +} +⋮---- +export interface HistoryOrderV3 { + 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; +} +⋮---- +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; + /** Cash dividend, USDT */ + cashDividend?: string; + createdTime: string; + updatedTime: string; +} +⋮---- +/** Cash dividend, USDT */ +⋮---- +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; +} +⋮---- +/** Cash dividend, USDT */ +⋮---- +export interface LoanDataDebtCoinV3 { + coin: string; + debt: string; + interestFreeAmount: string; + interestRateNextHour: string; +} +⋮---- +export interface LoanDataV3 { + currentLoans: string; + interestPaymentTime: string; + debtCoinList: LoanDataDebtCoinV3[]; +} +⋮---- +export interface ModifyOrderResponseV3 { + orderId: string; + clientOid: string; +} +⋮---- +export interface PlaceBatchOrdersResponseV3 { + orderId: string; + clientOid: string; + code?: string; + msg?: string; +} +⋮---- +export interface PlaceOrderResponseV3 { + orderId: string; + clientOid: string; +} +⋮---- +export interface PositionAdlRankV3 { + symbol: string; + marginCoin: string; + adlRank: string; + holdSide: 'long' | 'short'; +} -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. +================ +File: src/types/request/v3/account.ts +================ +// Account Management Request Types +⋮---- +export type AccountAdjustModeV3 = 'basic' | 'advanced' | 'delta' | 'isolated'; +⋮---- +export interface AdjustAccountModeRequestV3 { + mode: AccountAdjustModeV3; + /** Enable/disable delta-neutral mode when mode is advanced. `delta` mode is deprecated. */ + deltaSwitch?: 'yes' | 'no'; + /** Sub-account UID when the master account switches mode for a sub-account */ + targetUid?: string; +} +⋮---- +/** Enable/disable delta-neutral mode when mode is advanced. `delta` mode is deprecated. */ +⋮---- +/** 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 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol?: string; +} +⋮---- +export interface GetConvertRecordsRequestV3 { + fromCoin?: string; + toCoin?: string; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; +} +⋮---- +export interface GetFinancialRecordsRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + coin?: string; + type?: string; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; +} +⋮---- +export interface RepayRequestV3 { + repayableCoinList: string[]; + paymentCoinList: string[]; +} +⋮---- +// Sub-account Management Request Types +⋮---- +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; + 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; + cursor?: 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; + 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 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 */ +⋮---- +export interface GetSubUnifiedAssetsRequestV3 { + subUid?: string; + cursor?: string; + limit?: string; +} +⋮---- +export interface GetFeeRateRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol: string; + /** RPI fee rate flag for market maker users. Default: no */ + rpiFlag?: 'yes' | 'no'; +} +⋮---- +/** RPI fee rate flag for market maker users. Default: no */ +⋮---- +export interface GetFundingAssetsRequestV3 { + coin?: string; +} +⋮---- +export interface SwitchDeductRequestV3 { + deduct: 'on' | 'off'; +} +⋮---- +// Deposit Request Types +⋮---- +export interface GetDepositAddressRequestV3 { + coin: string; + chain?: string; + size?: string; +} +⋮---- +export interface GetSubDepositAddressRequestV3 { + subUid: string; + coin: string; + chain?: string; + size?: string; +} +⋮---- +export interface GetDepositRecordsRequestV3 { + coin?: string; + orderId?: string; + startTime: string; + endTime: string; + limit?: string; + cursor?: string; +} +⋮---- +export interface GetSubDepositRecordsRequestV3 { + coin?: string; + subUid: string; + startTime: string; + endTime: string; + limit?: string; + cursor?: string; +} +⋮---- +// Withdraw Request Types +⋮---- +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; +} +⋮---- +/** Deduct from funding, uta, and/or otc accounts (comma-separated). Order: funding -> otc -> uta */ +⋮---- +export interface GetWithdrawRecordsRequestV3 { + coin?: string; + orderId?: string; + clientOid?: string; + startTime: string; + endTime: string; + limit?: string; + cursor?: string; +} +⋮---- +export interface GetWithdrawAddressBookRequestV3 { + coin?: string; + type?: 'EVM' | 'regular' | 'universal' | 'internal'; + limit?: string; + cursor?: string; +} +⋮---- +export interface CancelWithdrawalRequestV3 { + orderId?: string; + clientOid?: string; +} +⋮---- +export interface SetDepositAccountRequestV3 { + coin: string; + accountType: 'funding' | 'unified' | 'otc'; +} +⋮---- +export interface GetMaxTransferableRequestV3 { + coin: string; +} +⋮---- +export interface GetOpenInterestLimitRequestV3 { + symbol: string; + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; +} +⋮---- +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'; +⋮---- +export interface SetCollateralTypeRequestV3 { + collateralType: CollateralTypeV3; + /** Required when collateralType=custom. Comma-separated coin names */ + collateralCoins?: string; +} +⋮---- +/** 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 SetMarginRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol: string; + posSide: 'long' | 'short'; + operation: 'add' | 'remove'; + amount: string; +} +⋮---- +export interface GetMaxWithdrawalRequestV3 { + coin: string; +} +⋮---- +export interface GetRealityOrderBookRequestV3 { + symbol: string; +} +⋮---- +export interface GetRealityFillsRequestV3 { + symbol: string; + limit?: string; +} +⋮---- +export interface SubMasterTransferRequestV3 { + fromType: 'spot' | 'uta'; + toType: 'spot' | 'p2p' | 'uta'; + amount: string; + coin: string; + clientOid?: string; +} +⋮---- +export interface CreateAgentSubAccountRequestV3 { + username: string; + passphrase: string; + note?: string; +} +⋮---- +export interface MovePositionItemRequestV3 { + symbol: string; + side: 'buy' | 'sell'; + qty: string; +} +⋮---- +export interface MovePositionsRequestV3 { + fromUid: string; + toUid: string; + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + positionList: MovePositionItemRequestV3[]; +} +⋮---- +export interface GetMovePositionHistoryRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; + startTime?: string; + endTime?: string; + cursor?: string; + limit?: string; +} +⋮---- +export interface GetEligibleSymbolsRequestV3 { + symbol?: string; +} +⋮---- +export interface GetEligibleMarginTierRequestV3 { + coin?: string; +} +⋮---- +export interface GetEligibleLoanInfoRequestV3 { + coin?: string; +} +⋮---- +export interface GetEligibleDiscountRateRequestV3 { + coin?: string; +} +⋮---- +export interface GetFundingFinancialRecordsRequestV3 { + coin?: string; + type?: string; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; +} +⋮---- +export interface GetSmallAssetsRequestV3 { + coin?: string; +} +⋮---- +export interface TradeSmallAssetsRequestV3 { + fromCoinList: string[]; + toCoin?: string; +} +⋮---- +export interface GetSmallAssetsHistoryRequestV3 { + orderId?: string; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; +} +⋮---- +export interface GetRateLimitQuotaRequestV3 { + category: 'spot' | 'futures'; + uid?: string; + cursor?: string; + limit?: string; +} +⋮---- +export interface SetRateLimitQuotaRequestV3 { + category: 'spot' | 'futures'; + uids: string[]; + quota: string; +} -Use the following guidance to decide which one to use: +================ +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; -- **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). + /** Your API secret */ + apiSecret?: string; -All WebSocket clients support: + /** The passphrase you set when creating the API Key (NOT your account password) */ + apiPass?: string; -- 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 + /** + * 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; -Higher level examples below, while more thorough examples can be found in the examples folder on GitHub. + /** Define a recv window when preparing a private websocket signature. This is in milliseconds, so 5000 == 5 seconds */ + recvWindow?: number; -##### V3 Unified Trading Account + // Disable ping/pong ws heartbeat mechanism (not recommended) + disableHeartbeat?: boolean; -###### Sending orders via WebSockets + /** How often to check if the connection is alive */ + pingInterval?: number; -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. + /** How long to wait for a pong (heartbeat reply) before assuming the connection is dead */ + pongTimeout?: number; -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. + /** Delay in milliseconds before respawning the connection */ + reconnectTimeout?: number; -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. + requestOptions?: RestClientOptions; -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) + wsOptions?: { + protocols?: string[]; + agent?: any; + } & ( + | Omit, 'agent'> + | Omit, 'agent'> + ); -```typescript -import { WebsocketAPIClient } from 'bitget-api'; -// or if you prefer require: -// const { WebsocketAPIClient } = require("bitget-api"); + wsUrl?: string; -// 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, + /** + * 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; +} - // Whether to use the demo trading wss connection - // demoTrading: true, -}); +================ +File: src/index.ts +================ -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 +================ +File: src/rest-client-v2.ts +================ +import { FuturesProductTypeV2, MarginType } from './types/request/shared.js'; +import { + AgentCustomerAssetRequestV2, + AgentCustomerDepositRequestV2, + AgentCustomerListRequestV2, + AgentCustomerTradeVolumeRequestV2, + CreateSubAccountApiKeyRequestV2, + DeleteSubAccountApiKeyRequestV2, + GetAgentCommissionDetailRequestV2, + GetAgentCustomerCommissionsRequestV2, + GetAgentCustomerKycResultRequestV2, + GetAgentSubCustomerListRequestV2, + GetAllSubDepositWithdrawalRequestV2, + GetBrokerCommissionsRequestV2, + GetBrokerOrderCommissionRequestV2, + GetBrokerRebateInfoRequestV2, + GetBrokerSubaccountsRequestV2, + GetBrokerTotalCommissionRequestV2, + GetBrokerTradeVolumeRequestV2, + GetSubAccountsRequestV2, + ModifySubAccountApiKeyRequestV2, + ModifySubRequestV2, + SubDepositRecordsRequestV2, + SubWithdrawalRecordsRequestV2, + SubWithdrawalRequestV2, +} from './types/request/v2/broker.js'; +import { + ConvertQuoteRequestV2, + ConvertRequestV2, + CreateAgentSubaccountRequestV2, + CreateVirtualSubApiKeyRequestV2, + CreateVirtualSubRequestV2, + GetAllTradeRatesRequestV2, + GetAnnouncementsRequestV2, + GetConvertBGBHistoryRequestV2, + GetConvertHistoryRequestV2, + GetFuturesTransactionsRequestV2, + GetMarginTransactionsRequestV2, + GetMerchantAdvertisementsRequestV2, + GetMerchantP2POrdersRequestV2, + GetP2PMerchantsRequestV2, + GetP2PTransactionsRequestV2, + GetSpotTransactionsRequestV2, + GetTradeRateRequestV2, + ModifyVirtualSubApiKeyRequestV2, + ModifyVirtualSubRequestV2, +} from './types/request/v2/common.js'; +import { + CloseFuturesFollowerPositionsRequestV2, + CopyTradingProductTypeV2, + FuturesTraderSymbolSettingRequestV2, + GetFollowerFuturesCurrentTrackingOrdersRequestV2, + GetFollowerFuturesHistoryTrackingOrdersRequestV2, + GetFuturesFollowerTradersRequestV2, + GetFuturesTraderCurrentOrdersRequestV2, + GetFuturesTraderFollowersRequestV2, + GetFuturesTraderHistoryOrdersRequestV2, + GetFuturesTraderProfitShareDetailRequestV2, + GetSpotFollowerHistoryOrdersRequestV2, + GetSpotFollowerOpenOrdersRequestV2, + GetSpotTraderCurrentOrdersRequestV2, + GetSpotTraderFollowersRequestV2, + GetSpotTraderHistoryOrdersRequestV2, + GetSpotTraderHistoryProfitRequestV2, + ModifyFuturesTraderOrderTPSLRequestV2, + SpotFollowerCopyTradeSettingV2, + UpdateFuturesFollowerSettingsRequestV2, + UpdateFuturesFollowerTPSLRequestV2, +} from './types/request/v2/copytrading.js'; +import { + BorrowLoanRequestV2, + EarnEliteSubscribeRequestV2, + GetEarnEliteRecordsRequestV2, + GetEarnEliteRedeemInfoRequestV2, + GetEarnEliteSubscribeInfoRequestV2, + GetEarnEliteSubscribeResultRequestV2, + GetEarnSavingsAssetsRequestV2, + GetEarnSavingsRecordsRequestV2, + GetLiquidationRecordsRequestV2, + GetLoanEstInterestAndBorrowableRequestV2, + GetLoanHistoryRequestV2, + GetLoanPledgeRateHistoryRequestV2, + GetLoanRepayHistoryRequestV2, + GetSharkfinAssetsRequestV2, + GetSharkfinRecordsRequestV2, + ModifyLoanPledgeRateRequestV2, + RedeemEarnEliteRequestV2, + RedeemSavingsRequestV2, + RepayLoanRequestV2, +} from './types/request/v2/earn.js'; +import { + FuturesAccountBillRequestV2, + FuturesBatchCancelOrderRequestV2, + FuturesBatchOrderRequestV2, + FuturesCancelAllOrdersRequestV2, + FuturesCancelOrderRequestV2, + FuturesCancelPlanOrderRequestV2, + FuturesCandlesRequestV2, + FuturesFlashClosePositionsRequestV2, + FuturesGetHistoricalFillsRequestV2, + FuturesGetHistoryOrdersRequestV2, + FuturesGetHistoryPlanOrdersRequestV2, + FuturesGetOpenOrdersRequestV2, + FuturesGetOrderFillsRequestV2, + FuturesGetOrderRequestV2, + FuturesGetPlanOrdersRequestV2, + FuturesHistoricalPositionsRequestV2, + FuturesHistoricTradesRequestV2, + FuturesInterestHistoryRequestV2, + FuturesIsolatedSymbolsRequestV2, + FuturesLiquidationPriceRequestV2, + FuturesMaxOpenRequestV2, + FuturesMergeDepthRequestV2, + FuturesModifyOrderRequestV2, + FuturesModifyPlanOrderRequestV2, + FuturesModifyTPSLOrderRequestV2, + FuturesOiLimitRequestV2, + FuturesOpenCountRequestV2, + FuturesPlaceOrderRequestV2, + FuturesPlanOrderRequestV2, + FuturesPositionAdlRankRequestV2, + FuturesPositionTPSLOrderRequestV2, + FuturesRecentTradesRequestV2, + FuturesReversalOrderRequestV2, + FuturesSetAutoMarginRequestV2, + FuturesSetLeverageRequestV2, + FuturesSetMarginModeRequestV2, + FuturesSetPositionMarginRequestV2, + FuturesSingleAccountRequestV2, + FuturesTPSLOrderRequestV2, + GetUnionTransferLimitsRequestV2, + UnionConvertRequestV2, +} from './types/request/v2/futures.js'; +import { + GetInstLoanLTVConvertRequestV2, + GetInstLoanMarginCoinInfoRequestV2, + GetInstLoanOrderRequestV2, + GetInstLoanProductInfoRequestV2, + GetInstLoanRepaidHistoryRequestV2, + GetInstLoanSymbolsRequestV2, +} from './types/request/v2/instloan.js'; +import { + GetBorrowHistoryRequestV2, + GetFinancialHistoryRequestV2, + GetHistoryOrdersRequestV2, + GetInterestHistoryRequestV2, + GetLiquidationHistoryRequestV2, + GetMarginCurrentOrdersRequestV2, + GetMarginLiquidationOrdersRequestV2, + GetMarginOrderFillsRequestV2, + GetRepayHistoryRequestV2, + MarginBatchOrdersRequestV2, + MarginPlaceOrderRequestV2, +} from './types/request/v2/margin.js'; +import { + GetSpotAccountBillsRequestV2, + GetSpotCurrentPlanOrdersRequestV2, + GetSpotDepositRecordRequestV2, + GetSpotFillsRequestV2, + GetSpotHistoryOrdersRequestV2, + GetSpotHistoryPlanOrdersRequestV2, + GetSpotOpenOrdersRequestV2, + GetSpotOrderInfoRequestV2, + GetSpotSubAccountDepositRecordRequestV2, + GetSpotTransferRecordRequestV2, + GetSpotWithdrawalRecordRequestV2, + SpotAccountTypeV2, + SpotBatchCancelOrderRequestV2, + SpotBatchOrderRequestV2, + SpotCallAuctionRequestV2, + SpotCancelandSubmitOrderRequestV2, + SpotCancelOrderRequestV2, + SpotCandlesRequestV2, + SpotHistoricCandlesRequestV2, + SpotHistoricTradesRequestV2, + SpotMainSubTransferRecordRequestV2, + SpotModifyPlanOrderRequestV2, + SpotOrderRequestV2, + SpotPlanOrderRequestV2, + SpotSubAccountTransferRequestV2, + SpotTransferRequestV2, + SpotWithdrawalRequestV2, +} from './types/request/v2/spot.js'; +import { + AgentCommissionDetailV2, + AgentCustomerAssetItemV2, + AgentCustomerCommissionsV2, + AgentCustomerDepositItemV2, + AgentCustomerKycResultV2, + AgentCustomerListItemV2, + AgentCustomerTradeVolumeItemV2, + AgentSubCustomerListV2, + AllSubDepositWithdrawalRecordV2, + BrokerCommissionV2, + BrokerOrderCommissionV2, + BrokerRebateInfoV2, + BrokerSubaccountFutureAssetV2, + BrokerSubaccountInfoV2, + BrokerSubaccountSpotAssetV2, + BrokerSubaccountV2, + BrokerSubaccountWithdrawalV2, + BrokerTotalCommissionV2, + BrokerTradeVolumeV2, + CreateSubaccountApiKeyResponseV2, + CreateSubaccountDepositAddressV2, + CreateSubaccountResponseV2, + ModifySubaccountApiKeyResponseV2, + ModifySubaccountResponseV2, + SubaccountApiKeyV2, + SubaccountDepositV2, + SubaccountEmailV2, +} from './types/response/v2/broker.js'; +import { + AnnouncementV2, + BGBConvertCoinV2, + BGBConvertHistoryV2, + BotAssetV2, + ConvertBGBResponseV2, + ConvertCurrencyV2, + ConvertQuotedPriceV2, + ConvertRecordV2, + ConvertTradeResponseV2, + CreateAgentSubaccountV2, + CreateVirtualSubAccountAndApiKeyV2, + CreateVirtualSubAccountApiKeyV2, + CreateVirtualSubAccountV2, + FundingAssetV2, + FuturesActiveBuySellVolumeV2, + FuturesActiveLongShortAccountV2, + FuturesActiveLongShortPositionV2, + FuturesLongShortRatioV2, + FuturesTransactionRecordV2, + IsolatedMarginBorrowingRatioV2, + LeveragedLongShortRatioV2, + MarginLoanGrowthRateV2, + MarginTransactionRecordV2, + ModifyVirtualSubAccountApiKeyV2, + P2PMerchantAdvertismentV2, + P2PMerchantInfoV2, + P2PMerchantOrdersV2, + P2PMerchantOrderV2, + P2PMerchantV2, + SpotFundFlowV2, + SpotTransactionRecordV2, + SpotWhaleNetFlowV2, + SubAccountApiKeyItemV2, + VirtualSubAccountV2, +} from './types/response/v2/common.js'; +import { + CTFuturesFollowerCurrentOrdersV2, + CTFuturesFollowerHistoryOrdersV2, + CTFuturesFollowerMyTradersV2, + CTFuturesFollowerSettingsV2, + CTFuturesTraderCurrentOrdersV2, + CTFuturesTraderHistoryOrderV2, + CTFuturesTraderHistoryProfitSummaryV2, + CTFuturesTraderMyFollowersV2, + CTFuturesTraderProfitShareHistoryV2, + CTFuturesTraderSymbolSettingsV2, + CTFuturesTraderTotalOrderSummaryV2, + CTSpotFollowerCurrentOrdersV2, + CTSpotFollowerFollowConfigurationV2, + CTSpotFollowerHistoryOrdersV2, + CTSpotFollowerMyTradersV2, + CTSpotTraderCurrentTrackingOrdersV2, + CTSpotTraderFollowerListV2, + CTSpotTraderHistoryOrdersV2, + CTSpotTraderHistoryProfitSharingV2, + CTSpotTraderProfitSummaryV2, + CTSpotTraderTotalOrderDetailV2, + CTSpotTraderUnrealizedProfitV2, +} from './types/response/v2/copy-trading.js'; +import { + EarnEliteAssetsV2, + EarnEliteProductV2, + EarnEliteRecordsV2, + EarnEliteRedeemInfoV2, + EarnEliteSubscribeInfoV2, + EarnEliteSubscribeResultV2, + EarnEliteSubscribeStatusV2, + EarnLoanCurrenciesV2, + EarnLoanDebtsV2, + EarnLoanHistoryV2, + EarnLoanLiquidationRecordsV2, + EarnLoanOrdersV2, + EarnLoanPledgeRateHistoryV2, + EarnLoanRepayHistoryV2, + EarnLoanRepayResponseV2, + EarnSavingsAccountV2, + EarnSavingsAssetsV2, + EarnSavingsProductsV2, + EarnSavingsRecordsV2, + EarnSavingsSubscriptionDetailV2, + EarnSharkfinAccountV2, + EarnSharkfinAssetsV2, + EarnSharkfinProductsV2, + EarnSharkfinRecordsV2, + EarnSharkfinSubscriptionDetailV2, + RedeemEarnEliteResultV2, +} from './types/response/v2/earn.js'; +import { + FuturesAccountBillV2, + FuturesAccountsV2, + FuturesAccountV2, + FuturesBatchOrderResponseV2, + FuturesCancelAllOrdersV2, + FuturesCancelPlanOrderV2, + FuturesCandlestickV2, + FuturesClosePositionResponseV2, + FuturesContractConfigV2, + FuturesDiscountRatesV2, + FuturesFillV2, + FuturesFundingTimeV2, + FuturesHistoricalFundingRateV2, + FuturesHistoryInterestRateV2, + FuturesHistoryOrderV2, + FuturesHistoryPlanOrderV2, + FuturesHistoryPositionV2, + FuturesInterestExchangeRateV2, + FuturesInterestHistoryV2, + FuturesIsolatedSymbolV2, + FuturesLiquidationPriceV2, + FuturesMaxOpenV2, + FuturesMergeDepthV2, + FuturesOpenInterestV2, + FuturesOpenOrderV2, + FuturesOrderDetailV2, + FuturesOrderFillV2, + FuturesPendingPlanOrderV2, + FuturesPositionAdlRankV2, + FuturesPositionTierV2, + FuturesPositionV2, + FuturesSubAccountAssetV2, + FuturesSymbolPriceV2, + FuturesTickerV2, + FuturesTriggerSubOrderV2, + FuturesVipFeeRateV2, + SetLeverageResponseV2, + SetMarginModeResponseV2, + UnionConfigV2, + UnionConvertV2, + UnionSwitchUsdtV2, + UnionTransferLimitsV2, +} from './types/response/v2/futures.js'; +import { + InstLoanCoinInfoV2, + InstLoanLTVConvertV2, + InstLoanOrderV2, + InstLoanProductInfoV2, + InstLoanRepaidHistoryItemV2, + InstLoanSymbolsV2, +} from './types/response/v2/instloan.js'; +import { + CrossInterestRateAndLimitResponseV2, + CrossMaxBorrowableResponseV2, + CrossMaxTransferableResponseV2, + CrossTierConfigurationResponseV2, + IsolatedInterestRateAndLimitResponseV2, + IsolatedMaxBorrowableResponseV2, + IsolatedMaxTransferableResponseV2, + IsolatedTierConfigurationResponseV2, + MarginAccountAssetV2, + MarginBatchOrdersResponseV2, + MarginBorrowHistoryItemV2, + MarginCurrencyV2, + MarginCurrentOrderV2, + MarginFinancialHistoryItemV2, + MarginHistoryOrderV2, + MarginInterestHistoryItemV2, + MarginLiquidationHistoryItemV2, + MarginLiquidationOrderV2, + MarginOrderFillV2, + MarginRepaymentHistoryItemV2, +} from './types/response/v2/margin.js'; +import { + CancelAndSubmitSpotOrderResponseV2, + SpotAccountAssetV2, + SpotAccountBillV2, + SpotAccountInfoV2, + SpotCallAuctionV2, + SpotCancelPlanOrdersV2, + SpotCandlestickV2, + SpotCoinInfoV2, + SpotCurrentPlanOrderV2, + SpotDepositAddressV2, + SpotDepositRecordV2, + SpotFillV2, + SpotHistoryPlanOrderV2, + SpotMainSubTransferRecordV2, + SpotMergeDepthV2, + SpotOpenOrderV2, + SpotOrderBookDepthV2, + SpotOrderInfoV2, + SpotPlanSubOrderV2, + SpotSubAccountAssetsV2, + SpotSubAccountDepositRecordV2, + SpotSymbolInfoV2, + SpotTickerV2, + SpotTradeV2, + SpotTransferRecordV2, + SpotVipFeeRateV2, + SpotWithdrawalRecordV2, + SubmitSpotBatchOrdersResponseV2, +} from './types/response/v2/spot.js'; +import { APIResponse } from './types/shared.js'; +import BaseRestClient from './util/BaseRestClient.js'; +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 +⋮---- +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 + * + */ +⋮---- +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 + * + * - 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 + * + * - 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> +⋮---- +/** + * 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> +⋮---- +getFuturesHistoricPositions( + params?: FuturesHistoricalPositionsRequestV2, + ): Promise< + APIResponse<{ + list: FuturesHistoryPositionV2[]; + endId: string; + }> + > { + return this.getPrivate('/api/v2/mix/position/history-position', params); +⋮---- +getFuturesPositionAdlRank( + params: FuturesPositionAdlRankRequestV2, +): Promise> +⋮---- +/** + * + * * Futures | Trade + * + */ +⋮---- +futuresSubmitOrder(params: FuturesPlaceOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v2/mix/order/place-order', params); +⋮---- +futuresSubmitReversal(params: FuturesReversalOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v2/mix/order/click-backhand', params); +⋮---- +futuresBatchSubmitOrders( + params: FuturesBatchOrderRequestV2, +): Promise> +⋮---- +futuresModifyOrder(params: FuturesModifyOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v2/mix/order/modify-order', params); +⋮---- +futuresCancelOrder(params: FuturesCancelOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v2/mix/order/cancel-order', params); +⋮---- +futuresBatchCancelOrders( + params: FuturesBatchCancelOrderRequestV2, +): Promise> +⋮---- +futuresFlashClosePositions( + params: FuturesFlashClosePositionsRequestV2, +): Promise> +⋮---- +getFuturesOrder( + params: FuturesGetOrderRequestV2, +): Promise> +⋮---- +getFuturesFills(params: FuturesGetOrderFillsRequestV2): Promise< + APIResponse<{ + fillList: FuturesOrderFillV2[]; + endId: string; + }> + > { + return this.getPrivate('/api/v2/mix/order/fills', params); +⋮---- +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> +⋮---- +/** + * + * * Futures | Trigger Orders + * + */ +⋮---- +getFuturesTriggerSubOrder(params: { + planType: 'normal_plan' | 'track_plan'; + planOrderId: string; + productType: FuturesProductTypeV2; +}): Promise> +⋮---- +futuresSubmitTPSLOrder(params: FuturesTPSLOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v2/mix/order/place-tpsl-order', params); +⋮---- +futuresSubmitPositionTPSL(params: FuturesPositionTPSLOrderRequestV2): Promise< + APIResponse< + { + orderId: string; + stopSurplusClientOid: string; + stopLossClientOid: string; + }[] + > + > { + return this.postPrivate('/api/v2/mix/order/place-pos-tpsl', params); +⋮---- +futuresSubmitPlanOrder(params: FuturesPlanOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v2/mix/order/place-plan-order', params); +⋮---- +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<{ + entrustedList: FuturesHistoryPlanOrderV2[]; + endId: string; + }> + > { + return this.getPrivate('/api/v2/mix/order/orders-plan-history', params); +⋮---- +/** + * + * + * Broker + * + * + */ +⋮---- +/** + * + * * Broker | Subaccount + * + */ +⋮---- +modifySubaccountEmail(params: { + subUid: string; + subaccountEmail: string; +}): Promise> +⋮---- +getBrokerInfo(): Promise< + APIResponse<{ + subAccountSize: string; + maxSubAccountSize: string; + uTime: string; + }> + > { + return this.getPrivate('/api/v2/broker/account/info'); +⋮---- +createSubaccount(params: { + subaccountName: string; + label: string; +}): Promise> +⋮---- +getSubaccounts(params?: GetSubAccountsRequestV2): Promise< + APIResponse<{ + hasNextPage: boolean; + idLessThan: number; + subList: BrokerSubaccountV2[]; + }> + > { + return this.getPrivate('/api/v2/broker/account/subaccount-list', params); +⋮---- +modifySubaccount( + params: ModifySubRequestV2, +): Promise> +⋮---- +getSubaccountEmail(params: { + subUid: 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, + ); +⋮---- +getSubaccountFuturesAssets(params: { + subUid: string; + productType: FuturesProductTypeV2; + }): Promise< + APIResponse<{ + assetsList: BrokerSubaccountFutureAssetV2[]; + }> + > { + return this.getPrivate( + '/api/v2/broker/account/subaccount-future-assets', + params, + ); +⋮---- +createSubaccountDepositAddress(params: { + subUid: string; + coin: string; + chain?: string; +}): Promise> +⋮---- +subaccountWithdrawal(params: SubWithdrawalRequestV2): 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> +⋮---- +/** + * Sub Deposit Records + * + * - Only applicable for ND broker main-account to get ND sub-accounts deposit record */ - 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); -}); - +subaccountDepositRecords( + params: SubDepositRecordsRequestV2, +): Promise> +⋮---- +/** + * Sub Withdrawal Records + * + * - Only applicable for ND broker main-account + */ +subaccountWithdrawalRecords(params: SubWithdrawalRecordsRequestV2): Promise< + APIResponse<{ + resultList: BrokerSubaccountWithdrawalV2[]; + endId: string; + }> + > { + return this.getPrivate('/api/v2/broker/subaccount-withdrawal', params); +⋮---- +/** + * + * Broker | Api Key + * + */ +⋮---- +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; + }> + > { + 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> +⋮---- +/** + * 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 + * + * - 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> +⋮---- +/** + * Get Rebate Info + * + * - Rate limit: 20 req/sec/UID + * - Data retention: 30 days + * - Real-time data + */ +getBrokerRebateInfo( + params: GetBrokerRebateInfoRequestV2, +): 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 + * + * * Broker | Agent (affiliate) customer APIs + * + */ +⋮---- +getAgentCustomerCommissions( + params?: GetAgentCustomerCommissionsRequestV2, +): Promise> +⋮---- +/** + * Without startTime/endTime, returns all registered sub-customers (no time restriction). + */ +getAgentSubCustomerList( + params?: GetAgentSubCustomerListRequestV2, +): Promise> +⋮---- +getAgentCustomerTradeVolume( + params?: AgentCustomerTradeVolumeRequestV2, +): Promise> +⋮---- +/** + * Without startTime/endTime, returns all registered customers (no time restriction). + */ +getAgentCustomerList( + params?: AgentCustomerListRequestV2, +): Promise> +⋮---- +getAgentCustomerKycResult( + params?: GetAgentCustomerKycResultRequestV2, +): Promise> +⋮---- +getAgentCustomerDeposits( + params?: AgentCustomerDepositRequestV2, +): Promise> +⋮---- +getAgentCustomerAssets( + params?: AgentCustomerAssetRequestV2, +): Promise> +⋮---- +getAgentCommissionDetail( + params?: GetAgentCommissionDetailRequestV2, +): Promise> +⋮---- +/** + * + * + * Margin + * + * + */ +⋮---- +/** + * + * * Margin | Common + * + */ +⋮---- +getMarginCurrencies(): Promise> +⋮---- +/** + * + * * Margin | Cross/Isolated | Order Record + * + */ +⋮---- +getMarginBorrowHistory( + marginType: MarginType, + params: GetBorrowHistoryRequestV2, + ): Promise< + APIResponse<{ + resultList: MarginBorrowHistoryItemV2[]; + maxId: string; + minId: string; + }> + > { + assertMarginType(marginType); +⋮---- +getMarginRepayHistory( + marginType: MarginType, + params: GetRepayHistoryRequestV2, + ): Promise< + APIResponse<{ + resultList: MarginRepaymentHistoryItemV2[]; + maxId: string; + minId: string; + }> + > { + assertMarginType(marginType); +⋮---- +getMarginInterestHistory( + marginType: MarginType, + params: GetInterestHistoryRequestV2, + ): Promise< + APIResponse<{ + resultList: MarginInterestHistoryItemV2[]; + maxId: string; + minId: string; + }> + > { + assertMarginType(marginType); +⋮---- +getMarginLiquidationHistory( + marginType: MarginType, + params: GetLiquidationHistoryRequestV2, + ): Promise< + APIResponse<{ + resultList: MarginLiquidationHistoryItemV2[]; + maxId: string; + minId: string; + }> + > { + assertMarginType(marginType); +⋮---- +getMarginFinancialHistory( + marginType: MarginType, + params: GetFinancialHistoryRequestV2, + ): Promise< + APIResponse<{ + resultList: MarginFinancialHistoryItemV2[]; + maxId: string; + minId: string; + }> + > { + assertMarginType(marginType); +⋮---- +/** + * + * * Margin | Cross/Isolated | Account + * + */ +⋮---- +getMarginAccountAssets( + marginType: MarginType, + params?: { coin?: string }, +): Promise> +⋮---- +marginBorrow( + marginType: MarginType, + params: { + loanId: string; + symbol: string; + coin: string; + borrowAmount: string; + }, + ): Promise< + APIResponse<{ + loanId: string; + symbol: string; + coin: string; + borrowAmount: string; + }> + > { + assertMarginType(marginType); +⋮---- +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); +⋮---- +getMarginRiskRate(marginType: MarginType): Promise< + APIResponse< + { + symbol: string; + riskRateRatio: string; + }[] + > + > { + assertMarginType(marginType); +⋮---- +getMarginMaxBorrowable( + marginType: MarginType, + params: { coin: string }, + ): Promise< + APIResponse + > { + assertMarginType(marginType); +⋮---- +getMarginMaxTransferable( + marginType: MarginType, + params: { coin: string }, + ): Promise< + APIResponse< + CrossMaxTransferableResponseV2 | IsolatedMaxTransferableResponseV2 + > + > { + assertMarginType(marginType); +⋮---- +getMarginInterestRateAndMaxBorrowable( + marginType: MarginType, + params: { coin: string }, + ): Promise< + APIResponse< + | IsolatedInterestRateAndLimitResponseV2[] + | CrossInterestRateAndLimitResponseV2[] + > + > { + assertMarginType(marginType); +⋮---- +getMarginTierConfiguration( + marginType: MarginType, + params: { coin: string }, + ): Promise< + APIResponse< + CrossTierConfigurationResponseV2[] | IsolatedTierConfigurationResponseV2[] + > + > { + assertMarginType(marginType); +⋮---- +marginFlashRepay( + marginType: MarginType, + params: { coin: string }, + ): Promise< + APIResponse<{ + repayId: string; + coin?: string; + symbol?: string; + result?: string; + }> + > { + assertMarginType(marginType); +⋮---- +getMarginFlashRepayResult( + marginType: MarginType, + params: { idList: string }, + ): Promise< + APIResponse< + { + repayId: string; + status: string; + }[] + > + > { + assertMarginType(marginType); +⋮---- +/** + * + * * Margin | Cross/Isolated | Trade + * + */ +⋮---- +marginSubmitOrder( + marginType: MarginType, + params: MarginPlaceOrderRequestV2, + ): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + assertMarginType(marginType); +⋮---- +marginBatchSubmitOrders( + marginType: MarginType, + params: MarginBatchOrdersRequestV2, +): Promise> +⋮---- +marginCancelOrder( + marginType: MarginType, + params: { + symbol: string; + orderId?: string; + clientOid?: string; + }, + ): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + assertMarginType(marginType); +⋮---- +marginBatchCancelOrders( + marginType: MarginType, + params: { + symbol: string; + orderIdList: string[]; + }, +): Promise> +⋮---- +getMarginOpenOrders( + marginType: MarginType, + params: GetMarginCurrentOrdersRequestV2, + ): Promise< + APIResponse<{ + orderList: MarginCurrentOrderV2[]; + maxId: string; + minId: string; + }> + > { + assertMarginType(marginType); +⋮---- +getMarginHistoricOrders( + marginType: MarginType, + params: GetHistoryOrdersRequestV2, + ): Promise< + APIResponse<{ + orderList: MarginHistoryOrderV2[]; + maxId: string; + minId: string; + }> + > { + assertMarginType(marginType); +⋮---- +getMarginHistoricOrderFills( + marginType: MarginType, + params: GetMarginOrderFillsRequestV2, + ): Promise< + APIResponse<{ + fills: MarginOrderFillV2[]; + minId: string; + maxId: string; + }> + > { + assertMarginType(marginType); +⋮---- +getMarginLiquidationOrders( + marginType: MarginType, + params: GetMarginLiquidationOrdersRequestV2, + ): Promise< + APIResponse<{ + resultList: MarginLiquidationOrderV2[]; + idLessThan: string; + }> + > { + assertMarginType(marginType); +⋮---- +/** + * + * + * Copy Trading + * + * + */ +⋮---- +/** + * + * + * Copy Trading | Future copy trading | Trader Api + * + * + */ +⋮---- +getFuturesTraderCurrentOrder( + params: GetFuturesTraderCurrentOrdersRequestV2, +): Promise> +⋮---- +getFuturesTraderHistoryOrders( + params: GetFuturesTraderHistoryOrdersRequestV2, +): Promise> +⋮---- +modifyFuturesTraderOrderTPSL( + params: ModifyFuturesTraderOrderTPSLRequestV2, +): Promise> +⋮---- +getFuturesTraderOrder(): Promise< + APIResponse + > { + return this.getPrivate('/api/v2/copy/mix-trader/order-total-detail'); +⋮---- +getFuturesTraderProfitHistory(): Promise< + APIResponse + > { + return this.getPrivate('/api/v2/copy/mix-trader/profit-history-summarys'); +⋮---- +getFuturesTraderProfitShareHistory( + params: GetFuturesTraderProfitShareDetailRequestV2, +): Promise> +⋮---- +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, + ); +⋮---- +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); +⋮---- +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, + ); +⋮---- +getFuturesTraderSymbolSettings(params: { + productType: CopyTradingProductTypeV2; +}): Promise> +⋮---- +updateFuturesTraderSymbolSettings(params: { + settingList: FuturesTraderSymbolSettingRequestV2[]; +}): Promise> +⋮---- +updateFuturesTraderGlobalSettings(params?: { + enable?: 'YES' | 'NO'; + showTotalEquity?: 'YES' | 'NO'; + showTpsl?: 'YES' | 'NO'; +}): Promise> +⋮---- +getFuturesTraderFollowers( + params?: GetFuturesTraderFollowersRequestV2, +): Promise> +⋮---- +removeFuturesTraderFollower(params: { + followerUid: string; +}): Promise> +⋮---- +/** + * + * + * Copy Trading | Future copy trading | Follower Api + * + * + */ +⋮---- +getFuturesFollowerCurrentOrders( + params: GetFollowerFuturesCurrentTrackingOrdersRequestV2, +): Promise> +⋮---- +getFuturesFollowerHistoryOrders( + params: GetFollowerFuturesHistoryTrackingOrdersRequestV2, +): Promise> +⋮---- +updateFuturesFollowerTPSL( + params: UpdateFuturesFollowerTPSLRequestV2, +): Promise> +⋮---- +updateFuturesFollowerSettings( + params: UpdateFuturesFollowerSettingsRequestV2, +): Promise> +⋮---- +getFuturesFollowerSettings(params: { + traderId: string; +}): Promise> +⋮---- +closeFuturesFollowerPositions( + params: CloseFuturesFollowerPositionsRequestV2, + ): Promise< + APIResponse<{ + orderIdList: string[]; + }> + > { + return this.postPrivate( + '/api/v2/copy/mix-follower/close-positions', + params, + ); +⋮---- +getFuturesFollowerTraders( + params: GetFuturesFollowerTradersRequestV2, +): Promise> +⋮---- +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, + ); +⋮---- +unfollowFuturesTrader(params: { + traderId: string; +}): Promise> +⋮---- +/** + * + * + * Copy Trading | Future copy trading | Broker api + * + * + */ +⋮---- +getBrokerTraders(params: object): Promise> +⋮---- +getBrokerTradersHistoricalOrders(params: object): Promise> +⋮---- +getBrokerTradersPendingOrders(params: object): Promise> +⋮---- +/** + * + * + * Copy Trading | Spot copy trading | Trader api + * + * + */ +⋮---- +getSpotTraderProfit(): Promise> +⋮---- +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; +}): Promise> +⋮---- +getSpotTraderSymbolSettings(params: { + symbolList: string[]; + settingType: 'add' | 'delete'; +}): Promise> +⋮---- +removeSpotTraderFollowers(params: { + followerUid: string; +}): Promise> +⋮---- +getSpotTraderConfiguration(): Promise> +⋮---- +getSpotTraderFollowers( + params: GetSpotTraderFollowersRequestV2, +): Promise> +⋮---- +/** + * + * + * Copy Trading | Spot copy trading | Follower api + * + * + */ +⋮---- +cancelSpotFollowerOrder(params: { + trackingNoList: string[]; +}): Promise> +⋮---- +updateSpotFollowerSettings(params: { + traderId: string; + autoCopy?: 'on' | 'off'; + mode?: 'basic' | 'advanced'; + settings: SpotFollowerCopyTradeSettingV2[]; +}): Promise> +⋮---- +updateSpotFollowerTPSL(params: { + trackingNo: string; + stopSurplusPrice?: string; + stopLossPrice?: string; +}): Promise> +⋮---- +getSpotFollowerTraders(params?: { + pageNo?: string; + pageSize?: string; + startTime?: string; + endTime?: string; +}): Promise> +⋮---- +getSpotFollowerCurrentTraderSymbols(params: { traderId: string }): Promise< + APIResponse<{ + currentTradingList: string[]; + }> + > { + return this.getPrivate( + '/api/v2/copy/spot-follower/query-trader-symbols', + params, + ); +⋮---- +getSpotFollowerSettings(params: { + traderId: string; +}): Promise> +⋮---- +getSpotFollowerHistoryOrders( + params: GetSpotFollowerHistoryOrdersRequestV2, +): Promise> +⋮---- +getSpotFollowerOpenOrders( + params: GetSpotFollowerOpenOrdersRequestV2, +): Promise> +⋮---- +sellSpotFollower(params: { + trackingNoList: string[]; + symbol: string; +}): Promise> +⋮---- +unfollowSpotTrader(params: { + traderId: string; +}): Promise> +⋮---- +/** + * + * + * Earn | Savings + * + * + */ +⋮---- +getEarnSavingsProducts(params?: { + coin?: string; + filter?: string; +}): Promise> +⋮---- +getEarnSavingsAccount(): Promise> +⋮---- +getEarnSavingsAssets( + params: GetEarnSavingsAssetsRequestV2, +): Promise> +⋮---- +getEarnSavingsRecords( + params: GetEarnSavingsRecordsRequestV2, +): Promise> +⋮---- +getEarnSavingsSubscription(params: { + productId: string; + periodType: string; +}): Promise> +⋮---- +earnSubscribeSavings(params: { + productId: string; + periodType: string; + amount: string; + }): Promise< + APIResponse<{ + orderId: string; + status: string; + }> + > { + return this.postPrivate('/api/v2/earn/savings/subscribe', params); +⋮---- +getEarnSavingsSubscriptionResult(params: { + productId: string; + periodType: string; + }): Promise< + APIResponse<{ + result: 'success' | 'fail'; + msg: string; + }> + > { + return this.getPrivate('/api/v2/earn/savings/subscribe-result', params); +⋮---- +earnRedeemSavings(params: RedeemSavingsRequestV2): Promise< + APIResponse<{ + orderId: string; + status: string; + }> + > { + return this.postPrivate('/api/v2/earn/savings/redeem', params); +⋮---- +getEarnSavingsRedemptionResult(params: { + orderId: string; + periodType: string; + }): Promise< + APIResponse<{ + result: 'success' | 'fail'; + msg: string; + }> + > { + return this.getPrivate('/api/v2/earn/savings/redeem-result', params); +⋮---- +/** + * + * + * Earn | Earn Account + * + * + */ +⋮---- +getEarnAccount(params?: { coin?: string }): Promise< + APIResponse< + { + coin: string; + amount: string; + }[] + > + > { + return this.getPrivate('/api/v2/earn/account/assets', params); +⋮---- +/** + * + * + * 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> +⋮---- +/** + * + * + * Earn | Shark Fin + * + * + */ +⋮---- +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); +⋮---- +/** + * + * + * 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> +⋮---- +/** + * + * * Inst Loan | Product Info + * + */ +⋮---- +getLoanProductInfo( + params: GetInstLoanProductInfoRequestV2, +): Promise> +⋮---- +getLoanSymbols( + params: GetInstLoanSymbolsRequestV2, +): Promise> +⋮---- +getLoanMarginCoinInfo(params: GetInstLoanMarginCoinInfoRequestV2): Promise< + APIResponse<{ + productId: string; + coinInfo: InstLoanCoinInfoV2[]; + }> + > { + return this.getPrivate( + '/api/v2/spot/ins-loan/ensure-coins-convert', + params, + ); +⋮---- +/** + * + * * Inst Loan | Account + * + */ +⋮---- +getLoanRiskUnit(): Promise< + APIResponse<{ + riskUnitId: string[]; + }> + > { + return this.getPrivate('/api/v2/spot/ins-loan/risk-unit'); +⋮---- +getLoanLTVConvert( + params?: GetInstLoanLTVConvertRequestV2, +): Promise> +⋮---- +/** + * + * * Inst Loan | Orders + * + */ +⋮---- +getLoanRepaidHistory( + params?: GetInstLoanRepaidHistoryRequestV2, +): Promise> +⋮---- +getLoanOrder( + params?: GetInstLoanOrderRequestV2, +): Promise> -Contributions are encouraged, I will review any incoming pull requests. See the issues tab for todo items. +================ +File: src/types/response/v3/public.ts +================ +export interface PublicFillV3 { + execId: string; + execLinkId?: string; + price: string; + size: string; + side: 'sell' | 'buy'; + ts: string; + isRPI?: 'yes' | 'no' | 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 +} +⋮---- +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 ContractOiV3 { + symbol: string; + notionalValue: string; + totalNotionalValue: string; +} +⋮---- +export interface CurrentFundingRateV3 { + symbol: string; + fundingRate: string; + fundingRateInterval: string; + nextUpdate: string; + minFundingRate: string; + maxFundingRate: string; + cashDividend?: string; + cashDividendNextUpdate?: string; +} +⋮---- +export interface DiscountRateTierV3 { + tierStartValue: string; + discountRate: string; +} +⋮---- +export interface DiscountRateV3 { + coin: string; + list: DiscountRateTierV3[]; +} +⋮---- +export interface HistoryFundingRateV3 { + symbol: string; + fundingRate: string; + fundingRateTimestamp: string; +} +⋮---- +export interface MarginLoanV3 { + dailyInterest: string; + annualInterest: string; + limit: string; + masterSubLimit?: string; + /** Bitget spelling */ + platformRemaingQuota?: string; +} +⋮---- +/** Bitget spelling */ +⋮---- +export interface OpenInterestItemV3 { + symbol: string; + openInterest: string; +} +⋮---- +export interface OpenInterestV3 { + list: OpenInterestItemV3[]; + ts: string; +} +⋮---- +export interface PositionTierV3 { + tier: string; + minTierValue: string; + maxTierValue: string; + leverage: string; + mmr: string; +} +⋮---- +export interface RiskReserveRecordV3 { + balance: string; + amount: string; + ts: string; + type?: string; +} +⋮---- +export interface RiskReserveV3 { + totalBalance?: string; + coin: string; + riskReserveRecords: RiskReserveRecordV3[]; +} +⋮---- +export interface RiskReserveHourRecordV3 { + amount: string; + balance: string; + ts: string; +} +⋮---- +export interface RiskReserveHourV3 { + coin: string; + riskReserveRecords: RiskReserveHourRecordV3[]; +} +⋮---- +export interface RiskReserveAllItemV3 { + symbols: string[]; + coin: string; + balance: string; +} +⋮---- +export interface RiskReserveAllV3 { + list: RiskReserveAllItemV3[]; +} +⋮---- +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; + /** Spot only. Max amount for a single market order. */ + maxMarketOrderAmount?: 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'; -## Star History + // 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; -[![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) + // Margin specific fields + isIsolatedBaseBorrowable?: 'YES' | 'NO'; + isIsolatedQuotedBorrowable?: 'YES' | 'NO'; + warningRiskRatio?: string; + liquidationRiskRatio?: string; + maxCrossedLeverage?: string; + maxIsolatedLeverage?: string; + userMinBorrow?: string; +} +⋮---- +/** Spot only. Max amount for a single market order. */ +⋮---- +/** 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 MarketFeeGroupTierV3 { + level: string; + makerFeeRate: string; + /** PRO1~PRO6 only. Taker fee rate in decimal form */ + takerFeeRate?: string; + /** Market maker RPI maker fee rate in decimal form */ + rpiMakerFeeRate?: string; +} +⋮---- +/** PRO1~PRO6 only. Taker fee rate in decimal form */ +⋮---- +/** Market maker RPI maker fee rate in decimal form */ +⋮---- +export interface MarketFeeGroupV3 { + category: string; + group: string; + labelList: MarketFeeGroupLabelV3[]; + tierList: MarketFeeGroupTierV3[]; +} +⋮---- +export interface MarketScoreWeightV3 { + category: string; + label: string; + symbol: string; + requiredSpread: string; + minMakerVolume: string; + weight: string; +} +⋮---- +export interface LiquidationV3 { + symbol: string; + side: 'buy' | 'sell'; + price: 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; +} +⋮---- +a: string[][]; // asks - [price, size] +b: string[][]; // bids - [price, size] +⋮---- +export interface RealityOrderBookV3 { + symbol: string; + a: string[][]; + b: string[][]; + ts: string; +} +⋮---- +export interface RealityFillV3 { + execId: string; + price: string; + size: string; + side: 'buy' | 'sell'; + ts: string; +} +⋮---- +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; +} +⋮---- +/** 24h platform turnover; only available for rtoken */ +⋮---- +// Futures specific fields +⋮---- +export interface ProofOfReservesV3 { + merkleRootHash: string; + totalReserveRatio: string; + list: { + coin: string; + userAssets: string; + platformAssets: string; + reserveRatio: string; + }[]; +} +⋮---- +export interface IndexComponentV3 { + exchange: string; + spotPair: string; + equivalentPrice: string; + weight: string; +} +⋮---- +export interface IndexPriceComponentsV3 { + symbol: string; + componentList: IndexComponentV3[]; +} +⋮---- +export interface RpiSymbolV3 { + category: 'spot' | 'usdt-futures' | 'coin-futures' | 'usdc-futures'; + symbol: string; +} +⋮---- +/** RPI order book depth: [price, nonRpiQty, rpiQty] */ +export interface RpiOrderBookV3 { + a: [string, string, string][]; + b: [string, string, string][]; + ts: string; +} +⋮---- +export interface CashDividendRecordV3 { + symbol: string; + exDividendDate: string; + cashDividendPerShare: string; + cashDividendTimestamp: string; +} +⋮---- +export interface SplitRecordV3 { + symbol: string; + type: 'split' | 'reverse_split' | string; + status: 'pending' | 'ongoing' | 'completed' | string; + adjustmentRatio: string; + exDividendDate: string; + exDividendDateTimezone: string; + tradingHaltStartTime: string; + tradingHaltEndTime: string; +} +⋮---- +export interface SpotWhaleFlowV3 { + volume: string; + date: string; +} +⋮---- +export interface SpotNetFlowV3 { + netFlow: string; + ts: 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 interface MarginLongShortV3 { + longShortRatio: string; + ts: string; +} +⋮---- +export interface MarginLoanGrowthV3 { + growthRate: string; + ts: string; +} +⋮---- +export interface MarginIsolatedBorrowV3 { + borrowRate: string; + ts: string; +} +⋮---- +export interface FuturesActiveBuySellV3 { + buyVolume: string; + sellVolume: string; + ts: string; +} +⋮---- +export interface FuturesLongShortV3 { + longRatio: string; + shortRatio: string; + longShortRatio: string; + ts: string; +} +⋮---- +export interface FuturesPositionLongShortV3 { + longPositionRatio: string; + shortPositionRatio: string; + longShortPositionRatio: string; + ts: string; +} +⋮---- +export interface FuturesAccountLongShortV3 { + longAccountRatio: string; + shortAccountRatio: string; + longShortAccountRatio: string; + ts: string; +} ================ File: src/rest-client-v3.ts @@ -16900,12 +17318,14 @@ import { GetConvertRecordsRequestV3, GetDepositAddressRequestV3, GetDepositRecordsRequestV3, + GetEligibleDiscountRateRequestV3, GetEligibleLoanInfoRequestV3, GetEligibleMarginTierRequestV3, GetEligibleSymbolsRequestV3, GetFeeRateRequestV3, GetFinancialRecordsRequestV3, GetFundingAssetsRequestV3, + GetFundingFinancialRecordsRequestV3, GetMaxTransferableRequestV3, GetMaxWithdrawalRequestV3, GetMovePositionHistoryRequestV3, @@ -16913,6 +17333,8 @@ import { GetRateLimitQuotaRequestV3, GetRealityFillsRequestV3, GetRealityOrderBookRequestV3, + GetSmallAssetsHistoryRequestV3, + GetSmallAssetsRequestV3, GetSubAccountApiKeysRequestV3, GetSubAccountListRequestV3, GetSubDepositAddressRequestV3, @@ -16934,6 +17356,7 @@ import { SubAccountTransferRequestV3, SubMasterTransferRequestV3, SwitchDeductRequestV3, + TradeSmallAssetsRequestV3, TransferRequestV3, UpdateSubAccountApiKeyRequestV3, WithdrawRequestV3, @@ -16951,6 +17374,23 @@ import { ModifyBrokerSubAccountRequestV3, ModifyBrokerSubApiKeyRequestV3, } from './types/request/v3/broker.js'; +import { + CancelAllCfdOrdersRequestV3, + CancelCfdOrderRequestV3, + CfdTransferRequestV3, + CloseAllCfdPositionsRequestV3, + CloseCfdPositionsRequestV3, + GetCfdCurrentPositionsRequestV3, + GetCfdFinancialRecordsRequestV3, + GetCfdHistoryCandlestickRequestV3, + GetCfdInstrumentsRequestV3, + GetCfdOrderHistoryRequestV3, + GetCfdTickersRequestV3, + GetCfdTransferRecordsRequestV3, + GetCfdUnfilledOrdersRequestV3, + ModifyCfdOrderRequestV3, + PlaceCfdOrderRequestV3, +} from './types/request/v3/cfd.js'; import { CopyFuturesTransferRequestV3, GetCopyFuturesFollowersRequestV3, @@ -16966,6 +17406,22 @@ import { GetEarnEliteSubscribeResultRequestV3, RedeemEarnEliteRequestV3, } from './types/request/v3/earn.js'; +import { + AddGridInvestmentRequestV3, + CloseGridBotRequestV3, + CreateGridBotRequestV3, + CreateNeutralGridBotRequestV3, + GetGridBotDetailRequestV3, + GetGridBotOrderDetailsRequestV3, + GetNeutralGridBotDetailRequestV3, + GetNeutralGridBotOrderDetailsRequestV3, + ModifyGridBotRequestV3, + ModifyGridIntervalRequestV3, + ModifyNeutralGridBotRequestV3, + ModifyNeutralGridIntervalRequestV3, + ValidateGridBotRequestV3, + ValidateNeutralGridBotRequestV3, +} from './types/request/v3/grid.js'; import { BindUidRequestV3, GetEnsureCoinsRequestV3, @@ -17026,11 +17482,24 @@ import { GetRiskReserveAllRequestV3, GetRiskReserveRequestV3, GetRpiOrderBookRequestV3, + GetSplitRecordsRequestV3, GetSpotFundFlowRequestV3, GetSpotNetFlowRequestV3, GetSpotWhaleFlowRequestV3, GetTickersRequestV3, } from './types/request/v3/public.js'; +import { + GetRealityCompanyOverviewRequestV3, + GetRealityDividendsRequestV3, + GetRealityEarningsForecastRequestV3, + GetRealityExecutiveShareholdingsRequestV3, + GetRealityInnerTradesRequestV3, + GetRealityShareCapitalChangeRequestV3, + GetRealityShareholdDetailRequestV3, + GetRealityStockInfoRequestV3, + GetRealitySuspensionResumptionInfoRequestV3, + GetRealityValuationIndicatorsRequestV3, +} from './types/request/v3/reality.js'; import { CancelStockPlusOrderRequestV3, GetStockPlusAccountRequestV3, @@ -17060,6 +17529,7 @@ import { import { CancelStrategyOrderRequestV3, GetHistoryStrategyOrdersRequestV3, + GetStrategySubOrdersRequestV3, GetUnfilledStrategyOrdersRequestV3, ModifyStrategyOrderRequestV3, PlaceStrategyOrderRequestV3, @@ -17098,11 +17568,13 @@ import { CustomCollateralCoinV3, DepositAddressV3, DepositRecordV3, + EligibleDiscountRateV3, EligibleLoanInfoV3, EligibleMarginTierV3, EligibleSymbolV3, FinancialRecordV3, FundingAssetV3, + FundingFinancialRecordV3, MaxTransferableV3, MaxWithdrawalV3, MovePositionHistoryV3, @@ -17113,6 +17585,9 @@ import { RateLimitQuotaV3, RepayableCoinV3, RepayResponseV3, + SmallAssetsHistoryItemV3, + SmallAssetsTradeResponseV3, + SmallAssetV3, SubAccountApiKeyV3, SubAccountV3, SubTransferRecordV3, @@ -17136,6 +17611,20 @@ import { ModifyBrokerSubAccountResponseV3, ModifyBrokerSubApiKeyResponseV3, } from './types/response/v3/broker.js'; +import { + CfdCandlestickV3, + CfdCurrentPositionV3, + CfdFinancialRecordV3, + CfdFundDetailV3, + CfdInstrumentV3, + CfdOrderHistoryV3, + CfdTickerV3, + CfdTransferRecordsV3, + CfdTransferResponseV3, + CfdUnfilledOrderV3, + ModifyCfdOrderResponseV3, + PlaceCfdOrderResponseV3, +} from './types/response/v3/cfd.js'; import { CopyFuturesCurrentFollowersV3, CopyFuturesHistoryFollowersV3, @@ -17157,6 +17646,13 @@ import { EarnEliteSubscribeStatusV3, RedeemEarnEliteResultV3, } from './types/response/v3/earn.js'; +import { + GridBotDetailV3, + GridBotIdResponseV3, + GridBotOrderDetailsV3, + GridValidateResponseV3, + NeutralGridBotDetailV3, +} from './types/response/v3/grid.js'; import { BindUidResponseV3, CoinInfoV3, @@ -17226,11 +17722,27 @@ import { RiskReserveV3, RpiOrderBookV3, RpiSymbolV3, + SplitRecordV3, SpotFundFlowV3, SpotNetFlowV3, SpotWhaleFlowV3, TickerV3, } from './types/response/v3/public.js'; +import { + RealityCompanyOverviewV3, + RealityCursorListV3, + RealityDividendItemV3, + RealityEarningsForecastV3, + RealityExecutiveShareholdingItemV3, + RealityInnerTradeItemV3, + RealityMarketCalendarV3, + RealityMarketStateV3, + RealityShareCapitalChangeV3, + RealityShareholdDetailItemV3, + RealityStockInfoV3, + RealitySuspensionResumptionInfoV3, + RealityValuationIndicatorsV3, +} from './types/response/v3/reality.js'; import { StockPlusAccountV3, StockPlusCancelOrderResponseV3, @@ -17261,6 +17773,7 @@ import { ModifyStrategyOrderResponseV3, PlaceStrategyOrderResponseV3, StrategyOrderV3, + StrategySubOrderV3, } from './types/response/v3/strategy.js'; import { BatchModifyOrderResponseV3, @@ -17372,6 +17885,10 @@ getCashDividendRecords( params: GetCashDividendRecordsRequestV3, ): Promise> ⋮---- +getSplitRecords( + params?: GetSplitRecordsRequestV3, +): Promise> +⋮---- /** * Get Spot Whale Net Flow Data */ @@ -17577,6 +18094,53 @@ getRealityFills( params: GetRealityFillsRequestV3, ): Promise> ⋮---- +getRealityCompanyOverview( + params: GetRealityCompanyOverviewRequestV3, +): Promise> +⋮---- +getRealityValuationIndicators( + params: GetRealityValuationIndicatorsRequestV3, +): Promise> +⋮---- +getRealityEarningsForecast( + params: GetRealityEarningsForecastRequestV3, +): Promise> +⋮---- +getRealitySuspensionResumptionInfo( + params: GetRealitySuspensionResumptionInfoRequestV3, +): Promise> +⋮---- +getRealityDividends( + params: GetRealityDividendsRequestV3, +): Promise>> +⋮---- +getRealityShareCapitalChange( + params: GetRealityShareCapitalChangeRequestV3, +): Promise> +⋮---- +getRealityInnerTrades( + params: GetRealityInnerTradesRequestV3, +): Promise>> +⋮---- +getRealityExecutiveShareholdings( + params: GetRealityExecutiveShareholdingsRequestV3, + ): Promise< + APIResponse> + > { + return this.get('/api/v3/reality/market/executive-shareholdings', params); +⋮---- +getRealityShareholdDetail( + params: GetRealityShareholdDetailRequestV3, +): Promise>> +⋮---- +getRealityStockInfo( + params?: GetRealityStockInfoRequestV3, +): Promise> +⋮---- +getRealityMarketStates(): Promise> +⋮---- +getRealityMarketCalendar(): Promise> +⋮---- /** * * =====Copy Trading | Futures===== @@ -17746,6 +18310,72 @@ getStockPlusTransferRecords( params?: GetStockPlusTransferRecordsRequestV3, ): Promise> ⋮---- +/** + * + * =====CFD======= endpoints + * + */ +⋮---- +getCfdTickers( + params?: GetCfdTickersRequestV3, +): Promise> +⋮---- +getCfdHistoryCandlestick( + params: GetCfdHistoryCandlestickRequestV3, +): Promise> +⋮---- +placeCfdOrder( + params: PlaceCfdOrderRequestV3, +): Promise> +⋮---- +modifyCfdOrder( + params: ModifyCfdOrderRequestV3, +): Promise> +⋮---- +cancelCfdOrder(params: CancelCfdOrderRequestV3): Promise> +⋮---- +cancelAllCfdOrders( + params?: CancelAllCfdOrdersRequestV3, +): Promise> +⋮---- +closeCfdPositions( + params: CloseCfdPositionsRequestV3, +): Promise> +⋮---- +closeAllCfdPositions( + params?: CloseAllCfdPositionsRequestV3, +): Promise> +⋮---- +getCfdUnfilledOrders( + params?: GetCfdUnfilledOrdersRequestV3, +): Promise> +⋮---- +getCfdOrderHistory( + params: GetCfdOrderHistoryRequestV3, +): Promise> +⋮---- +getCfdCurrentPositions( + params?: GetCfdCurrentPositionsRequestV3, +): Promise> +⋮---- +getCfdFundDetail(): Promise> +⋮---- +cfdTransfer( + params: CfdTransferRequestV3, +): Promise> +⋮---- +getCfdTransferRecords( + params?: GetCfdTransferRecordsRequestV3, +): Promise> +⋮---- +getCfdFinancialRecords( + params?: GetCfdFinancialRecordsRequestV3, +): Promise> +⋮---- +getCfdInstruments( + params?: GetCfdInstrumentsRequestV3, +): Promise> +⋮---- /** * * =====Account======= endpoints @@ -17848,6 +18478,16 @@ getFinancialRecords(params: GetFinancialRecordsRequestV3): Promise< > { return this.getPrivate('/api/v3/account/financial-records', params); ⋮---- +getFundingFinancialRecords( + params?: GetFundingFinancialRecordsRequestV3, + ): Promise< + APIResponse<{ + list: FundingFinancialRecordV3[]; + cursor: string; + }> + > { + return this.getPrivate('/api/v3/account/funding-financial-records', params); +⋮---- /** * Get Repayable Coins */ @@ -17886,6 +18526,22 @@ getConvertRecords(params: GetConvertRecordsRequestV3): Promise< > { return this.getPrivate('/api/v3/account/convert-records', params); ⋮---- +getSmallAssets( + params?: GetSmallAssetsRequestV3, +): Promise> +⋮---- +tradeSmallAssets( + params: TradeSmallAssetsRequestV3, +): Promise> +⋮---- +getSmallAssetsHistory(params?: GetSmallAssetsHistoryRequestV3): Promise< + APIResponse<{ + list: SmallAssetsHistoryItemV3[]; + cursor: string; + }> + > { + return this.getPrivate('/api/v3/convert/small-assets-history', params); +⋮---- /** * Set up deposit account - Configure default recharge account for a certain symbol * This configuration item remains valid for a long time. That is, once a user sets a default @@ -17962,6 +18618,10 @@ getEligibleLoanInfo( params?: GetEligibleLoanInfoRequestV3, ): Promise> ⋮---- +getEligibleDiscountRate( + params?: GetEligibleDiscountRateRequestV3, +): Promise> +⋮---- /** * Switch Account - Switch to classic account mode * Only supports parent accounts. @@ -18585,6 +19245,76 @@ getHistoryStrategyOrders(params: GetHistoryStrategyOrdersRequestV3): Promise< > { return this.getPrivate('/api/v3/trade/history-strategy-orders', params); ⋮---- +getStrategySubOrders(params: GetStrategySubOrdersRequestV3): Promise< + APIResponse<{ + list: StrategySubOrderV3[]; + cursor?: string; + }> + > { + return this.getPrivate('/api/v3/trade/strategy-sub-orders', params); +⋮---- +/** + * + * =====Grid======= endpoints + * + */ +⋮---- +validateGridBot( + params: ValidateGridBotRequestV3, +): Promise> +⋮---- +createGridBot( + params: CreateGridBotRequestV3, +): Promise> +⋮---- +modifyGridBot( + params: ModifyGridBotRequestV3, +): Promise> +⋮---- +modifyGridInterval( + params: ModifyGridIntervalRequestV3, +): Promise> +⋮---- +addGridInvestment( + params: AddGridInvestmentRequestV3, +): Promise> +⋮---- +closeGridBot( + params: CloseGridBotRequestV3, +): Promise> +⋮---- +getGridBotDetail( + params: GetGridBotDetailRequestV3, +): Promise> +⋮---- +getGridBotOrderDetails( + params: GetGridBotOrderDetailsRequestV3, +): Promise> +⋮---- +validateNeutralGridBot( + params: ValidateNeutralGridBotRequestV3, +): Promise> +⋮---- +createNeutralGridBot( + params: CreateNeutralGridBotRequestV3, +): Promise> +⋮---- +modifyNeutralGridBot( + params: ModifyNeutralGridBotRequestV3, +): Promise> +⋮---- +modifyNeutralGridInterval( + params: ModifyNeutralGridIntervalRequestV3, +): Promise> +⋮---- +getNeutralGridBotDetail( + params: GetNeutralGridBotDetailRequestV3, +): Promise> +⋮---- +getNeutralGridBotOrderDetails( + params: GetNeutralGridBotOrderDetailsRequestV3, +): Promise> +⋮---- /** * * =====Broker======= endpoints @@ -18698,124 +19428,775 @@ deleteBrokerSubApiKey( params: DeleteBrokerSubApiKeyRequestV3, ): Promise> ⋮---- -/** - * Get Broker Sub-Account API Key - * - * Rate limit: 20/sec/UID - * Only the master account with a user type of ND Broker can call this API endpoint. - */ -getBrokerSubApiKey( - params: GetBrokerSubApiKeyRequestV3, -): Promise> +/** + * Get Broker Sub-Account API Key + * + * Rate limit: 20/sec/UID + * Only the master account with a user type of ND Broker can call this API endpoint. + */ +getBrokerSubApiKey( + params: GetBrokerSubApiKeyRequestV3, +): Promise> +⋮---- +/** + * + * =====P2P Merchant (UTA)===== + * + */ +⋮---- +getP2pAdList( + params: GetP2pAdListRequestV3, +): Promise> +⋮---- +getP2pExchangeRate( + params: GetP2pExchangeRateRequestV3, +): Promise> +⋮---- +simulateP2pFee( + params: P2pFeeSimulateRequestV3, +): Promise> +⋮---- +getP2pAdLimit( + params: GetP2pAdLimitRequestV3, +): Promise> +⋮---- +createP2pAd( + params: CreateP2pAdRequestV3, +): Promise> +⋮---- +updateP2pAd(params: UpdateP2pAdRequestV3): Promise> +⋮---- +operateP2pAd(params: OperateP2pAdRequestV3): Promise> +⋮---- +getP2pAdInfo( + params: GetP2pAdInfoRequestV3, +): Promise> +⋮---- +getP2pMyAds( + params?: GetP2pMyAdsRequestV3, +): Promise>> +⋮---- +getP2pPendingOrders( + params?: GetP2pPendingOrdersRequestV3, +): Promise>> +⋮---- +getP2pAllOrders( + params?: GetP2pAllOrdersRequestV3, +): Promise>> +⋮---- +getP2pOrderInfo( + params: GetP2pOrderInfoRequestV3, +): Promise> +⋮---- +confirmP2pOrderPayment( + params: P2pOrderActionRequestV3, +): Promise> +⋮---- +releaseP2pOrderAsset( + params: P2pOrderActionRequestV3, +): Promise> +⋮---- +getP2pUserInfo(): Promise> +⋮---- +getP2pCurrencies(): Promise> +⋮---- +getP2pPayMethods(): Promise> +⋮---- +getP2pBalance( + params: GetP2pBalanceRequestV3, +): Promise> +⋮---- +/** + * + * =====Earn | On-Chain Elite (UTA)===== + * + */ +⋮---- +getEarnEliteProducts(): Promise> +⋮---- +getEarnEliteAssets(): Promise> +⋮---- +getEarnEliteRecords( + params: GetEarnEliteRecordsRequestV3, +): Promise> +⋮---- +getEarnEliteSubscribeInfo( + params: GetEarnEliteSubscribeInfoRequestV3, +): Promise> +⋮---- +subscribeEarnElite( + params: EarnEliteSubscribeRequestV3, +): Promise> +⋮---- +getEarnEliteSubscribeResult( + params: GetEarnEliteSubscribeResultRequestV3, +): Promise> ⋮---- -/** - * - * =====P2P Merchant (UTA)===== - * +getEarnEliteRedeemInfo( + params: GetEarnEliteRedeemInfoRequestV3, +): Promise> +⋮---- +redeemEarnElite( + params: RedeemEarnEliteRequestV3, +): Promise> + +================ +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 +- Bitget JavaScript Tutorial: https://siebly.io/sdk/bitget/javascript/tutorial + +## 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/sieblyio/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 */ -⋮---- -getP2pAdList( - params: GetP2pAdListRequestV3, -): Promise> -⋮---- -getP2pExchangeRate( - params: GetP2pExchangeRateRequestV3, -): Promise> -⋮---- -simulateP2pFee( - params: P2pFeeSimulateRequestV3, -): Promise> -⋮---- -getP2pAdLimit( - params: GetP2pAdLimitRequestV3, -): Promise> -⋮---- -createP2pAd( - params: CreateP2pAdRequestV3, -): Promise> -⋮---- -updateP2pAd(params: UpdateP2pAdRequestV3): Promise> -⋮---- -operateP2pAd(params: OperateP2pAdRequestV3): Promise> -⋮---- -getP2pAdInfo( - params: GetP2pAdInfoRequestV3, -): Promise> -⋮---- -getP2pMyAds( - params?: GetP2pMyAdsRequestV3, -): Promise>> -⋮---- -getP2pPendingOrders( - params?: GetP2pPendingOrdersRequestV3, -): Promise>> -⋮---- -getP2pAllOrders( - params?: GetP2pAllOrdersRequestV3, -): Promise>> -⋮---- -getP2pOrderInfo( - params: GetP2pOrderInfoRequestV3, -): Promise> -⋮---- -confirmP2pOrderPayment( - params: P2pOrderActionRequestV3, -): Promise> -⋮---- -releaseP2pOrderAsset( - params: P2pOrderActionRequestV3, -): Promise> -⋮---- -getP2pUserInfo(): Promise> -⋮---- -getP2pCurrencies(): Promise> -⋮---- -getP2pPayMethods(): Promise> -⋮---- -getP2pBalance( - params: GetP2pBalanceRequestV3, -): Promise> -⋮---- + 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 | On-Chain Elite (UTA)===== - * - */ -⋮---- -getEarnEliteProducts(): Promise> -⋮---- -getEarnEliteAssets(): Promise> -⋮---- -getEarnEliteRecords( - params: GetEarnEliteRecordsRequestV3, -): Promise> -⋮---- -getEarnEliteSubscribeInfo( - params: GetEarnEliteSubscribeInfoRequestV3, -): Promise> -⋮---- -subscribeEarnElite( - params: EarnEliteSubscribeRequestV3, -): Promise> -⋮---- -getEarnEliteSubscribeResult( - params: GetEarnEliteSubscribeResultRequestV3, -): Promise> -⋮---- -getEarnEliteRedeemInfo( - params: GetEarnEliteRedeemInfoRequestV3, -): Promise> -⋮---- -redeemEarnElite( - params: RedeemEarnEliteRequestV3, -): 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: package.json ================ { "name": "bitget-api", - "version": "3.2.2", + "version": "3.2.4", "description": "Complete Node.js & JavaScript SDK for Bitget V1-V3 REST APIs & WebSockets, with TypeScript & end-to-end tests.", "scripts": { "test": "jest", @@ -18851,9 +20232,9 @@ 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", + "@types/ws": "8.18.1", + "axios": "1.18.1", + "isomorphic-ws": "5.0.0", "ws": "8.21.1" }, "devDependencies": { @@ -18875,6 +20256,14 @@ File: package.json "webpack": "^5.74.0", "webpack-cli": "^4.10.0" }, + "overrides": { + "brace-expansion@<2": "1.1.18", + "brace-expansion@>=2 <3": "2.1.4", + "brace-expansion@>=5 <6": "5.0.9", + "fast-uri@>=3 <4": "3.1.5", + "js-yaml@>=3 <4": "3.15.1", + "js-yaml@>=4 <5": "4.3.1" + }, "keywords": [ "bitget", "bitget api", @@ -18909,7 +20298,7 @@ File: package.json "bugs": { "url": "https://github.com/sieblyio/bitget-api/issues" }, - "homepage": "https://github.com/sieblyio/bitget-api#readme" + "homepage": "https://siebly.io/sdk/bitget/javascript" } diff --git a/package-lock.json b/package-lock.json index d2f8f8a..2f0e82c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bitget-api", - "version": "3.2.3", + "version": "3.2.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "bitget-api", - "version": "3.2.3", + "version": "3.2.4", "license": "MIT", "dependencies": { "@types/ws": "8.18.1", diff --git a/package.json b/package.json index cbdcf9f..0cf2505 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bitget-api", - "version": "3.2.3", + "version": "3.2.4", "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 b9e7180..4ea6674 100644 --- a/src/index.ts +++ b/src/index.ts @@ -11,11 +11,14 @@ export * from './types/request/v2/margin.js'; export * from './types/request/v2/spot.js'; export * from './types/request/v3/account.js'; export * from './types/request/v3/broker.js'; +export * from './types/request/v3/cfd.js'; export * from './types/request/v3/copytrading.js'; export * from './types/request/v3/earn.js'; +export * from './types/request/v3/grid.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/reality.js'; export * from './types/request/v3/stockplus.js'; export * from './types/request/v3/strategy.js'; export * from './types/request/v3/trade.js'; @@ -28,11 +31,14 @@ export * from './types/response/v2/margin.js'; export * from './types/response/v2/spot.js'; export * from './types/response/v3/account.js'; export * from './types/response/v3/broker.js'; +export * from './types/response/v3/cfd.js'; export * from './types/response/v3/copytrading.js'; export * from './types/response/v3/earn.js'; +export * from './types/response/v3/grid.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/reality.js'; export * from './types/response/v3/stockplus.js'; export * from './types/response/v3/strategy.js'; export * from './types/response/v3/trade.js'; diff --git a/src/rest-client-v3.ts b/src/rest-client-v3.ts index 19b4c6b..7b47741 100644 --- a/src/rest-client-v3.ts +++ b/src/rest-client-v3.ts @@ -10,12 +10,14 @@ import { GetConvertRecordsRequestV3, GetDepositAddressRequestV3, GetDepositRecordsRequestV3, + GetEligibleDiscountRateRequestV3, GetEligibleLoanInfoRequestV3, GetEligibleMarginTierRequestV3, GetEligibleSymbolsRequestV3, GetFeeRateRequestV3, GetFinancialRecordsRequestV3, GetFundingAssetsRequestV3, + GetFundingFinancialRecordsRequestV3, GetMaxTransferableRequestV3, GetMaxWithdrawalRequestV3, GetMovePositionHistoryRequestV3, @@ -23,6 +25,8 @@ import { GetRateLimitQuotaRequestV3, GetRealityFillsRequestV3, GetRealityOrderBookRequestV3, + GetSmallAssetsHistoryRequestV3, + GetSmallAssetsRequestV3, GetSubAccountApiKeysRequestV3, GetSubAccountListRequestV3, GetSubDepositAddressRequestV3, @@ -44,6 +48,7 @@ import { SubAccountTransferRequestV3, SubMasterTransferRequestV3, SwitchDeductRequestV3, + TradeSmallAssetsRequestV3, TransferRequestV3, UpdateSubAccountApiKeyRequestV3, WithdrawRequestV3, @@ -61,6 +66,23 @@ import { ModifyBrokerSubAccountRequestV3, ModifyBrokerSubApiKeyRequestV3, } from './types/request/v3/broker.js'; +import { + CancelAllCfdOrdersRequestV3, + CancelCfdOrderRequestV3, + CfdTransferRequestV3, + CloseAllCfdPositionsRequestV3, + CloseCfdPositionsRequestV3, + GetCfdCurrentPositionsRequestV3, + GetCfdFinancialRecordsRequestV3, + GetCfdHistoryCandlestickRequestV3, + GetCfdInstrumentsRequestV3, + GetCfdOrderHistoryRequestV3, + GetCfdTickersRequestV3, + GetCfdTransferRecordsRequestV3, + GetCfdUnfilledOrdersRequestV3, + ModifyCfdOrderRequestV3, + PlaceCfdOrderRequestV3, +} from './types/request/v3/cfd.js'; import { CopyFuturesTransferRequestV3, GetCopyFuturesFollowersRequestV3, @@ -76,6 +98,22 @@ import { GetEarnEliteSubscribeResultRequestV3, RedeemEarnEliteRequestV3, } from './types/request/v3/earn.js'; +import { + AddGridInvestmentRequestV3, + CloseGridBotRequestV3, + CreateGridBotRequestV3, + CreateNeutralGridBotRequestV3, + GetGridBotDetailRequestV3, + GetGridBotOrderDetailsRequestV3, + GetNeutralGridBotDetailRequestV3, + GetNeutralGridBotOrderDetailsRequestV3, + ModifyGridBotRequestV3, + ModifyGridIntervalRequestV3, + ModifyNeutralGridBotRequestV3, + ModifyNeutralGridIntervalRequestV3, + ValidateGridBotRequestV3, + ValidateNeutralGridBotRequestV3, +} from './types/request/v3/grid.js'; import { BindUidRequestV3, GetEnsureCoinsRequestV3, @@ -136,11 +174,24 @@ import { GetRiskReserveAllRequestV3, GetRiskReserveRequestV3, GetRpiOrderBookRequestV3, + GetSplitRecordsRequestV3, GetSpotFundFlowRequestV3, GetSpotNetFlowRequestV3, GetSpotWhaleFlowRequestV3, GetTickersRequestV3, } from './types/request/v3/public.js'; +import { + GetRealityCompanyOverviewRequestV3, + GetRealityDividendsRequestV3, + GetRealityEarningsForecastRequestV3, + GetRealityExecutiveShareholdingsRequestV3, + GetRealityInnerTradesRequestV3, + GetRealityShareCapitalChangeRequestV3, + GetRealityShareholdDetailRequestV3, + GetRealityStockInfoRequestV3, + GetRealitySuspensionResumptionInfoRequestV3, + GetRealityValuationIndicatorsRequestV3, +} from './types/request/v3/reality.js'; import { CancelStockPlusOrderRequestV3, GetStockPlusAccountRequestV3, @@ -170,6 +221,7 @@ import { import { CancelStrategyOrderRequestV3, GetHistoryStrategyOrdersRequestV3, + GetStrategySubOrdersRequestV3, GetUnfilledStrategyOrdersRequestV3, ModifyStrategyOrderRequestV3, PlaceStrategyOrderRequestV3, @@ -208,11 +260,13 @@ import { CustomCollateralCoinV3, DepositAddressV3, DepositRecordV3, + EligibleDiscountRateV3, EligibleLoanInfoV3, EligibleMarginTierV3, EligibleSymbolV3, FinancialRecordV3, FundingAssetV3, + FundingFinancialRecordV3, MaxTransferableV3, MaxWithdrawalV3, MovePositionHistoryV3, @@ -223,6 +277,9 @@ import { RateLimitQuotaV3, RepayableCoinV3, RepayResponseV3, + SmallAssetsHistoryItemV3, + SmallAssetsTradeResponseV3, + SmallAssetV3, SubAccountApiKeyV3, SubAccountV3, SubTransferRecordV3, @@ -246,6 +303,20 @@ import { ModifyBrokerSubAccountResponseV3, ModifyBrokerSubApiKeyResponseV3, } from './types/response/v3/broker.js'; +import { + CfdCandlestickV3, + CfdCurrentPositionV3, + CfdFinancialRecordV3, + CfdFundDetailV3, + CfdInstrumentV3, + CfdOrderHistoryV3, + CfdTickerV3, + CfdTransferRecordsV3, + CfdTransferResponseV3, + CfdUnfilledOrderV3, + ModifyCfdOrderResponseV3, + PlaceCfdOrderResponseV3, +} from './types/response/v3/cfd.js'; import { CopyFuturesCurrentFollowersV3, CopyFuturesHistoryFollowersV3, @@ -267,6 +338,13 @@ import { EarnEliteSubscribeStatusV3, RedeemEarnEliteResultV3, } from './types/response/v3/earn.js'; +import { + GridBotDetailV3, + GridBotIdResponseV3, + GridBotOrderDetailsV3, + GridValidateResponseV3, + NeutralGridBotDetailV3, +} from './types/response/v3/grid.js'; import { BindUidResponseV3, CoinInfoV3, @@ -336,11 +414,27 @@ import { RiskReserveV3, RpiOrderBookV3, RpiSymbolV3, + SplitRecordV3, SpotFundFlowV3, SpotNetFlowV3, SpotWhaleFlowV3, TickerV3, } from './types/response/v3/public.js'; +import { + RealityCompanyOverviewV3, + RealityCursorListV3, + RealityDividendItemV3, + RealityEarningsForecastV3, + RealityExecutiveShareholdingItemV3, + RealityInnerTradeItemV3, + RealityMarketCalendarV3, + RealityMarketStateV3, + RealityShareCapitalChangeV3, + RealityShareholdDetailItemV3, + RealityStockInfoV3, + RealitySuspensionResumptionInfoV3, + RealityValuationIndicatorsV3, +} from './types/response/v3/reality.js'; import { StockPlusAccountV3, StockPlusCancelOrderResponseV3, @@ -371,6 +465,7 @@ import { ModifyStrategyOrderResponseV3, PlaceStrategyOrderResponseV3, StrategyOrderV3, + StrategySubOrderV3, } from './types/response/v3/strategy.js'; import { BatchModifyOrderResponseV3, @@ -543,6 +638,12 @@ export class RestClientV3 extends BaseRestClient { return this.get('/api/v3/market/cash-dividend-records', params); } + getSplitRecords( + params?: GetSplitRecordsRequestV3, + ): Promise> { + return this.get('/api/v3/market/split-records', params); + } + /** * Get Spot Whale Net Flow Data */ @@ -808,6 +909,79 @@ export class RestClientV3 extends BaseRestClient { return this.getPrivate('/api/v3/account/reality-fills', params); } + getRealityCompanyOverview( + params: GetRealityCompanyOverviewRequestV3, + ): Promise> { + return this.get('/api/v3/reality/market/company-overview', params); + } + + getRealityValuationIndicators( + params: GetRealityValuationIndicatorsRequestV3, + ): Promise> { + return this.get('/api/v3/reality/market/valuation-indicators', params); + } + + getRealityEarningsForecast( + params: GetRealityEarningsForecastRequestV3, + ): Promise> { + return this.get('/api/v3/reality/market/earnings-forecast', params); + } + + getRealitySuspensionResumptionInfo( + params: GetRealitySuspensionResumptionInfoRequestV3, + ): Promise> { + return this.get( + '/api/v3/reality/market/suspension-resumption-info', + params, + ); + } + + getRealityDividends( + params: GetRealityDividendsRequestV3, + ): Promise>> { + return this.get('/api/v3/reality/market/dividends', params); + } + + getRealityShareCapitalChange( + params: GetRealityShareCapitalChangeRequestV3, + ): Promise> { + return this.get('/api/v3/reality/market/share-capital-change', params); + } + + getRealityInnerTrades( + params: GetRealityInnerTradesRequestV3, + ): Promise>> { + return this.get('/api/v3/reality/market/inner-trades', params); + } + + getRealityExecutiveShareholdings( + params: GetRealityExecutiveShareholdingsRequestV3, + ): Promise< + APIResponse> + > { + return this.get('/api/v3/reality/market/executive-shareholdings', params); + } + + getRealityShareholdDetail( + params: GetRealityShareholdDetailRequestV3, + ): Promise>> { + return this.get('/api/v3/reality/market/sharehold-detail', params); + } + + getRealityStockInfo( + params?: GetRealityStockInfoRequestV3, + ): Promise> { + return this.get('/api/v3/reality/market/stock-info', params); + } + + getRealityMarketStates(): Promise> { + return this.get('/api/v3/reality/market/states'); + } + + getRealityMarketCalendar(): Promise> { + return this.get('/api/v3/reality/market/calendar'); + } + /** * * =====Copy Trading | Futures===== @@ -1052,6 +1226,104 @@ export class RestClientV3 extends BaseRestClient { return this.getPrivate('/api/v3/stockplus/asset/transfer-records', params); } + /** + * + * =====CFD======= endpoints + * + */ + + getCfdTickers( + params?: GetCfdTickersRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/cfd/market/tickers', params); + } + + getCfdHistoryCandlestick( + params: GetCfdHistoryCandlestickRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/cfd/market/history-candlestick', params); + } + + placeCfdOrder( + params: PlaceCfdOrderRequestV3, + ): Promise> { + return this.postPrivate('/api/v3/cfd/trade/place-order', params); + } + + modifyCfdOrder( + params: ModifyCfdOrderRequestV3, + ): Promise> { + return this.postPrivate('/api/v3/cfd/trade/modify-order', params); + } + + cancelCfdOrder(params: CancelCfdOrderRequestV3): Promise> { + return this.postPrivate('/api/v3/cfd/trade/cancel-order', params); + } + + cancelAllCfdOrders( + params?: CancelAllCfdOrdersRequestV3, + ): Promise> { + return this.postPrivate('/api/v3/cfd/trade/cancel-all', params); + } + + closeCfdPositions( + params: CloseCfdPositionsRequestV3, + ): Promise> { + return this.postPrivate('/api/v3/cfd/trade/close-positions', params); + } + + closeAllCfdPositions( + params?: CloseAllCfdPositionsRequestV3, + ): Promise> { + return this.postPrivate('/api/v3/cfd/trade/close-all-positions', params); + } + + getCfdUnfilledOrders( + params?: GetCfdUnfilledOrdersRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/cfd/trade/unfilled-order', params); + } + + getCfdOrderHistory( + params: GetCfdOrderHistoryRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/cfd/trade/history-order', params); + } + + getCfdCurrentPositions( + params?: GetCfdCurrentPositionsRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/cfd/trade/current-positions', params); + } + + getCfdFundDetail(): Promise> { + return this.getPrivate('/api/v3/cfd/account/fund-detail'); + } + + cfdTransfer( + params: CfdTransferRequestV3, + ): Promise> { + return this.postPrivate('/api/v3/cfd/account/transfer', params); + } + + getCfdTransferRecords( + params?: GetCfdTransferRecordsRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/cfd/account/transfer-records', params); + } + + getCfdFinancialRecords( + params?: GetCfdFinancialRecordsRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/cfd/account/financial-records', params); + } + + getCfdInstruments( + params?: GetCfdInstrumentsRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/cfd/account/instruments', params); + } + /** * * =====Account======= endpoints @@ -1183,6 +1455,17 @@ export class RestClientV3 extends BaseRestClient { return this.getPrivate('/api/v3/account/financial-records', params); } + getFundingFinancialRecords( + params?: GetFundingFinancialRecordsRequestV3, + ): Promise< + APIResponse<{ + list: FundingFinancialRecordV3[]; + cursor: string; + }> + > { + return this.getPrivate('/api/v3/account/funding-financial-records', params); + } + /** * Get Repayable Coins */ @@ -1226,6 +1509,27 @@ export class RestClientV3 extends BaseRestClient { return this.getPrivate('/api/v3/account/convert-records', params); } + getSmallAssets( + params?: GetSmallAssetsRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/convert/small-assets', params); + } + + tradeSmallAssets( + params: TradeSmallAssetsRequestV3, + ): Promise> { + return this.postPrivate('/api/v3/convert/small-assets-trade', params); + } + + getSmallAssetsHistory(params?: GetSmallAssetsHistoryRequestV3): Promise< + APIResponse<{ + list: SmallAssetsHistoryItemV3[]; + cursor: string; + }> + > { + return this.getPrivate('/api/v3/convert/small-assets-history', params); + } + /** * Set up deposit account - Configure default recharge account for a certain symbol * This configuration item remains valid for a long time. That is, once a user sets a default @@ -1320,6 +1624,12 @@ export class RestClientV3 extends BaseRestClient { return this.getPrivate('/api/v3/account/eligible-loan-info', params); } + getEligibleDiscountRate( + params?: GetEligibleDiscountRateRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/account/eligible-discount-rate', params); + } + /** * Switch Account - Switch to classic account mode * Only supports parent accounts. @@ -2076,6 +2386,108 @@ export class RestClientV3 extends BaseRestClient { return this.getPrivate('/api/v3/trade/history-strategy-orders', params); } + getStrategySubOrders(params: GetStrategySubOrdersRequestV3): Promise< + APIResponse<{ + list: StrategySubOrderV3[]; + cursor?: string; + }> + > { + return this.getPrivate('/api/v3/trade/strategy-sub-orders', params); + } + + /** + * + * =====Grid======= endpoints + * + */ + + validateGridBot( + params: ValidateGridBotRequestV3, + ): Promise> { + return this.postPrivate('/api/v3/trade/grid/validate', params); + } + + createGridBot( + params: CreateGridBotRequestV3, + ): Promise> { + return this.postPrivate('/api/v3/trade/grid/create-bot', params); + } + + modifyGridBot( + params: ModifyGridBotRequestV3, + ): Promise> { + return this.postPrivate('/api/v3/trade/grid/modify-bot', params); + } + + modifyGridInterval( + params: ModifyGridIntervalRequestV3, + ): Promise> { + return this.postPrivate('/api/v3/trade/grid/modify-grid-interval', params); + } + + addGridInvestment( + params: AddGridInvestmentRequestV3, + ): Promise> { + return this.postPrivate('/api/v3/trade/grid/add-investment', params); + } + + closeGridBot( + params: CloseGridBotRequestV3, + ): Promise> { + return this.postPrivate('/api/v3/trade/grid/close-bot', params); + } + + getGridBotDetail( + params: GetGridBotDetailRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/trade/grid/bot-detail', params); + } + + getGridBotOrderDetails( + params: GetGridBotOrderDetailsRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/trade/grid/list-details', params); + } + + validateNeutralGridBot( + params: ValidateNeutralGridBotRequestV3, + ): Promise> { + return this.postPrivate('/api/v3/trade/grid/validate-neutral', params); + } + + createNeutralGridBot( + params: CreateNeutralGridBotRequestV3, + ): Promise> { + return this.postPrivate('/api/v3/trade/grid/create-neutral-bot', params); + } + + modifyNeutralGridBot( + params: ModifyNeutralGridBotRequestV3, + ): Promise> { + return this.postPrivate('/api/v3/trade/grid/modify-neutral-bot', params); + } + + modifyNeutralGridInterval( + params: ModifyNeutralGridIntervalRequestV3, + ): Promise> { + return this.postPrivate( + '/api/v3/trade/grid/modify-neutral-grid-interval', + params, + ); + } + + getNeutralGridBotDetail( + params: GetNeutralGridBotDetailRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/trade/grid/neutral-bot-detail', params); + } + + getNeutralGridBotOrderDetails( + params: GetNeutralGridBotOrderDetailsRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/trade/grid/neutral-list-details', params); + } + /** * * =====Broker======= endpoints diff --git a/src/types/request/v3/account.ts b/src/types/request/v3/account.ts index 557176f..7b568c7 100644 --- a/src/types/request/v3/account.ts +++ b/src/types/request/v3/account.ts @@ -4,6 +4,8 @@ export type AccountAdjustModeV3 = 'basic' | 'advanced' | 'delta' | 'isolated'; export interface AdjustAccountModeRequestV3 { mode: AccountAdjustModeV3; + /** Enable/disable delta-neutral mode when mode is advanced. `delta` mode is deprecated. */ + deltaSwitch?: 'yes' | 'no'; /** Sub-account UID when the master account switches mode for a sub-account */ targetUid?: string; } @@ -207,6 +209,8 @@ export interface GetFeeRateRequestV3 { | 'COIN-FUTURES' | 'USDC-FUTURES'; symbol: string; + /** RPI fee rate flag for market maker users. Default: no */ + rpiFlag?: 'yes' | 'no'; } export interface GetFundingAssetsRequestV3 { @@ -411,6 +415,36 @@ export interface GetEligibleLoanInfoRequestV3 { coin?: string; } +export interface GetEligibleDiscountRateRequestV3 { + coin?: string; +} + +export interface GetFundingFinancialRecordsRequestV3 { + coin?: string; + type?: string; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; +} + +export interface GetSmallAssetsRequestV3 { + coin?: string; +} + +export interface TradeSmallAssetsRequestV3 { + fromCoinList: string[]; + toCoin?: string; +} + +export interface GetSmallAssetsHistoryRequestV3 { + orderId?: string; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; +} + export interface GetRateLimitQuotaRequestV3 { category: 'spot' | 'futures'; uid?: string; diff --git a/src/types/request/v3/cfd.ts b/src/types/request/v3/cfd.ts new file mode 100644 index 0000000..81d080a --- /dev/null +++ b/src/types/request/v3/cfd.ts @@ -0,0 +1,103 @@ +export type CfdYesNoV3 = 'yes' | 'no'; + +export type CfdOrderTypeV3 = 'limit' | 'market'; + +export type CfdSideV3 = 'buy' | 'sell'; + +export type CfdKlineIntervalV3 = '1m' | '15m' | '1h' | '4h' | '1d'; + +export type CfdTransferAccountTypeV3 = 'funding' | 'uta'; + +export type CfdTransferDirectionV3 = 'in' | 'out'; + +export interface GetCfdTickersRequestV3 { + symbol?: string; +} + +export interface GetCfdHistoryCandlestickRequestV3 { + symbol: string; + interval: CfdKlineIntervalV3; + side?: CfdSideV3; + startTime?: string; + endTime?: string; + limit?: string; +} + +export interface PlaceCfdOrderRequestV3 { + symbol: string; + orderType: CfdOrderTypeV3; + side: CfdSideV3; + qty: string; + price?: string; + takeProfit?: string; + stopLoss?: string; +} + +export interface ModifyCfdOrderRequestV3 { + orderId: string; + price?: string; + takeProfit?: string; + stopLoss?: string; +} + +export interface CancelCfdOrderRequestV3 { + orderId: string; +} + +export interface CancelAllCfdOrdersRequestV3 { + symbol?: string; +} + +export interface CloseCfdPositionsRequestV3 { + positionId: string; + qty: string; +} + +export interface CloseAllCfdPositionsRequestV3 { + symbol?: string; +} + +export interface GetCfdUnfilledOrdersRequestV3 { + symbol?: string; + subUid?: string; +} + +export interface GetCfdOrderHistoryRequestV3 { + symbol: string; + subUid?: string; + startTime?: string; + endTime?: string; + limit?: string; +} + +export interface GetCfdCurrentPositionsRequestV3 { + symbol?: string; + subUid?: string; +} + +export interface CfdTransferRequestV3 { + coin: string; + amount: string; + accountType: CfdTransferAccountTypeV3; + direction: CfdTransferDirectionV3; +} + +export interface GetCfdTransferRecordsRequestV3 { + transferId?: string; + subUid?: string; + startTime?: string; + endTime?: string; + direction?: CfdTransferDirectionV3; + limit?: string; +} + +export interface GetCfdFinancialRecordsRequestV3 { + type?: string; + startTime?: string; + endTime?: string; + limit?: string; +} + +export interface GetCfdInstrumentsRequestV3 { + symbol?: string; +} diff --git a/src/types/request/v3/grid.ts b/src/types/request/v3/grid.ts new file mode 100644 index 0000000..82dbe99 --- /dev/null +++ b/src/types/request/v3/grid.ts @@ -0,0 +1,151 @@ +export type GridCategoryV3 = 'SPOT' | 'USDT-FUTURES' | 'USDC-FUTURES'; + +export type NeutralGridCategoryV3 = 'USDT-FUTURES' | 'USDC-FUTURES'; + +export type GridFundsSourceV3 = 'funding' | 'uta' | 'otc'; + +export type GridYesNoV3 = 'yes' | 'no'; + +export type GridOrderModeV3 = 'arithmetic' | 'geometric'; + +export type GridTypeV3 = 'long' | 'short' | 'neutral' | 'netural'; + +export type GridTriggerConditionV3 = 'instant' | 'price' | 'rsi' | 'boll'; + +export type GridTerminationConditionV3 = 'rsi' | 'boll'; + +export type GridAdjustTypeV3 = 'increase' | 'decrease'; + +export interface GridInvestmentAmountV3 { + coin: string; + amount: string; +} + +export interface GridIndicatorParamsV3 { + indicatorLength?: string; + threshold?: string; + multiplier?: string; + interval?: string; +} + +export interface GridBotIdRequestV3 { + botId: string; +} + +export interface GetGridBotDetailRequestV3 { + botId: string; +} + +export interface GetGridBotOrderDetailsRequestV3 { + category: GridCategoryV3; + botId: string; +} + +export interface CloseGridBotRequestV3 { + botId: string; +} + +export interface AddGridInvestmentRequestV3 { + category: GridCategoryV3; + botId: string; + coin?: string; + size?: string; + fundsSource: GridFundsSourceV3[]; + adjustType?: GridAdjustTypeV3; + reinvestProfit?: GridYesNoV3; +} + +export interface CreateGridBotRequestV3 { + category: GridCategoryV3; + symbol: string; + maxPrice: string; + minPrice: string; + gridNum: string; + gridOrderMode: GridOrderModeV3; + investmentAmount: GridInvestmentAmountV3[]; + fundsSource?: GridFundsSourceV3[]; + slippage?: string; + autoTransferProfits?: GridYesNoV3; + gridType?: GridTypeV3; + leverage?: string; + autoReserveMargin?: GridYesNoV3; + reservedMargin?: string; + triggerCondition?: GridTriggerConditionV3; + triggerParams?: GridIndicatorParamsV3[]; + triggerPrice?: string; + terminationCondition?: GridTerminationConditionV3; + terminationParams?: GridIndicatorParamsV3[]; + terminationSell?: GridYesNoV3; + stopLoss?: string; + takeProfit?: string; + trailingGrid?: GridYesNoV3; + movingAverageGains?: string; + stopUpwardPrice?: string; + hodlMode?: GridYesNoV3; + marketOpen?: GridYesNoV3; + lossReserve?: GridYesNoV3; +} + +export type ValidateGridBotRequestV3 = CreateGridBotRequestV3; + +export interface ModifyGridBotRequestV3 { + botId: string; + category: GridCategoryV3; + takeProfit?: string; + stopLoss?: string; + terminationCondition?: GridTerminationConditionV3; + terminationParams?: GridIndicatorParamsV3[]; + hodlMode?: GridYesNoV3; + autoTransferProfits?: GridYesNoV3; +} + +export interface ModifyGridIntervalRequestV3 { + category: GridCategoryV3; + botId: string; + maxPrice: string; + minPrice: string; + gridNum: string; +} + +export interface CreateNeutralGridBotRequestV3 { + category: NeutralGridCategoryV3; + symbol: string; + maxPrice: string; + minPrice: string; + gridNum: string; + gridOrderMode: GridOrderModeV3; + fundsSource?: GridFundsSourceV3[]; + leverage?: string; + investmentAmount: GridInvestmentAmountV3[]; + triggerPrice?: string; + stopLoss?: string; + takeProfit?: string; + autoTransferProfits?: GridYesNoV3; +} + +export type ValidateNeutralGridBotRequestV3 = CreateNeutralGridBotRequestV3; + +export interface ModifyNeutralGridBotRequestV3 { + botId: string; + category: NeutralGridCategoryV3; + takeProfit?: string; + stopLoss?: string; + autoTransferProfits?: GridYesNoV3; +} + +export interface ModifyNeutralGridIntervalRequestV3 { + category: NeutralGridCategoryV3; + botId: string; + maxPrice: string; + minPrice: string; + gridNum: string; +} + +export interface GetNeutralGridBotDetailRequestV3 { + botId: string; +} + +export interface GetNeutralGridBotOrderDetailsRequestV3 { + category: NeutralGridCategoryV3 | GridCategoryV3; + botId: string; +} diff --git a/src/types/request/v3/public.ts b/src/types/request/v3/public.ts index 31beeac..962364c 100644 --- a/src/types/request/v3/public.ts +++ b/src/types/request/v3/public.ts @@ -75,6 +75,26 @@ export interface GetHistoryFundingRateRequestV3 { export interface GetMarginLoansRequestV3 { coin: string; + /** User level. Default: vip0 */ + level?: + | 'vip0' + | 'vip1' + | 'vip2' + | 'vip3' + | 'vip4' + | 'vip5' + | 'vip6' + | 'vip7' + | 'pro1' + | 'pro2' + | 'pro3' + | 'pro4' + | 'pro5' + | 'pro6'; +} + +export interface GetSplitRecordsRequestV3 { + symbol?: string; } export interface GetOpenInterestRequestV3 { diff --git a/src/types/request/v3/reality.ts b/src/types/request/v3/reality.ts new file mode 100644 index 0000000..5450f48 --- /dev/null +++ b/src/types/request/v3/reality.ts @@ -0,0 +1,47 @@ +export interface GetRealityCompanyOverviewRequestV3 { + code: string; +} + +export interface GetRealityValuationIndicatorsRequestV3 { + code: string; +} + +export interface GetRealityEarningsForecastRequestV3 { + code: string; +} + +export interface GetRealitySuspensionResumptionInfoRequestV3 { + code: string; +} + +export interface GetRealityDividendsRequestV3 { + code: string; + limit?: string; + cursor?: string; +} + +export interface GetRealityShareCapitalChangeRequestV3 { + code: string; +} + +export interface GetRealityInnerTradesRequestV3 { + code: string; + limit?: string; + cursor?: string; +} + +export interface GetRealityExecutiveShareholdingsRequestV3 { + code: string; + limit?: string; + cursor?: string; +} + +export interface GetRealityShareholdDetailRequestV3 { + code: string; + limit?: string; + cursor?: string; +} + +export interface GetRealityStockInfoRequestV3 { + symbol?: string; +} diff --git a/src/types/request/v3/strategy.ts b/src/types/request/v3/strategy.ts index 9d090cc..849d011 100644 --- a/src/types/request/v3/strategy.ts +++ b/src/types/request/v3/strategy.ts @@ -1,4 +1,10 @@ -export type StrategyOrderTypeV3 = 'tpsl' | 'trigger'; +export type StrategyOrderTypeV3 = + | 'tpsl' + | 'trigger' + | 'oco' + | 'trailing_stop' + | 'iceberg' + | 'twap'; export type StrategyOrderStatusV3 = | 'pending' @@ -11,6 +17,45 @@ export type StrategyTriggerByV3 = 'market' | 'mark'; export type StrategyTriggerOrderTypeV3 = 'limit' | 'market'; +export interface StrategyOcoParamsV3 { + ocoLimitPrice?: string; + ocoTriggerPrice?: string; + ocoOrderType?: StrategyTriggerOrderTypeV3; + ocoOrderPrice?: string; +} + +export interface StrategyTrailingStopParamsV3 { + activationPrice?: string; + activationType?: string; + trailType?: string; + trailVariance?: string; + preOrderType?: StrategyTriggerOrderTypeV3; + preOrderPrice?: string; +} + +export interface StrategyIcebergParamsV3 { + splitMode?: string; + qtyPerOrder?: string; + splitOrderNumbers?: string; + orderPreference?: string; + executionStrategy?: string; + fixedDistanceType?: string; + distance?: string; + fixedPrice?: string; + priceLimit?: string; +} + +export interface StrategyTwapParamsV3 { + duration?: string; + interval?: string; + orderType?: StrategyTriggerOrderTypeV3; + limitOffsetType?: string; + limitOffsetPercentage?: string; + limitOffsetSpread?: string; + twapTriggerPrice?: string; + twapTerminationPrice?: string; +} + export interface PlaceStrategyOrderRequestV3 { category: | 'SPOT' @@ -39,6 +84,10 @@ export interface PlaceStrategyOrderRequestV3 { triggerPrice?: string; triggerOrderType?: StrategyTriggerOrderTypeV3; triggerOrderPrice?: string; + ocoParams?: StrategyOcoParamsV3; + trailingStopParams?: StrategyTrailingStopParamsV3; + icebergParams?: StrategyIcebergParamsV3; + twapParams?: StrategyTwapParamsV3; } export interface ModifyStrategyOrderRequestV3 { @@ -87,3 +136,10 @@ export interface GetHistoryStrategyOrdersRequestV3 { limit?: string; cursor?: string; } + +export interface GetStrategySubOrdersRequestV3 { + orderId?: string; + clientOid?: string; + limit?: string; + cursor?: string; +} diff --git a/src/types/request/v3/trade.ts b/src/types/request/v3/trade.ts index f78a34b..a617c52 100644 --- a/src/types/request/v3/trade.ts +++ b/src/types/request/v3/trade.ts @@ -3,7 +3,18 @@ export interface BatchModifyOrderRequestV3 { clientOid?: string; qty?: string; price?: string; + /** Custom request ID. Numbers within 18 digits. */ + requestId?: number; autoCancel?: 'yes' | 'no'; + /** Required from 30 Sep 2026 */ + symbol?: string; + /** Required from 30 Sep 2026 */ + category?: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; } export interface CancelAllOrdersRequestV3 { @@ -57,6 +68,8 @@ export interface GetMaxOpenAvailableRequestV3 { side: 'buy' | 'sell'; price?: string; size?: string; + /** Spot only. Default: no */ + autoBorrow?: 'yes' | 'no'; } export interface GetOrderInfoRequestV3 { @@ -126,8 +139,12 @@ export interface ModifyOrderRequestV3 { clientOid?: string; qty?: string; price?: string; + /** Custom request ID. Numbers within 18 digits. */ + requestId?: number; autoCancel?: 'yes' | 'no'; + /** Required from 30 Sep 2026 */ symbol?: string; + /** Required from 30 Sep 2026 */ category?: | 'SPOT' | 'MARGIN' @@ -193,7 +210,7 @@ export interface PlaceOrderRequestV3 { price?: string; side: 'buy' | 'sell'; orderType: 'limit' | 'market'; - timeInForce?: 'ioc' | 'fok' | 'gtc' | 'post_only'; + timeInForce?: 'ioc' | 'fok' | 'gtc' | 'post_only' | 'rpi'; posSide?: 'long' | 'short'; clientOid?: string; reduceOnly?: 'yes' | 'no'; @@ -208,6 +225,8 @@ export interface PlaceOrderRequestV3 { slOrderType?: 'limit' | 'market'; tpLimitPrice?: string; slLimitPrice?: string; + /** Spot only. Default: no */ + autoBorrow?: 'yes' | 'no'; } export interface CountdownCancelAllRequestV3 { diff --git a/src/types/response/v3/account.ts b/src/types/response/v3/account.ts index 66cd86c..3f9e2d5 100644 --- a/src/types/response/v3/account.ts +++ b/src/types/response/v3/account.ts @@ -42,6 +42,7 @@ export interface AccountSettingsV3 { accountLevel: AccountLevelV3; holdMode: string; stpMode: 'none' | 'cancel_taker' | 'cancel_maker' | 'cancel_both'; + deltaSwitch?: 'yes' | 'no'; symbolConfigList: AccountSymbolConfigV3[]; coinConfigList: AccountCoinConfigV3[]; } @@ -51,9 +52,11 @@ export interface AccountDeltaCoinPositionV3 { positionRatio: string; } -/** Delta-neutral mode metrics. Only available when accountLevel is delta. */ +/** Delta-neutral mode metrics. Available when deltaSwitch is enabled. */ export interface AccountDeltaInfoV3 { + /** Deprecated, no longer used as a hedge-eligibility criterion */ deltaEquityRatio: string; + /** Deprecated, no longer used as a hedge-eligibility criterion */ deltaThreshold: string; positionThreshold: string; list: AccountDeltaCoinPositionV3[]; @@ -87,6 +90,8 @@ export interface AccountAssetsV3 { imr: string; mgnRatio: string; positionMgnRatio: string; + positionValue?: string; + leverage?: string; assets: AccountAssetV3[]; } @@ -182,7 +187,7 @@ export interface SubAccountV3 { username: string; status: string; accountMode: string; - type: 'normal' | 'virtual' | 'custodian'; + type: 'normal' | 'virtual' | 'custodian' | 'fund_management'; note: string; createdTime: string; updatedTime: string; @@ -432,6 +437,66 @@ export interface EligibleLoanInfoV3 { platformRemaingQuota: string; } +export interface EligibleDiscountRateTierV3 { + tierStartValue: string; + discountRate: string; +} + +export interface EligibleDiscountRateV3 { + coin: string; + list: EligibleDiscountRateTierV3[]; +} + +export interface FundingFinancialRecordV3 { + id: string; + coin: string; + groupType: string; + type: string; + amount: string; + balance: string; + ts: string; +} + +export interface SmallAssetFeeDetailV3 { + feeRate?: string; + fee?: string; + feeCoin?: string; +} + +export interface SmallAssetV3 { + coin: string; + available?: string; + estimatedCoin?: string; + estimatedAmount?: string; + feeDetail?: SmallAssetFeeDetailV3; + cTime?: string; + size?: string; + usdtValue?: string; +} + +export interface SmallAssetsTradeResponseV3 { + fromCoin?: string; + toCoin?: string; + orderId?: string; + result?: string; +} + +export interface SmallAssetsHistoryItemV3 { + orderId?: string; + fromCoin?: string; + fromAmount?: string; + fromCoinPrice?: string; + fromCoinSize?: string; + toCoin?: string; + toAmount?: string; + toCoinPrice?: string; + toCoinSize?: string; + feeDetail?: SmallAssetFeeDetailV3; + status?: string; + createdTime?: string; + ts?: string; +} + export interface RateLimitQuotaItemV3 { uid: string; quota: string; diff --git a/src/types/response/v3/cfd.ts b/src/types/response/v3/cfd.ts new file mode 100644 index 0000000..90adad1 --- /dev/null +++ b/src/types/response/v3/cfd.ts @@ -0,0 +1,160 @@ +import type { CfdOrderTypeV3, CfdSideV3 } from '../../request/v3/cfd.js'; + +export interface CfdTickerV3 { + symbol: string; + openPriceChange: string; + highPrice: string; + lowPrice: string; + quoteTime: string; +} + +export interface CfdCandlestickV3 extends Array { + 0: string; + 1: string; + 2: string; + 3: string; + 4: string; +} + +export interface PlaceCfdOrderResponseV3 { + trxId: string; +} + +export interface ModifyCfdOrderResponseV3 { + orderId: string; +} + +export interface CfdUnfilledOrderV3 { + symbol: string; + orderType: CfdOrderTypeV3 | string; + side: CfdSideV3 | string; + price: string; + qty: string; + takeProfit?: string; + stopLoss?: string; + trxId: string; + orderId: string; +} + +export interface CfdHistoryOrderV3 { + symbol: string; + orderType: CfdOrderTypeV3 | string; + side: CfdSideV3 | string; + price: string; + qty: string; + cumExecQty?: string; + takeProfit?: string; + stopLoss?: string; + status: string; + trxId: string; + orderId: string; +} + +export interface CfdOrderHistoryV3 { + list: CfdHistoryOrderV3[]; +} + +export interface CfdCurrentPositionV3 { + positionId: string; + symbol: string; + orderType: CfdOrderTypeV3 | string; + side: CfdSideV3 | string; + qty: string; + openPrice: string; + takeProfit?: string; + stopLoss?: string; + interest: string; + unrealizedPnl: string; + totalProfit: string; +} + +export interface CfdFundDetailV3 { + leverage: string; + balance: string; + credit: string; + marginStopOut: string; + marginUsed: string; + marginCall: string; + marginFree: string; + marginLevel: string; + equity: string; + pnl: string; + status: string; + swap: string; + frozen: string; + currency: string; +} + +export interface CfdTransferResponseV3 { + transferId: string; +} + +export interface CfdTransferRecordV3 { + transferId: string; + coin: string; + amount: string; + direction: string; + status: string; + accountType: string; + createdTime: string; + updatedTime: string; +} + +export interface CfdTransferRecordsV3 { + list: CfdTransferRecordV3[]; + cursor?: string; +} + +export interface CfdFinancialRecordV3 { + id: string | number; + symbol: string; + side: string | number; + qty: string | number; + swap: string | number; + fee: string | number; + cashFlow: string | number; + balanceBefore: string | number; + balanceChange: string | number; + balanceAfter: string | number; + creditBefore: string | number; + creditChange: string | number; + creditAfter: string | number; + openPrice: string | number; + closePrice: string | number; + orderId: string | number; + ts: string | number; +} + +export interface CfdInstrumentV3 { + symbol: string; + onlineTime: string; + currency: string; + digits: string; + spread: string; + contractSize: string; + marginCurrency: string; + profitCurrency: string; + stopLevel: string; + enable: string; + marginPercent: string; + initialMargin: string; + marginMode: string; + maintMargin: string; + maintMarginRateBuy: string; + maintMarginRateSell: string; + initialMarginRateBuy: string; + initialMarginRateSell: string; + maxVolume: string; + minVolume: string; + stepVolume: string; + priceCurrency: string; + tickSize: string; + tickValue: string; + leverage: string; + tradeTime: string; + commissionType: string; + commissionRate: string; + symbolCategory: string; + exchangeRate: string; + marginUsdRate: string; +} diff --git a/src/types/response/v3/grid.ts b/src/types/response/v3/grid.ts new file mode 100644 index 0000000..e9ac9f9 --- /dev/null +++ b/src/types/response/v3/grid.ts @@ -0,0 +1,101 @@ +import type { GridIndicatorParamsV3 } from '../../request/v3/grid.js'; + +export interface GridBotIdResponseV3 { + botId: string; +} + +export interface GridValidateResponseV3 { + valid: string; + reason?: string; + minInvestment?: string; +} + +export interface GridBotOrderItemV3 { + orderId: string; + delegateCount: string; + delegatePrice: string; + changeRequired: number | string; +} + +export interface GridBotOrderDetailsV3 { + botId: string; + symbol: string; + buyOrderList: GridBotOrderItemV3[]; + sellOrderList: GridBotOrderItemV3[]; +} + +export interface GridBotDetailV3 { + botId: string; + symbol: string; + status: string; + totalProfit: string; + roi: string; + gridProfit: string; + gridProfitRate: string; + unpairedProfit: string; + unpairedProfitRate: string; + margin?: string; + arbitrageAPR: string; + totalAPR: string; + createdTime: string; + runningTime: string; + currentBaseBalance?: string; + currentQuoteBalance?: string; + initialBaseHoldings?: string; + initialQuoteHoldings?: string; + reservedBaseTradingFee?: string; + reservedQuoteTradingFee?: string; + gridStartPrice?: string; + gridType?: string; + maxPrice: string; + minPrice: string; + gridNum: string; + gridOrderMode: string; + baseInvestmentCoin?: string; + baseInvestmentAmount?: string; + quoteInvestmentCoin?: string; + quoteInvestmentAmount?: string; + slippage?: string; + triggerCondition?: string; + triggerParams?: GridIndicatorParamsV3[]; + triggerPrice?: string; + terminationCondition?: string; + terminationParams?: GridIndicatorParamsV3[]; + terminationSell?: string; + stopLoss?: string; + takeProfit?: string; + hodlMode?: string; + autoTransferProfits?: string; + arbitrageCount?: string; + terminationReason?: string; +} + +export interface NeutralGridBotDetailV3 { + botId: string; + symbol: string; + status: string; + totalProfit: string; + roi: string; + gridProfit: string; + gridProfitRate: string; + unpairedProfit: string; + unpairedProfitRate: string; + margin?: string; + arbitrageAPR: string; + totalAPR: string; + createdTime: string; + runningTime: string; + gridStartPrice?: string; + maxPrice: string; + minPrice: string; + gridNum: string; + gridOrderMode: string; + triggerPrice?: string; + leverage?: string; + stopLoss?: string; + takeProfit?: string; + holdPosition?: string; + oneGridMinProfit?: string; + oneGridMaxProfit?: string; + autoTransferProfits?: string; +} diff --git a/src/types/response/v3/public.ts b/src/types/response/v3/public.ts index bb55579..bd6fff0 100644 --- a/src/types/response/v3/public.ts +++ b/src/types/response/v3/public.ts @@ -1,9 +1,11 @@ export interface PublicFillV3 { execId: string; + execLinkId?: string; price: string; size: string; side: 'sell' | 'buy'; ts: string; + isRPI?: 'yes' | 'no' | string; } export interface CandlestickV3 extends Array { @@ -126,6 +128,8 @@ export interface InstrumentV3 { minOrderQty: string; maxOrderQty: string; maxMarketOrderQty: string; + /** Spot only. Max amount for a single market order. */ + maxMarketOrderAmount?: string; pricePrecision: string; quantityPrecision: string; quotePrecision: string; @@ -187,6 +191,8 @@ export interface MarketFeeGroupTierV3 { makerFeeRate: string; /** PRO1~PRO6 only. Taker fee rate in decimal form */ takerFeeRate?: string; + /** Market maker RPI maker fee rate in decimal form */ + rpiMakerFeeRate?: string; } export interface MarketFeeGroupV3 { @@ -308,6 +314,17 @@ export interface CashDividendRecordV3 { cashDividendTimestamp: string; } +export interface SplitRecordV3 { + symbol: string; + type: 'split' | 'reverse_split' | string; + status: 'pending' | 'ongoing' | 'completed' | string; + adjustmentRatio: string; + exDividendDate: string; + exDividendDateTimezone: string; + tradingHaltStartTime: string; + tradingHaltEndTime: string; +} + export interface SpotWhaleFlowV3 { volume: string; date: string; diff --git a/src/types/response/v3/reality.ts b/src/types/response/v3/reality.ts new file mode 100644 index 0000000..2c2d4b2 --- /dev/null +++ b/src/types/response/v3/reality.ts @@ -0,0 +1,165 @@ +export interface RealityCompanyOverviewV3 { + peRatio: string; + pbRatio: string; + totalShares: string; + marketCap: string; + high52Week: string; + low52Week: string; + code: string; + name: string; + ListingDate: string; + employees: string; + companyAddress: string; +} + +export interface RealityValuationIndicatorsV3 { + date: string; + pb: string; + pbEd: string; + pbPd: string; + pbMrq: string; + pe: string; + peLyr: string; + peTtmEd: string; + peTtmPd: string; + ps: string; + psLyr: string; + psTtmEd: string; + psTtmPd: string; + pcf: string; + pcfNet: string; + pcfNetTtmEd: string; + pcfNetTtmPd: string; + pcfTtmEd: string; + pcfTtmPd: string; + evEbitda: string; + equityValue: string; + grossEv: string; + netEv: string; + tmvUsd: string; + cirTmvUsd: string; + dividendYieldTtm: string; +} + +export interface RealityEarningsForecastV3 { + fiscalYear: string; + publicationDeadline: string; + isActual: boolean; + revenue: string; + ebit: string; + netIncomeParent: string; + eps: string; + bps: string; + cfps: string; + roe: string; + roa: string; + currency: string; +} + +export interface RealitySuspensionResumptionInfoV3 { + code: string; + name: string; + suspensionDate: string; + suspensionTime: string; + suspensionReason: string; + suspensionPrice: string; + resumptionDate: string; + resumptionQuoteTime: string; + resumptionTradingTime: string; +} + +export interface RealityDividendItemV3 { + type: string; + announcementDate: string; + recordDate: string; + exrightDate: string; + dividendDate: string; + dividendPerShare: string; + stockDividendPerShare: string; + splitValidDate: string; + splitNumerator: string; + splitDenominator: string; +} + +export interface RealityShareCapitalChangeV3 { + announcementDate: string; + changeDate: string; + totalShares: string; + commonShares: string; + preferredShares: string; + otherShares: string; + specialExplain: string; + changeReason: string; +} + +export interface RealityInnerTradeItemV3 { + reporterName: string; + issueOrgName: string; + endDate: string; + announcementDate: string; + innerType: string; + position: string; + securityTitle: string; + tradeDate: string; + designatedExerciseDate: string; + innerTradeType: string; + actionType: string; + tradeVolume: string; + tradePrice: string; + holdingType: string; + indirectHoldingStatement: string; + postTradeQuantity: string; +} + +export interface RealityExecutiveShareholdingItemV3 { + name: string; + holdingNum: string; + holdingRatio: string; + voteRatio: string; + period: string; + announcementDate: string; +} + +export interface RealityShareholdDetailItemV3 { + name: string; + holdingNum: string; + holdingRatio: string; +} + +export interface RealityCursorListV3 { + list: T[]; + cursor?: string; +} + +export interface RealityStockInfoV3 { + symbol: string; + code: string; + name: string; + tradingPeriod: string[]; + weekendTradable: 'yes' | 'no' | string; +} + +export interface RealityMarketSessionStateV3 { + state: string; + timeZone: string; + startTime: string; + endTime: string; +} + +export interface RealityMarketStateV3 { + market: string; + daylightType: string; + stateList: RealityMarketSessionStateV3[]; +} + +export interface RealityMarketSpecificConfigV3 { + remark: string; + startTime: string; + endTime: string; +} + +export interface RealityMarketCalendarV3 { + timeZone: string; + specificConfig: RealityMarketSpecificConfigV3[]; + regularConfig: string[]; +} diff --git a/src/types/response/v3/strategy.ts b/src/types/response/v3/strategy.ts index 915df45..6ae2725 100644 --- a/src/types/response/v3/strategy.ts +++ b/src/types/response/v3/strategy.ts @@ -1,7 +1,12 @@ import type { + StrategyIcebergParamsV3, + StrategyOcoParamsV3, StrategyOrderStatusV3, + StrategyOrderTypeV3, + StrategyTrailingStopParamsV3, StrategyTriggerByV3, StrategyTriggerOrderTypeV3, + StrategyTwapParamsV3, } from '../../request/v3/strategy.js'; export interface PlaceStrategyOrderResponseV3 { @@ -17,11 +22,12 @@ export interface ModifyStrategyOrderResponseV3 { export interface StrategyOrderV3 { orderId: string; clientOid: string; - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES' | string; symbol: string; qty: string; posSide: 'long' | 'short'; status: StrategyOrderStatusV3; + type?: StrategyOrderTypeV3 | string; triggerType?: 'takeProfit' | 'stopLoss'; tpTriggerBy?: StrategyTriggerByV3; slTriggerBy?: StrategyTriggerByV3; @@ -35,6 +41,29 @@ export interface StrategyOrderV3 { triggerPrice?: string; triggerOrderType?: StrategyTriggerOrderTypeV3; triggerOrderPrice?: string; + ocoParams?: StrategyOcoParamsV3; + trailingStopParams?: StrategyTrailingStopParamsV3; + icebergParams?: StrategyIcebergParamsV3; + twapParams?: StrategyTwapParamsV3; createdTime: string; updatedTime: string; } + +export interface StrategySubOrderV3 { + subOrderId: string; + subClientOid?: string; + orderId?: string; + clientOid?: string; + category?: string; + symbol?: string; + side?: string; + posSide?: string; + orderType?: string; + price?: string; + qty?: string; + cumExecQty?: string; + avgPrice?: string; + status?: string; + createdTime?: string; + updatedTime?: string; +} diff --git a/src/types/response/v3/trade.ts b/src/types/response/v3/trade.ts index af0c070..890ba88 100644 --- a/src/types/response/v3/trade.ts +++ b/src/types/response/v3/trade.ts @@ -40,6 +40,8 @@ export interface GetMaxOpenAvailableResponseV3 { sellOpenCost: string; maxBuyOpen: string; maxSellOpen: string; + maxBuyAvailable?: string; + maxSellAvailable?: string; } export interface FeeDetailV3 { diff --git a/src/types/websockets/ws-api-request.ts b/src/types/websockets/ws-api-request.ts index 4fb410a..0034506 100644 --- a/src/types/websockets/ws-api-request.ts +++ b/src/types/websockets/ws-api-request.ts @@ -7,7 +7,7 @@ export interface WSAPIPlaceOrderRequestV3 { price?: string; side: 'buy' | 'sell'; posSide?: 'long' | 'short'; - timeInForce?: 'gtc' | 'ioc' | 'fok' | 'post_only'; + timeInForce?: 'gtc' | 'ioc' | 'fok' | 'post_only' | 'rpi'; 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; @@ -23,4 +23,6 @@ export interface WSAPIPlaceOrderRequestV3 { slLimitPrice?: string; /** Order TTL in ms [10, 60000]. Only effective when requestTime is also set on the envelope */ receiveWindow?: string; + /** Spot only. Default: no */ + autoBorrow?: 'yes' | 'no'; } diff --git a/src/types/websockets/ws-api.ts b/src/types/websockets/ws-api.ts index c631e8b..ffafc2b 100644 --- a/src/types/websockets/ws-api.ts +++ b/src/types/websockets/ws-api.ts @@ -1,6 +1,12 @@ import { WS_KEY_MAP } from '../../util/websocket-util.js'; -import { CancelOrderRequestV3 } from '../request/v3/trade.js'; -import { CancelOrderResponseV3 } from '../response/v3/trade.js'; +import { + CancelOrderRequestV3, + ModifyOrderRequestV3, +} from '../request/v3/trade.js'; +import { + CancelOrderResponseV3, + ModifyOrderResponseV3, +} 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'; @@ -12,13 +18,17 @@ export type WSAPIOperation = | 'place-order' | 'batch-place' | 'cancel-order' - | 'batch-cancel'; + | 'batch-cancel' + | 'modify-order' + | 'batch-modify'; export const WS_API_Operations: WSAPIOperation[] = [ 'place-order', 'batch-place', 'cancel-order', 'batch-cancel', + 'modify-order', + 'batch-modify', ]; export interface WSOperationLoginParams { @@ -119,8 +129,10 @@ export interface WsAPITopicRequestParamMap { '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 + // https://www.bitget.com/docs/uta/websocket/private/Batch-Cancel-Order-Channel 'batch-cancel': CancelOrderRequestV3[]; + 'modify-order': ModifyOrderRequestV3; + 'batch-modify': ModifyOrderRequestV3[]; } /** @@ -133,6 +145,8 @@ export interface WsAPIOperationResponseMap { '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 + // https://www.bitget.com/docs/uta/websocket/private/Batch-Cancel-Order-Channel 'batch-cancel': WSAPIResponse; + 'modify-order': WSAPIResponse<[ModifyOrderResponseV3], 'modify-order'>; + 'batch-modify': WSAPIResponse; } diff --git a/src/websocket-api-client.ts b/src/websocket-api-client.ts index c43d482..0dd95a4 100644 --- a/src/websocket-api-client.ts +++ b/src/websocket-api-client.ts @@ -1,5 +1,11 @@ -import { CancelOrderRequestV3 } from './types/request/v3/trade.js'; -import { CancelOrderResponseV3 } from './types/response/v3/trade.js'; +import { + CancelOrderRequestV3, + ModifyOrderRequestV3, +} from './types/request/v3/trade.js'; +import { + CancelOrderResponseV3, + ModifyOrderResponseV3, +} 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'; @@ -150,6 +156,30 @@ export class WebsocketAPIClient { ); } + updateOrder( + category: BitgetInstTypeV3, + params: ModifyOrderRequestV3, + ): Promise> { + return this.wsClient.sendWSAPIRequest( + WS_KEY_MAP.v3Private, + 'modify-order', + category, + params, + ); + } + + batchUpdateOrders( + category: BitgetInstTypeV3, + params: ModifyOrderRequestV3[], + ): Promise> { + return this.wsClient.sendWSAPIRequest( + WS_KEY_MAP.v3Private, + 'batch-modify', + category, + params, + ); + } + /** * *