bitget-api 3.0.2 → 3.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/llms.txt CHANGED
@@ -5931,6 +5931,194 @@ export type KlineInterval =
5931
5931
  export type RestClientType =
5932
5932
  (typeof REST_CLIENT_TYPE_ENUM)[keyof typeof REST_CLIENT_TYPE_ENUM];
5933
5933
 
5934
+ ================
5935
+ File: src/broker-client.ts
5936
+ ================
5937
+ import {
5938
+ BrokerProductType,
5939
+ BrokerSubAPIKeyModifyRequest,
5940
+ BrokerSubListRequest,
5941
+ BrokerSubWithdrawalRequest,
5942
+ } from './types/request/v1/brokerV1.js';
5943
+ import { APIResponse } from './types/response/v1/shared.js';
5944
+ import BaseRestClient from './util/BaseRestClient.js';
5945
+ import { REST_CLIENT_TYPE_ENUM } from './util/requestUtils.js';
5946
+ ⋮----
5947
+ /**
5948
+ * REST API client for the V1 bitget Broker APIs. These are the previous generation of Bitget's APIs and should be considered deprecated.
5949
+ * These will be removed in a future release, once Bitget formally deprecates them.
5950
+ *
5951
+ * @deprecated use RestClientV2 instead
5952
+ */
5953
+ export class BrokerClient extends BaseRestClient
5954
+ ⋮----
5955
+ getClientType()
5956
+ ⋮----
5957
+ /**
5958
+ *
5959
+ * Sub Account Interface
5960
+ *
5961
+ */
5962
+ ⋮----
5963
+ /** Get Broker Info */
5964
+ getBrokerInfo(): Promise<APIResponse<any>>
5965
+ ⋮----
5966
+ /** Create Sub Account */
5967
+ createSubAccount(
5968
+ subName: string,
5969
+ remark?: string,
5970
+ ): Promise<APIResponse<any>>
5971
+ ⋮----
5972
+ /** Get Sub List */
5973
+ getSubAccounts(params?: BrokerSubListRequest): Promise<APIResponse<any>>
5974
+ ⋮----
5975
+ /** Modify Sub Account */
5976
+ modifySubAccount(
5977
+ subUid: string,
5978
+ perm: string,
5979
+ status: 'normal' | 'freeze' | 'del',
5980
+ ): Promise<APIResponse<any>>
5981
+ ⋮----
5982
+ /** Modify Sub Email */
5983
+ modifySubEmail(subUid: string, subEmail: string): Promise<APIResponse<any>>
5984
+ ⋮----
5985
+ /** Get Sub Email */
5986
+ getSubEmail(subUid: string): Promise<APIResponse<any>>
5987
+ ⋮----
5988
+ /** Get Sub Spot Assets */
5989
+ getSubSpotAssets(subUid: string): Promise<APIResponse<any>>
5990
+ ⋮----
5991
+ /** Get Sub Future Assets */
5992
+ getSubFutureAssets(
5993
+ subUid: string,
5994
+ productType: BrokerProductType,
5995
+ ): Promise<APIResponse<any>>
5996
+ ⋮----
5997
+ /** Get Sub Deposit Address (Only Broker) */
5998
+ getSubDepositAddress(
5999
+ subUid: string,
6000
+ coin: string,
6001
+ chain?: string,
6002
+ ): Promise<APIResponse<any>>
6003
+ ⋮----
6004
+ /** Sub Withdrawal (Only Broker) */
6005
+ subWithdrawal(params: BrokerSubWithdrawalRequest): Promise<APIResponse<any>>
6006
+ ⋮----
6007
+ /** Sub Deposit Auto Transfer (Only Broker) */
6008
+ setSubDepositAutoTransfer(
6009
+ subUid: string,
6010
+ coin: string,
6011
+ toAccountType: 'spot' | 'mix_usdt' | 'mix_usd' | 'mix_usdc',
6012
+ ): Promise<APIResponse<any>>
6013
+ ⋮----
6014
+ /**
6015
+ *
6016
+ * Sub API Interface
6017
+ *
6018
+ */
6019
+ ⋮----
6020
+ /** Create Sub ApiKey (Only Broker) */
6021
+ createSubAPIKey(
6022
+ subUid: string,
6023
+ passphrase: string,
6024
+ remark: string,
6025
+ ip: string,
6026
+ perm?: string,
6027
+ ): Promise<APIResponse<any>>
6028
+ ⋮----
6029
+ /** Get Sub ApiKey List */
6030
+ getSubAPIKeys(subUid: string): Promise<APIResponse<any>>
6031
+ ⋮----
6032
+ /** Modify Sub ApiKey (Only Broker) */
6033
+ modifySubAPIKey(
6034
+ params: BrokerSubAPIKeyModifyRequest,
6035
+ ): Promise<APIResponse<any>>
6036
+ ⋮----
6037
+ /**
6038
+ * Undocumented endpoints
6039
+ */
6040
+ ⋮----
6041
+ getAgentCommissionDetail(params?: {
6042
+ startTime?: string;
6043
+ endTime?: string;
6044
+ limit?: string;
6045
+ idLessThan?: string;
6046
+ }): Promise<APIResponse<any>>
6047
+ ⋮----
6048
+ /** Get Agent Customer List */
6049
+ getAgentCustomerList(params?: {
6050
+ startTime?: string;
6051
+ endTime?: string;
6052
+ pageNo?: string;
6053
+ pageSize?: string;
6054
+ uid?: string;
6055
+ referralCode?: string;
6056
+ }): Promise<APIResponse<any>>
6057
+ ⋮----
6058
+ /**
6059
+ * Get Agent Customer Deposit List
6060
+ * Includes both on-chain deposits and internal transfers
6061
+ * Note: Can only query data within the last 90 days
6062
+ */
6063
+ getAgentCustomerDepositList(params?: {
6064
+ startTime?: string;
6065
+ endTime?: string;
6066
+ pageNo?: string;
6067
+ pageSize?: string;
6068
+ uid?: string;
6069
+ }): Promise<APIResponse<any>>
6070
+ ⋮----
6071
+ /**
6072
+ * Get Agent Customer Trade Volume List
6073
+ * Includes trading volume for both spot and futures
6074
+ * Note: Data updates every 10 minutes and can only query last 90 days
6075
+ */
6076
+ getAgentCustomerTradeVolumeList(params?: {
6077
+ startTime?: string;
6078
+ endTime?: string;
6079
+ pageNo?: string;
6080
+ pageSize?: string;
6081
+ uid?: string;
6082
+ }): Promise<APIResponse<any>>
6083
+ ⋮----
6084
+ /**
6085
+ * Get Agent Customer Assets List
6086
+ * Returns account balances for customer accounts
6087
+ * Note: Data updates every 10 minutes
6088
+ */
6089
+ getAgentCustomerAssetsList(params?: {
6090
+ pageNo?: string;
6091
+ pageSize?: string;
6092
+ uid?: string;
6093
+ }): Promise<APIResponse<any>>
6094
+ ⋮----
6095
+ /**
6096
+ * Get Agent Direct Commissions
6097
+ * Returns commission data for direct customers
6098
+ * Note: Data updates on T+1 (UTC+8) basis and can only query last 90 days
6099
+ */
6100
+ getAgentCustomerCommissions(params?: {
6101
+ startTime?: string;
6102
+ endTime?: string;
6103
+ idLessThan?: string;
6104
+ limit?: string;
6105
+ uid?: string;
6106
+ coin?: string;
6107
+ symbol?: string;
6108
+ }): Promise<APIResponse<any>>
6109
+ ⋮----
6110
+ /**
6111
+ * Get Agent Customer KYC Result
6112
+ * Returns KYC verification status for customers
6113
+ */
6114
+ getAgentCustomerKycResult(params?: {
6115
+ startTime?: string;
6116
+ endTime?: string;
6117
+ pageNo?: string;
6118
+ pageSize?: string;
6119
+ uid?: string;
6120
+ }): Promise<APIResponse<any>>
6121
+
5934
6122
  ================
5935
6123
  File: src/futures-client.ts
5936
6124
  ================
@@ -7177,11 +7365,13 @@ File: examples/README.md
7177
7365
  # Examples
7178
7366
 
7179
7367
  These samples can be executed using `ts-node`:
7368
+
7180
7369
  ```
7181
7370
  ts-node ./examples/rest-spot-public.ts
7182
7371
  ```
7183
7372
 
7184
7373
  Samples that require authentication can be edited directly but also support environmental variables. E.g. on mac/unix:
7374
+
7185
7375
  ```
7186
7376
  API_KEY_COM='yourkeyhere' API_SECRET_COM='yoursecrethere' API_PASS_COM='yourapipasshere' ts-node examples/rest-trade-futures.ts
7187
7377
  ```
@@ -7195,7 +7385,7 @@ These newer examples are for Bitget's V3 APIs and WebSockets. They can be found
7195
7385
  Refer to the V3 / UTA API documentation for more information on the V3 APIs:
7196
7386
  https://www.bitget.com/api-doc/uta/intro
7197
7387
 
7198
- These APIs require your account to be permanently upgraded to the Unified Trading Account, if you plan on using the account-level REST APIs and WebSockets. Once upgraded, the V2 APIs are no longer available to you.
7388
+ These APIs require your account to be upgraded to the Unified Trading Account, if you plan on using the account-level REST APIs and WebSockets. Once upgraded, the V2 APIs are no longer available to you, unless you revert back to Classic Account mode.
7199
7389
 
7200
7390
  ### WebSocket API (WS API)
7201
7391
 
@@ -7210,21 +7400,19 @@ This integration looks & feels like a REST API client, but uses WebSockets, via
7210
7400
  This is the recommended approach to easily start sending orders via an automatically persisted WebSocket connection. A simple example is below, but for a more thorough example, check the example here: [./V3/ws-api-client-trade.ts](./V3/ws-api-client-trade.ts)
7211
7401
 
7212
7402
  ```typescript
7213
- import { WebsocketAPIClient } from "bitget-api";
7403
+ import { WebsocketAPIClient } from 'bitget-api';
7214
7404
  // or if you prefer require:
7215
7405
  // const { WebsocketAPIClient } = require("bitget-api");
7216
7406
 
7217
7407
  // Make an instance of the WS API Client class with your API keys
7218
- const wsClient = new WebsocketAPIClient(
7219
- {
7220
- apiKey: API_KEY,
7221
- apiSecret: API_SECRET,
7222
- apiPass: API_PASS,
7408
+ const wsClient = new WebsocketAPIClient({
7409
+ apiKey: API_KEY,
7410
+ apiSecret: API_SECRET,
7411
+ apiPass: API_PASS,
7223
7412
 
7224
- // Whether to use the demo trading wss connection
7225
- // demoTrading: true,
7226
- }
7227
- );
7413
+ // Whether to use the demo trading wss connection
7414
+ // demoTrading: true,
7415
+ });
7228
7416
 
7229
7417
  async function start() {
7230
7418
  // Start using it like a REST API. All actions are sent via a persisted WebSocket connection.
@@ -7249,7 +7437,7 @@ async function start() {
7249
7437
  }
7250
7438
  }
7251
7439
 
7252
- start().catch(e => console.error("Exception in example: ". e));
7440
+ start().catch((e) => console.error('Exception in example: '.e));
7253
7441
  ```
7254
7442
 
7255
7443
  #### ws.sendWSAPIRequest(wsKey, command, category, operation)
@@ -8075,192 +8263,149 @@ export interface WSAPIPlaceOrderRequestV3 {
8075
8263
  reduceOnly?: 'YES' | 'NO'; // Note: reduceOnly is not supported for batch place WS API. Might be supported starting late Q4 2025, but not supported yet.
8076
8264
 
8077
8265
  ================
8078
- File: src/broker-client.ts
8266
+ File: src/websocket-api-client.ts
8079
8267
  ================
8268
+ import { CancelOrderRequestV3 } from './types/request/v3/trade.js';
8269
+ import { CancelOrderResponseV3 } from './types/response/v3/trade.js';
8270
+ import { WSAPIResponse } from './types/websockets/ws-api.js';
8271
+ import { WSAPIPlaceOrderRequestV3 } from './types/websockets/ws-api-request.js';
8272
+ import { WSAPIPlaceOrderResponseV3 } from './types/websockets/ws-api-response.js';
8080
8273
  import {
8081
- BrokerProductType,
8082
- BrokerSubAPIKeyModifyRequest,
8083
- BrokerSubListRequest,
8084
- BrokerSubWithdrawalRequest,
8085
- } from './types/request/v1/brokerV1.js';
8086
- import { APIResponse } from './types/response/v1/shared.js';
8087
- import BaseRestClient from './util/BaseRestClient.js';
8088
- import { REST_CLIENT_TYPE_ENUM } from './util/requestUtils.js';
8274
+ BitgetInstTypeV3,
8275
+ WSClientConfigurableOptions,
8276
+ } from './types/websockets/ws-general.js';
8277
+ import { DefaultLogger } from './util/logger.js';
8278
+ import { WS_KEY_MAP } from './util/websocket-util.js';
8279
+ import { WebsocketClientV3 } from './websocket-client-v3.js';
8089
8280
  ⋮----
8090
8281
  /**
8091
- * REST API client for the V1 bitget Broker APIs. These are the previous generation of Bitget's APIs and should be considered deprecated.
8092
- * These will be removed in a future release, once Bitget formally deprecates them.
8093
- *
8094
- * @deprecated use RestClientV2 instead
8282
+ * Configurable options specific to only the REST-like WebsocketAPIClient
8095
8283
  */
8096
- export class BrokerClient extends BaseRestClient
8097
- ⋮----
8098
- getClientType()
8284
+ export interface WSAPIClientConfigurableOptions {
8285
+ /**
8286
+ * Default: true
8287
+ *
8288
+ * Attach default event listeners, which will console log any high level
8289
+ * events (opened/reconnecting/reconnected/etc).
8290
+ *
8291
+ * If you disable this, you should set your own event listeners
8292
+ * on the embedded WS Client `wsApiClient.getWSClient().on(....)`.
8293
+ */
8294
+ attachEventListeners: boolean;
8295
+ }
8099
8296
  ⋮----
8100
8297
  /**
8298
+ * Default: true
8101
8299
  *
8102
- * Sub Account Interface
8300
+ * Attach default event listeners, which will console log any high level
8301
+ * events (opened/reconnecting/reconnected/etc).
8103
8302
  *
8303
+ * If you disable this, you should set your own event listeners
8304
+ * on the embedded WS Client `wsApiClient.getWSClient().on(....)`.
8104
8305
  */
8105
8306
  ⋮----
8106
- /** Get Broker Info */
8107
- getBrokerInfo(): Promise<APIResponse<any>>
8108
- ⋮----
8109
- /** Create Sub Account */
8110
- createSubAccount(
8111
- subName: string,
8112
- remark?: string,
8113
- ): Promise<APIResponse<any>>
8114
- ⋮----
8115
- /** Get Sub List */
8116
- getSubAccounts(params?: BrokerSubListRequest): Promise<APIResponse<any>>
8117
- ⋮----
8118
- /** Modify Sub Account */
8119
- modifySubAccount(
8120
- subUid: string,
8121
- perm: string,
8122
- status: 'normal' | 'freeze' | 'del',
8123
- ): Promise<APIResponse<any>>
8124
- ⋮----
8125
- /** Modify Sub Email */
8126
- modifySubEmail(subUid: string, subEmail: string): Promise<APIResponse<any>>
8127
- ⋮----
8128
- /** Get Sub Email */
8129
- getSubEmail(subUid: string): Promise<APIResponse<any>>
8130
- ⋮----
8131
- /** Get Sub Spot Assets */
8132
- getSubSpotAssets(subUid: string): Promise<APIResponse<any>>
8307
+ /**
8308
+ * This is a minimal Websocket API wrapper around the WebsocketClient.
8309
+ *
8310
+ * Note: You can also directly use the sendWSAPIRequest() method to make WS API calls, but some
8311
+ * may find the below methods slightly more intuitive.
8312
+ *
8313
+ * Refer to the WS API promises example for a more detailed example on using sendWSAPIRequest() directly:
8314
+ * https://github.com/tiagosiebler/bitget-api/blob/master/examples/V3/ws-api-trade-raw.ts
8315
+ */
8316
+ export class WebsocketAPIClient
8133
8317
  ⋮----
8134
- /** Get Sub Future Assets */
8135
- getSubFutureAssets(
8136
- subUid: string,
8137
- productType: BrokerProductType,
8138
- ): Promise<APIResponse<any>>
8318
+ constructor(
8319
+ options?: WSClientConfigurableOptions &
8320
+ Partial<WSAPIClientConfigurableOptions>,
8321
+ logger?: DefaultLogger,
8322
+ )
8139
8323
  ⋮----
8140
- /** Get Sub Deposit Address (Only Broker) */
8141
- getSubDepositAddress(
8142
- subUid: string,
8143
- coin: string,
8144
- chain?: string,
8145
- ): Promise<APIResponse<any>>
8324
+ public getWSClient(): WebsocketClientV3
8146
8325
  ⋮----
8147
- /** Sub Withdrawal (Only Broker) */
8148
- subWithdrawal(params: BrokerSubWithdrawalRequest): Promise<APIResponse<any>>
8326
+ public setTimeOffsetMs(newOffset: number): void
8149
8327
  ⋮----
8150
- /** Sub Deposit Auto Transfer (Only Broker) */
8151
- setSubDepositAutoTransfer(
8152
- subUid: string,
8153
- coin: string,
8154
- toAccountType: 'spot' | 'mix_usdt' | 'mix_usd' | 'mix_usdc',
8155
- ): Promise<APIResponse<any>>
8328
+ /*
8329
+ * Bitget WebSocket API Methods
8330
+ * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel
8331
+ */
8156
8332
  ⋮----
8157
8333
  /**
8334
+ * Submit a new order
8158
8335
  *
8159
- * Sub API Interface
8336
+ * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel
8160
8337
  *
8338
+ * @returns
8161
8339
  */
8162
- ⋮----
8163
- /** Create Sub ApiKey (Only Broker) */
8164
- createSubAPIKey(
8165
- subUid: string,
8166
- passphrase: string,
8167
- remark: string,
8168
- ip: string,
8169
- perm?: string,
8170
- ): Promise<APIResponse<any>>
8171
- ⋮----
8172
- /** Get Sub ApiKey List */
8173
- getSubAPIKeys(subUid: string): Promise<APIResponse<any>>
8174
- ⋮----
8175
- /** Modify Sub ApiKey (Only Broker) */
8176
- modifySubAPIKey(
8177
- params: BrokerSubAPIKeyModifyRequest,
8178
- ): Promise<APIResponse<any>>
8340
+ submitNewOrder(
8341
+ category: BitgetInstTypeV3,
8342
+ params: WSAPIPlaceOrderRequestV3,
8343
+ ): Promise<WSAPIResponse<[WSAPIPlaceOrderResponseV3], 'place-order'>>
8179
8344
  ⋮----
8180
8345
  /**
8181
- * Undocumented endpoints
8346
+ * Submit a new order
8347
+ *
8348
+ * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel
8349
+ *
8350
+ * @returns
8182
8351
  */
8352
+ placeBatchOrders(
8353
+ category: BitgetInstTypeV3,
8354
+ params: WSAPIPlaceOrderRequestV3[],
8355
+ ): Promise<WSAPIResponse<WSAPIPlaceOrderResponseV3[], 'batch-place'>>
8183
8356
  ⋮----
8184
- getAgentCommissionDetail(params?: {
8185
- startTime?: string;
8186
- endTime?: string;
8187
- limit?: string;
8188
- idLessThan?: string;
8189
- }): Promise<APIResponse<any>>
8190
- ⋮----
8191
- /** Get Agent Customer List */
8192
- getAgentCustomerList(params?: {
8193
- startTime?: string;
8194
- endTime?: string;
8195
- pageNo?: string;
8196
- pageSize?: string;
8197
- uid?: string;
8198
- referralCode?: string;
8199
- }): Promise<APIResponse<any>>
8200
- ⋮----
8201
- /**
8202
- * Get Agent Customer Deposit List
8203
- * Includes both on-chain deposits and internal transfers
8204
- * Note: Can only query data within the last 90 days
8357
+ /*
8358
+ * Bitget WebSocket API Methods
8359
+ * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel
8205
8360
  */
8206
- getAgentCustomerDepositList(params?: {
8207
- startTime?: string;
8208
- endTime?: string;
8209
- pageNo?: string;
8210
- pageSize?: string;
8211
- uid?: string;
8212
- }): Promise<APIResponse<any>>
8213
8361
  ⋮----
8214
8362
  /**
8215
- * Get Agent Customer Trade Volume List
8216
- * Includes trading volume for both spot and futures
8217
- * Note: Data updates every 10 minutes and can only query last 90 days
8363
+ * Cancel Order
8364
+ *
8365
+ * https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel
8366
+ *
8367
+ * @returns
8218
8368
  */
8219
- getAgentCustomerTradeVolumeList(params?: {
8220
- startTime?: string;
8221
- endTime?: string;
8222
- pageNo?: string;
8223
- pageSize?: string;
8224
- uid?: string;
8225
- }): Promise<APIResponse<any>>
8369
+ cancelOrder(
8370
+ category: BitgetInstTypeV3,
8371
+ params: CancelOrderRequestV3,
8372
+ ): Promise<WSAPIResponse<[CancelOrderResponseV3], 'cancel-order'>>
8226
8373
  ⋮----
8227
8374
  /**
8228
- * Get Agent Customer Assets List
8229
- * Returns account balances for customer accounts
8230
- * Note: Data updates every 10 minutes
8375
+ * Batch Cancel Order
8376
+ *
8377
+ * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Cancel-Order-Channel
8378
+ *
8379
+ * @returns
8231
8380
  */
8232
- getAgentCustomerAssetsList(params?: {
8233
- pageNo?: string;
8234
- pageSize?: string;
8235
- uid?: string;
8236
- }): Promise<APIResponse<any>>
8381
+ cancelBatchOrders(
8382
+ category: BitgetInstTypeV3,
8383
+ params: CancelOrderRequestV3[],
8384
+ ): Promise<WSAPIResponse<CancelOrderResponseV3[], 'batch-cancel'>>
8237
8385
  ⋮----
8238
8386
  /**
8239
- * Get Agent Direct Commissions
8240
- * Returns commission data for direct customers
8241
- * Note: Data updates on T+1 (UTC+8) basis and can only query last 90 days
8387
+ *
8388
+ *
8389
+ *
8390
+ *
8391
+ *
8392
+ *
8393
+ *
8394
+ * Private methods for handling some of the convenience/automation provided by the WS API Client
8395
+ *
8396
+ *
8397
+ *
8398
+ *
8399
+ *
8400
+ *
8401
+ *
8242
8402
  */
8243
- getAgentCustomerCommissions(params?: {
8244
- startTime?: string;
8245
- endTime?: string;
8246
- idLessThan?: string;
8247
- limit?: string;
8248
- uid?: string;
8249
- coin?: string;
8250
- symbol?: string;
8251
- }): Promise<APIResponse<any>>
8403
+ ⋮----
8404
+ private setupDefaultEventListeners()
8252
8405
  ⋮----
8253
8406
  /**
8254
- * Get Agent Customer KYC Result
8255
- * Returns KYC verification status for customers
8256
- */
8257
- getAgentCustomerKycResult(params?: {
8258
- startTime?: string;
8259
- endTime?: string;
8260
- pageNo?: string;
8261
- pageSize?: string;
8262
- uid?: string;
8263
- }): Promise<APIResponse<any>>
8407
+ * General event handlers for monitoring the WebsocketClient
8408
+ */
8264
8409
 
8265
8410
  ================
8266
8411
  File: src/rest-client-v2.ts
@@ -9182,6 +9327,30 @@ getSpotDepositHistory(
9182
9327
  params: GetSpotDepositRecordRequestV2,
9183
9328
  ): Promise<APIResponse<SpotDepositRecordV2[]>>
9184
9329
  ⋮----
9330
+ /**
9331
+ * Upgrade Account - Upgrade to unified account mode
9332
+ * No account type restrictions; both parent and sub-accounts are supported.
9333
+ * This interface is only used for upgrading to the unified account mode.
9334
+ * Please note that as the account upgrade process takes approximately 1 minute,
9335
+ * the successful response you receive only indicates that the request has been received,
9336
+ * and does not mean that the account has been successfully upgraded to a unified account.
9337
+ * Please use the query upgrade status interface to confirm whether the account upgrade is successful.
9338
+ */
9339
+ upgradeToUnifiedAccount(params?: {
9340
+ subUid?: string;
9341
+ }): Promise<APIResponse<null>>
9342
+ ⋮----
9343
+ /**
9344
+ * Get Upgrade Status - Get account upgrade status
9345
+ * No account type restrictions; both parent and sub-accounts are supported.
9346
+ */
9347
+ getUnifiedAccountUpgradeStatus(params?: { subUid?: string }): Promise<
9348
+ APIResponse<{
9349
+ status: 'processProcessing' | 'successSuccess' | 'failFailed';
9350
+ }>
9351
+ > {
9352
+ return this.getPrivate('/api/v2/spot/account/upgrade-status', params);
9353
+ ⋮----
9185
9354
  /**
9186
9355
  *
9187
9356
  *
@@ -10506,236 +10675,378 @@ getLoanLiquidationRecords(
10506
10675
  ): Promise<APIResponse<EarnLoanLiquidationRecordsV2[]>>
10507
10676
 
10508
10677
  ================
10509
- File: src/websocket-api-client.ts
10678
+ File: src/websocket-client-v3.ts
10510
10679
  ================
10511
- import { CancelOrderRequestV3 } from './types/request/v3/trade.js';
10512
- import { CancelOrderResponseV3 } from './types/response/v3/trade.js';
10513
- import { WSAPIResponse } from './types/websockets/ws-api.js';
10514
- import { WSAPIPlaceOrderRequestV3 } from './types/websockets/ws-api-request.js';
10515
- import { WSAPIPlaceOrderResponseV3 } from './types/websockets/ws-api-response.js';
10680
+ import {
10681
+ WsAPIOperationResponseMap,
10682
+ WSAPIRequestBitgetV3,
10683
+ WSAPIRequestFlags,
10684
+ WsAPITopicRequestParamMap,
10685
+ WsAPIWsKeyTopicMap,
10686
+ WSOperation,
10687
+ WSOperationLoginParams,
10688
+ WsRequestOperationBitget,
10689
+ } from './types/websockets/ws-api.js';
10690
+ import { MessageEventLike } from './types/websockets/ws-events.js';
10516
10691
  import {
10517
10692
  BitgetInstTypeV3,
10518
- WSClientConfigurableOptions,
10693
+ WsKey,
10694
+ WsTopicV3,
10519
10695
  } from './types/websockets/ws-general.js';
10520
- import { DefaultLogger } from './util/logger.js';
10521
- import { WS_KEY_MAP } from './util/websocket-util.js';
10522
- import { WebsocketClientV3 } from './websocket-client-v3.js';
10523
- ⋮----
10524
- /**
10525
- * Configurable options specific to only the REST-like WebsocketAPIClient
10526
- */
10527
- export interface WSAPIClientConfigurableOptions {
10528
- /**
10529
- * Default: true
10530
- *
10531
- * Attach default event listeners, which will console log any high level
10532
- * events (opened/reconnecting/reconnected/etc).
10533
- *
10534
- * If you disable this, you should set your own event listeners
10535
- * on the embedded WS Client `wsApiClient.getWSClient().on(....)`.
10536
- */
10537
- attachEventListeners: boolean;
10538
- }
10539
- ⋮----
10540
- /**
10541
- * Default: true
10542
- *
10543
- * Attach default event listeners, which will console log any high level
10544
- * events (opened/reconnecting/reconnected/etc).
10545
- *
10546
- * If you disable this, you should set your own event listeners
10547
- * on the embedded WS Client `wsApiClient.getWSClient().on(....)`.
10548
- */
10696
+ import {
10697
+ BaseWebsocketClient,
10698
+ EmittableEvent,
10699
+ MidflightWsRequestEvent,
10700
+ } from './util/BaseWSClient.js';
10701
+ import { isWsPong } from './util/requestUtils.js';
10702
+ import { isWSAPIResponse } from './util/type-guards.js';
10703
+ import { SignAlgorithm, signMessage } from './util/webCryptoAPI.js';
10704
+ import {
10705
+ getMaxTopicsPerSubscribeEvent,
10706
+ getNormalisedTopicRequests,
10707
+ getPromiseRefForWSAPIRequest,
10708
+ getWsUrl,
10709
+ WS_AUTH_ON_CONNECT_KEYS,
10710
+ WS_KEY_MAP,
10711
+ WS_LOGGER_CATEGORY,
10712
+ WsTopicRequest,
10713
+ } from './util/websocket-util.js';
10714
+ import { WSConnectedResult } from './util/WsStore.types.js';
10549
10715
  ⋮----
10550
10716
  /**
10551
- * This is a minimal Websocket API wrapper around the WebsocketClient.
10552
- *
10553
- * Note: You can also directly use the sendWSAPIRequest() method to make WS API calls, but some
10554
- * may find the below methods slightly more intuitive.
10717
+ * WebSocket client dedicated to the unified account (V3) WebSockets.
10555
10718
  *
10556
- * Refer to the WS API promises example for a more detailed example on using sendWSAPIRequest() directly:
10557
- * https://github.com/tiagosiebler/bitget-api/blob/master/examples/V3/ws-api-trade-raw.ts
10719
+ * Your Bitget account needs to be upgraded to unified account mode, to use the account-level WebSocket topics.
10558
10720
  */
10559
- export class WebsocketAPIClient
10560
- ⋮----
10561
- constructor(
10562
- options?: WSClientConfigurableOptions &
10563
- Partial<WSAPIClientConfigurableOptions>,
10564
- logger?: DefaultLogger,
10565
- )
10566
- ⋮----
10567
- public getWSClient(): WebsocketClientV3
10568
- ⋮----
10569
- public setTimeOffsetMs(newOffset: number): void
10721
+ export class WebsocketClientV3 extends BaseWebsocketClient<
10570
10722
  ⋮----
10571
- /*
10572
- * Bitget WebSocket API Methods
10573
- * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel
10574
- */
10723
+ WsRequestOperationBitget<object> // subscribe requests have an "args" parameter with an object within
10575
10724
  ⋮----
10576
10725
  /**
10577
- * Submit a new order
10578
- *
10579
- * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel
10580
- *
10581
- * @returns
10726
+ * Request connection of all dependent (public & private) websockets, instead of waiting for automatic connection by library
10582
10727
  */
10583
- submitNewOrder(
10584
- category: BitgetInstTypeV3,
10585
- params: WSAPIPlaceOrderRequestV3,
10586
- ): Promise<WSAPIResponse<[WSAPIPlaceOrderResponseV3], 'place-order'>>
10728
+ public connectAll(): Promise<WSConnectedResult | undefined>[]
10587
10729
  ⋮----
10588
10730
  /**
10589
- * Submit a new order
10590
- *
10591
- * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel
10731
+ * Ensures the WS API connection is active and ready.
10592
10732
  *
10593
- * @returns
10733
+ * You do not need to call this, but if you call this before making any WS API requests,
10734
+ * it can accelerate the first request (by preparing the connection in advance).
10594
10735
  */
10595
- placeBatchOrders(
10596
- category: BitgetInstTypeV3,
10597
- params: WSAPIPlaceOrderRequestV3[],
10598
- ): Promise<WSAPIResponse<WSAPIPlaceOrderResponseV3[], 'batch-place'>>
10736
+ public connectWSAPI(): Promise<unknown>
10599
10737
  ⋮----
10600
- /*
10601
- * Bitget WebSocket API Methods
10602
- * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel
10603
- */
10738
+ /** This call automatically ensures the connection is active AND authenticated before resolving */
10604
10739
  ⋮----
10605
10740
  /**
10606
- * Cancel Order
10741
+ * Request subscription to one or more topics. Pass topics as either an array of strings,
10742
+ * or array of objects (if the topic has parameters).
10607
10743
  *
10608
- * https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel
10744
+ * Objects should be formatted as {topic: string, params: object, category: CategoryV5}.
10609
10745
  *
10610
- * @returns
10746
+ * - Subscriptions are automatically routed to the correct websocket connection.
10747
+ * - Authentication/connection is automatic.
10748
+ * - Resubscribe after network issues is automatic.
10749
+ *
10750
+ * Call `unsubscribe(topics)` to remove topics
10611
10751
  */
10612
- cancelOrder(
10613
- category: BitgetInstTypeV3,
10614
- params: CancelOrderRequestV3,
10615
- ): Promise<WSAPIResponse<[CancelOrderResponseV3], 'cancel-order'>>
10752
+ public subscribe<TWSPayload extends { instType?: BitgetInstTypeV3 }>(
10753
+ requests:
10754
+ | (WsTopicRequest<WsTopicV3, TWSPayload> | WsTopicV3)
10755
+ | (WsTopicRequest<WsTopicV3, TWSPayload> | WsTopicV3)[],
10756
+ wsKey: WsKey,
10757
+ ): Promise<unknown>
10616
10758
  ⋮----
10617
10759
  /**
10618
- * Batch Cancel Order
10619
- *
10620
- * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Cancel-Order-Channel
10760
+ * Unsubscribe from one or more topics. Similar to subscribe() but in reverse.
10621
10761
  *
10622
- * @returns
10762
+ * - Requests are automatically routed to the correct websocket connection.
10763
+ * - These topics will be removed from the topic cache, so they won't be subscribed to again.
10623
10764
  */
10624
- cancelBatchOrders(
10625
- category: BitgetInstTypeV3,
10626
- params: CancelOrderRequestV3[],
10627
- ): Promise<WSAPIResponse<CancelOrderResponseV3[], 'batch-cancel'>>
10765
+ public unsubscribe<TWSPayload extends { instType?: BitgetInstTypeV3 }>(
10766
+ requests:
10767
+ | (WsTopicRequest<WsTopicV3, TWSPayload> | WsTopicV3)
10768
+ | (WsTopicRequest<WsTopicV3, TWSPayload> | WsTopicV3)[],
10769
+ wsKey: WsKey,
10770
+ )
10628
10771
  ⋮----
10629
10772
  /**
10630
10773
  *
10631
10774
  *
10632
- *
10633
- *
10634
- *
10635
- *
10636
- *
10637
- * Private methods for handling some of the convenience/automation provided by the WS API Client
10638
- *
10639
- *
10640
- *
10641
- *
10642
- *
10775
+ * Internal methods required to integrate with the BaseWSClient
10643
10776
  *
10644
10777
  *
10645
10778
  */
10646
10779
  ⋮----
10647
- private setupDefaultEventListeners()
10780
+ protected sendPingEvent(wsKey: WsKey): void
10648
10781
  ⋮----
10649
- /**
10650
- * General event handlers for monitoring the WebsocketClient
10651
- */
10652
-
10653
- ================
10654
- File: src/types/response/v3/public.ts
10655
- ================
10656
- export interface PublicFillV3 {
10657
- execId: string;
10658
- price: string;
10659
- size: string;
10660
- side: 'sell' | 'buy';
10661
- ts: string;
10662
- }
10782
+ protected sendPongEvent(wsKey: WsKey): void
10663
10783
  ⋮----
10664
- export interface CandlestickV3 extends Array<string> {
10665
- 0: string; // timestamp
10666
- 1: string; // open price
10667
- 2: string; // high price
10668
- 3: string; // low price
10669
- 4: string; // close price
10670
- 5: string; // volume
10671
- 6: string; // turnover
10672
- }
10784
+ protected isWsPing(data: any): boolean
10673
10785
  ⋮----
10674
- 0: string; // timestamp
10675
- 1: string; // open price
10676
- 2: string; // high price
10677
- 3: string; // low price
10678
- 4: string; // close price
10679
- 5: string; // volume
10680
- 6: string; // turnover
10786
+ protected isWsPong(data: any): boolean
10681
10787
  ⋮----
10682
- export interface ContractOiV3 {
10683
- symbol: string;
10684
- notionalValue: string;
10685
- totalNotionalValue: string;
10686
- }
10788
+ protected isPrivateTopicRequest(
10789
+ _request: WsTopicRequest<string>,
10790
+ wsKey: WsKey,
10791
+ ): boolean
10687
10792
  ⋮----
10688
- export interface CurrentFundingRateV3 {
10689
- symbol: string;
10690
- fundingRate: string;
10691
- fundingRateInterval: string;
10692
- nextUpdate: string;
10693
- minFundingRate: string;
10694
- maxFundingRate: string;
10695
- }
10793
+ protected getPrivateWSKeys(): WsKey[]
10696
10794
  ⋮----
10697
- export interface DiscountRateTierV3 {
10698
- tierStartValue: string;
10699
- discountRate: string;
10700
- }
10795
+ protected isAuthOnConnectWsKey(wsKey: WsKey): boolean
10701
10796
  ⋮----
10702
- export interface DiscountRateV3 {
10703
- coin: string;
10704
- list: DiscountRateTierV3[];
10705
- }
10797
+ protected async getWsUrl(wsKey: WsKey): Promise<string>
10706
10798
  ⋮----
10707
- export interface HistoryFundingRateV3 {
10708
- symbol: string;
10709
- fundingRate: string;
10710
- fundingRateTimestamp: string;
10711
- }
10799
+ protected getMaxTopicsPerSubscribeEvent(wsKey: WsKey): number | null
10712
10800
  ⋮----
10713
- export interface MarginLoanV3 {
10714
- dailyInterest: string;
10715
- annualInterest: string;
10716
- limit: string;
10717
- }
10801
+ /**
10802
+ * @returns one or more correctly structured request events for performing a operations over WS. This can vary per exchange spec.
10803
+ */
10804
+ protected async getWsRequestEvents(
10805
+ operation: WSOperation,
10806
+ requests: WsTopicRequest<string, object>[],
10807
+ ): Promise<MidflightWsRequestEvent<WsRequestOperationBitget<object>>[]>
10718
10808
  ⋮----
10719
- export interface OpenInterestItemV3 {
10720
- symbol: string;
10721
- openInterest: string;
10722
- }
10809
+ // Previously used to track topics in a request. Keeping this for subscribe/unsubscribe requests, no need for incremental values
10723
10810
  ⋮----
10724
- export interface OpenInterestV3 {
10725
- list: OpenInterestItemV3[];
10726
- ts: string;
10727
- }
10811
+ /**
10812
+ {
10813
+ "op":"subscribe",
10814
+ "args":[
10815
+ {
10816
+ "instType":"spot",
10817
+ "topic":"ticker",
10818
+ "symbol":"BTCUSDT"
10819
+ },
10820
+ {
10821
+ "instType":"spot",
10822
+ "topic":"candle5m",
10823
+ "symbol":"BTCUSDT"
10824
+ }
10825
+ ]
10826
+ }
10827
+ */
10728
10828
  ⋮----
10729
- export interface PositionTierV3 {
10730
- tier: string;
10731
- minTierValue: string;
10732
- maxTierValue: string;
10733
- leverage: string;
10734
- mmr: string;
10735
- }
10829
+ // const request = {
10830
+ // topic: 'ticker',
10831
+ // payload: { instType: 'spot', symbol: 'BTCUSDT' },
10832
+ // };
10833
+ // becomes:
10834
+ // const request = {
10835
+ // topic: 'ticker',
10836
+ // instType: 'spot',
10837
+ // symbol: 'BTCUSDT',
10838
+ // };
10736
10839
  ⋮----
10737
- export interface RiskReserveRecordV3 {
10738
- type: 'in' | 'out';
10840
+ private async getWsAuthSignature(
10841
+ wsKey: WsKey,
10842
+ ): Promise<
10843
+ ⋮----
10844
+ private async signMessage(
10845
+ paramsStr: string,
10846
+ secret: string,
10847
+ method: 'hex' | 'base64',
10848
+ algorithm: SignAlgorithm,
10849
+ ): Promise<string>
10850
+ ⋮----
10851
+ protected async getWsAuthRequestEvent(
10852
+ wsKey: WsKey,
10853
+ ): Promise<WsRequestOperationBitget<WSOperationLoginParams>>
10854
+ ⋮----
10855
+ /**
10856
+ * Abstraction called to sort ws events into emittable event types (response to a request, data update, etc)
10857
+ */
10858
+ protected resolveEmittableEvents(
10859
+ wsKey: WsKey,
10860
+ event: MessageEventLike,
10861
+ ): EmittableEvent[]
10862
+ ⋮----
10863
+ /**
10864
+ * WS API response handling
10865
+ */
10866
+ ⋮----
10867
+ // const eg1 = {
10868
+ // event: 'error',
10869
+ // id: '1',
10870
+ // code: '43012',
10871
+ // msg: 'Insufficient balance',
10872
+ // };
10873
+ ⋮----
10874
+ // WS API Success
10875
+ ⋮----
10876
+ /**
10877
+ * V3 event handling for consumers - behaves the same as V2
10878
+ */
10879
+ ⋮----
10880
+ // v2 authentication event
10881
+ ⋮----
10882
+ // messageType: typeof msg,
10883
+ // messageString: JSON.stringify(msg),
10884
+ ⋮----
10885
+ // messageType: typeof msg,
10886
+ // messageString: JSON.stringify(msg),
10887
+ ⋮----
10888
+ // fallback emit anyway
10889
+ ⋮----
10890
+ /**
10891
+ * V3/UTA supports order placement via WebSockets. This is the WS API:
10892
+ * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel
10893
+ *
10894
+ * @returns a promise that resolves/rejects when a matching response arrives
10895
+ */
10896
+ async sendWSAPIRequest<
10897
+ TWSKey extends keyof WsAPIWsKeyTopicMap,
10898
+ TWSOperation extends WsAPIWsKeyTopicMap[TWSKey],
10899
+ TWSParams extends WsAPITopicRequestParamMap[TWSOperation],
10900
+ TWSAPIResponse extends
10901
+ WsAPIOperationResponseMap[TWSOperation] = WsAPIOperationResponseMap[TWSOperation],
10902
+ >(
10903
+ wsKey: WsKey,
10904
+ operation: TWSOperation,
10905
+ category: BitgetInstTypeV3,
10906
+ params: TWSParams & { signRequest?: boolean },
10907
+ requestFlags?: WSAPIRequestFlags,
10908
+ ): Promise<TWSAPIResponse>
10909
+ ⋮----
10910
+ // this.logger.trace('sendWSAPIRequest(): assertIsAuthenticated(${wsKey})...');
10911
+ ⋮----
10912
+ // this.logger.trace('sendWSAPIRequest(): assertIsAuthenticated(${wsKey}) ok');
10913
+ ⋮----
10914
+ // Ensure "args" is always wrapped as array
10915
+ ⋮----
10916
+ // Store deferred promise, resolved within the "resolveEmittableEvents" method while parsing incoming events
10917
+ ⋮----
10918
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10919
+ ⋮----
10920
+ // Enrich returned promise with request context for easier debugging
10921
+ ⋮----
10922
+ // throw e;
10923
+ ⋮----
10924
+ // Send event
10925
+ ⋮----
10926
+ // Return deferred promise, so caller can await this call
10927
+
10928
+ ================
10929
+ File: tsconfig.json
10930
+ ================
10931
+ {
10932
+ "compilerOptions": {
10933
+ "allowSyntheticDefaultImports": true,
10934
+ "baseUrl": ".",
10935
+ "noEmitOnError": true,
10936
+ "declaration": true,
10937
+ "esModuleInterop": true,
10938
+ "forceConsistentCasingInFileNames": false,
10939
+ "inlineSourceMap": false,
10940
+ "lib": ["esnext", "DOM"],
10941
+ "listEmittedFiles": false,
10942
+ "listFiles": false,
10943
+ "moduleResolution": "node",
10944
+ "noFallthroughCasesInSwitch": true,
10945
+ "noImplicitAny": true,
10946
+ "noUnusedParameters": true,
10947
+ "pretty": true,
10948
+ "removeComments": false,
10949
+ "resolveJsonModule": true,
10950
+ "skipLibCheck": false,
10951
+ "sourceMap": true,
10952
+ "strict": true,
10953
+ "strictNullChecks": true,
10954
+ "types": ["node", "jest"],
10955
+ "module": "commonjs",
10956
+ "outDir": "dist/cjs",
10957
+ "target": "esnext"
10958
+ },
10959
+ "compileOnSave": true,
10960
+ "exclude": ["node_modules", "dist"],
10961
+ "include": ["src/**/*.*", "test/**/*.*", ".eslintrc.cjs"]
10962
+ }
10963
+
10964
+ ================
10965
+ File: src/types/response/v3/public.ts
10966
+ ================
10967
+ export interface PublicFillV3 {
10968
+ execId: string;
10969
+ price: string;
10970
+ size: string;
10971
+ side: 'sell' | 'buy';
10972
+ ts: string;
10973
+ }
10974
+ ⋮----
10975
+ export interface CandlestickV3 extends Array<string> {
10976
+ 0: string; // timestamp
10977
+ 1: string; // open price
10978
+ 2: string; // high price
10979
+ 3: string; // low price
10980
+ 4: string; // close price
10981
+ 5: string; // volume
10982
+ 6: string; // turnover
10983
+ }
10984
+ ⋮----
10985
+ 0: string; // timestamp
10986
+ 1: string; // open price
10987
+ 2: string; // high price
10988
+ 3: string; // low price
10989
+ 4: string; // close price
10990
+ 5: string; // volume
10991
+ 6: string; // turnover
10992
+ ⋮----
10993
+ export interface ContractOiV3 {
10994
+ symbol: string;
10995
+ notionalValue: string;
10996
+ totalNotionalValue: string;
10997
+ }
10998
+ ⋮----
10999
+ export interface CurrentFundingRateV3 {
11000
+ symbol: string;
11001
+ fundingRate: string;
11002
+ fundingRateInterval: string;
11003
+ nextUpdate: string;
11004
+ minFundingRate: string;
11005
+ maxFundingRate: string;
11006
+ }
11007
+ ⋮----
11008
+ export interface DiscountRateTierV3 {
11009
+ tierStartValue: string;
11010
+ discountRate: string;
11011
+ }
11012
+ ⋮----
11013
+ export interface DiscountRateV3 {
11014
+ coin: string;
11015
+ list: DiscountRateTierV3[];
11016
+ }
11017
+ ⋮----
11018
+ export interface HistoryFundingRateV3 {
11019
+ symbol: string;
11020
+ fundingRate: string;
11021
+ fundingRateTimestamp: string;
11022
+ }
11023
+ ⋮----
11024
+ export interface MarginLoanV3 {
11025
+ dailyInterest: string;
11026
+ annualInterest: string;
11027
+ limit: string;
11028
+ }
11029
+ ⋮----
11030
+ export interface OpenInterestItemV3 {
11031
+ symbol: string;
11032
+ openInterest: string;
11033
+ }
11034
+ ⋮----
11035
+ export interface OpenInterestV3 {
11036
+ list: OpenInterestItemV3[];
11037
+ ts: string;
11038
+ }
11039
+ ⋮----
11040
+ export interface PositionTierV3 {
11041
+ tier: string;
11042
+ minTierValue: string;
11043
+ maxTierValue: string;
11044
+ leverage: string;
11045
+ mmr: string;
11046
+ }
11047
+ ⋮----
11048
+ export interface RiskReserveRecordV3 {
11049
+ balance: string;
10739
11050
  amount: string;
10740
11051
  ts: string;
10741
11052
  }
@@ -10838,6 +11149,17 @@ export interface TickerV3 {
10838
11149
  }
10839
11150
  ⋮----
10840
11151
  // Futures specific fields
11152
+ ⋮----
11153
+ export interface ProofOfReservesV3 {
11154
+ merkleRootHash: string;
11155
+ totalReserveRatio: string;
11156
+ list: {
11157
+ coin: string;
11158
+ userAssets: string;
11159
+ platformAssets: string;
11160
+ reserveRatio: string;
11161
+ }[];
11162
+ }
10841
11163
 
10842
11164
  ================
10843
11165
  File: src/types/response/v3/trade.ts
@@ -11021,321 +11343,41 @@ export interface CurrentPositionV3 {
11021
11343
  curRealisedPnl: string;
11022
11344
  avgPrice: string;
11023
11345
  positionStatus: string;
11024
- unrealisedPnl: string;
11025
- liquidationPrice: string;
11026
- mmr: string;
11027
- profitRate: string;
11028
- markPrice: string;
11029
- breakEvenPrice: string;
11030
- totalFunding: string;
11031
- openFeeTotal: string;
11032
- closeFeeTotal: string;
11033
- createdTime: string;
11034
- updatedTime: string;
11035
- }
11036
- ⋮----
11037
- export interface ModifyOrderResponseV3 {
11038
- orderId: string;
11039
- clientOid: string;
11040
- }
11041
- ⋮----
11042
- export interface PlaceBatchOrdersResponseV3 {
11043
- orderId: string;
11044
- clientOid: string;
11045
- code?: string;
11046
- msg?: string;
11047
- }
11048
- ⋮----
11049
- export interface PlaceOrderResponseV3 {
11050
- orderId: string;
11051
- clientOid: string;
11052
- }
11053
-
11054
- ================
11055
- File: src/websocket-client-v3.ts
11056
- ================
11057
- import {
11058
- WsAPIOperationResponseMap,
11059
- WSAPIRequestBitgetV3,
11060
- WSAPIRequestFlags,
11061
- WsAPITopicRequestParamMap,
11062
- WsAPIWsKeyTopicMap,
11063
- WSOperation,
11064
- WSOperationLoginParams,
11065
- WsRequestOperationBitget,
11066
- } from './types/websockets/ws-api.js';
11067
- import { MessageEventLike } from './types/websockets/ws-events.js';
11068
- import {
11069
- BitgetInstTypeV3,
11070
- WsKey,
11071
- WsTopicV3,
11072
- } from './types/websockets/ws-general.js';
11073
- import {
11074
- BaseWebsocketClient,
11075
- EmittableEvent,
11076
- MidflightWsRequestEvent,
11077
- } from './util/BaseWSClient.js';
11078
- import { isWsPong } from './util/requestUtils.js';
11079
- import { isWSAPIResponse } from './util/type-guards.js';
11080
- import { SignAlgorithm, signMessage } from './util/webCryptoAPI.js';
11081
- import {
11082
- getMaxTopicsPerSubscribeEvent,
11083
- getNormalisedTopicRequests,
11084
- getPromiseRefForWSAPIRequest,
11085
- getWsUrl,
11086
- WS_AUTH_ON_CONNECT_KEYS,
11087
- WS_KEY_MAP,
11088
- WS_LOGGER_CATEGORY,
11089
- WsTopicRequest,
11090
- } from './util/websocket-util.js';
11091
- import { WSConnectedResult } from './util/WsStore.types.js';
11092
- ⋮----
11093
- /**
11094
- * WebSocket client dedicated to the unified account (V3) WebSockets.
11095
- *
11096
- * Your Bitget account needs to be upgraded to unified account mode, to use the account-level WebSocket topics.
11097
- */
11098
- export class WebsocketClientV3 extends BaseWebsocketClient<
11099
- ⋮----
11100
- WsRequestOperationBitget<object> // subscribe requests have an "args" parameter with an object within
11101
- ⋮----
11102
- /**
11103
- * Request connection of all dependent (public & private) websockets, instead of waiting for automatic connection by library
11104
- */
11105
- public connectAll(): Promise<WSConnectedResult | undefined>[]
11106
- ⋮----
11107
- /**
11108
- * Ensures the WS API connection is active and ready.
11109
- *
11110
- * You do not need to call this, but if you call this before making any WS API requests,
11111
- * it can accelerate the first request (by preparing the connection in advance).
11112
- */
11113
- public connectWSAPI(): Promise<unknown>
11114
- ⋮----
11115
- /** This call automatically ensures the connection is active AND authenticated before resolving */
11116
- ⋮----
11117
- /**
11118
- * Request subscription to one or more topics. Pass topics as either an array of strings,
11119
- * or array of objects (if the topic has parameters).
11120
- *
11121
- * Objects should be formatted as {topic: string, params: object, category: CategoryV5}.
11122
- *
11123
- * - Subscriptions are automatically routed to the correct websocket connection.
11124
- * - Authentication/connection is automatic.
11125
- * - Resubscribe after network issues is automatic.
11126
- *
11127
- * Call `unsubscribe(topics)` to remove topics
11128
- */
11129
- public subscribe<TWSPayload extends { instType?: BitgetInstTypeV3 }>(
11130
- requests:
11131
- | (WsTopicRequest<WsTopicV3, TWSPayload> | WsTopicV3)
11132
- | (WsTopicRequest<WsTopicV3, TWSPayload> | WsTopicV3)[],
11133
- wsKey: WsKey,
11134
- ): Promise<unknown>
11135
- ⋮----
11136
- /**
11137
- * Unsubscribe from one or more topics. Similar to subscribe() but in reverse.
11138
- *
11139
- * - Requests are automatically routed to the correct websocket connection.
11140
- * - These topics will be removed from the topic cache, so they won't be subscribed to again.
11141
- */
11142
- public unsubscribe<TWSPayload extends { instType?: BitgetInstTypeV3 }>(
11143
- requests:
11144
- | (WsTopicRequest<WsTopicV3, TWSPayload> | WsTopicV3)
11145
- | (WsTopicRequest<WsTopicV3, TWSPayload> | WsTopicV3)[],
11146
- wsKey: WsKey,
11147
- )
11148
- ⋮----
11149
- /**
11150
- *
11151
- *
11152
- * Internal methods required to integrate with the BaseWSClient
11153
- *
11154
- *
11155
- */
11156
- ⋮----
11157
- protected sendPingEvent(wsKey: WsKey): void
11158
- ⋮----
11159
- protected sendPongEvent(wsKey: WsKey): void
11160
- ⋮----
11161
- protected isWsPing(data: any): boolean
11162
- ⋮----
11163
- protected isWsPong(data: any): boolean
11164
- ⋮----
11165
- protected isPrivateTopicRequest(
11166
- _request: WsTopicRequest<string>,
11167
- wsKey: WsKey,
11168
- ): boolean
11169
- ⋮----
11170
- protected getPrivateWSKeys(): WsKey[]
11171
- ⋮----
11172
- protected isAuthOnConnectWsKey(wsKey: WsKey): boolean
11173
- ⋮----
11174
- protected async getWsUrl(wsKey: WsKey): Promise<string>
11175
- ⋮----
11176
- protected getMaxTopicsPerSubscribeEvent(wsKey: WsKey): number | null
11177
- ⋮----
11178
- /**
11179
- * @returns one or more correctly structured request events for performing a operations over WS. This can vary per exchange spec.
11180
- */
11181
- protected async getWsRequestEvents(
11182
- operation: WSOperation,
11183
- requests: WsTopicRequest<string, object>[],
11184
- ): Promise<MidflightWsRequestEvent<WsRequestOperationBitget<object>>[]>
11185
- ⋮----
11186
- // Previously used to track topics in a request. Keeping this for subscribe/unsubscribe requests, no need for incremental values
11187
- ⋮----
11188
- /**
11189
- {
11190
- "op":"subscribe",
11191
- "args":[
11192
- {
11193
- "instType":"spot",
11194
- "topic":"ticker",
11195
- "symbol":"BTCUSDT"
11196
- },
11197
- {
11198
- "instType":"spot",
11199
- "topic":"candle5m",
11200
- "symbol":"BTCUSDT"
11201
- }
11202
- ]
11203
- }
11204
- */
11205
- ⋮----
11206
- // const request = {
11207
- // topic: 'ticker',
11208
- // payload: { instType: 'spot', symbol: 'BTCUSDT' },
11209
- // };
11210
- // becomes:
11211
- // const request = {
11212
- // topic: 'ticker',
11213
- // instType: 'spot',
11214
- // symbol: 'BTCUSDT',
11215
- // };
11216
- ⋮----
11217
- private async getWsAuthSignature(
11218
- wsKey: WsKey,
11219
- ): Promise<
11220
- ⋮----
11221
- private async signMessage(
11222
- paramsStr: string,
11223
- secret: string,
11224
- method: 'hex' | 'base64',
11225
- algorithm: SignAlgorithm,
11226
- ): Promise<string>
11227
- ⋮----
11228
- protected async getWsAuthRequestEvent(
11229
- wsKey: WsKey,
11230
- ): Promise<WsRequestOperationBitget<WSOperationLoginParams>>
11231
- ⋮----
11232
- /**
11233
- * Abstraction called to sort ws events into emittable event types (response to a request, data update, etc)
11234
- */
11235
- protected resolveEmittableEvents(
11236
- wsKey: WsKey,
11237
- event: MessageEventLike,
11238
- ): EmittableEvent[]
11239
- ⋮----
11240
- /**
11241
- * WS API response handling
11242
- */
11243
- ⋮----
11244
- // const eg1 = {
11245
- // event: 'error',
11246
- // id: '1',
11247
- // code: '43012',
11248
- // msg: 'Insufficient balance',
11249
- // };
11250
- ⋮----
11251
- // WS API Success
11252
- ⋮----
11253
- /**
11254
- * V3 event handling for consumers - behaves the same as V2
11255
- */
11256
- ⋮----
11257
- // v2 authentication event
11258
- ⋮----
11259
- // messageType: typeof msg,
11260
- // messageString: JSON.stringify(msg),
11261
- ⋮----
11262
- // messageType: typeof msg,
11263
- // messageString: JSON.stringify(msg),
11264
- ⋮----
11265
- // fallback emit anyway
11266
- ⋮----
11267
- /**
11268
- * V3/UTA supports order placement via WebSockets. This is the WS API:
11269
- * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel
11270
- *
11271
- * @returns a promise that resolves/rejects when a matching response arrives
11272
- */
11273
- async sendWSAPIRequest<
11274
- TWSKey extends keyof WsAPIWsKeyTopicMap,
11275
- TWSOperation extends WsAPIWsKeyTopicMap[TWSKey],
11276
- TWSParams extends WsAPITopicRequestParamMap[TWSOperation],
11277
- TWSAPIResponse extends
11278
- WsAPIOperationResponseMap[TWSOperation] = WsAPIOperationResponseMap[TWSOperation],
11279
- >(
11280
- wsKey: WsKey,
11281
- operation: TWSOperation,
11282
- category: BitgetInstTypeV3,
11283
- params: TWSParams & { signRequest?: boolean },
11284
- requestFlags?: WSAPIRequestFlags,
11285
- ): Promise<TWSAPIResponse>
11286
- ⋮----
11287
- // this.logger.trace('sendWSAPIRequest(): assertIsAuthenticated(${wsKey})...');
11288
- ⋮----
11289
- // this.logger.trace('sendWSAPIRequest(): assertIsAuthenticated(${wsKey}) ok');
11290
- ⋮----
11291
- // Ensure "args" is always wrapped as array
11292
- ⋮----
11293
- // Store deferred promise, resolved within the "resolveEmittableEvents" method while parsing incoming events
11294
- ⋮----
11295
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
11296
- ⋮----
11297
- // Enrich returned promise with request context for easier debugging
11298
- ⋮----
11299
- // throw e;
11300
- ⋮----
11301
- // Send event
11302
- ⋮----
11303
- // Return deferred promise, so caller can await this call
11304
-
11305
- ================
11306
- File: tsconfig.json
11307
- ================
11308
- {
11309
- "compilerOptions": {
11310
- "allowSyntheticDefaultImports": true,
11311
- "baseUrl": ".",
11312
- "noEmitOnError": true,
11313
- "declaration": true,
11314
- "esModuleInterop": true,
11315
- "forceConsistentCasingInFileNames": false,
11316
- "inlineSourceMap": false,
11317
- "lib": ["esnext", "DOM"],
11318
- "listEmittedFiles": false,
11319
- "listFiles": false,
11320
- "moduleResolution": "node",
11321
- "noFallthroughCasesInSwitch": true,
11322
- "noImplicitAny": true,
11323
- "noUnusedParameters": true,
11324
- "pretty": true,
11325
- "removeComments": false,
11326
- "resolveJsonModule": true,
11327
- "skipLibCheck": false,
11328
- "sourceMap": true,
11329
- "strict": true,
11330
- "strictNullChecks": true,
11331
- "types": ["node", "jest"],
11332
- "module": "commonjs",
11333
- "outDir": "dist/cjs",
11334
- "target": "esnext"
11335
- },
11336
- "compileOnSave": true,
11337
- "exclude": ["node_modules", "dist"],
11338
- "include": ["src/**/*.*", "test/**/*.*", ".eslintrc.cjs"]
11346
+ unrealisedPnl: string;
11347
+ liquidationPrice: string;
11348
+ mmr: string;
11349
+ profitRate: string;
11350
+ markPrice: string;
11351
+ breakEvenPrice: string;
11352
+ totalFunding: string;
11353
+ openFeeTotal: string;
11354
+ closeFeeTotal: string;
11355
+ createdTime: string;
11356
+ updatedTime: string;
11357
+ }
11358
+ ⋮----
11359
+ export interface ModifyOrderResponseV3 {
11360
+ orderId: string;
11361
+ clientOid: string;
11362
+ }
11363
+ ⋮----
11364
+ export interface PlaceBatchOrdersResponseV3 {
11365
+ orderId: string;
11366
+ clientOid: string;
11367
+ code?: string;
11368
+ msg?: string;
11369
+ }
11370
+ ⋮----
11371
+ export interface PlaceOrderResponseV3 {
11372
+ orderId: string;
11373
+ clientOid: string;
11374
+ }
11375
+ ⋮----
11376
+ export interface PositionAdlRankV3 {
11377
+ symbol: string;
11378
+ marginCoin: string;
11379
+ adlRank: string;
11380
+ holdSide: 'long' | 'short';
11339
11381
  }
11340
11382
 
11341
11383
  ================
@@ -11593,6 +11635,11 @@ export interface GetWithdrawRecordsRequestV3 {
11593
11635
  limit?: string;
11594
11636
  cursor?: string;
11595
11637
  }
11638
+ ⋮----
11639
+ export interface SetDepositAccountRequestV3 {
11640
+ coin: string;
11641
+ accountType: 'funding' | 'unified' | 'otc';
11642
+ }
11596
11643
 
11597
11644
  ================
11598
11645
  File: src/types/response/v3/account.ts
@@ -11826,6 +11873,10 @@ export interface WithdrawRecordV3 {
11826
11873
  createdTime: string;
11827
11874
  updatedTime: string;
11828
11875
  }
11876
+ ⋮----
11877
+ export interface SwitchStatusResponseV3 {
11878
+ status: 'processProcessing' | 'successSuccess' | 'failFailed';
11879
+ }
11829
11880
 
11830
11881
  ================
11831
11882
  File: .eslintrc.cjs
@@ -12508,108 +12559,6 @@ public unsubscribeTopic(
12508
12559
  instId: string = 'default',
12509
12560
  )
12510
12561
 
12511
- ================
12512
- File: package.json
12513
- ================
12514
- {
12515
- "name": "bitget-api",
12516
- "version": "3.0.2",
12517
- "description": "Complete Node.js & JavaScript SDK for Bitget V1-V3 REST APIs & WebSockets, with TypeScript & end-to-end tests.",
12518
- "scripts": {
12519
- "test": "jest",
12520
- "test:watch": "jest --watch",
12521
- "test:public": "jest --testPathIgnorePatterns='.*private.*'",
12522
- "test:private": "jest --testPathPattern='.*private.*'",
12523
- "clean": "rm -rf lib dist",
12524
- "build": "npm run clean && tsc -p tsconfig.esm.json && tsc -p tsconfig.cjs.json && bash ./postBuild.sh",
12525
- "build:clean": "npm run clean && npm run build",
12526
- "build:watch": "npm run clean && tsc --watch",
12527
- "pack": "webpack --config webpack/webpack.config.js",
12528
- "lint": "eslint src",
12529
- "prepublish": "npm run build:clean",
12530
- "betapublish": "npm publish --tag beta"
12531
- },
12532
- "main": "dist/cjs/index.js",
12533
- "module": "dist/mjs/index.js",
12534
- "types": "dist/mjs/index.d.ts",
12535
- "exports": {
12536
- ".": {
12537
- "import": "./dist/mjs/index.js",
12538
- "require": "./dist/cjs/index.js",
12539
- "types": "./dist/mjs/index.d.ts"
12540
- }
12541
- },
12542
- "files": [
12543
- "dist/*",
12544
- "llms.txt"
12545
- ],
12546
- "type": "module",
12547
- "author": "Tiago Siebler (https://github.com/tiagosiebler)",
12548
- "contributors": [],
12549
- "dependencies": {
12550
- "axios": "^1.10.0",
12551
- "isomorphic-ws": "^5.0.0",
12552
- "ws": "^8.9.0"
12553
- },
12554
- "devDependencies": {
12555
- "@types/jest": "^29.0.3",
12556
- "@types/node": "^22.10.2",
12557
- "@types/ws": "^8.18.1",
12558
- "@typescript-eslint/eslint-plugin": "^8.18.0",
12559
- "@typescript-eslint/parser": "^8.18.0",
12560
- "eslint": "^8.24.0",
12561
- "eslint-config-prettier": "^9.1.0",
12562
- "eslint-plugin-prettier": "^5.2.1",
12563
- "eslint-plugin-require-extensions": "^0.1.3",
12564
- "eslint-plugin-simple-import-sort": "^12.1.1",
12565
- "jest": "^29.7.0",
12566
- "ts-jest": "^29.4.0",
12567
- "ts-node": "^10.9.2",
12568
- "typescript": "^5.7.3"
12569
- },
12570
- "optionalDependencies": {
12571
- "source-map-loader": "^4.0.0",
12572
- "ts-loader": "^9.4.1",
12573
- "webpack": "^5.74.0",
12574
- "webpack-cli": "^4.10.0"
12575
- },
12576
- "keywords": [
12577
- "bitget",
12578
- "bitget api",
12579
- "bitget nodejs",
12580
- "bitget javascript",
12581
- "bitget typescript",
12582
- "bitget sdk",
12583
- "bitget v3 api",
12584
- "bitget UTA api",
12585
- "api",
12586
- "websocket",
12587
- "rest",
12588
- "rest api",
12589
- "usdt",
12590
- "trading bots",
12591
- "nodejs",
12592
- "node",
12593
- "trading",
12594
- "cryptocurrency",
12595
- "bitcoin",
12596
- "best"
12597
- ],
12598
- "funding": {
12599
- "type": "individual",
12600
- "url": "https://github.com/sponsors/tiagosiebler"
12601
- },
12602
- "license": "MIT",
12603
- "repository": {
12604
- "type": "git",
12605
- "url": "https://github.com/tiagosiebler/bitget-api"
12606
- },
12607
- "bugs": {
12608
- "url": "https://github.com/tiagosiebler/bitget-api/issues"
12609
- },
12610
- "homepage": "https://github.com/tiagosiebler/bitget-api#readme"
12611
- }
12612
-
12613
12562
  ================
12614
12563
  File: src/websocket-client-v2.ts
12615
12564
  ================
@@ -12826,6 +12775,108 @@ protected resolveEmittableEvents(
12826
12775
  */
12827
12776
  async sendWSAPIRequest(): Promise<unknown>
12828
12777
 
12778
+ ================
12779
+ File: package.json
12780
+ ================
12781
+ {
12782
+ "name": "bitget-api",
12783
+ "version": "3.0.3",
12784
+ "description": "Complete Node.js & JavaScript SDK for Bitget V1-V3 REST APIs & WebSockets, with TypeScript & end-to-end tests.",
12785
+ "scripts": {
12786
+ "test": "jest",
12787
+ "test:watch": "jest --watch",
12788
+ "test:public": "jest --testPathIgnorePatterns='.*private.*'",
12789
+ "test:private": "jest --testPathPattern='.*private.*'",
12790
+ "clean": "rm -rf lib dist",
12791
+ "build": "npm run clean && tsc -p tsconfig.esm.json && tsc -p tsconfig.cjs.json && bash ./postBuild.sh",
12792
+ "build:clean": "npm run clean && npm run build",
12793
+ "build:watch": "npm run clean && tsc --watch",
12794
+ "pack": "webpack --config webpack/webpack.config.js",
12795
+ "lint": "eslint src",
12796
+ "prepublish": "npm run build:clean",
12797
+ "betapublish": "npm publish --tag beta"
12798
+ },
12799
+ "main": "dist/cjs/index.js",
12800
+ "module": "dist/mjs/index.js",
12801
+ "types": "dist/mjs/index.d.ts",
12802
+ "exports": {
12803
+ ".": {
12804
+ "import": "./dist/mjs/index.js",
12805
+ "require": "./dist/cjs/index.js",
12806
+ "types": "./dist/mjs/index.d.ts"
12807
+ }
12808
+ },
12809
+ "files": [
12810
+ "dist/*",
12811
+ "llms.txt"
12812
+ ],
12813
+ "type": "module",
12814
+ "author": "Tiago Siebler (https://github.com/tiagosiebler)",
12815
+ "contributors": [],
12816
+ "dependencies": {
12817
+ "axios": "^1.10.0",
12818
+ "isomorphic-ws": "^5.0.0",
12819
+ "ws": "^8.9.0"
12820
+ },
12821
+ "devDependencies": {
12822
+ "@types/jest": "^29.0.3",
12823
+ "@types/node": "^22.10.2",
12824
+ "@types/ws": "^8.18.1",
12825
+ "@typescript-eslint/eslint-plugin": "^8.18.0",
12826
+ "@typescript-eslint/parser": "^8.18.0",
12827
+ "eslint": "^8.24.0",
12828
+ "eslint-config-prettier": "^9.1.0",
12829
+ "eslint-plugin-prettier": "^5.2.1",
12830
+ "eslint-plugin-require-extensions": "^0.1.3",
12831
+ "eslint-plugin-simple-import-sort": "^12.1.1",
12832
+ "jest": "^29.7.0",
12833
+ "ts-jest": "^29.4.0",
12834
+ "ts-node": "^10.9.2",
12835
+ "typescript": "^5.7.3"
12836
+ },
12837
+ "optionalDependencies": {
12838
+ "source-map-loader": "^4.0.0",
12839
+ "ts-loader": "^9.4.1",
12840
+ "webpack": "^5.74.0",
12841
+ "webpack-cli": "^4.10.0"
12842
+ },
12843
+ "keywords": [
12844
+ "bitget",
12845
+ "bitget api",
12846
+ "bitget nodejs",
12847
+ "bitget javascript",
12848
+ "bitget typescript",
12849
+ "bitget sdk",
12850
+ "bitget v3 api",
12851
+ "bitget UTA api",
12852
+ "api",
12853
+ "websocket",
12854
+ "rest",
12855
+ "rest api",
12856
+ "usdt",
12857
+ "trading bots",
12858
+ "nodejs",
12859
+ "node",
12860
+ "trading",
12861
+ "cryptocurrency",
12862
+ "bitcoin",
12863
+ "best"
12864
+ ],
12865
+ "funding": {
12866
+ "type": "individual",
12867
+ "url": "https://github.com/sponsors/tiagosiebler"
12868
+ },
12869
+ "license": "MIT",
12870
+ "repository": {
12871
+ "type": "git",
12872
+ "url": "https://github.com/tiagosiebler/bitget-api"
12873
+ },
12874
+ "bugs": {
12875
+ "url": "https://github.com/tiagosiebler/bitget-api/issues"
12876
+ },
12877
+ "homepage": "https://github.com/tiagosiebler/bitget-api#readme"
12878
+ }
12879
+
12829
12880
  ================
12830
12881
  File: README.md
12831
12882
  ================
@@ -13488,6 +13539,7 @@ import {
13488
13539
  GetTransferableCoinsRequestV3,
13489
13540
  GetWithdrawRecordsRequestV3,
13490
13541
  RepayRequestV3,
13542
+ SetDepositAccountRequestV3,
13491
13543
  SetLeverageRequestV3,
13492
13544
  SubAccountTransferRequestV3,
13493
13545
  SwitchDeductRequestV3,
@@ -13563,6 +13615,7 @@ import {
13563
13615
  SubAccountV3,
13564
13616
  SubTransferRecordV3,
13565
13617
  SubUnifiedAssetV3,
13618
+ SwitchStatusResponseV3,
13566
13619
  TransferResponseV3,
13567
13620
  UpdateSubAccountApiKeyResponseV3,
13568
13621
  WithdrawRecordV3,
@@ -13589,6 +13642,7 @@ import {
13589
13642
  OpenInterestV3,
13590
13643
  OrderBookV3,
13591
13644
  PositionTierV3,
13645
+ ProofOfReservesV3,
13592
13646
  PublicFillV3,
13593
13647
  RiskReserveV3,
13594
13648
  TickerV3,
@@ -13612,6 +13666,7 @@ import {
13612
13666
  OrderInfoV3,
13613
13667
  PlaceBatchOrdersResponseV3,
13614
13668
  PlaceOrderResponseV3,
13669
+ PositionAdlRankV3,
13615
13670
  PositionHistoryV3,
13616
13671
  UnfilledOrderV3,
13617
13672
  } from './types/response/v3/trade.js';
@@ -13691,6 +13746,11 @@ getFills(
13691
13746
  params: GetPublicFillsRequestV3,
13692
13747
  ): Promise<APIResponse<PublicFillV3[]>>
13693
13748
  ⋮----
13749
+ /**
13750
+ * Get Proof Of Reserves
13751
+ */
13752
+ getProofOfReserves(): Promise<APIResponse<ProofOfReservesV3>>
13753
+ ⋮----
13694
13754
  /**
13695
13755
  * Get Open Interest
13696
13756
  */
@@ -13843,6 +13903,16 @@ getConvertRecords(params: GetConvertRecordsRequestV3): Promise<
13843
13903
  > {
13844
13904
  return this.getPrivate('/api/v3/account/convert-records', params);
13845
13905
  ⋮----
13906
+ /**
13907
+ * Set up deposit account - Configure default recharge account for a certain symbol
13908
+ * This configuration item remains valid for a long time. That is, once a user sets a default
13909
+ * recharge account for a certain symbol, it will be retained permanently, and there is no need to reconfigure it.
13910
+ * Permission: UTA mgt. (read & write)
13911
+ */
13912
+ setDepositAccount(
13913
+ params: SetDepositAccountRequestV3,
13914
+ ): Promise<APIResponse<string>>
13915
+ ⋮----
13846
13916
  /**
13847
13917
  * Switch Deduct - Set BGB deduction
13848
13918
  */
@@ -13869,6 +13939,23 @@ getFeeRate(params: GetFeeRateRequestV3): Promise<
13869
13939
  > {
13870
13940
  return this.getPrivate('/api/v3/account/fee-rate', params);
13871
13941
  ⋮----
13942
+ /**
13943
+ * Switch Account - Switch to classic account mode
13944
+ * Only supports parent accounts.
13945
+ * This endpoint is only used for switching to classic account mode.
13946
+ * Please note that since the account switching process takes approximately 1 minute,
13947
+ * the successful response you receive only indicates that the request has been received,
13948
+ * and does not mean that the account has been successfully switched to the classic account.
13949
+ * Please use the query switching status interface to confirm whether the account switching is successful.
13950
+ */
13951
+ downgradeAccountToClassic(): Promise<APIResponse<null>>
13952
+ ⋮----
13953
+ /**
13954
+ * Get Switch Status - Get account switching status
13955
+ * Only supports parent accounts.
13956
+ */
13957
+ getSwitchAccountStatus(): Promise<APIResponse<SwitchStatusResponseV3>>
13958
+ ⋮----
13872
13959
  /**
13873
13960
  *
13874
13961
  * =====SubAccount======= endpoints
@@ -14167,6 +14254,11 @@ getMaxOpenAvailable(
14167
14254
  params: GetMaxOpenAvailableRequestV3,
14168
14255
  ): Promise<APIResponse<GetMaxOpenAvailableResponseV3>>
14169
14256
  ⋮----
14257
+ /**
14258
+ * Get Position ADL Rank - Get position auto-deleveraging ranking
14259
+ */
14260
+ getPositionAdlRank(): Promise<APIResponse<PositionAdlRankV3[]>>
14261
+ ⋮----
14170
14262
  /**
14171
14263
  * CountDown Cancel All
14172
14264
  */