From 288df6a2a7a2cdb6e62c6df21e0ef4421fb8cd2b Mon Sep 17 00:00:00 2001 From: "JJ-Cro (Codex)" Date: Mon, 2 Nov 2026 09:01:08 +0100 Subject: [PATCH 1/9] feat(v3.2.8): align websocket test helpers with current clients - Replace removed legacy client types with the supported V2 and V3 clients to restore full typechecking. --- test/ws.util.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/ws.util.ts b/test/ws.util.ts index 4f69ea6d..dfe4e763 100644 --- a/test/ws.util.ts +++ b/test/ws.util.ts @@ -1,5 +1,9 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ -import { DefaultLogger, WebsocketClientLegacyV1 } from '../src/index.js'; +import { + DefaultLogger, + WebsocketClientV2, + WebsocketClientV3, +} from '../src/index.js'; // eslint-disable-next-line @typescript-eslint/no-unused-vars export function getSilentLogger(_logHint?: string): DefaultLogger { @@ -27,7 +31,7 @@ type WsClientEvent = /** Resolves a promise if an event is seen before a timeout (defaults to 4.5 seconds) */ export function waitForSocketEvent( - wsClient: WebsocketClientLegacyV1, + wsClient: WebsocketClientV2 | WebsocketClientV3, event: WsClientEvent, timeoutMs: number = 10 * 1000, ) { @@ -74,7 +78,9 @@ export function waitForSocketEvent( }); } -export function listenToSocketEvents(wsClient: WebsocketClientLegacyV1) { +export function listenToSocketEvents( + wsClient: WebsocketClientV2 | WebsocketClientV3, +) { const retVal: Record< 'update' | 'open' | 'response' | 'close' | 'error', typeof jest.fn @@ -104,7 +110,7 @@ export function listenToSocketEvents(wsClient: WebsocketClientLegacyV1) { }; } -export function logAllEvents(wsClient: WebsocketClientLegacyV1) { +export function logAllEvents(wsClient: WebsocketClientV2 | WebsocketClientV3) { wsClient.on('update', (_data) => { // console.log('wsUpdate: ', JSON.stringify(data, null, 2)); }); From b6a635d4997ab2dfb6434d7df23e46b81cdc609a Mon Sep 17 00:00:00 2001 From: "JJ-Cro (Codex)" Date: Mon, 2 Nov 2026 09:01:30 +0100 Subject: [PATCH 2/9] feat(v3.2.8): add Stock+ purchase estimates and UTA channels - Add the Stock+ max-purchase method with documented request and response types. - Add six public UTA parameter channels and the lowercase uta instrument type. - Allow staff-confirmed null V3 position and financial lists, financial cursors, and V2 pending-order lists. - Document pending-order status defaults and single-value planType queries. - Add offline response, request-routing, and subscription regression tests. - Bump the package patch version from 3.2.7 to 3.2.8. --- package-lock.json | 4 +- package.json | 2 +- src/rest-client-v2.ts | 12 +++++- src/rest-client-v3.ts | 23 +++++++++-- src/types/request/v2/futures.ts | 2 + src/types/request/v3/stockplus.ts | 9 +++++ src/types/response/v3/stockplus.ts | 5 +++ src/types/websockets/ws-general.ts | 9 ++++- test/v2/response-types.test.ts | 57 ++++++++++++++++++++++++++++ test/v3/response-types.test.ts | 61 ++++++++++++++++++++++++++++++ test/v3/stockplus.test.ts | 55 +++++++++++++++++++++++++++ test/websockets/v3-topics.test.ts | 47 +++++++++++++++++++++++ 12 files changed, 277 insertions(+), 9 deletions(-) create mode 100644 test/v2/response-types.test.ts create mode 100644 test/v3/response-types.test.ts create mode 100644 test/v3/stockplus.test.ts create mode 100644 test/websockets/v3-topics.test.ts diff --git a/package-lock.json b/package-lock.json index 7ec7afb2..5c36a31d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bitget-api", - "version": "3.2.7", + "version": "3.2.8", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "bitget-api", - "version": "3.2.7", + "version": "3.2.8", "license": "MIT", "dependencies": { "@types/ws": "8.18.1", diff --git a/package.json b/package.json index 9e425386..d0da1f38 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bitget-api", - "version": "3.2.7", + "version": "3.2.8", "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/rest-client-v2.ts b/src/rest-client-v2.ts index 70818489..0315fd17 100644 --- a/src/rest-client-v2.ts +++ b/src/rest-client-v2.ts @@ -1758,7 +1758,11 @@ export class RestClientV2 extends BaseRestClient { getFuturesOpenOrders(params: FuturesGetOpenOrdersRequestV2): Promise< APIResponse<{ - entrustedList: FuturesOpenOrderV2[]; + /** + * Undocumented but staff-confirmed: null and [] can both represent an empty page. + * @see https://t.me/bitgetOpenapi/153977 + */ + entrustedList: FuturesOpenOrderV2[] | null; endId: string; }> > { @@ -1844,7 +1848,11 @@ export class RestClientV2 extends BaseRestClient { getFuturesPlanOrders(params: FuturesGetPlanOrdersRequestV2): Promise< APIResponse<{ - entrustedList: FuturesPendingPlanOrderV2[]; + /** + * Undocumented but staff-confirmed: null and [] can both represent an empty page. + * @see https://t.me/bitgetOpenapi/153977 + */ + entrustedList: FuturesPendingPlanOrderV2[] | null; endId: string; }> > { diff --git a/src/rest-client-v3.ts b/src/rest-client-v3.ts index 1c63c3fb..1e33ba7d 100644 --- a/src/rest-client-v3.ts +++ b/src/rest-client-v3.ts @@ -237,6 +237,7 @@ import { GetStockPlusHistoryExecutionsRequestV3, GetStockPlusHistoryOrdersRequestV3, GetStockPlusIntradayRequestV3, + GetStockPlusMaxPurchaseRequestV3, GetStockPlusOptionChainInfoRequestV3, GetStockPlusOptionExpiryDateRequestV3, GetStockPlusOptionQuoteRequestV3, @@ -509,6 +510,7 @@ import { StockPlusHistoryExecutionsV3, StockPlusHistoryOrdersV3, StockPlusIntradayV3, + StockPlusMaxPurchaseV3, StockPlusModifyOrderResponseV3, StockPlusOptionChainInfoV3, StockPlusOptionExpiryDateV3, @@ -1447,6 +1449,12 @@ export class RestClientV3 extends BaseRestClient { return this.getPrivate('/api/v3/stockplus/trade/order-detail', params); } + getStockPlusMaxPurchase( + params: GetStockPlusMaxPurchaseRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/stockplus/trade/max-purchase', params); + } + getStockPlusTodayExecutions( params?: GetStockPlusTodayExecutionsRequestV3, ): Promise> { @@ -1721,8 +1729,13 @@ export class RestClientV3 extends BaseRestClient { */ getFinancialRecords(params: GetFinancialRecordsRequestV3): Promise< APIResponse<{ - list: FinancialRecordV3[]; - cursor: string; + /** + * Undocumented but staff-confirmed: null when there are no records. + * @see https://t.me/bitgetOpenapi/153704 + */ + list: FinancialRecordV3[] | null; + /** Undocumented but staff-confirmed: null when pagination is exhausted. */ + cursor: string | null; }> > { return this.getPrivate('/api/v3/account/financial-records', params); @@ -2443,7 +2456,11 @@ export class RestClientV3 extends BaseRestClient { */ getCurrentPosition(params: GetCurrentPositionRequestV3): Promise< APIResponse<{ - list: CurrentPositionV3[]; + /** + * Undocumented but staff-confirmed: null when there are no matching positions. + * @see https://t.me/bitgetOpenapi/153786 + */ + list: CurrentPositionV3[] | null; }> > { return this.getPrivate('/api/v3/position/current-position', params); diff --git a/src/types/request/v2/futures.ts b/src/types/request/v2/futures.ts index 348e7cc5..05a5820c 100644 --- a/src/types/request/v2/futures.ts +++ b/src/types/request/v2/futures.ts @@ -284,6 +284,7 @@ export interface FuturesGetOpenOrdersRequestV2 { clientOid?: string; symbol?: string; productType: FuturesProductTypeV2; + /** Defaults to live; query partially_filled separately to include partially filled orders. */ status?: 'live' | 'partially_filled'; idLessThan?: string; startTime?: string; @@ -444,6 +445,7 @@ export interface FuturesGetPlanOrdersRequestV2 { orderId?: string; clientOid?: string; symbol?: string; + /** A single plan type per request; comma-separated values are not supported. */ planType: 'normal_plan' | 'track_plan' | 'profit_loss'; productType: FuturesProductTypeV2; idLessThan?: string; diff --git a/src/types/request/v3/stockplus.ts b/src/types/request/v3/stockplus.ts index 2817d003..27e7d7fb 100644 --- a/src/types/request/v3/stockplus.ts +++ b/src/types/request/v3/stockplus.ts @@ -122,6 +122,15 @@ export interface GetStockPlusOrderDetailRequestV3 { orderId: string; } +export interface GetStockPlusMaxPurchaseRequestV3 { + symbol: string; + orderType: 'LO' | 'MO' | 'LIT' | 'MIT' | 'TSLPAMT' | 'TSLPPCT'; + side: 'Buy' | 'Sell'; + price?: string; + currency?: string; + orderId?: string; +} + export interface GetStockPlusTodayExecutionsRequestV3 { symbol?: string; orderId?: string; diff --git a/src/types/response/v3/stockplus.ts b/src/types/response/v3/stockplus.ts index 4e94594e..338287a1 100644 --- a/src/types/response/v3/stockplus.ts +++ b/src/types/response/v3/stockplus.ts @@ -165,6 +165,11 @@ export interface StockPlusPlaceOrderResponseV3 { export type StockPlusCancelOrderResponseV3 = StockPlusPlaceOrderResponseV3; export type StockPlusModifyOrderResponseV3 = StockPlusPlaceOrderResponseV3; +export interface StockPlusMaxPurchaseV3 { + cashMaxQty: string; + marginMaxQty: string; +} + export interface StockPlusOrderV3 { orderId: string; status: string; diff --git a/src/types/websockets/ws-general.ts b/src/types/websockets/ws-general.ts index 01814d16..0c2fd6e9 100644 --- a/src/types/websockets/ws-general.ts +++ b/src/types/websockets/ws-general.ts @@ -9,6 +9,7 @@ export type BitgetInstType = 'SP' | 'SPBL' | 'MC' | 'UMCBL' | 'DMCBL'; export type BitgetInstTypeV2 = 'SPOT' | FuturesProductTypeV2; export type BitgetInstTypeV3 = | 'UTA' // for account-level topics + | 'uta' | 'spot' | 'usdt-futures' | 'coin-futures' @@ -117,7 +118,13 @@ export type WsPublicTopicV3 = | 'books1' | 'books5' | 'books50' - | 'publicTrade'; + | 'publicTrade' + | 'instruments' + | 'open-interest-limit' + | 'position-tier' + | 'funding-rate' + | 'margin-loan' + | 'margin-coins'; // Also update PRIVATE_TOPICS_V3 if this is updated. // `order` includes venue and rTokenTimeInForce for rToken orders. export type WsPrivateTopicV3 = diff --git a/test/v2/response-types.test.ts b/test/v2/response-types.test.ts new file mode 100644 index 00000000..fca7cf46 --- /dev/null +++ b/test/v2/response-types.test.ts @@ -0,0 +1,57 @@ +import { RestClientV2 } from '../../src/rest-client-v2.js'; + +describe('Bitget V2 empty pending orders', () => { + const api = new RestClientV2(); + + afterEach(() => jest.restoreAllMocks()); + + it.each([null, []])( + 'accepts an empty order list: %p', + async (entrustedList) => { + const response: Awaited< + ReturnType + > = { + code: '00000', + msg: 'success', + requestTime: 1, + data: { entrustedList, endId: '' }, + }; + const request = jest.spyOn(api, 'getPrivate').mockResolvedValue(response); + const params = { productType: 'USDT-FUTURES' as const }; + + expect(await api.getFuturesOpenOrders(params)).toBe(response); + expect(request).toHaveBeenCalledWith( + '/api/v2/mix/order/orders-pending', + params, + ); + }, + ); + + it.each([null, []])( + 'accepts an empty plan order list: %p', + async (entrustedList) => { + const response: Awaited< + ReturnType + > = { + code: '00000', + msg: 'success', + requestTime: 1, + data: { entrustedList, endId: '' }, + }; + const request = jest.spyOn(api, 'getPrivate').mockResolvedValue(response); + for (const planType of [ + 'normal_plan', + 'track_plan', + 'profit_loss', + ] as const) { + const params = { productType: 'USDT-FUTURES' as const, planType }; + + expect(await api.getFuturesPlanOrders(params)).toBe(response); + expect(request).toHaveBeenLastCalledWith( + '/api/v2/mix/order/orders-plan-pending', + params, + ); + } + }, + ); +}); diff --git a/test/v3/response-types.test.ts b/test/v3/response-types.test.ts new file mode 100644 index 00000000..d2d6860b --- /dev/null +++ b/test/v3/response-types.test.ts @@ -0,0 +1,61 @@ +import { RestClientV3 } from '../../src/rest-client-v3.js'; + +describe('Bitget V3 empty responses', () => { + const api = new RestClientV3(); + + afterEach(() => jest.restoreAllMocks()); + + it.each([null, []])('accepts an empty position list: %p', async (list) => { + const response: Awaited> = { + code: '00000', + msg: 'success', + requestTime: 1, + data: { list }, + }; + const request = jest.spyOn(api, 'getPrivate').mockResolvedValue(response); + const params = { category: 'USDT-FUTURES' as const, symbol: 'BTCUSDT' }; + + expect(await api.getCurrentPosition(params)).toBe(response); + expect(request).toHaveBeenCalledWith( + '/api/v3/position/current-position', + params, + ); + }); + + it.each([ + { list: null, cursor: null }, + { list: [], cursor: null }, + { list: [], cursor: '' }, + { + list: [ + { + category: 'USDT-FUTURES', + id: '1', + symbol: 'BTCUSDT', + coin: 'USDT', + type: 'TRANSFER_IN' as const, + amount: '10', + fee: '0', + balance: '10', + ts: '1', + }, + ], + cursor: '1', + }, + ])('preserves financial record pagination: %p', async (data) => { + const response: Awaited> = { + code: '00000', + msg: 'success', + requestTime: 1, + data, + }; + const request = jest.spyOn(api, 'getPrivate').mockResolvedValue(response); + const params = { category: 'USDT-FUTURES' as const }; + + expect(await api.getFinancialRecords(params)).toBe(response); + expect(request).toHaveBeenCalledWith( + '/api/v3/account/financial-records', + params, + ); + }); +}); diff --git a/test/v3/stockplus.test.ts b/test/v3/stockplus.test.ts new file mode 100644 index 00000000..bc2d8a51 --- /dev/null +++ b/test/v3/stockplus.test.ts @@ -0,0 +1,55 @@ +import { InternalAxiosRequestConfig } from 'axios'; + +import { + GetStockPlusMaxPurchaseRequestV3, + RestClientV3, + StockPlusMaxPurchaseV3, +} from '../../src/index.js'; + +describe('Bitget Stock+ max purchase', () => { + it.each<{ + params: GetStockPlusMaxPurchaseRequestV3; + data: StockPlusMaxPurchaseV3; + }>([ + { + params: { symbol: 'AAPL.US', orderType: 'MO', side: 'Buy' }, + data: { cashMaxQty: '', marginMaxQty: '' }, + }, + { + params: { + symbol: 'AAPL.US', + orderType: 'LO', + side: 'Sell', + price: '200', + currency: 'USD', + orderId: '1', + }, + data: { cashMaxQty: '100', marginMaxQty: '300' }, + }, + ])('queries max purchase with $params', async ({ params, data }) => { + const response = { code: '00000', msg: 'success', requestTime: 1, data }; + const adapter = jest.fn(async (config: InternalAxiosRequestConfig) => ({ + data: response, + status: 200, + statusText: 'OK', + headers: {}, + config, + })); + const api = new RestClientV3({}, { adapter }); + const privateRequest = jest.spyOn(api, 'getPrivate'); + + const result = await api.getStockPlusMaxPurchase(params); + + expect(result).toEqual(response); + expect(privateRequest).toHaveBeenCalledWith( + '/api/v3/stockplus/trade/max-purchase', + params, + ); + expect(adapter).toHaveBeenCalledTimes(1); + expect(adapter.mock.calls[0][0]).toMatchObject({ + method: 'get', + url: 'https://api.bitget.com/api/v3/stockplus/trade/max-purchase', + params, + }); + }); +}); diff --git a/test/websockets/v3-topics.test.ts b/test/websockets/v3-topics.test.ts new file mode 100644 index 00000000..1c576e6d --- /dev/null +++ b/test/websockets/v3-topics.test.ts @@ -0,0 +1,47 @@ +import { + BitgetInstTypeV3, + WsPublicTopicV3, +} from '../../src/types/websockets/ws-general.js'; +import { isPrivateChannel } from '../../src/util/websocket-util.js'; +import { WebsocketClientV3 } from '../../src/websocket-client-v3.js'; + +class TestWebsocketClientV3 extends WebsocketClientV3 { + public subscribeTopicsForWsKey = jest.fn().mockResolvedValue(undefined); +} + +describe('Bitget V3 financial parameter channels', () => { + const subscriptions: { + topic: WsPublicTopicV3; + payload: { instType: BitgetInstTypeV3; symbol?: string; coin?: string }; + }[] = [ + { topic: 'instruments', payload: { instType: 'usdt-futures' } }, + { + topic: 'open-interest-limit', + payload: { instType: 'usdt-futures', symbol: 'BTCUSDT' }, + }, + { + topic: 'position-tier', + payload: { instType: 'usdt-futures', symbol: 'BTCUSDT' }, + }, + { + topic: 'funding-rate', + payload: { instType: 'usdt-futures', symbol: 'BTCUSDT' }, + }, + { topic: 'margin-loan', payload: { instType: 'uta', coin: 'BTC' } }, + { topic: 'margin-coins', payload: { instType: 'uta', coin: 'BTC' } }, + ]; + + it.each(subscriptions)( + 'subscribes to $topic without authentication', + async (request) => { + const api = new TestWebsocketClientV3(); + + expect(isPrivateChannel(request.topic)).toBe(false); + await api.subscribe(request, 'v3Public'); + expect(api.subscribeTopicsForWsKey).toHaveBeenCalledWith( + [request], + 'v3Public', + ); + }, + ); +}); From 55cb185cbb5466ad12c42ddcdcec2321b32c11bb Mon Sep 17 00:00:00 2001 From: JJ-Cro sync bot Date: Mon, 2 Nov 2026 11:33:19 +0100 Subject: [PATCH 3/9] chore: regenerate endpoint docs and examples --- docs/endpointFunctionList.md | 917 +- llms.txt | 21242 +++++++++++++++++---------------- 2 files changed, 11117 insertions(+), 11042 deletions(-) diff --git a/docs/endpointFunctionList.md b/docs/endpointFunctionList.md index 89d36393..ad435eaf 100644 --- a/docs/endpointFunctionList.md +++ b/docs/endpointFunctionList.md @@ -196,165 +196,165 @@ This table includes all endpoints from the official Exchange API docs and corres | [getFuturesFills()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1739) | :closed_lock_with_key: | GET | `/api/v2/mix/order/fills` | | [getFuturesHistoricOrderFills()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1748) | :closed_lock_with_key: | GET | `/api/v2/mix/order/fill-history` | | [getFuturesOpenOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1759) | :closed_lock_with_key: | GET | `/api/v2/mix/order/orders-pending` | -| [getFuturesHistoricOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1768) | :closed_lock_with_key: | GET | `/api/v2/mix/order/orders-history` | -| [futuresCancelAllOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1777) | :closed_lock_with_key: | POST | `/api/v2/mix/order/cancel-all-orders` | -| [getFuturesTriggerSubOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1789) | :closed_lock_with_key: | GET | `/api/v2/mix/order/plan-sub-order` | -| [futuresSubmitTPSLOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1797) | :closed_lock_with_key: | POST | `/api/v2/mix/order/place-tpsl-order` | -| [futuresSubmitPositionTPSL()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1806) | :closed_lock_with_key: | POST | `/api/v2/mix/order/place-pos-tpsl` | -| [futuresSubmitPlanOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1818) | :closed_lock_with_key: | POST | `/api/v2/mix/order/place-plan-order` | -| [futuresModifyTPSLPOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1827) | :closed_lock_with_key: | POST | `/api/v2/mix/order/modify-tpsl-order` | -| [futuresModifyPlanOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1836) | :closed_lock_with_key: | POST | `/api/v2/mix/order/modify-plan-order` | -| [getFuturesPlanOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1845) | :closed_lock_with_key: | GET | `/api/v2/mix/order/orders-plan-pending` | -| [futuresCancelPlanOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1854) | :closed_lock_with_key: | POST | `/api/v2/mix/order/cancel-plan-order` | -| [getFuturesHistoricPlanOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1860) | :closed_lock_with_key: | GET | `/api/v2/mix/order/orders-plan-history` | -| [modifySubaccountEmail()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1885) | :closed_lock_with_key: | POST | `/api/v2/broker/account/modify-subaccount-email` | -| [getBrokerInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1895) | :closed_lock_with_key: | GET | `/api/v2/broker/account/info` | -| [createSubaccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1905) | :closed_lock_with_key: | POST | `/api/v2/broker/account/create-subaccount` | -| [getSubaccounts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1912) | :closed_lock_with_key: | GET | `/api/v2/broker/account/subaccount-list` | -| [modifySubaccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1922) | :closed_lock_with_key: | POST | `/api/v2/broker/account/modify-subaccount` | -| [getSubaccountEmail()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1928) | :closed_lock_with_key: | GET | `/api/v2/broker/account/subaccount-email` | -| [getSubaccountSpotAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1934) | :closed_lock_with_key: | GET | `/api/v2/broker/account/subaccount-spot-assets` | -| [getSubaccountFuturesAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1949) | :closed_lock_with_key: | GET | `/api/v2/broker/account/subaccount-future-assets` | -| [createSubaccountDepositAddress()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1963) | :closed_lock_with_key: | POST | `/api/v2/broker/account/subaccount-address` | -| [subaccountWithdrawal()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1974) | :closed_lock_with_key: | POST | `/api/v2/broker/account/subaccount-withdrawal` | -| [subaccountSetAutoTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1986) | :closed_lock_with_key: | POST | `/api/v2/broker/account/set-subaccount-autotransfer` | -| [subaccountDepositRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2002) | :closed_lock_with_key: | GET | `/api/v2/broker/subaccount-deposit` | -| [subaccountWithdrawalRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2013) | :closed_lock_with_key: | GET | `/api/v2/broker/subaccount-withdrawal` | -| [createSubaccountApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2028) | :closed_lock_with_key: | POST | `/api/v2/broker/manage/create-subaccount-apikey` | -| [getSubaccountApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2037) | :closed_lock_with_key: | GET | `/api/v2/broker/manage/subaccount-apikey-list` | -| [modifySubaccountApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2046) | :closed_lock_with_key: | POST | `/api/v2/broker/manage/modify-subaccount-apikey` | -| [deleteSubaccountApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2055) | :closed_lock_with_key: | POST | `/api/v2/broker/manage/delete-subaccount-apikey` | -| [getAllSubDepositWithdrawalRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2071) | :closed_lock_with_key: | GET | `/api/v2/broker/all-sub-deposit-withdrawal` | -| [getBrokerSubaccounts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2088) | :closed_lock_with_key: | GET | `/api/v2/broker/subaccounts` | -| [getBrokerCommissions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2100) | :closed_lock_with_key: | GET | `/api/v2/broker/commissions` | -| [getBrokerTradeVolume()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2112) | :closed_lock_with_key: | GET | `/api/v2/broker/trade-volume` | -| [getBrokerTotalCommission()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2132) | :closed_lock_with_key: | GET | `/api/v2/broker/total-commission` | -| [getBrokerOrderCommission()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2154) | :closed_lock_with_key: | GET | `/api/v2/broker/order-commission` | -| [getBrokerRebateInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2167) | :closed_lock_with_key: | GET | `/api/v2/broker/rebate-info` | -| [getAgentCustomerCommissions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2179) | :closed_lock_with_key: | GET | `/api/v2/broker/customer-commissions` | -| [getAgentSubCustomerList()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2188) | :closed_lock_with_key: | GET | `/api/v2/broker/sub-customer-list` | -| [getSubAffiliateInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2194) | :closed_lock_with_key: | GET | `/api/v2/broker/sub-affiliate-info` | -| [getAgentCustomerTradeVolume()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2200) | :closed_lock_with_key: | POST | `/api/v2/broker/customer-trade-volume` | -| [getAgentCustomerList()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2209) | :closed_lock_with_key: | POST | `/api/v2/broker/customer-list` | -| [getAgentCustomerKycResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2215) | :closed_lock_with_key: | GET | `/api/v2/broker/customer-kyc-result` | -| [getAgentCustomerDeposits()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2221) | :closed_lock_with_key: | POST | `/api/v2/broker/customer-deposit` | -| [getAgentCustomerAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2227) | :closed_lock_with_key: | POST | `/api/v2/broker/customer-asset` | -| [getAgentCommissionDetail()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2233) | :closed_lock_with_key: | GET | `/api/v2/broker/agent-commission` | -| [getMarginCurrencies()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2253) | | GET | `/api/v2/margin/currencies` | -| [getMarginBorrowHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2263) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/borrow-history` | -| [getMarginRepayHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2280) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/repay-history` | -| [getMarginInterestHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2297) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/interest-history` | -| [getMarginLiquidationHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2314) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/liquidation-history` | -| [getMarginFinancialHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2331) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/financial-records` | -| [getMarginAccountAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2354) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/account/assets` | -| [marginBorrow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2365) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/account/borrow` | -| [marginRepay()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2388) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/account/repay` | -| [getMarginRiskRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2413) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/account/risk-rate` | -| [getMarginMaxBorrowable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2425) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/account/max-borrowable-amount` | -| [getMarginMaxTransferable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2438) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/account/max-transfer-out-amount` | -| [getMarginInterestRateAndMaxBorrowable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2453) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/interest-rate-and-limit` | -| [getMarginTierConfiguration()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2469) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/tier-data` | -| [marginFlashRepay()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2481) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/account/flash-repay` | -| [getMarginFlashRepayResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2499) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/account/query-flash-repay-status` | -| [marginSubmitOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2523) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/place-order` | -| [marginBatchSubmitOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2536) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/batch-place-order` | -| [marginCancelOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2547) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/cancel-order` | -| [marginBatchCancelOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2567) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/batch-cancel-order` | -| [getMarginOpenOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2581) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/open-orders` | -| [getMarginHistoricOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2595) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/history-orders` | -| [getMarginHistoricOrderFills()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2612) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/fills` | -| [getMarginLiquidationOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2626) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/liquidation-order` | -| [getFuturesTraderCurrentOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2658) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/order-current-track` | -| [getFuturesTraderHistoryOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2667) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/order-history-track` | -| [modifyFuturesTraderOrderTPSL()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2676) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-trader/order-modify-tpsl` | -| [getFuturesTraderOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2685) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/order-total-detail` | -| [getFuturesTraderProfitHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2691) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/profit-history-summarys` | -| [getFuturesTraderProfitShareHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2697) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/profit-history-details` | -| [closeFuturesTraderOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2706) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-trader/order-close-positions` | -| [getFuturesTraderProfitShare()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2725) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/profit-details` | -| [getFuturesTraderProfitShareGroup()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2741) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/profits-group-coin-date` | -| [getFuturesTraderSymbolSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2759) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/config-query-symbols` | -| [updateFuturesTraderSymbolSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2768) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-trader/config-setting-symbols` | -| [updateFuturesTraderGlobalSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2777) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-trader/config-settings-base` | -| [getFuturesTraderFollowers()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2788) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/config-query-followers` | -| [removeFuturesTraderFollower()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2797) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-trader/config-remove-follower` | -| [getFuturesFollowerCurrentOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2814) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-follower/query-current-orders` | -| [getFuturesFollowerHistoryOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2823) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-follower/query-history-orders` | -| [updateFuturesFollowerTPSL()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2832) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-follower/setting-tpsl` | -| [updateFuturesFollowerSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2838) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-follower/settings` | -| [getFuturesFollowerSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2844) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-follower/query-settings` | -| [closeFuturesFollowerPositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2850) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-follower/close-positions` | -| [getFuturesFollowerTraders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2863) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-follower/query-traders` | -| [getFuturesFollowerFollowLimit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2869) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-follower/query-quantity-limit` | -| [unfollowFuturesTrader()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2887) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-follower/cancel-trader` | -| [getBrokerTraders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2901) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-broker/query-traders` | -| [getBrokerTradersHistoricalOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2905) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-broker/query-history-traces` | -| [getBrokerTradersPendingOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2912) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-broker/query-current-traces` | -| [getSpotTraderProfit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2927) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/profit-summarys` | -| [getSpotTraderHistoryProfit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2931) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/profit-history-details` | -| [getSpotTraderUnrealizedProfit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2940) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/profit-details` | -| [getSpotTraderOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2948) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/order-total-detail` | -| [modifySpotTraderOrderTPSL()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2952) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-trader/order-modify-tpsl` | -| [getSpotTraderHistoryOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2963) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/order-history-track` | -| [getSpotTraderCurrentOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2972) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/order-current-track` | -| [sellSpotTrader()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2981) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-trader/order-close-tracking` | -| [getSpotTraderSymbolSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2991) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-trader/config-setting-symbols` | -| [removeSpotTraderFollowers()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3001) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-trader/config-remove-follower` | -| [getSpotTraderConfiguration()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3010) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/config-query-settings` | -| [getSpotTraderFollowers()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3014) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/config-query-followers` | -| [cancelSpotFollowerOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3031) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-follower/stop-order` | -| [updateSpotFollowerSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3037) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-follower/settings` | -| [updateSpotFollowerTPSL()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3046) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-follower/setting-tpsl` | -| [getSpotFollowerTraders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3054) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-follower/query-traders` | -| [getSpotFollowerCurrentTraderSymbols()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3063) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-follower/query-trader-symbols` | -| [getSpotFollowerSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3074) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-follower/query-settings` | -| [getSpotFollowerHistoryOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3080) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-follower/query-history-orders` | -| [getSpotFollowerOpenOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3089) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-follower/query-current-orders` | -| [sellSpotFollower()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3098) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-follower/order-close-tracking` | -| [unfollowSpotTrader()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3108) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-follower/cancel-trader` | -| [getEarnSavingsProducts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3122) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/product` | -| [getEarnSavingsAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3129) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/account` | -| [getEarnSavingsAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3133) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/assets` | -| [getEarnSavingsRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3139) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/records` | -| [getEarnSavingsSubscription()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3145) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/subscribe-info` | -| [earnSubscribeSavings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3152) | :closed_lock_with_key: | POST | `/api/v2/earn/savings/subscribe` | -| [getEarnSavingsSubscriptionResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3165) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/subscribe-result` | -| [earnRedeemSavings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3177) | :closed_lock_with_key: | POST | `/api/v2/earn/savings/redeem` | -| [getEarnSavingsRedemptionResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3186) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/redeem-result` | -| [getEarnAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3206) | :closed_lock_with_key: | GET | `/api/v2/earn/account/assets` | -| [getEarnEliteProducts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3225) | :closed_lock_with_key: | GET | `/api/v2/earn/elite/product` | -| [getEarnEliteAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3229) | :closed_lock_with_key: | GET | `/api/v2/earn/elite/assets` | -| [getEarnEliteRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3233) | :closed_lock_with_key: | GET | `/api/v2/earn/elite/records` | -| [getEarnEliteSubscribeInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3239) | :closed_lock_with_key: | GET | `/api/v2/earn/elite/subscribe-info` | -| [subscribeEarnElite()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3245) | :closed_lock_with_key: | POST | `/api/v2/earn/elite/subscribe` | -| [getEarnEliteSubscribeResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3251) | :closed_lock_with_key: | GET | `/api/v2/earn/elite/subscribe-result` | -| [getEarnEliteRedeemInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3257) | :closed_lock_with_key: | GET | `/api/v2/earn/elite/redeem-info` | -| [redeemEarnElite()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3263) | :closed_lock_with_key: | POST | `/api/v2/earn/elite/redeem` | -| [getSharkfinProducts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3277) | :closed_lock_with_key: | GET | `/api/v2/earn/sharkfin/product` | -| [getSharkfinAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3285) | :closed_lock_with_key: | GET | `/api/v2/earn/sharkfin/account` | -| [getSharkfinAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3289) | :closed_lock_with_key: | GET | `/api/v2/earn/sharkfin/assets` | -| [getSharkfinRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3295) | :closed_lock_with_key: | GET | `/api/v2/earn/sharkfin/records` | -| [getSharkfinSubscription()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3301) | :closed_lock_with_key: | GET | `/api/v2/earn/sharkfin/subscribe-info` | -| [subscribeSharkfin()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3307) | :closed_lock_with_key: | POST | `/api/v2/earn/sharkfin/subscribe` | -| [getSharkfinSubscriptionResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3316) | :closed_lock_with_key: | GET | `/api/v2/earn/sharkfin/subscribe-result` | -| [getLoanCurrencies()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3333) | | GET | `/api/v2/earn/loan/public/coinInfos` | -| [getLoanEstInterestAndBorrowable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3339) | | GET | `/api/v2/earn/loan/public/hour-interest` | -| [borrowLoan()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3350) | :closed_lock_with_key: | POST | `/api/v2/earn/loan/borrow` | -| [getOngoingLoanOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3358) | :closed_lock_with_key: | GET | `/api/v2/earn/loan/ongoing-orders` | -| [repayLoan()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3366) | :closed_lock_with_key: | POST | `/api/v2/earn/loan/repay` | -| [getRepayHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3372) | :closed_lock_with_key: | GET | `/api/v2/earn/loan/repay-history` | -| [updateLoanPledgeRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3378) | :closed_lock_with_key: | POST | `/api/v2/earn/loan/revise-pledge` | -| [getLoanPledgeRateHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3388) | :closed_lock_with_key: | GET | `/api/v2/earn/loan/revise-history` | -| [getLoanHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3394) | :closed_lock_with_key: | GET | `/api/v2/earn/loan/borrow-history` | -| [getLoanDebts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3400) | :closed_lock_with_key: | GET | `/api/v2/earn/loan/debts` | -| [getLoanLiquidationRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3404) | :closed_lock_with_key: | GET | `/api/v2/earn/loan/reduces` | -| [getLoanProductInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3416) | :closed_lock_with_key: | GET | `/api/v2/spot/ins-loan/product-infos` | -| [getLoanSymbols()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3422) | :closed_lock_with_key: | GET | `/api/v2/spot/ins-loan/symbols` | -| [getLoanMarginCoinInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3428) | :closed_lock_with_key: | GET | `/api/v2/spot/ins-loan/ensure-coins-convert` | -| [getLoanRiskUnit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3446) | :closed_lock_with_key: | GET | `/api/v2/spot/ins-loan/risk-unit` | -| [getLoanLTVConvert()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3454) | :closed_lock_with_key: | GET | `/api/v2/spot/ins-loan/ltv-convert` | -| [getLoanRepaidHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3466) | :closed_lock_with_key: | GET | `/api/v2/spot/ins-loan/repaid-history` | -| [getLoanOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3472) | :closed_lock_with_key: | GET | `/api/v2/spot/ins-loan/loan-order` | +| [getFuturesHistoricOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1772) | :closed_lock_with_key: | GET | `/api/v2/mix/order/orders-history` | +| [futuresCancelAllOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1781) | :closed_lock_with_key: | POST | `/api/v2/mix/order/cancel-all-orders` | +| [getFuturesTriggerSubOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1793) | :closed_lock_with_key: | GET | `/api/v2/mix/order/plan-sub-order` | +| [futuresSubmitTPSLOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1801) | :closed_lock_with_key: | POST | `/api/v2/mix/order/place-tpsl-order` | +| [futuresSubmitPositionTPSL()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1810) | :closed_lock_with_key: | POST | `/api/v2/mix/order/place-pos-tpsl` | +| [futuresSubmitPlanOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1822) | :closed_lock_with_key: | POST | `/api/v2/mix/order/place-plan-order` | +| [futuresModifyTPSLPOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1831) | :closed_lock_with_key: | POST | `/api/v2/mix/order/modify-tpsl-order` | +| [futuresModifyPlanOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1840) | :closed_lock_with_key: | POST | `/api/v2/mix/order/modify-plan-order` | +| [getFuturesPlanOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1849) | :closed_lock_with_key: | GET | `/api/v2/mix/order/orders-plan-pending` | +| [futuresCancelPlanOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1862) | :closed_lock_with_key: | POST | `/api/v2/mix/order/cancel-plan-order` | +| [getFuturesHistoricPlanOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1868) | :closed_lock_with_key: | GET | `/api/v2/mix/order/orders-plan-history` | +| [modifySubaccountEmail()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1893) | :closed_lock_with_key: | POST | `/api/v2/broker/account/modify-subaccount-email` | +| [getBrokerInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1903) | :closed_lock_with_key: | GET | `/api/v2/broker/account/info` | +| [createSubaccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1913) | :closed_lock_with_key: | POST | `/api/v2/broker/account/create-subaccount` | +| [getSubaccounts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1920) | :closed_lock_with_key: | GET | `/api/v2/broker/account/subaccount-list` | +| [modifySubaccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1930) | :closed_lock_with_key: | POST | `/api/v2/broker/account/modify-subaccount` | +| [getSubaccountEmail()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1936) | :closed_lock_with_key: | GET | `/api/v2/broker/account/subaccount-email` | +| [getSubaccountSpotAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1942) | :closed_lock_with_key: | GET | `/api/v2/broker/account/subaccount-spot-assets` | +| [getSubaccountFuturesAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1957) | :closed_lock_with_key: | GET | `/api/v2/broker/account/subaccount-future-assets` | +| [createSubaccountDepositAddress()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1971) | :closed_lock_with_key: | POST | `/api/v2/broker/account/subaccount-address` | +| [subaccountWithdrawal()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1982) | :closed_lock_with_key: | POST | `/api/v2/broker/account/subaccount-withdrawal` | +| [subaccountSetAutoTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L1994) | :closed_lock_with_key: | POST | `/api/v2/broker/account/set-subaccount-autotransfer` | +| [subaccountDepositRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2010) | :closed_lock_with_key: | GET | `/api/v2/broker/subaccount-deposit` | +| [subaccountWithdrawalRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2021) | :closed_lock_with_key: | GET | `/api/v2/broker/subaccount-withdrawal` | +| [createSubaccountApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2036) | :closed_lock_with_key: | POST | `/api/v2/broker/manage/create-subaccount-apikey` | +| [getSubaccountApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2045) | :closed_lock_with_key: | GET | `/api/v2/broker/manage/subaccount-apikey-list` | +| [modifySubaccountApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2054) | :closed_lock_with_key: | POST | `/api/v2/broker/manage/modify-subaccount-apikey` | +| [deleteSubaccountApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2063) | :closed_lock_with_key: | POST | `/api/v2/broker/manage/delete-subaccount-apikey` | +| [getAllSubDepositWithdrawalRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2079) | :closed_lock_with_key: | GET | `/api/v2/broker/all-sub-deposit-withdrawal` | +| [getBrokerSubaccounts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2096) | :closed_lock_with_key: | GET | `/api/v2/broker/subaccounts` | +| [getBrokerCommissions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2108) | :closed_lock_with_key: | GET | `/api/v2/broker/commissions` | +| [getBrokerTradeVolume()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2120) | :closed_lock_with_key: | GET | `/api/v2/broker/trade-volume` | +| [getBrokerTotalCommission()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2140) | :closed_lock_with_key: | GET | `/api/v2/broker/total-commission` | +| [getBrokerOrderCommission()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2162) | :closed_lock_with_key: | GET | `/api/v2/broker/order-commission` | +| [getBrokerRebateInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2175) | :closed_lock_with_key: | GET | `/api/v2/broker/rebate-info` | +| [getAgentCustomerCommissions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2187) | :closed_lock_with_key: | GET | `/api/v2/broker/customer-commissions` | +| [getAgentSubCustomerList()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2196) | :closed_lock_with_key: | GET | `/api/v2/broker/sub-customer-list` | +| [getSubAffiliateInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2202) | :closed_lock_with_key: | GET | `/api/v2/broker/sub-affiliate-info` | +| [getAgentCustomerTradeVolume()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2208) | :closed_lock_with_key: | POST | `/api/v2/broker/customer-trade-volume` | +| [getAgentCustomerList()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2217) | :closed_lock_with_key: | POST | `/api/v2/broker/customer-list` | +| [getAgentCustomerKycResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2223) | :closed_lock_with_key: | GET | `/api/v2/broker/customer-kyc-result` | +| [getAgentCustomerDeposits()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2229) | :closed_lock_with_key: | POST | `/api/v2/broker/customer-deposit` | +| [getAgentCustomerAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2235) | :closed_lock_with_key: | POST | `/api/v2/broker/customer-asset` | +| [getAgentCommissionDetail()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2241) | :closed_lock_with_key: | GET | `/api/v2/broker/agent-commission` | +| [getMarginCurrencies()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2261) | | GET | `/api/v2/margin/currencies` | +| [getMarginBorrowHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2271) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/borrow-history` | +| [getMarginRepayHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2288) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/repay-history` | +| [getMarginInterestHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2305) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/interest-history` | +| [getMarginLiquidationHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2322) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/liquidation-history` | +| [getMarginFinancialHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2339) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/financial-records` | +| [getMarginAccountAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2362) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/account/assets` | +| [marginBorrow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2373) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/account/borrow` | +| [marginRepay()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2396) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/account/repay` | +| [getMarginRiskRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2421) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/account/risk-rate` | +| [getMarginMaxBorrowable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2433) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/account/max-borrowable-amount` | +| [getMarginMaxTransferable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2446) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/account/max-transfer-out-amount` | +| [getMarginInterestRateAndMaxBorrowable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2461) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/interest-rate-and-limit` | +| [getMarginTierConfiguration()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2477) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/tier-data` | +| [marginFlashRepay()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2489) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/account/flash-repay` | +| [getMarginFlashRepayResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2507) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/account/query-flash-repay-status` | +| [marginSubmitOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2531) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/place-order` | +| [marginBatchSubmitOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2544) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/batch-place-order` | +| [marginCancelOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2555) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/cancel-order` | +| [marginBatchCancelOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2575) | :closed_lock_with_key: | POST | `/api/v2/margin/${marginType}/batch-cancel-order` | +| [getMarginOpenOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2589) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/open-orders` | +| [getMarginHistoricOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2603) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/history-orders` | +| [getMarginHistoricOrderFills()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2620) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/fills` | +| [getMarginLiquidationOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2634) | :closed_lock_with_key: | GET | `/api/v2/margin/${marginType}/liquidation-order` | +| [getFuturesTraderCurrentOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2666) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/order-current-track` | +| [getFuturesTraderHistoryOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2675) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/order-history-track` | +| [modifyFuturesTraderOrderTPSL()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2684) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-trader/order-modify-tpsl` | +| [getFuturesTraderOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2693) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/order-total-detail` | +| [getFuturesTraderProfitHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2699) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/profit-history-summarys` | +| [getFuturesTraderProfitShareHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2705) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/profit-history-details` | +| [closeFuturesTraderOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2714) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-trader/order-close-positions` | +| [getFuturesTraderProfitShare()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2733) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/profit-details` | +| [getFuturesTraderProfitShareGroup()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2749) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/profits-group-coin-date` | +| [getFuturesTraderSymbolSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2767) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/config-query-symbols` | +| [updateFuturesTraderSymbolSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2776) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-trader/config-setting-symbols` | +| [updateFuturesTraderGlobalSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2785) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-trader/config-settings-base` | +| [getFuturesTraderFollowers()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2796) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-trader/config-query-followers` | +| [removeFuturesTraderFollower()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2805) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-trader/config-remove-follower` | +| [getFuturesFollowerCurrentOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2822) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-follower/query-current-orders` | +| [getFuturesFollowerHistoryOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2831) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-follower/query-history-orders` | +| [updateFuturesFollowerTPSL()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2840) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-follower/setting-tpsl` | +| [updateFuturesFollowerSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2846) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-follower/settings` | +| [getFuturesFollowerSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2852) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-follower/query-settings` | +| [closeFuturesFollowerPositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2858) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-follower/close-positions` | +| [getFuturesFollowerTraders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2871) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-follower/query-traders` | +| [getFuturesFollowerFollowLimit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2877) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-follower/query-quantity-limit` | +| [unfollowFuturesTrader()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2895) | :closed_lock_with_key: | POST | `/api/v2/copy/mix-follower/cancel-trader` | +| [getBrokerTraders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2909) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-broker/query-traders` | +| [getBrokerTradersHistoricalOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2913) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-broker/query-history-traces` | +| [getBrokerTradersPendingOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2920) | :closed_lock_with_key: | GET | `/api/v2/copy/mix-broker/query-current-traces` | +| [getSpotTraderProfit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2935) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/profit-summarys` | +| [getSpotTraderHistoryProfit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2939) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/profit-history-details` | +| [getSpotTraderUnrealizedProfit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2948) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/profit-details` | +| [getSpotTraderOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2956) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/order-total-detail` | +| [modifySpotTraderOrderTPSL()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2960) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-trader/order-modify-tpsl` | +| [getSpotTraderHistoryOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2971) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/order-history-track` | +| [getSpotTraderCurrentOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2980) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/order-current-track` | +| [sellSpotTrader()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2989) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-trader/order-close-tracking` | +| [getSpotTraderSymbolSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L2999) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-trader/config-setting-symbols` | +| [removeSpotTraderFollowers()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3009) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-trader/config-remove-follower` | +| [getSpotTraderConfiguration()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3018) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/config-query-settings` | +| [getSpotTraderFollowers()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3022) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-trader/config-query-followers` | +| [cancelSpotFollowerOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3039) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-follower/stop-order` | +| [updateSpotFollowerSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3045) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-follower/settings` | +| [updateSpotFollowerTPSL()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3054) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-follower/setting-tpsl` | +| [getSpotFollowerTraders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3062) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-follower/query-traders` | +| [getSpotFollowerCurrentTraderSymbols()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3071) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-follower/query-trader-symbols` | +| [getSpotFollowerSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3082) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-follower/query-settings` | +| [getSpotFollowerHistoryOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3088) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-follower/query-history-orders` | +| [getSpotFollowerOpenOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3097) | :closed_lock_with_key: | GET | `/api/v2/copy/spot-follower/query-current-orders` | +| [sellSpotFollower()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3106) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-follower/order-close-tracking` | +| [unfollowSpotTrader()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3116) | :closed_lock_with_key: | POST | `/api/v2/copy/spot-follower/cancel-trader` | +| [getEarnSavingsProducts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3130) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/product` | +| [getEarnSavingsAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3137) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/account` | +| [getEarnSavingsAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3141) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/assets` | +| [getEarnSavingsRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3147) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/records` | +| [getEarnSavingsSubscription()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3153) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/subscribe-info` | +| [earnSubscribeSavings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3160) | :closed_lock_with_key: | POST | `/api/v2/earn/savings/subscribe` | +| [getEarnSavingsSubscriptionResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3173) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/subscribe-result` | +| [earnRedeemSavings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3185) | :closed_lock_with_key: | POST | `/api/v2/earn/savings/redeem` | +| [getEarnSavingsRedemptionResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3194) | :closed_lock_with_key: | GET | `/api/v2/earn/savings/redeem-result` | +| [getEarnAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3214) | :closed_lock_with_key: | GET | `/api/v2/earn/account/assets` | +| [getEarnEliteProducts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3233) | :closed_lock_with_key: | GET | `/api/v2/earn/elite/product` | +| [getEarnEliteAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3237) | :closed_lock_with_key: | GET | `/api/v2/earn/elite/assets` | +| [getEarnEliteRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3241) | :closed_lock_with_key: | GET | `/api/v2/earn/elite/records` | +| [getEarnEliteSubscribeInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3247) | :closed_lock_with_key: | GET | `/api/v2/earn/elite/subscribe-info` | +| [subscribeEarnElite()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3253) | :closed_lock_with_key: | POST | `/api/v2/earn/elite/subscribe` | +| [getEarnEliteSubscribeResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3259) | :closed_lock_with_key: | GET | `/api/v2/earn/elite/subscribe-result` | +| [getEarnEliteRedeemInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3265) | :closed_lock_with_key: | GET | `/api/v2/earn/elite/redeem-info` | +| [redeemEarnElite()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3271) | :closed_lock_with_key: | POST | `/api/v2/earn/elite/redeem` | +| [getSharkfinProducts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3285) | :closed_lock_with_key: | GET | `/api/v2/earn/sharkfin/product` | +| [getSharkfinAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3293) | :closed_lock_with_key: | GET | `/api/v2/earn/sharkfin/account` | +| [getSharkfinAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3297) | :closed_lock_with_key: | GET | `/api/v2/earn/sharkfin/assets` | +| [getSharkfinRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3303) | :closed_lock_with_key: | GET | `/api/v2/earn/sharkfin/records` | +| [getSharkfinSubscription()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3309) | :closed_lock_with_key: | GET | `/api/v2/earn/sharkfin/subscribe-info` | +| [subscribeSharkfin()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3315) | :closed_lock_with_key: | POST | `/api/v2/earn/sharkfin/subscribe` | +| [getSharkfinSubscriptionResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3324) | :closed_lock_with_key: | GET | `/api/v2/earn/sharkfin/subscribe-result` | +| [getLoanCurrencies()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3341) | | GET | `/api/v2/earn/loan/public/coinInfos` | +| [getLoanEstInterestAndBorrowable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3347) | | GET | `/api/v2/earn/loan/public/hour-interest` | +| [borrowLoan()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3358) | :closed_lock_with_key: | POST | `/api/v2/earn/loan/borrow` | +| [getOngoingLoanOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3366) | :closed_lock_with_key: | GET | `/api/v2/earn/loan/ongoing-orders` | +| [repayLoan()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3374) | :closed_lock_with_key: | POST | `/api/v2/earn/loan/repay` | +| [getRepayHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3380) | :closed_lock_with_key: | GET | `/api/v2/earn/loan/repay-history` | +| [updateLoanPledgeRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3386) | :closed_lock_with_key: | POST | `/api/v2/earn/loan/revise-pledge` | +| [getLoanPledgeRateHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3396) | :closed_lock_with_key: | GET | `/api/v2/earn/loan/revise-history` | +| [getLoanHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3402) | :closed_lock_with_key: | GET | `/api/v2/earn/loan/borrow-history` | +| [getLoanDebts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3408) | :closed_lock_with_key: | GET | `/api/v2/earn/loan/debts` | +| [getLoanLiquidationRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3412) | :closed_lock_with_key: | GET | `/api/v2/earn/loan/reduces` | +| [getLoanProductInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3424) | :closed_lock_with_key: | GET | `/api/v2/spot/ins-loan/product-infos` | +| [getLoanSymbols()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3430) | :closed_lock_with_key: | GET | `/api/v2/spot/ins-loan/symbols` | +| [getLoanMarginCoinInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3436) | :closed_lock_with_key: | GET | `/api/v2/spot/ins-loan/ensure-coins-convert` | +| [getLoanRiskUnit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3454) | :closed_lock_with_key: | GET | `/api/v2/spot/ins-loan/risk-unit` | +| [getLoanLTVConvert()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3462) | :closed_lock_with_key: | GET | `/api/v2/spot/ins-loan/ltv-convert` | +| [getLoanRepaidHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3474) | :closed_lock_with_key: | GET | `/api/v2/spot/ins-loan/repaid-history` | +| [getLoanOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v2.ts#L3480) | :closed_lock_with_key: | GET | `/api/v2/spot/ins-loan/loan-order` | # rest-client-v3.ts @@ -362,305 +362,306 @@ 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#L645) | | GET | `/api/v3/market/time` | -| [getAnnouncements()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L659) | | GET | `/api/v3/public/annoucements` | -| [getInstruments()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L678) | | GET | `/api/v3/market/instruments` | -| [getMarketFeeGroup()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L687) | | GET | `/api/v3/market/fee-group` | -| [getLiquidations()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L696) | | GET | `/api/v3/market/liquidations` | -| [getRpiSymbols()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L705) | | GET | `/api/v3/market/rpi-symbols` | -| [getRpiOrderBook()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L712) | | GET | `/api/v3/market/rpi-orderbook` | -| [getCashDividendRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L721) | | GET | `/api/v3/market/cash-dividend-records` | -| [getSplitRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L727) | | GET | `/api/v3/market/split-records` | -| [getSpotWhaleFlow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L736) | | GET | `/api/v3/market/spot-whale-flow` | -| [getSpotFundFlow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L745) | | GET | `/api/v3/market/spot-fund-flow` | -| [getSpotNetFlow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L754) | | GET | `/api/v3/market/spot-net-flow` | -| [getMarginLongShort()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L763) | | GET | `/api/v3/market/margin-long-short` | -| [getMarginLoanGrowth()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L772) | | GET | `/api/v3/market/margin-loan-growth` | -| [getMarginIsolatedBorrow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L781) | | GET | `/api/v3/market/margin-isolated-borrow` | -| [getFuturesActiveBuySell()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L790) | | GET | `/api/v3/market/futures-active-buy-sell` | -| [getFuturesLongShort()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L799) | | GET | `/api/v3/market/futures-long-short` | -| [getFuturesPositionLongShort()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L808) | | GET | `/api/v3/market/futures-position-long-short` | -| [getFuturesAccountLongShort()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L817) | | GET | `/api/v3/market/futures-account-long-short` | -| [getMarketScoreWeights()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L826) | | GET | `/api/v3/market/score-weights` | -| [getTickers()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L835) | | GET | `/api/v3/market/tickers` | -| [getOrderBook()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L845) | | GET | `/api/v3/market/orderbook` | -| [getFills()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L854) | | GET | `/api/v3/market/fills` | -| [getProofOfReserves()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L863) | | GET | `/api/v3/market/proof-of-reserves` | -| [getOpenInterest()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L870) | | GET | `/api/v3/market/open-interest` | -| [getOpenInterestHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L880) | | GET | `/api/v3/market/open-interest-history` | -| [getCoins()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L891) | | GET | `/api/v3/market/coins` | -| [getCandles()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L899) | | GET | `/api/v3/market/candles` | -| [getHistoryCandles()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L908) | | GET | `/api/v3/market/history-candles` | -| [getCurrentFundingRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L917) | | GET | `/api/v3/market/current-fund-rate` | -| [getHistoryFundingRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L926) | | GET | `/api/v3/market/history-fund-rate` | -| [getRiskReserve()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L935) | | GET | `/api/v3/market/risk-reserve` | -| [getRiskReserveHour()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L944) | | GET | `/api/v3/market/risk-reserve-hour` | -| [getRiskReserveAll()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L953) | | GET | `/api/v3/market/risk-reserve-all` | -| [getDiscountRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L962) | | GET | `/api/v3/market/discount-rate` | -| [getInterestRateHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L971) | | GET | `/api/v3/market/interest-rate-history` | -| [getMarginLoans()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L980) | | GET | `/api/v3/market/margin-loans` | -| [getMarginLoansAll()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L990) | | GET | `/api/v3/market/margin-loans-all` | -| [getPositionTier()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L999) | | GET | `/api/v3/market/position-tier` | -| [getContractsOi()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1008) | | GET | `/api/v3/market/oi-limit` | -| [getIndexComponents()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1017) | | GET | `/api/v3/market/index-components` | -| [getRealityOrderBook()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1028) | :closed_lock_with_key: | GET | `/api/v3/account/reality-orderbook` | -| [getRealityOrderBookSegmented()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1041) | :closed_lock_with_key: | GET | `/api/v3/account/reality-orderbook-segmented` | -| [getRealityFills()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1053) | :closed_lock_with_key: | GET | `/api/v3/account/reality-fills` | -| [getRealityCompanyOverview()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1059) | | GET | `/api/v3/reality/market/company-overview` | -| [getRealityValuationIndicators()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1065) | | GET | `/api/v3/reality/market/valuation-indicators` | -| [getRealityEarningsForecast()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1071) | | GET | `/api/v3/reality/market/earnings-forecast` | -| [getRealitySuspensionResumptionInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1077) | | GET | `/api/v3/reality/market/suspension-resumption-info` | -| [getRealityDividends()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1086) | | GET | `/api/v3/reality/market/dividends` | -| [getRealityShareCapitalChange()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1092) | | GET | `/api/v3/reality/market/share-capital-change` | -| [getRealityInnerTrades()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1098) | | GET | `/api/v3/reality/market/inner-trades` | -| [getRealityExecutiveShareholdings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1104) | | GET | `/api/v3/reality/market/executive-shareholdings` | -| [getRealityShareholdDetail()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1112) | | GET | `/api/v3/reality/market/sharehold-detail` | -| [getRealityStockInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1118) | | GET | `/api/v3/reality/market/stock-info` | -| [getRealityMarketStates()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1124) | | GET | `/api/v3/reality/market/states` | -| [getRealityMarketCalendar()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1128) | | GET | `/api/v3/reality/market/calendar` | -| [getCopyFuturesTradingPairs()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1143) | :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#L1154) | :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#L1164) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/max-transferable` | -| [getCopyFuturesCopyMaxTransferable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1175) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/copy-max-transferable` | -| [copyFuturesTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1188) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/transfer` | -| [getCopyFuturesTransferRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1198) | :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#L1204) | :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#L1210) | :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#L1216) | :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#L1222) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/profit-details` | -| [getCopyFuturesPortfolioOverview()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1228) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/portfolio-overview` | -| [createCopyFutures()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1234) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/follower-settings` | -| [modifyCopyFuturesFollowerSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1240) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/modify-follower-settings` | -| [unfollowCopyFutures()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1249) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/unfollow` | -| [getCopyFuturesCopySettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1255) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/copy-settings` | -| [copyFuturesFollowerTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1261) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/copy-transfer` | -| [getCopyFuturesFollowerTransferRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1267) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/copy-transfer-record` | -| [getCopyFuturesCurrentCopy()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1273) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/current-copy` | -| [getCopyFuturesCopyProfitDetails()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1279) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/copy-profit-details` | -| [closeCopyFuturesPositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1285) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/close-positions` | -| [closeAllCopyFuturesPositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1291) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/close-all` | -| [getCopyFuturesCurrentPositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1297) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/current-positions` | -| [placeCopyFuturesTpSl()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1303) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/place-tpsl` | -| [modifyCopyFuturesTpSl()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1309) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/modify-tpsl` | -| [cancelCopyFuturesTpSl()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1315) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/cancel-tpsl` | -| [getCopyFuturesCurrentTpSlOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1321) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/current-tpsl-orders` | -| [getCopyFuturesTpSlOrderHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1327) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/tpsl-order-history` | -| [getStockPlusOptionQuote()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1339) | :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#L1345) | :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#L1354) | :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#L1363) | :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#L1369) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/static` | -| [getStockPlusQuote()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1375) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/quote` | -| [getStockPlusTradeDetail()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1381) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/trade` | -| [getStockPlusIntraday()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1387) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/intraday` | -| [getStockPlusHistoryCandlestick()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1393) | :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#L1402) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/candlestick` | -| [getStockPlusDepth()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1408) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/depth` | -| [placeStockPlusOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1414) | :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#L1420) | :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#L1426) | :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#L1432) | :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#L1438) | :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#L1444) | :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#L1450) | :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#L1456) | :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#L1465) | :closed_lock_with_key: | GET | `/api/v3/stockplus/asset/account` | -| [getStockPlusCashFlow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1471) | :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#L1477) | :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#L1483) | :closed_lock_with_key: | POST | `/api/v3/stockplus/asset/transfer` | -| [getStockPlusTransferRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1489) | :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#L1501) | :closed_lock_with_key: | GET | `/api/v3/cfd/market/tickers` | -| [getCfdHistoryCandlestick()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1507) | :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#L1513) | :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#L1519) | :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#L1525) | :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#L1529) | :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#L1535) | :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#L1541) | :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#L1547) | :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#L1558) | :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#L1564) | :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#L1570) | :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#L1574) | :closed_lock_with_key: | POST | `/api/v3/cfd/account/transfer` | -| [getCfdTransferRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1580) | :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#L1586) | :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#L1592) | :closed_lock_with_key: | GET | `/api/v3/cfd/account/instruments` | -| [getBalances()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1607) | :closed_lock_with_key: | GET | `/api/v3/account/assets` | -| [getFundingAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1614) | :closed_lock_with_key: | GET | `/api/v3/account/funding-assets` | -| [getAccountInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1624) | :closed_lock_with_key: | GET | `/api/v3/account/info` | -| [getAccountSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1632) | :closed_lock_with_key: | GET | `/api/v3/account/settings` | -| [adjustAccountMode()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1639) | :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#L1649) | :closed_lock_with_key: | GET | `/api/v3/account/delta-info` | -| [setLeverage()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1658) | :closed_lock_with_key: | POST | `/api/v3/account/set-leverage` | -| [setHoldMode()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1665) | :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#L1674) | :closed_lock_with_key: | GET | `/api/v3/account/collateral-type` | -| [setCollateralType()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1681) | :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#L1690) | | GET | `/api/v3/account/custom-collateral-coins` | -| [preSetLeverage()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1697) | :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#L1706) | :closed_lock_with_key: | POST | `/api/v3/account/set-margin` | -| [getMaxWithdrawal()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1713) | :closed_lock_with_key: | GET | `/api/v3/account/max-withdrawal` | -| [getFinancialRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1722) | :closed_lock_with_key: | GET | `/api/v3/account/financial-records` | -| [getFundingFinancialRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1731) | :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#L1745) | :closed_lock_with_key: | GET | `/api/v3/account/repayable-coins` | -| [getPaymentCoins()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1757) | :closed_lock_with_key: | GET | `/api/v3/account/payment-coins` | -| [submitRepay()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1769) | :closed_lock_with_key: | POST | `/api/v3/account/repay` | -| [borrow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1773) | :closed_lock_with_key: | POST | `/api/v3/account/borrow` | -| [getMaxBorrowable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1777) | :closed_lock_with_key: | GET | `/api/v3/account/max-borrowable` | -| [setRepayMode()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1783) | :closed_lock_with_key: | POST | `/api/v3/account/set-repay-mode` | -| [getConvertRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1792) | :closed_lock_with_key: | GET | `/api/v3/account/convert-records` | -| [getSmallAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1801) | :closed_lock_with_key: | GET | `/api/v3/convert/small-assets` | -| [tradeSmallAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1807) | :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#L1813) | :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#L1828) | :closed_lock_with_key: | POST | `/api/v3/account/deposit-account` | -| [switchDeduct()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1837) | :closed_lock_with_key: | POST | `/api/v3/account/switch-deduct` | -| [getDeductInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1844) | :closed_lock_with_key: | GET | `/api/v3/account/deduct-info` | -| [getFeeRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1855) | :closed_lock_with_key: | GET | `/api/v3/account/fee-rate` | -| [getAllFeeRates()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1867) | :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#L1880) | :closed_lock_with_key: | GET | `/api/v3/account/max-transferable` | -| [getOpenInterestLimit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1892) | :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#L1898) | :closed_lock_with_key: | GET | `/api/v3/account/eligible-symbols` | -| [getEligibleMarginTier()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1904) | :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#L1910) | :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#L1916) | :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#L1931) | :closed_lock_with_key: | POST | `/api/v3/account/switch` | -| [getUnifiedAccountSwitchStatus()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1939) | :closed_lock_with_key: | GET | `/api/v3/account/switch-status` | -| [getTaxRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1955) | :closed_lock_with_key: | GET | `/api/v3/tax/records` | -| [createSubAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1970) | :closed_lock_with_key: | POST | `/api/v3/user/create-sub` | -| [createAgentSubAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1979) | :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#L1988) | :closed_lock_with_key: | POST | `/api/v3/user/freeze-sub` | -| [deleteSubAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1994) | :closed_lock_with_key: | POST | `/api/v3/user/delete-sub` | -| [getSubUnifiedAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2003) | :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#L2012) | :closed_lock_with_key: | GET | `/api/v3/user/sub-list` | -| [createSubAccountApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2025) | :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#L2034) | :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#L2043) | :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#L2052) | :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#L2066) | :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#L2077) | :closed_lock_with_key: | POST | `/api/v3/user/set-rate-limit-quota` | -| [createStpGroup()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2087) | :closed_lock_with_key: | POST | `/api/v3/account/create-stp-groups` | -| [getStpGroups()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2097) | :closed_lock_with_key: | GET | `/api/v3/account/stp-groups` | -| [addStpGroupMembers()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2107) | :closed_lock_with_key: | POST | `/api/v3/account/add-groups-members` | -| [removeStpGroupMembers()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2119) | :closed_lock_with_key: | POST | `/api/v3/account/remove-groups-members` | -| [getTransferableCoins()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2134) | :closed_lock_with_key: | GET | `/api/v3/account/transferable-coins` | -| [submitTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2143) | :closed_lock_with_key: | POST | `/api/v3/account/transfer` | -| [subAccountTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2152) | :closed_lock_with_key: | POST | `/api/v3/account/sub-transfer` | -| [getSubTransferRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2164) | :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#L2176) | :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#L2194) | :closed_lock_with_key: | GET | `/api/v3/account/deposit-address` | -| [getSubDepositAddress()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2203) | :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#L2212) | :closed_lock_with_key: | GET | `/api/v3/account/deposit-records` | -| [getSubDepositRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2221) | :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#L2236) | :closed_lock_with_key: | POST | `/api/v3/account/withdraw` | -| [getWithdrawRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2245) | :closed_lock_with_key: | GET | `/api/v3/account/withdrawal-records` | -| [getWithdrawAddressBook()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2254) | :closed_lock_with_key: | GET | `/api/v3/account/withdraw-address` | -| [cancelWithdrawal()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2263) | :closed_lock_with_key: | POST | `/api/v3/account/cancel-withdrawal` | -| [submitNewOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2281) | :closed_lock_with_key: | POST | `/api/v3/trade/place-order` | -| [modifyOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2290) | :closed_lock_with_key: | POST | `/api/v3/trade/modify-order` | -| [placeRealityOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2299) | :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#L2308) | :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#L2317) | :closed_lock_with_key: | GET | `/api/v3/trade/loan-data` | -| [cancelOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2324) | :closed_lock_with_key: | POST | `/api/v3/trade/cancel-order` | -| [placeBatchOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2333) | :closed_lock_with_key: | POST | `/api/v3/trade/place-batch` | -| [batchModifyOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2342) | :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#L2351) | :closed_lock_with_key: | POST | `/api/v3/trade/cancel-batch` | -| [cancelAllOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2360) | :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#L2369) | :closed_lock_with_key: | POST | `/api/v3/trade/close-positions` | -| [getOrderInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2378) | :closed_lock_with_key: | GET | `/api/v3/trade/order-info` | -| [getUnfilledOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2387) | :closed_lock_with_key: | GET | `/api/v3/trade/unfilled-orders` | -| [getHistoryOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2399) | :closed_lock_with_key: | GET | `/api/v3/trade/history-orders` | -| [movePositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2411) | :closed_lock_with_key: | POST | `/api/v3/account/move-positions` | -| [getMovePositionHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2420) | :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#L2432) | :closed_lock_with_key: | GET | `/api/v3/trade/fills` | -| [getCurrentPosition()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2444) | :closed_lock_with_key: | GET | `/api/v3/position/current-position` | -| [getPositionHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2455) | :closed_lock_with_key: | GET | `/api/v3/position/history-position` | -| [getMaxOpenAvailable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2469) | :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#L2478) | :closed_lock_with_key: | GET | `/api/v3/position/adlRank` | -| [countdownCancelAll()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2485) | :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#L2500) | :closed_lock_with_key: | GET | `/api/v3/ins-loan/transfered` | -| [getLoanSymbols()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2509) | :closed_lock_with_key: | GET | `/api/v3/ins-loan/symbols` | -| [getLoanRiskUnit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2518) | :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#L2529) | :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#L2538) | :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#L2547) | :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#L2556) | :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#L2565) | :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#L2577) | :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#L2592) | :closed_lock_with_key: | GET | `/api/v3/loan/coins` | -| [getLoanInterest()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2601) | :closed_lock_with_key: | GET | `/api/v3/loan/interest` | -| [loanBorrow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2610) | :closed_lock_with_key: | POST | `/api/v3/loan/borrow` | -| [getLoanBorrowOngoing()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2619) | :closed_lock_with_key: | GET | `/api/v3/loan/borrow-ongoing` | -| [getLoanBorrowHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2628) | :closed_lock_with_key: | GET | `/api/v3/loan/borrow-history` | -| [loanRepay()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2637) | :closed_lock_with_key: | POST | `/api/v3/loan/repay` | -| [getLoanRepayHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2646) | :closed_lock_with_key: | GET | `/api/v3/loan/repay-history` | -| [loanRevisePledge()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2655) | :closed_lock_with_key: | POST | `/api/v3/loan/revise-pledge` | -| [getLoanPledgeRateHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2664) | :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#L2673) | :closed_lock_with_key: | GET | `/api/v3/loan/debts` | -| [getLoanReduces()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2680) | :closed_lock_with_key: | GET | `/api/v3/loan/reduces` | -| [submitStrategyOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2695) | :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#L2704) | :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#L2713) | :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#L2722) | :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#L2731) | :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#L2741) | :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#L2756) | :closed_lock_with_key: | POST | `/api/v3/trade/grid/validate` | -| [createGridBot()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2762) | :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#L2768) | :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#L2774) | :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#L2780) | :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#L2786) | :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#L2792) | :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#L2798) | :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#L2804) | :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#L2810) | :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#L2816) | :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#L2822) | :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#L2831) | :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#L2837) | :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#L2855) | :closed_lock_with_key: | POST | `/api/v3/broker/create-sub` | -| [getBrokerSubAccountList()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2867) | :closed_lock_with_key: | GET | `/api/v3/broker/sub-list` | -| [modifyBrokerSubAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2879) | :closed_lock_with_key: | POST | `/api/v3/broker/modify-sub` | -| [brokerSubWithdrawal()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2894) | :closed_lock_with_key: | POST | `/api/v3/broker/sub-withdrawal` | -| [getBrokerSubDepositAddress()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2906) | :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#L2918) | :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#L2930) | :closed_lock_with_key: | GET | `/api/v3/broker/commission` | -| [createBrokerSubApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2942) | :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#L2954) | :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#L2970) | :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#L2982) | :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#L2994) | :closed_lock_with_key: | GET | `/api/v3/p2p/ad-list` | -| [getP2pExchangeRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3000) | :closed_lock_with_key: | GET | `/api/v3/p2p/exchange-rate` | -| [simulateP2pFee()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3006) | :closed_lock_with_key: | POST | `/api/v3/p2p/fee-simulate` | -| [getP2pAdLimit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3012) | :closed_lock_with_key: | GET | `/api/v3/p2p/ad-limit` | -| [createP2pAd()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3018) | :closed_lock_with_key: | POST | `/api/v3/p2p/ad-create` | -| [updateP2pAd()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3024) | :closed_lock_with_key: | POST | `/api/v3/p2p/ad-update` | -| [operateP2pAd()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3028) | :closed_lock_with_key: | POST | `/api/v3/p2p/ad-operate` | -| [getP2pAdInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3032) | :closed_lock_with_key: | GET | `/api/v3/p2p/ad-info` | -| [getP2pMyAds()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3038) | :closed_lock_with_key: | GET | `/api/v3/p2p/my-ads` | -| [getP2pPendingOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3044) | :closed_lock_with_key: | GET | `/api/v3/p2p/pending-orders` | -| [getP2pAllOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3050) | :closed_lock_with_key: | GET | `/api/v3/p2p/all-orders` | -| [getP2pOrderInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3056) | :closed_lock_with_key: | GET | `/api/v3/p2p/order-info` | -| [confirmP2pOrderPayment()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3062) | :closed_lock_with_key: | POST | `/api/v3/p2p/order-pay` | -| [releaseP2pOrderAsset()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3068) | :closed_lock_with_key: | POST | `/api/v3/p2p/order-release` | -| [getP2pUserInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3074) | :closed_lock_with_key: | GET | `/api/v3/p2p/user-info` | -| [getP2pCurrencies()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3078) | :closed_lock_with_key: | GET | `/api/v3/p2p/currencies` | -| [getP2pPayMethods()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3082) | :closed_lock_with_key: | GET | `/api/v3/p2p/pay-method` | -| [getP2pBalance()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3086) | :closed_lock_with_key: | GET | `/api/v3/p2p/balance` | -| [getEarnEliteProducts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3098) | :closed_lock_with_key: | GET | `/api/v3/earn/elite-product` | -| [getEarnEliteAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3102) | :closed_lock_with_key: | GET | `/api/v3/earn/elite-assets` | -| [getEarnEliteRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3106) | :closed_lock_with_key: | GET | `/api/v3/earn/elite-records` | -| [getEarnEliteSubscribeInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3112) | :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#L3118) | :closed_lock_with_key: | POST | `/api/v3/earn/elite-subscribe` | -| [getEarnEliteSubscribeResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3124) | :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#L3130) | :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#L3136) | :closed_lock_with_key: | POST | `/api/v3/earn/elite-redeem` | -| [getEarnCashPlusSubscribeInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3153) | :closed_lock_with_key: | GET | `/api/v3/earn/cashplus/subscribe-info` | -| [subscribeEarnCashPlus()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3162) | :closed_lock_with_key: | POST | `/api/v3/earn/cashplus/subscribe` | -| [getEarnCashPlusSubscribeResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3171) | :closed_lock_with_key: | GET | `/api/v3/earn/cashplus/subscribe-result` | -| [getEarnCashPlusRedeemInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3181) | :closed_lock_with_key: | GET | `/api/v3/earn/cashplus/redeem-info` | -| [redeemEarnCashPlus()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3188) | :closed_lock_with_key: | POST | `/api/v3/earn/cashplus/redeem` | -| [getEarnCashPlusRedeemResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3197) | :closed_lock_with_key: | GET | `/api/v3/earn/cashplus/redeem-result` | -| [getEarnCashPlusPositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3206) | :closed_lock_with_key: | GET | `/api/v3/earn/cashplus/positions` | -| [getEarnCashPlusHistoryOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3213) | :closed_lock_with_key: | GET | `/api/v3/earn/cashplus/history-orders` | +| [getServerTime()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L647) | | GET | `/api/v3/market/time` | +| [getAnnouncements()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L661) | | GET | `/api/v3/public/annoucements` | +| [getInstruments()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L680) | | GET | `/api/v3/market/instruments` | +| [getMarketFeeGroup()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L689) | | GET | `/api/v3/market/fee-group` | +| [getLiquidations()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L698) | | GET | `/api/v3/market/liquidations` | +| [getRpiSymbols()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L707) | | GET | `/api/v3/market/rpi-symbols` | +| [getRpiOrderBook()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L714) | | GET | `/api/v3/market/rpi-orderbook` | +| [getCashDividendRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L723) | | GET | `/api/v3/market/cash-dividend-records` | +| [getSplitRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L729) | | GET | `/api/v3/market/split-records` | +| [getSpotWhaleFlow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L738) | | GET | `/api/v3/market/spot-whale-flow` | +| [getSpotFundFlow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L747) | | GET | `/api/v3/market/spot-fund-flow` | +| [getSpotNetFlow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L756) | | GET | `/api/v3/market/spot-net-flow` | +| [getMarginLongShort()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L765) | | GET | `/api/v3/market/margin-long-short` | +| [getMarginLoanGrowth()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L774) | | GET | `/api/v3/market/margin-loan-growth` | +| [getMarginIsolatedBorrow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L783) | | GET | `/api/v3/market/margin-isolated-borrow` | +| [getFuturesActiveBuySell()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L792) | | GET | `/api/v3/market/futures-active-buy-sell` | +| [getFuturesLongShort()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L801) | | GET | `/api/v3/market/futures-long-short` | +| [getFuturesPositionLongShort()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L810) | | GET | `/api/v3/market/futures-position-long-short` | +| [getFuturesAccountLongShort()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L819) | | GET | `/api/v3/market/futures-account-long-short` | +| [getMarketScoreWeights()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L828) | | GET | `/api/v3/market/score-weights` | +| [getTickers()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L837) | | GET | `/api/v3/market/tickers` | +| [getOrderBook()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L847) | | GET | `/api/v3/market/orderbook` | +| [getFills()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L856) | | GET | `/api/v3/market/fills` | +| [getProofOfReserves()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L865) | | GET | `/api/v3/market/proof-of-reserves` | +| [getOpenInterest()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L872) | | GET | `/api/v3/market/open-interest` | +| [getOpenInterestHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L882) | | GET | `/api/v3/market/open-interest-history` | +| [getCoins()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L893) | | GET | `/api/v3/market/coins` | +| [getCandles()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L901) | | GET | `/api/v3/market/candles` | +| [getHistoryCandles()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L910) | | GET | `/api/v3/market/history-candles` | +| [getCurrentFundingRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L919) | | GET | `/api/v3/market/current-fund-rate` | +| [getHistoryFundingRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L928) | | GET | `/api/v3/market/history-fund-rate` | +| [getRiskReserve()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L937) | | GET | `/api/v3/market/risk-reserve` | +| [getRiskReserveHour()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L946) | | GET | `/api/v3/market/risk-reserve-hour` | +| [getRiskReserveAll()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L955) | | GET | `/api/v3/market/risk-reserve-all` | +| [getDiscountRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L964) | | GET | `/api/v3/market/discount-rate` | +| [getInterestRateHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L973) | | GET | `/api/v3/market/interest-rate-history` | +| [getMarginLoans()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L982) | | GET | `/api/v3/market/margin-loans` | +| [getMarginLoansAll()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L992) | | GET | `/api/v3/market/margin-loans-all` | +| [getPositionTier()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1001) | | GET | `/api/v3/market/position-tier` | +| [getContractsOi()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1010) | | GET | `/api/v3/market/oi-limit` | +| [getIndexComponents()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1019) | | GET | `/api/v3/market/index-components` | +| [getRealityOrderBook()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1030) | :closed_lock_with_key: | GET | `/api/v3/account/reality-orderbook` | +| [getRealityOrderBookSegmented()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1043) | :closed_lock_with_key: | GET | `/api/v3/account/reality-orderbook-segmented` | +| [getRealityFills()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1055) | :closed_lock_with_key: | GET | `/api/v3/account/reality-fills` | +| [getRealityCompanyOverview()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1061) | | GET | `/api/v3/reality/market/company-overview` | +| [getRealityValuationIndicators()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1067) | | GET | `/api/v3/reality/market/valuation-indicators` | +| [getRealityEarningsForecast()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1073) | | GET | `/api/v3/reality/market/earnings-forecast` | +| [getRealitySuspensionResumptionInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1079) | | GET | `/api/v3/reality/market/suspension-resumption-info` | +| [getRealityDividends()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1088) | | GET | `/api/v3/reality/market/dividends` | +| [getRealityShareCapitalChange()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1094) | | GET | `/api/v3/reality/market/share-capital-change` | +| [getRealityInnerTrades()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1100) | | GET | `/api/v3/reality/market/inner-trades` | +| [getRealityExecutiveShareholdings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1106) | | GET | `/api/v3/reality/market/executive-shareholdings` | +| [getRealityShareholdDetail()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1114) | | GET | `/api/v3/reality/market/sharehold-detail` | +| [getRealityStockInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1120) | | GET | `/api/v3/reality/market/stock-info` | +| [getRealityMarketStates()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1126) | | GET | `/api/v3/reality/market/states` | +| [getRealityMarketCalendar()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1130) | | GET | `/api/v3/reality/market/calendar` | +| [getCopyFuturesTradingPairs()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1145) | :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#L1156) | :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#L1166) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/max-transferable` | +| [getCopyFuturesCopyMaxTransferable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1177) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/copy-max-transferable` | +| [copyFuturesTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1190) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/transfer` | +| [getCopyFuturesTransferRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1200) | :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#L1206) | :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#L1212) | :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#L1218) | :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#L1224) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/profit-details` | +| [getCopyFuturesPortfolioOverview()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1230) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/portfolio-overview` | +| [createCopyFutures()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1236) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/follower-settings` | +| [modifyCopyFuturesFollowerSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1242) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/modify-follower-settings` | +| [unfollowCopyFutures()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1251) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/unfollow` | +| [getCopyFuturesCopySettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1257) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/copy-settings` | +| [copyFuturesFollowerTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1263) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/copy-transfer` | +| [getCopyFuturesFollowerTransferRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1269) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/copy-transfer-record` | +| [getCopyFuturesCurrentCopy()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1275) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/current-copy` | +| [getCopyFuturesCopyProfitDetails()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1281) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/copy-profit-details` | +| [closeCopyFuturesPositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1287) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/close-positions` | +| [closeAllCopyFuturesPositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1293) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/close-all` | +| [getCopyFuturesCurrentPositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1299) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/current-positions` | +| [placeCopyFuturesTpSl()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1305) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/place-tpsl` | +| [modifyCopyFuturesTpSl()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1311) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/modify-tpsl` | +| [cancelCopyFuturesTpSl()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1317) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/cancel-tpsl` | +| [getCopyFuturesCurrentTpSlOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1323) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/current-tpsl-orders` | +| [getCopyFuturesTpSlOrderHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1329) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/tpsl-order-history` | +| [getStockPlusOptionQuote()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1341) | :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#L1347) | :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#L1356) | :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#L1365) | :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#L1371) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/static` | +| [getStockPlusQuote()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1377) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/quote` | +| [getStockPlusTradeDetail()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1383) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/trade` | +| [getStockPlusIntraday()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1389) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/intraday` | +| [getStockPlusHistoryCandlestick()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1395) | :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#L1404) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/candlestick` | +| [getStockPlusDepth()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1410) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/depth` | +| [placeStockPlusOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1416) | :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#L1422) | :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#L1428) | :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#L1434) | :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#L1440) | :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#L1446) | :closed_lock_with_key: | GET | `/api/v3/stockplus/trade/order-detail` | +| [getStockPlusMaxPurchase()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1452) | :closed_lock_with_key: | GET | `/api/v3/stockplus/trade/max-purchase` | +| [getStockPlusTodayExecutions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1458) | :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#L1464) | :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#L1473) | :closed_lock_with_key: | GET | `/api/v3/stockplus/asset/account` | +| [getStockPlusCashFlow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1479) | :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#L1485) | :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#L1491) | :closed_lock_with_key: | POST | `/api/v3/stockplus/asset/transfer` | +| [getStockPlusTransferRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1497) | :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#L1509) | :closed_lock_with_key: | GET | `/api/v3/cfd/market/tickers` | +| [getCfdHistoryCandlestick()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1515) | :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#L1521) | :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#L1527) | :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#L1533) | :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#L1537) | :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#L1543) | :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#L1549) | :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#L1555) | :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#L1566) | :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#L1572) | :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#L1578) | :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#L1582) | :closed_lock_with_key: | POST | `/api/v3/cfd/account/transfer` | +| [getCfdTransferRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1588) | :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#L1594) | :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#L1600) | :closed_lock_with_key: | GET | `/api/v3/cfd/account/instruments` | +| [getBalances()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1615) | :closed_lock_with_key: | GET | `/api/v3/account/assets` | +| [getFundingAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1622) | :closed_lock_with_key: | GET | `/api/v3/account/funding-assets` | +| [getAccountInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1632) | :closed_lock_with_key: | GET | `/api/v3/account/info` | +| [getAccountSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1640) | :closed_lock_with_key: | GET | `/api/v3/account/settings` | +| [adjustAccountMode()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1647) | :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#L1657) | :closed_lock_with_key: | GET | `/api/v3/account/delta-info` | +| [setLeverage()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1666) | :closed_lock_with_key: | POST | `/api/v3/account/set-leverage` | +| [setHoldMode()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1673) | :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#L1682) | :closed_lock_with_key: | GET | `/api/v3/account/collateral-type` | +| [setCollateralType()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1689) | :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#L1698) | | GET | `/api/v3/account/custom-collateral-coins` | +| [preSetLeverage()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1705) | :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#L1714) | :closed_lock_with_key: | POST | `/api/v3/account/set-margin` | +| [getMaxWithdrawal()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1721) | :closed_lock_with_key: | GET | `/api/v3/account/max-withdrawal` | +| [getFinancialRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1730) | :closed_lock_with_key: | GET | `/api/v3/account/financial-records` | +| [getFundingFinancialRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1744) | :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#L1758) | :closed_lock_with_key: | GET | `/api/v3/account/repayable-coins` | +| [getPaymentCoins()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1770) | :closed_lock_with_key: | GET | `/api/v3/account/payment-coins` | +| [submitRepay()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1782) | :closed_lock_with_key: | POST | `/api/v3/account/repay` | +| [borrow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1786) | :closed_lock_with_key: | POST | `/api/v3/account/borrow` | +| [getMaxBorrowable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1790) | :closed_lock_with_key: | GET | `/api/v3/account/max-borrowable` | +| [setRepayMode()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1796) | :closed_lock_with_key: | POST | `/api/v3/account/set-repay-mode` | +| [getConvertRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1805) | :closed_lock_with_key: | GET | `/api/v3/account/convert-records` | +| [getSmallAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1814) | :closed_lock_with_key: | GET | `/api/v3/convert/small-assets` | +| [tradeSmallAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1820) | :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#L1826) | :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#L1841) | :closed_lock_with_key: | POST | `/api/v3/account/deposit-account` | +| [switchDeduct()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1850) | :closed_lock_with_key: | POST | `/api/v3/account/switch-deduct` | +| [getDeductInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1857) | :closed_lock_with_key: | GET | `/api/v3/account/deduct-info` | +| [getFeeRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1868) | :closed_lock_with_key: | GET | `/api/v3/account/fee-rate` | +| [getAllFeeRates()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1880) | :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#L1893) | :closed_lock_with_key: | GET | `/api/v3/account/max-transferable` | +| [getOpenInterestLimit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1905) | :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#L1911) | :closed_lock_with_key: | GET | `/api/v3/account/eligible-symbols` | +| [getEligibleMarginTier()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1917) | :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#L1923) | :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#L1929) | :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#L1944) | :closed_lock_with_key: | POST | `/api/v3/account/switch` | +| [getUnifiedAccountSwitchStatus()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1952) | :closed_lock_with_key: | GET | `/api/v3/account/switch-status` | +| [getTaxRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1968) | :closed_lock_with_key: | GET | `/api/v3/tax/records` | +| [createSubAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1983) | :closed_lock_with_key: | POST | `/api/v3/user/create-sub` | +| [createAgentSubAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1992) | :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#L2001) | :closed_lock_with_key: | POST | `/api/v3/user/freeze-sub` | +| [deleteSubAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2007) | :closed_lock_with_key: | POST | `/api/v3/user/delete-sub` | +| [getSubUnifiedAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2016) | :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#L2025) | :closed_lock_with_key: | GET | `/api/v3/user/sub-list` | +| [createSubAccountApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2038) | :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#L2047) | :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#L2056) | :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#L2065) | :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#L2079) | :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#L2090) | :closed_lock_with_key: | POST | `/api/v3/user/set-rate-limit-quota` | +| [createStpGroup()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2100) | :closed_lock_with_key: | POST | `/api/v3/account/create-stp-groups` | +| [getStpGroups()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2110) | :closed_lock_with_key: | GET | `/api/v3/account/stp-groups` | +| [addStpGroupMembers()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2120) | :closed_lock_with_key: | POST | `/api/v3/account/add-groups-members` | +| [removeStpGroupMembers()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2132) | :closed_lock_with_key: | POST | `/api/v3/account/remove-groups-members` | +| [getTransferableCoins()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2147) | :closed_lock_with_key: | GET | `/api/v3/account/transferable-coins` | +| [submitTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2156) | :closed_lock_with_key: | POST | `/api/v3/account/transfer` | +| [subAccountTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2165) | :closed_lock_with_key: | POST | `/api/v3/account/sub-transfer` | +| [getSubTransferRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2177) | :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#L2189) | :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#L2207) | :closed_lock_with_key: | GET | `/api/v3/account/deposit-address` | +| [getSubDepositAddress()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2216) | :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#L2225) | :closed_lock_with_key: | GET | `/api/v3/account/deposit-records` | +| [getSubDepositRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2234) | :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#L2249) | :closed_lock_with_key: | POST | `/api/v3/account/withdraw` | +| [getWithdrawRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2258) | :closed_lock_with_key: | GET | `/api/v3/account/withdrawal-records` | +| [getWithdrawAddressBook()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2267) | :closed_lock_with_key: | GET | `/api/v3/account/withdraw-address` | +| [cancelWithdrawal()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2276) | :closed_lock_with_key: | POST | `/api/v3/account/cancel-withdrawal` | +| [submitNewOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2294) | :closed_lock_with_key: | POST | `/api/v3/trade/place-order` | +| [modifyOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2303) | :closed_lock_with_key: | POST | `/api/v3/trade/modify-order` | +| [placeRealityOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2312) | :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#L2321) | :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#L2330) | :closed_lock_with_key: | GET | `/api/v3/trade/loan-data` | +| [cancelOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2337) | :closed_lock_with_key: | POST | `/api/v3/trade/cancel-order` | +| [placeBatchOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2346) | :closed_lock_with_key: | POST | `/api/v3/trade/place-batch` | +| [batchModifyOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2355) | :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#L2364) | :closed_lock_with_key: | POST | `/api/v3/trade/cancel-batch` | +| [cancelAllOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2373) | :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#L2382) | :closed_lock_with_key: | POST | `/api/v3/trade/close-positions` | +| [getOrderInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2391) | :closed_lock_with_key: | GET | `/api/v3/trade/order-info` | +| [getUnfilledOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2400) | :closed_lock_with_key: | GET | `/api/v3/trade/unfilled-orders` | +| [getHistoryOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2412) | :closed_lock_with_key: | GET | `/api/v3/trade/history-orders` | +| [movePositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2424) | :closed_lock_with_key: | POST | `/api/v3/account/move-positions` | +| [getMovePositionHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2433) | :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#L2445) | :closed_lock_with_key: | GET | `/api/v3/trade/fills` | +| [getCurrentPosition()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2457) | :closed_lock_with_key: | GET | `/api/v3/position/current-position` | +| [getPositionHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2472) | :closed_lock_with_key: | GET | `/api/v3/position/history-position` | +| [getMaxOpenAvailable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2486) | :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#L2495) | :closed_lock_with_key: | GET | `/api/v3/position/adlRank` | +| [countdownCancelAll()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2502) | :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#L2517) | :closed_lock_with_key: | GET | `/api/v3/ins-loan/transfered` | +| [getLoanSymbols()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2526) | :closed_lock_with_key: | GET | `/api/v3/ins-loan/symbols` | +| [getLoanRiskUnit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2535) | :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#L2546) | :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#L2555) | :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#L2564) | :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#L2573) | :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#L2582) | :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#L2594) | :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#L2609) | :closed_lock_with_key: | GET | `/api/v3/loan/coins` | +| [getLoanInterest()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2618) | :closed_lock_with_key: | GET | `/api/v3/loan/interest` | +| [loanBorrow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2627) | :closed_lock_with_key: | POST | `/api/v3/loan/borrow` | +| [getLoanBorrowOngoing()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2636) | :closed_lock_with_key: | GET | `/api/v3/loan/borrow-ongoing` | +| [getLoanBorrowHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2645) | :closed_lock_with_key: | GET | `/api/v3/loan/borrow-history` | +| [loanRepay()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2654) | :closed_lock_with_key: | POST | `/api/v3/loan/repay` | +| [getLoanRepayHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2663) | :closed_lock_with_key: | GET | `/api/v3/loan/repay-history` | +| [loanRevisePledge()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2672) | :closed_lock_with_key: | POST | `/api/v3/loan/revise-pledge` | +| [getLoanPledgeRateHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2681) | :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#L2690) | :closed_lock_with_key: | GET | `/api/v3/loan/debts` | +| [getLoanReduces()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2697) | :closed_lock_with_key: | GET | `/api/v3/loan/reduces` | +| [submitStrategyOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2712) | :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#L2721) | :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#L2730) | :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#L2739) | :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#L2748) | :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#L2758) | :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#L2773) | :closed_lock_with_key: | POST | `/api/v3/trade/grid/validate` | +| [createGridBot()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2779) | :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#L2785) | :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#L2791) | :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#L2797) | :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#L2803) | :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#L2809) | :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#L2815) | :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#L2821) | :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#L2827) | :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#L2833) | :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#L2839) | :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#L2848) | :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#L2854) | :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#L2872) | :closed_lock_with_key: | POST | `/api/v3/broker/create-sub` | +| [getBrokerSubAccountList()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2884) | :closed_lock_with_key: | GET | `/api/v3/broker/sub-list` | +| [modifyBrokerSubAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2896) | :closed_lock_with_key: | POST | `/api/v3/broker/modify-sub` | +| [brokerSubWithdrawal()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2911) | :closed_lock_with_key: | POST | `/api/v3/broker/sub-withdrawal` | +| [getBrokerSubDepositAddress()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2923) | :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#L2935) | :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#L2947) | :closed_lock_with_key: | GET | `/api/v3/broker/commission` | +| [createBrokerSubApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2959) | :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#L2971) | :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#L2987) | :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#L2999) | :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#L3011) | :closed_lock_with_key: | GET | `/api/v3/p2p/ad-list` | +| [getP2pExchangeRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3017) | :closed_lock_with_key: | GET | `/api/v3/p2p/exchange-rate` | +| [simulateP2pFee()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3023) | :closed_lock_with_key: | POST | `/api/v3/p2p/fee-simulate` | +| [getP2pAdLimit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3029) | :closed_lock_with_key: | GET | `/api/v3/p2p/ad-limit` | +| [createP2pAd()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3035) | :closed_lock_with_key: | POST | `/api/v3/p2p/ad-create` | +| [updateP2pAd()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3041) | :closed_lock_with_key: | POST | `/api/v3/p2p/ad-update` | +| [operateP2pAd()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3045) | :closed_lock_with_key: | POST | `/api/v3/p2p/ad-operate` | +| [getP2pAdInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3049) | :closed_lock_with_key: | GET | `/api/v3/p2p/ad-info` | +| [getP2pMyAds()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3055) | :closed_lock_with_key: | GET | `/api/v3/p2p/my-ads` | +| [getP2pPendingOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3061) | :closed_lock_with_key: | GET | `/api/v3/p2p/pending-orders` | +| [getP2pAllOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3067) | :closed_lock_with_key: | GET | `/api/v3/p2p/all-orders` | +| [getP2pOrderInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3073) | :closed_lock_with_key: | GET | `/api/v3/p2p/order-info` | +| [confirmP2pOrderPayment()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3079) | :closed_lock_with_key: | POST | `/api/v3/p2p/order-pay` | +| [releaseP2pOrderAsset()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3085) | :closed_lock_with_key: | POST | `/api/v3/p2p/order-release` | +| [getP2pUserInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3091) | :closed_lock_with_key: | GET | `/api/v3/p2p/user-info` | +| [getP2pCurrencies()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3095) | :closed_lock_with_key: | GET | `/api/v3/p2p/currencies` | +| [getP2pPayMethods()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3099) | :closed_lock_with_key: | GET | `/api/v3/p2p/pay-method` | +| [getP2pBalance()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3103) | :closed_lock_with_key: | GET | `/api/v3/p2p/balance` | +| [getEarnEliteProducts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3115) | :closed_lock_with_key: | GET | `/api/v3/earn/elite-product` | +| [getEarnEliteAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3119) | :closed_lock_with_key: | GET | `/api/v3/earn/elite-assets` | +| [getEarnEliteRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3123) | :closed_lock_with_key: | GET | `/api/v3/earn/elite-records` | +| [getEarnEliteSubscribeInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3129) | :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#L3135) | :closed_lock_with_key: | POST | `/api/v3/earn/elite-subscribe` | +| [getEarnEliteSubscribeResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3141) | :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#L3147) | :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#L3153) | :closed_lock_with_key: | POST | `/api/v3/earn/elite-redeem` | +| [getEarnCashPlusSubscribeInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3170) | :closed_lock_with_key: | GET | `/api/v3/earn/cashplus/subscribe-info` | +| [subscribeEarnCashPlus()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3179) | :closed_lock_with_key: | POST | `/api/v3/earn/cashplus/subscribe` | +| [getEarnCashPlusSubscribeResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3188) | :closed_lock_with_key: | GET | `/api/v3/earn/cashplus/subscribe-result` | +| [getEarnCashPlusRedeemInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3198) | :closed_lock_with_key: | GET | `/api/v3/earn/cashplus/redeem-info` | +| [redeemEarnCashPlus()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3205) | :closed_lock_with_key: | POST | `/api/v3/earn/cashplus/redeem` | +| [getEarnCashPlusRedeemResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3214) | :closed_lock_with_key: | GET | `/api/v3/earn/cashplus/redeem-result` | +| [getEarnCashPlusPositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3223) | :closed_lock_with_key: | GET | `/api/v3/earn/cashplus/positions` | +| [getEarnCashPlusHistoryOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3230) | :closed_lock_with_key: | GET | `/api/v3/earn/cashplus/history-orders` | # websocket-api-client.ts diff --git a/llms.txt b/llms.txt index 5d8679c4..430ea383 100644 --- a/llms.txt +++ b/llms.txt @@ -2486,2254 +2486,2077 @@ export interface RedeemEarnEliteRequestV2 { } ================ -File: src/types/request/v2/futures.ts +File: src/types/request/v2/instloan.ts ================ -import { FuturesPlanTypeV2, FuturesProductTypeV2 } from '../shared.js'; -⋮---- -export type FuturesKlineInterval = - | '1m' - | '3m' - | '5m' - | '15m' - | '30m' - | '1H' - | '2H' - | '4H' - | '6H' - | '12H' - | '1D' - | '3D' - | '1W' - | '1M' - | '6Hutc' - | '12Hutc' - | '1Dutc' - | '3Dutc' - | '1Wutc' - | '1Mutc'; +export interface GetInstLoanProductInfoRequestV2 { + productId: string; +} ⋮---- -export type FuturesKlineTypeV2 = 'MARKET' | 'MARK' | 'INDEX'; +export interface GetInstLoanSymbolsRequestV2 { + productId: string; +} ⋮---- -export interface FuturesAccountBillRequestV2 { - productType: FuturesProductTypeV2; - symbol?: string; - coin?: string; - businessType?: string; - idLessThan?: string; +export interface GetInstLoanRepaidHistoryRequestV2 { startTime?: string; endTime?: string; limit?: string; } ⋮---- -/** - * - * * Futures | Market - * - */ +export interface GetInstLoanOrderRequestV2 { + orderId?: string; + startTime?: string; + endTime?: string; +} ⋮---- -export interface FuturesMergeDepthRequestV2 { - symbol: string; - productType: FuturesProductTypeV2; - precision?: 'scale0' | 'scale1' | 'scale2' | 'scale3'; - limit?: '1' | '5' | '15' | '50' | 'max'; +export interface GetInstLoanLTVConvertRequestV2 { + riskUnitId?: string; } ⋮---- -export interface FuturesOiLimitRequestV2 { - productType: FuturesProductTypeV2; - symbol?: string; +export interface GetInstLoanMarginCoinInfoRequestV2 { + productId: string; } + +================ +File: src/types/request/v2/spot.ts +================ +type SpotKlineIntervalV2 = + | '1min' + | '5min' + | '15min' + | '30min' + | '1h' + | '4h' + | '6h' + | '12h' + | '1day' + | '3day' + | '1week' + | '1M' + | '6Hutc' + | '12Hutc' + | '1Dutc' + | '3Dutc' + | '1Wutc' + | '1Mutc'; ⋮---- -export interface FuturesPositionAdlRankRequestV2 { - productType: FuturesProductTypeV2; +export interface SpotCandlesRequestV2 { + symbol: string; + granularity: SpotKlineIntervalV2; + startTime?: string; + endTime?: string; + limit?: string; } ⋮---- -export interface FuturesRecentTradesRequestV2 { +export interface SpotHistoricCandlesRequestV2 { symbol: string; - productType: FuturesProductTypeV2; + granularity: SpotKlineIntervalV2; + endTime?: string; limit?: string; } ⋮---- -export interface FuturesHistoricTradesRequestV2 { +export interface SpotHistoricTradesRequestV2 { symbol: string; - productType: FuturesProductTypeV2; limit?: string; idLessThan?: string; startTime?: string; endTime?: string; } ⋮---- -export interface FuturesCandlesRequestV2 { +export interface SpotCallAuctionRequestV2 { symbol: string; - productType: FuturesProductTypeV2; - granularity: FuturesKlineInterval; - startTime?: string; - endTime?: string; - kLineType?: FuturesKlineTypeV2; - limit?: string; } ⋮---- /** * - * * Futures | Account + * * Spot | Trade * */ ⋮---- -export interface FuturesSingleAccountRequestV2 { - symbol: string; - productType: FuturesProductTypeV2; - marginCoin: string; -} +export type SpotOrderSideV2 = 'buy' | 'sell'; ⋮---- -export interface FuturesInterestHistoryRequestV2 { - productType: 'USDT-FUTURES' | 'SUSDT-FUTURES'; - coin?: string; - idLessThan?: string; - startTime?: string; - endTime?: string; - limit?: string; -} +export type SpotOrderTypeV2 = 'limit' | 'market'; ⋮---- -export interface FuturesOpenCountRequestV2 { - symbol: string; - productType: FuturesProductTypeV2; - marginCoin: string; - openAmount: string; - openPrice: string; - leverage?: string; -} +export type SpotOrderForceV2 = 'gtc' | 'post_only' | 'fok' | 'ioc'; ⋮---- -export interface FuturesSetAutoMarginRequestV2 { - symbol: string; - autoMargin: 'on' | 'off'; - marginCoin: string; - amount: string; - holdSide?: 'long' | 'short'; -} +export type SpotTPSLTypeV2 = 'normal' | 'tpsl'; ⋮---- -export interface FuturesSetLeverageRequestV2 { - symbol: string; - productType: FuturesProductTypeV2; - marginCoin: string; - leverage: string; - holdSide?: 'long' | 'short'; -} +export type SpotSTPModeV2 = + | 'none' + | 'cancel_taker' + | 'cancel_maker' + | 'cancel_both'; ⋮---- -export interface FuturesSetPositionMarginRequestV2 { - symbol: string; - productType: FuturesProductTypeV2; - marginCoin: string; - holdSide: 'long' | 'short'; - amount: string; -} +export type SpotBatchModeV2 = 'single' | 'multiple'; ⋮---- -export interface FuturesSetMarginModeRequestV2 { +export interface SpotOrderRequestV2 { symbol: string; - productType: FuturesProductTypeV2; - marginCoin: string; - marginMode: 'isolated' | 'crossed'; -} -⋮---- -/** - * - * * Futures | Position - * - */ -⋮---- -export interface FuturesHistoricalPositionsRequestV2 { - symbol?: string; - productType?: FuturesProductTypeV2; - idLessThan?: string; - startTime?: string; - endTime?: string; - limit?: string; + side: SpotOrderSideV2; + orderType: SpotOrderTypeV2; + force: SpotOrderForceV2; + price?: string; + size: string; + clientOid?: string; + triggerPrice?: string; + tpslType?: SpotTPSLTypeV2; + requestTime?: string; + receiveWindow?: string; + stpMode?: SpotSTPModeV2; + presetTakeProfitPrice?: string; + executeTakeProfitPrice?: string; + presetStopLossPrice?: string; + executeStopLossPrice?: string; } ⋮---- -/** - * - * * Futures | Trade - * - */ -⋮---- -export interface FuturesPlaceOrderRequestV2 { +export interface SpotCancelandSubmitOrderRequestV2 { symbol: string; - productType: FuturesProductTypeV2; - marginMode: 'isolated' | 'crossed'; - marginCoin: string; + price: string; size: string; - price?: string; - side: 'buy' | 'sell'; - tradeSide?: 'open' | 'close'; - orderType: 'limit' | 'market'; - force?: 'ioc' | 'fok' | 'gtc' | 'post_only'; + orderId?: string; clientOid?: string; - reduceOnly?: 'YES' | 'NO'; - presetStopSurplusPrice?: string; + newClientOid?: string; + presetTakeProfitPrice?: string; + executeTakeProfitPrice?: string; presetStopLossPrice?: string; - stpMode?: 'none' | 'cancel_taker' | 'cancel_maker' | 'cancel_both'; + executeStopLossPrice?: string; } ⋮---- -export interface FuturesReversalOrderRequestV2 { +export interface SpotCancelOrderRequestV2 { symbol: string; - productType: FuturesProductTypeV2; - marginCoin: string; - size: string; - side?: 'buy' | 'sell'; - tradeSide?: 'open' | 'close'; + tpslType?: SpotTPSLTypeV2; + orderId?: string; clientOid?: string; } ⋮---- -interface FuturesBatchOrderItem { - size: string; +export interface SpotBatchOrderRequestItemV2 { + symbol?: string; + side: SpotOrderSideV2; + orderType: SpotOrderTypeV2; + force: SpotOrderForceV2; price?: string; - side: 'buy' | 'sell'; - tradeSide?: 'open' | 'close'; - orderType: 'limit' | 'market'; - force?: 'ioc' | 'fok' | 'gtc' | 'post_only'; + size: string; clientOid?: string; - reduceOnly?: 'YES' | 'NO'; - presetStopSurplusPrice?: string; + stpMode?: SpotSTPModeV2; + presetTakeProfitPrice?: string; + executeTakeProfitPrice?: string; presetStopLossPrice?: string; - stpMode?: 'none' | 'cancel_taker' | 'cancel_maker' | 'cancel_both'; + executeStopLossPrice?: string; } ⋮---- -export interface FuturesBatchOrderRequestV2 { - symbol: string; - productType: FuturesProductTypeV2; - marginCoin: string; - marginMode: 'isolated' | 'crossed'; - orderList: FuturesBatchOrderItem[]; -} -⋮---- -export interface FuturesModifyOrderRequestV2 { - orderId?: string; - clientOid?: string; - symbol: string; - productType: FuturesProductTypeV2; - newClientOid: string; - newSize?: string; - newPrice?: string; - newPresetStopSurplusPrice?: string; - newPresetStopLossPrice?: string; -} -⋮---- -export interface FuturesCancelOrderRequestV2 { - symbol: string; - productType: FuturesProductTypeV2; - marginCoin?: string; - orderId?: string; - clientOid?: string; -} -⋮---- -interface FuturesBatchCancelOrderItem { - orderId?: string; - clientOid?: string; -} -⋮---- -export interface FuturesBatchCancelOrderRequestV2 { - orderIdList?: FuturesBatchCancelOrderItem[]; +export interface SpotBatchOrderRequestV2 { symbol?: string; - productType: FuturesProductTypeV2; - marginCoin?: string; + batchMode?: SpotBatchModeV2; + orderList: SpotBatchOrderRequestItemV2[]; } ⋮---- -export interface FuturesFlashClosePositionsRequestV2 { +export interface SpotBatchCancelOrderRequestV2 { symbol?: string; - productType: FuturesProductTypeV2; - holdSide?: 'long' | 'short'; + batchMode?: SpotBatchModeV2; + orderList: { + symbol?: string; + orderId?: string; + clientOid?: string; + }[]; } ⋮---- -export interface FuturesGetOrderRequestV2 { - symbol: string; - productType: FuturesProductTypeV2; +export interface GetSpotOrderInfoRequestV2 { orderId?: string; clientOid?: string; + requestTime?: string; + receiveWindow?: string; } ⋮---- -export interface FuturesGetOrderFillsRequestV2 { - orderId?: string; +export interface GetSpotOpenOrdersRequestV2 { symbol?: string; - productType: FuturesProductTypeV2; - idLessThan?: string; startTime?: string; endTime?: string; + idLessThan?: string; limit?: string; + orderId?: string; + tpslType?: SpotTPSLTypeV2; + requestTime?: string; + receiveWindow?: string; } ⋮---- -export interface FuturesGetHistoricalFillsRequestV2 { - orderId?: string; +export interface GetSpotHistoryOrdersRequestV2 { symbol?: string; - productType: FuturesProductTypeV2; startTime?: string; endTime?: string; idLessThan?: string; limit?: string; -} -⋮---- -export interface FuturesGetOpenOrdersRequestV2 { orderId?: string; - clientOid?: string; - symbol?: string; - productType: FuturesProductTypeV2; - status?: 'live' | 'partially_filled'; - idLessThan?: string; - startTime?: string; - endTime?: string; - limit?: string; + tpslType?: SpotTPSLTypeV2; + requestTime?: string; + receiveWindow?: string; } ⋮---- -export type FuturesOrderSourceV2 = - | 'normal' - | 'market' - | 'profit_market' - | 'loss_market' - | 'Trader_delegate' - | 'trader_profit' - | 'trader_loss' - | 'reverse' - | 'trader_reverse' - | 'profit_limit' - | 'loss_limit' - | 'liquidation' - | 'delivery_close_long' - | 'delivery_close_short' - | 'pos_profit_limit' - | 'pos_profit_market' - | 'pos_loss_limit' - | 'pos_loss_market'; -⋮---- -export interface FuturesGetHistoryOrdersRequestV2 { +export interface GetSpotFillsRequestV2 { + symbol: string; orderId?: string; - clientOid?: string; - symbol?: string; - productType: FuturesProductTypeV2; - idLessThan?: string; - orderSource?: FuturesOrderSourceV2; startTime?: string; endTime?: string; limit?: string; -} -⋮---- -export interface FuturesCancelAllOrdersRequestV2 { - symbol?: string; - productType: FuturesProductTypeV2; - marginCoin?: string; - requestTime?: string; - receiveWindow?: string; + idLessThan?: string; } ⋮---- /** * - * * Futures | Trigger Orders + * * Spot | Trigger Orders * */ ⋮---- -export type FuturesTriggerTypeV2 = 'fill_price' | 'mark_price'; +export type SpotPlanTypeV2 = 'amount' | 'total'; ⋮---- -export type FuturesStpModeV2 = - | 'none' - | 'cancel_taker' - | 'cancel_maker' - | 'cancel_both'; +export type SpotTriggerTypeV2 = 'fill_price' | 'mark_price'; ⋮---- -export interface FuturesTPSLOrderRequestV2 { - marginCoin: string; - productType: FuturesProductTypeV2; +export interface SpotPlanOrderRequestV2 { symbol: string; - planType: FuturesPlanTypeV2; + side: SpotOrderSideV2; triggerPrice: string; - triggerType?: FuturesTriggerTypeV2; + orderType: SpotOrderTypeV2; executePrice?: string; - holdSide: 'long' | 'short' | 'buy' | 'sell'; - size: string; - rangeRate?: string; - clientOid?: string; - stpMode?: FuturesStpModeV2; -} -⋮---- -export interface FuturesPositionTPSLOrderRequestV2 { - marginCoin: string; - productType: FuturesProductTypeV2; - symbol: string; - stopSurplusTriggerPrice?: string; - stopSurplusSize?: string; - stopSurplusTriggerType?: FuturesTriggerTypeV2; - stopSurplusExecutePrice?: string; - stopLossTriggerPrice?: string; - stopLossSize?: string; - stopLossTriggerType?: FuturesTriggerTypeV2; - stopLossExecutePrice?: string; - holdSide: 'long' | 'short' | 'buy' | 'sell'; - stpMode?: FuturesStpModeV2; - stopSurplusClientOid?: string; - stopLossClientOid?: string; -} -⋮---- -export type FuturesTriggerPriceTypeV2 = - | 'fill_price' - | 'mark_price' - | 'index_price'; -⋮---- -export interface FuturesPlanOrderRequestV2 { - planType: 'normal_plan' | 'track_plan'; - symbol: string; - productType: FuturesProductTypeV2; - marginMode: 'isolated' | 'crossed'; - marginCoin: string; + planType?: SpotPlanTypeV2; size: string; - price?: string; - callbackRatio?: string; - triggerPrice: string; - triggerType: 'mark_price' | 'fill_price'; - side: 'buy' | 'sell'; - tradeSide?: 'open' | 'close'; - orderType: 'limit' | 'market'; + triggerType: SpotTriggerTypeV2; clientOid?: string; - reduceOnly?: 'YES' | 'NO'; - stopSurplusTriggerPrice?: string; - stopSurplusExecutePrice?: string; - stopSurplusTriggerType?: FuturesTriggerPriceTypeV2; - stopLossTriggerPrice?: string; - stopLossExecutePrice?: string; - stopLossTriggerType?: FuturesTriggerPriceTypeV2; - stpMode?: FuturesStpModeV2; + force?: SpotOrderForceV2; + stpMode?: SpotSTPModeV2; } ⋮---- -export interface FuturesModifyTPSLOrderRequestV2 { +export interface SpotModifyPlanOrderRequestV2 { orderId?: string; clientOid?: string; - marginCoin: string; - productType: FuturesProductTypeV2; - symbol: string; triggerPrice: string; - triggerType?: 'fill_price' | 'mark_price'; + orderType: SpotOrderTypeV2; executePrice?: string; size: string; - rangeRate?: string; } ⋮---- -export interface FuturesModifyPlanOrderRequestV2 { - planType: 'normal_plan' | 'track_plan'; - orderId?: string; - clientOid?: string; +export interface GetSpotCurrentPlanOrdersRequestV2 { symbol: string; - productType: FuturesProductTypeV2; - newSize?: string; - newPrice?: string; - newCallbackRatio?: string; - newTriggerPrice?: string; - newTriggerType?: 'fill_price' | 'mark_price'; - newStopSurplusTriggerPrice?: string; - newStopSurplusExecutePrice?: string; - newStopSurplusTriggerType?: FuturesTriggerPriceTypeV2; - newStopLossTriggerPrice?: string; - newStopLossExecutePrice?: string; - newStopLossTriggerType?: FuturesTriggerPriceTypeV2; -} -⋮---- -export interface FuturesGetPlanOrdersRequestV2 { - orderId?: string; - clientOid?: string; - symbol?: string; - planType: 'normal_plan' | 'track_plan' | 'profit_loss'; - productType: FuturesProductTypeV2; + limit?: string; idLessThan?: string; startTime?: string; endTime?: string; - limit?: string; } ⋮---- -interface FuturesCancelPlanOrderItemV2 { - orderId?: string; - clientOid?: string; +export interface GetSpotHistoryPlanOrdersRequestV2 { + symbol: string; + startTime: string; + endTime: string; + limit?: string; } ⋮---- -export type FuturesPlanOrderTypeV2 = - | 'normal_plan' - | 'profit_plan' - | 'loss_plan' - | 'pos_profit' - | 'pos_loss' - | 'moving_plan'; +/** + * + * * Spot | Account + * + */ ⋮---- -export interface FuturesCancelPlanOrderRequestV2 { - orderIdList?: FuturesCancelPlanOrderItemV2[]; - symbol?: string; - productType: FuturesProductTypeV2; - marginCoin?: string; - planType?: FuturesPlanOrderTypeV2; -} +export type SpotBillGroupTypeV2 = + | 'deposit' + | 'withdraw' + | 'transaction' + | 'transfer' + | 'other'; ⋮---- -export type FuturesPlanStatusV2 = 'executed' | 'fail_trigger' | 'cancelled'; +export type SpotBusinessTypeV2 = + | 'deposit' + | 'withdraw' + | 'buy' + | 'sell' + | 'deduction of handling fee' + | 'transfer-in' + | 'transfer-out' + | 'rebate rewards' + | 'airdrop rewards' + | 'USDT contract rewards' + | 'mix contract rewards' + | 'system lock' + | 'user lock'; ⋮---- -export interface FuturesGetHistoryPlanOrdersRequestV2 { - orderId?: string; - clientOid?: string; - planType: 'normal_plan' | 'track_plan' | 'profit_loss'; - planStatus?: FuturesPlanStatusV2; - symbol?: string; - productType: FuturesProductTypeV2; - idLessThan?: string; +export type SpotAccountTypeV2 = + | 'spot' + | 'p2p' + | 'coin_futures' + | 'usdt_futures' + | 'usdc_futures' + | 'crossed_margin' + | 'isolated_margin'; +⋮---- +export interface GetSpotAccountBillsRequestV2 { + coin?: string; + groupType?: SpotBillGroupTypeV2; + businessType?: SpotBusinessTypeV2; startTime?: string; endTime?: string; limit?: string; + idLessThan?: string; } ⋮---- -/** - * - * * Futures | Union Margin - * - */ -⋮---- -export interface GetUnionTransferLimitsRequestV2 { - coin: string; -} -⋮---- -export interface UnionConvertRequestV2 { - coin: string; +export interface SpotTransferRequestV2 { + fromType: SpotAccountTypeV2; + toType: SpotAccountTypeV2; amount: string; -} -⋮---- -/** - * - * * Futures | Account | Max Openable Quantity - * - */ -⋮---- -export interface FuturesMaxOpenRequestV2 { - symbol: string; - productType: FuturesProductTypeV2; - marginCoin: string; - posSide: 'long' | 'short'; - orderType: 'limit' | 'market'; - openPrice?: string; -} -⋮---- -/** - * - * * Futures | Account | Liquidation Price - * - */ -⋮---- -export interface FuturesLiquidationPriceRequestV2 { + coin: string; symbol: string; - productType: FuturesProductTypeV2; - marginCoin: string; - posSide: 'long' | 'short'; - orderType: 'limit' | 'market'; - openAmount: string; - openPrice?: string; + clientOid?: string; } ⋮---- -/** - * - * * Futures | Account | Isolated Symbols - * - */ -⋮---- -export interface FuturesIsolatedSymbolsRequestV2 { - productType: FuturesProductTypeV2; -} - -================ -File: src/types/request/v2/instloan.ts -================ -export interface GetInstLoanProductInfoRequestV2 { - productId: string; +export interface SpotSubAccountTransferRequestV2 { + fromType: SpotAccountTypeV2; + toType: SpotAccountTypeV2; + amount: string; + coin: string; + symbol?: string; + clientOid?: string; + fromUserId: string; + toUserId: string; } ⋮---- -export interface GetInstLoanSymbolsRequestV2 { - productId: string; +export interface SpotWithdrawalRequestV2 { + coin: string; + transferType: 'on_chain' | 'internal_transfer'; + address: string; + chain?: string; + innerToType?: 'email' | 'mobile' | 'uid'; + areaCode?: string; + tag?: string; + size: string; + remark?: string; + clientOid?: string; } ⋮---- -export interface GetInstLoanRepaidHistoryRequestV2 { +export interface SpotMainSubTransferRecordRequestV2 { + coin?: string; + role?: 'initiator' | 'receiver'; + subUid?: string; startTime?: string; endTime?: string; + clientOid?: string; limit?: string; + idLessThan?: string; } ⋮---- -export interface GetInstLoanOrderRequestV2 { - orderId?: string; +export interface GetSpotTransferRecordRequestV2 { + coin: string; + fromType: SpotAccountTypeV2; startTime?: string; endTime?: string; + clientOid?: string; + limit?: string; + idLessThan?: string; } ⋮---- -export interface GetInstLoanLTVConvertRequestV2 { - riskUnitId?: string; -} -⋮---- -export interface GetInstLoanMarginCoinInfoRequestV2 { - productId: string; -} - -================ -File: src/types/request/v2/spot.ts -================ -type SpotKlineIntervalV2 = - | '1min' - | '5min' - | '15min' - | '30min' - | '1h' - | '4h' - | '6h' - | '12h' - | '1day' - | '3day' - | '1week' - | '1M' - | '6Hutc' - | '12Hutc' - | '1Dutc' - | '3Dutc' - | '1Wutc' - | '1Mutc'; -⋮---- -export interface SpotCandlesRequestV2 { - symbol: string; - granularity: SpotKlineIntervalV2; +export interface GetSpotSubAccountDepositRecordRequestV2 { + subUid: string; + coin?: string; startTime?: string; endTime?: string; + idLessThan?: string; limit?: string; } ⋮---- -export interface SpotHistoricCandlesRequestV2 { - symbol: string; - granularity: SpotKlineIntervalV2; - endTime?: string; +export interface GetSpotWithdrawalRecordRequestV2 { + coin?: string; + clientOid?: string; + startTime: string; + endTime: string; + idLessThan?: string; + orderId?: string; limit?: string; } ⋮---- -export interface SpotHistoricTradesRequestV2 { - symbol: string; - limit?: string; +export interface GetSpotDepositRecordRequestV2 { + coin?: string; + orderId?: string; + startTime: string; + endTime: string; idLessThan?: string; - startTime?: string; - endTime?: string; + limit?: string; } + +================ +File: src/types/request/v3/grid.ts +================ +export type GridCategoryV3 = 'SPOT' | 'USDT-FUTURES' | 'USDC-FUTURES'; ⋮---- -export interface SpotCallAuctionRequestV2 { - symbol: string; -} +export type NeutralGridCategoryV3 = 'USDT-FUTURES' | 'USDC-FUTURES'; ⋮---- -/** - * - * * Spot | Trade - * - */ +export type GridFundsSourceV3 = 'funding' | 'uta' | 'otc'; ⋮---- -export type SpotOrderSideV2 = 'buy' | 'sell'; +export type GridYesNoV3 = 'yes' | 'no'; ⋮---- -export type SpotOrderTypeV2 = 'limit' | 'market'; +export type GridOrderModeV3 = 'arithmetic' | 'geometric'; ⋮---- -export type SpotOrderForceV2 = 'gtc' | 'post_only' | 'fok' | 'ioc'; +export type GridTypeV3 = 'long' | 'short' | 'neutral' | 'netural'; ⋮---- -export type SpotTPSLTypeV2 = 'normal' | 'tpsl'; +export type GridTriggerConditionV3 = 'instant' | 'price' | 'rsi' | 'boll'; ⋮---- -export type SpotSTPModeV2 = - | 'none' - | 'cancel_taker' - | 'cancel_maker' - | 'cancel_both'; +export type GridTerminationConditionV3 = 'rsi' | 'boll'; ⋮---- -export type SpotBatchModeV2 = 'single' | 'multiple'; +export type GridAdjustTypeV3 = 'increase' | 'decrease'; ⋮---- -export interface SpotOrderRequestV2 { - symbol: string; - side: SpotOrderSideV2; - orderType: SpotOrderTypeV2; - force: SpotOrderForceV2; - price?: string; - size: string; - clientOid?: string; - triggerPrice?: string; - tpslType?: SpotTPSLTypeV2; - requestTime?: string; - receiveWindow?: string; - stpMode?: SpotSTPModeV2; - presetTakeProfitPrice?: string; - executeTakeProfitPrice?: string; - presetStopLossPrice?: string; - executeStopLossPrice?: string; +export interface GridInvestmentAmountV3 { + coin: string; + amount: string; } ⋮---- -export interface SpotCancelandSubmitOrderRequestV2 { - symbol: string; - price: string; - size: string; - orderId?: string; - clientOid?: string; - newClientOid?: string; - presetTakeProfitPrice?: string; - executeTakeProfitPrice?: string; - presetStopLossPrice?: string; - executeStopLossPrice?: string; +export interface GridIndicatorParamsV3 { + indicatorLength?: string; + threshold?: string; + multiplier?: string; + interval?: string; } ⋮---- -export interface SpotCancelOrderRequestV2 { +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; - tpslType?: SpotTPSLTypeV2; - orderId?: string; - clientOid?: 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 interface SpotBatchOrderRequestItemV2 { - symbol?: string; - side: SpotOrderSideV2; - orderType: SpotOrderTypeV2; - force: SpotOrderForceV2; - price?: string; - size: string; - clientOid?: string; - stpMode?: SpotSTPModeV2; - presetTakeProfitPrice?: string; - executeTakeProfitPrice?: string; - presetStopLossPrice?: string; - executeStopLossPrice?: string; +export type ValidateGridBotRequestV3 = CreateGridBotRequestV3; +⋮---- +export interface ModifyGridBotRequestV3 { + botId: string; + category: GridCategoryV3; + takeProfit?: string; + stopLoss?: string; + terminationCondition?: GridTerminationConditionV3; + terminationParams?: GridIndicatorParamsV3[]; + hodlMode?: GridYesNoV3; + autoTransferProfits?: GridYesNoV3; } ⋮---- -export interface SpotBatchOrderRequestV2 { - symbol?: string; - batchMode?: SpotBatchModeV2; - orderList: SpotBatchOrderRequestItemV2[]; +export interface ModifyGridIntervalRequestV3 { + category: GridCategoryV3; + botId: string; + maxPrice: string; + minPrice: string; + gridNum: string; } ⋮---- -export interface SpotBatchCancelOrderRequestV2 { - symbol?: string; - batchMode?: SpotBatchModeV2; - orderList: { - symbol?: string; - orderId?: string; - clientOid?: 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 interface GetSpotOrderInfoRequestV2 { - orderId?: string; - clientOid?: string; - requestTime?: string; - receiveWindow?: string; +export type ValidateNeutralGridBotRequestV3 = CreateNeutralGridBotRequestV3; +⋮---- +export interface ModifyNeutralGridBotRequestV3 { + botId: string; + category: NeutralGridCategoryV3; + takeProfit?: string; + stopLoss?: string; + autoTransferProfits?: GridYesNoV3; } ⋮---- -export interface GetSpotOpenOrdersRequestV2 { - symbol?: string; - startTime?: string; - endTime?: string; - idLessThan?: string; - limit?: string; - orderId?: string; - tpslType?: SpotTPSLTypeV2; - requestTime?: string; - receiveWindow?: string; +export interface ModifyNeutralGridIntervalRequestV3 { + category: NeutralGridCategoryV3; + botId: string; + maxPrice: string; + minPrice: string; + gridNum: string; } ⋮---- -export interface GetSpotHistoryOrdersRequestV2 { - symbol?: string; +export interface GetNeutralGridBotDetailRequestV3 { + botId: string; +} +⋮---- +export interface GetNeutralGridBotOrderDetailsRequestV3 { + category: NeutralGridCategoryV3 | GridCategoryV3; + botId: string; +} + +================ +File: src/types/request/v3/loan.ts +================ +export interface GetTransferedRequestV3 { + userId?: string; + coin: string; +} +⋮---- +export interface GetSymbolsRequestV3 { + productId: string; +} +⋮---- +export interface GetRepaidHistoryRequestV3 { startTime?: string; endTime?: string; - idLessThan?: string; limit?: string; - orderId?: string; - tpslType?: SpotTPSLTypeV2; - requestTime?: string; - receiveWindow?: string; } ⋮---- -export interface GetSpotFillsRequestV2 { - symbol: string; +export interface GetProductInfosRequestV3 { + productId: string; +} +⋮---- +export interface GetLoanOrderRequestV3 { orderId?: string; startTime?: string; endTime?: string; - limit?: string; - idLessThan?: string; } ⋮---- -/** - * - * * Spot | Trigger Orders - * - */ +export interface GetEnsureCoinsRequestV3 { + productId: string; +} ⋮---- -export type SpotPlanTypeV2 = 'amount' | 'total'; +export interface BindUidRequestV3 { + riskUnitId?: string; + uid: string; + operate: 'bind' | 'unbind'; +} ⋮---- -export type SpotTriggerTypeV2 = 'fill_price' | 'mark_price'; +export interface GetLTVConvertRequestV3 { + riskUnitId?: string; +} ⋮---- -export interface SpotPlanOrderRequestV2 { - symbol: string; - side: SpotOrderSideV2; - triggerPrice: string; - orderType: SpotOrderTypeV2; - executePrice?: string; - planType?: SpotPlanTypeV2; - size: string; - triggerType: SpotTriggerTypeV2; - clientOid?: string; - force?: SpotOrderForceV2; - stpMode?: SpotSTPModeV2; +/* Unified Account Staking & Lending (Crypto Loans) - /api/v3/loan/* */ +⋮---- +export interface GetLoanCoinsRequestV3 { + coin?: string; } ⋮---- -export interface SpotModifyPlanOrderRequestV2 { - orderId?: string; - clientOid?: string; - triggerPrice: string; - orderType: SpotOrderTypeV2; - executePrice?: string; - size: string; +export interface GetLoanInterestRequestV3 { + loanCoin: string; + pledgeCoin: string; + daily: 'SEVEN' | 'THIRTY' | 'FLEXIBLE'; + pledgeAmount: string; } ⋮---- -export interface GetSpotCurrentPlanOrdersRequestV2 { - symbol: string; - limit?: string; - idLessThan?: string; - startTime?: string; - endTime?: string; +export interface LoanBorrowRequestV3 { + loanCoin: string; + pledgeCoin: string; + daily: 'SEVEN' | 'THIRTY' | 'FLEXIBLE'; + pledgeAmount?: string; + loanAmount?: string; } ⋮---- -export interface GetSpotHistoryPlanOrdersRequestV2 { - symbol: string; - startTime: string; - endTime: string; - limit?: string; +export interface GetLoanBorrowOngoingRequestV3 { + orderId?: string; + loanCoin?: string; + pledgeCoin?: string; } ⋮---- -/** - * - * * Spot | Account - * - */ -⋮---- -export type SpotBillGroupTypeV2 = - | 'deposit' - | 'withdraw' - | 'transaction' - | 'transfer' - | 'other'; -⋮---- -export type SpotBusinessTypeV2 = - | 'deposit' - | 'withdraw' - | 'buy' - | 'sell' - | 'deduction of handling fee' - | 'transfer-in' - | 'transfer-out' - | 'rebate rewards' - | 'airdrop rewards' - | 'USDT contract rewards' - | 'mix contract rewards' - | 'system lock' - | 'user lock'; -⋮---- -export type SpotAccountTypeV2 = - | 'spot' - | 'p2p' - | 'coin_futures' - | 'usdt_futures' - | 'usdc_futures' - | 'crossed_margin' - | 'isolated_margin'; -⋮---- -export interface GetSpotAccountBillsRequestV2 { - coin?: string; - groupType?: SpotBillGroupTypeV2; - businessType?: SpotBusinessTypeV2; - startTime?: string; - endTime?: string; - limit?: string; - idLessThan?: string; -} -⋮---- -export interface SpotTransferRequestV2 { - fromType: SpotAccountTypeV2; - toType: SpotAccountTypeV2; - amount: string; - coin: string; - symbol: string; - clientOid?: string; -} -⋮---- -export interface SpotSubAccountTransferRequestV2 { - fromType: SpotAccountTypeV2; - toType: SpotAccountTypeV2; - amount: string; - coin: string; - symbol?: string; - clientOid?: string; - fromUserId: string; - toUserId: string; -} -⋮---- -export interface SpotWithdrawalRequestV2 { - coin: string; - transferType: 'on_chain' | 'internal_transfer'; - address: string; - chain?: string; - innerToType?: 'email' | 'mobile' | 'uid'; - areaCode?: string; - tag?: string; - size: string; - remark?: string; - clientOid?: string; +export interface GetLoanBorrowHistoryRequestV3 { + orderId?: string; + loanCoin?: string; + pledgeCoin?: string; + status?: 'ROLLBACK' | 'FORCE' | 'REPAY'; + startTime: string; + endTime: string; + pageNum?: string; + pageSize?: string; } ⋮---- -export interface SpotMainSubTransferRecordRequestV2 { - coin?: string; - role?: 'initiator' | 'receiver'; - subUid?: string; - startTime?: string; - endTime?: string; - clientOid?: string; - limit?: string; - idLessThan?: string; +export interface LoanRepayRequestV3 { + orderId: string; + method: 'borrowed_coin' | 'collateral'; + repayAll: 'yes' | 'no'; + amount?: string; + repayUnlock?: 'yes' | 'no'; } ⋮---- -export interface GetSpotTransferRecordRequestV2 { - coin: string; - fromType: SpotAccountTypeV2; - startTime?: string; - endTime?: string; - clientOid?: string; - limit?: string; - idLessThan?: string; +export interface GetLoanRepayHistoryRequestV3 { + orderId?: string; + loanCoin?: string; + pledgeCoin?: string; + startTime: string; + endTime: string; + pageNum?: string; + pageSize?: string; } ⋮---- -export interface GetSpotSubAccountDepositRecordRequestV2 { - subUid: string; - coin?: string; - startTime?: string; - endTime?: string; - idLessThan?: string; - limit?: string; +export interface LoanRevisePledgeRequestV3 { + orderId: string; + amount: string; + pledgeCoin: string; + reviseType?: 'OUT' | 'IN'; } ⋮---- -export interface GetSpotWithdrawalRecordRequestV2 { - coin?: string; - clientOid?: string; +export interface GetLoanPledgeRateHistoryRequestV3 { + orderId?: string; + reviseSide?: 'down' | 'up'; + pledgeCoin?: string; startTime: string; endTime: string; - idLessThan?: string; - orderId?: string; - limit?: string; + pageNum?: string; + pageSize?: string; } ⋮---- -export interface GetSpotDepositRecordRequestV2 { - coin?: string; +export interface GetLoanReducesRequestV3 { orderId?: string; + loanCoin?: string; + pledgeCoin?: string; + status?: 'COMPLETE' | 'WAIT'; startTime: string; endTime: string; - idLessThan?: string; - limit?: string; + pageNum?: string; + pageSize?: string; } ================ -File: src/types/request/v3/grid.ts +File: src/types/request/v3/p2p.ts ================ -export type GridCategoryV3 = 'SPOT' | 'USDT-FUTURES' | 'USDC-FUTURES'; -⋮---- -export type NeutralGridCategoryV3 = 'USDT-FUTURES' | 'USDC-FUTURES'; +export type P2pSideV3 = 'buy' | 'sell'; ⋮---- -export type GridFundsSourceV3 = 'funding' | 'uta' | 'otc'; +export type P2pPriceTypeV3 = 'fixed' | 'floating'; ⋮---- -export type GridYesNoV3 = 'yes' | 'no'; +export type P2pMarketTypeV3 = 'public' | 'private'; ⋮---- -export type GridOrderModeV3 = 'arithmetic' | 'geometric'; +export type P2pAdStatusV3 = 'publish' | 'delist' | 'remove'; ⋮---- -export type GridTypeV3 = 'long' | 'short' | 'neutral' | 'netural'; +export type P2pAdOperationV3 = 'publish' | 'delist' | 'remove'; ⋮---- -export type GridTriggerConditionV3 = 'instant' | 'price' | 'rsi' | 'boll'; +export type P2pOrderStatusV3 = + | 'pending_payment' + | 'pending_release' + | 'completed' + | 'cancelled' + | 'in_appeal'; ⋮---- -export type GridTerminationConditionV3 = 'rsi' | 'boll'; +export interface P2pPayMethodIdRefV3 { + payMethodId: string; + userPayMethodId?: string; +} ⋮---- -export type GridAdjustTypeV3 = 'increase' | 'decrease'; +export interface GetP2pAdListRequestV3 { + token: string; + fiat: string; + side: P2pSideV3; + amount?: string; + pageNum: string; + limit: string; +} ⋮---- -export interface GridInvestmentAmountV3 { - coin: string; - amount: string; +export interface GetP2pExchangeRateRequestV3 { + token: string; + fiat: string; } ⋮---- -export interface GridIndicatorParamsV3 { - indicatorLength?: string; - threshold?: string; - multiplier?: string; - interval?: string; +export interface P2pFeeSimulateRequestV3 { + token: string; + fiat: string; + side: P2pSideV3; + marketType: P2pMarketTypeV3; + amount: string; } ⋮---- -export interface GridBotIdRequestV3 { - botId: string; +export interface GetP2pAdLimitRequestV3 { + token: string; + fiat: string; + side: P2pSideV3; } ⋮---- -export interface GetGridBotDetailRequestV3 { - botId: string; +export interface CreateP2pAdRequestV3 { + token: string; + fiat: string; + side: P2pSideV3; + priceType: P2pPriceTypeV3; + price?: string; + premium?: string; + minAmount: string; + maxAmount: string; + quantity: string; + payMethodIds: P2pPayMethodIdRefV3[]; + remark?: string; + tradeTerms?: string; + payTimeLimit: string; } ⋮---- -export interface GetGridBotOrderDetailsRequestV3 { - category: GridCategoryV3; - botId: string; +export interface UpdateP2pAdRequestV3 { + advId: string; + priceType?: P2pPriceTypeV3; + price?: string; + premium?: string; + minAmount?: string; + maxAmount?: string; + quantity?: string; + payMethodIds?: P2pPayMethodIdRefV3[]; + payTimeLimit?: string; + remark?: string; + tradeTerms?: string; } ⋮---- -export interface CloseGridBotRequestV3 { - botId: string; +export interface OperateP2pAdRequestV3 { + advId: string; + operation: P2pAdOperationV3; } ⋮---- -export interface AddGridInvestmentRequestV3 { - category: GridCategoryV3; - botId: string; - coin?: string; - size?: string; - fundsSource: GridFundsSourceV3[]; - adjustType?: GridAdjustTypeV3; - reinvestProfit?: GridYesNoV3; +export interface GetP2pAdInfoRequestV3 { + advId: string; } ⋮---- -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 GetP2pMyAdsRequestV3 { + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; + advId?: string; + token?: string; + fiat?: string; + status?: P2pAdStatusV3; } ⋮---- -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 interface GetP2pPendingOrdersRequestV3 { + orderId?: string; + side?: P2pSideV3; + startTime?: string; + endTime?: string; + cursor?: string; + limit?: string; } ⋮---- -export type ValidateNeutralGridBotRequestV3 = CreateNeutralGridBotRequestV3; -⋮---- -export interface ModifyNeutralGridBotRequestV3 { - botId: string; - category: NeutralGridCategoryV3; - takeProfit?: string; - stopLoss?: string; - autoTransferProfits?: GridYesNoV3; +export interface GetP2pAllOrdersRequestV3 { + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; + orderId?: string; + side?: P2pSideV3; + status?: P2pOrderStatusV3; } ⋮---- -export interface ModifyNeutralGridIntervalRequestV3 { - category: NeutralGridCategoryV3; - botId: string; - maxPrice: string; - minPrice: string; - gridNum: string; +export interface GetP2pOrderInfoRequestV3 { + orderId: string; } ⋮---- -export interface GetNeutralGridBotDetailRequestV3 { - botId: string; +export interface P2pOrderActionRequestV3 { + orderId: string; } ⋮---- -export interface GetNeutralGridBotOrderDetailsRequestV3 { - category: NeutralGridCategoryV3 | GridCategoryV3; - botId: string; +export interface GetP2pBalanceRequestV3 { + token: string; } ================ -File: src/types/request/v3/loan.ts +File: src/types/request/v3/reality.ts ================ -export interface GetTransferedRequestV3 { - userId?: string; - coin: string; +export interface GetRealityCompanyOverviewRequestV3 { + code: string; } ⋮---- -export interface GetSymbolsRequestV3 { - productId: string; +export interface GetRealityValuationIndicatorsRequestV3 { + code: string; } ⋮---- -export interface GetRepaidHistoryRequestV3 { - startTime?: string; - endTime?: string; - limit?: string; +export interface GetRealityEarningsForecastRequestV3 { + code: string; } ⋮---- -export interface GetProductInfosRequestV3 { - productId: string; +export interface GetRealitySuspensionResumptionInfoRequestV3 { + code: string; } ⋮---- -export interface GetLoanOrderRequestV3 { - orderId?: string; - startTime?: string; - endTime?: string; +export interface GetRealityDividendsRequestV3 { + code: string; + limit?: string; + cursor?: string; } ⋮---- -export interface GetEnsureCoinsRequestV3 { - productId: string; +export interface GetRealityShareCapitalChangeRequestV3 { + code: string; } ⋮---- -export interface BindUidRequestV3 { - riskUnitId?: string; - uid: string; - operate: 'bind' | 'unbind'; +export interface GetRealityInnerTradesRequestV3 { + code: string; + limit?: string; + cursor?: string; } ⋮---- -export interface GetLTVConvertRequestV3 { - riskUnitId?: string; +export interface GetRealityExecutiveShareholdingsRequestV3 { + code: string; + limit?: string; + cursor?: string; } ⋮---- -/* Unified Account Staking & Lending (Crypto Loans) - /api/v3/loan/* */ -⋮---- -export interface GetLoanCoinsRequestV3 { - coin?: string; +export interface GetRealityShareholdDetailRequestV3 { + code: string; + limit?: string; + cursor?: string; } ⋮---- -export interface GetLoanInterestRequestV3 { - loanCoin: string; - pledgeCoin: string; - daily: 'SEVEN' | 'THIRTY' | 'FLEXIBLE'; - pledgeAmount: string; +export interface GetRealityStockInfoRequestV3 { + symbol?: string; } + +================ +File: src/types/response/v2/common.ts +================ +/** + * + * * Common | Notice + * + */ ⋮---- -export interface LoanBorrowRequestV3 { - loanCoin: string; - pledgeCoin: string; - daily: 'SEVEN' | 'THIRTY' | 'FLEXIBLE'; - pledgeAmount?: string; - loanAmount?: string; +export interface AnnouncementV2 { + annId: string; + annTitle: string; + annDesc: string; + cTime: string; + language: string; + annUrl: string; } ⋮---- -export interface GetLoanBorrowOngoingRequestV3 { - orderId?: string; - loanCoin?: string; - pledgeCoin?: string; -} +/** + * + * * Common | Public + * + */ ⋮---- -export interface GetLoanBorrowHistoryRequestV3 { - orderId?: string; - loanCoin?: string; - pledgeCoin?: string; - status?: 'ROLLBACK' | 'FORCE' | 'REPAY'; - startTime: string; - endTime: string; - pageNum?: string; - pageSize?: string; -} +/** + * + * * Common | Tax + * + */ ⋮---- -export interface LoanRepayRequestV3 { - orderId: string; - method: 'borrowed_coin' | 'collateral'; - repayAll: 'yes' | 'no'; - amount?: string; - repayUnlock?: 'yes' | 'no'; +export interface SpotTransactionRecordV2 { + id: string; + coin: string; + spotTaxType: string; + amount: string; + fee: string; + balance: string; + ts: string; } ⋮---- -export interface GetLoanRepayHistoryRequestV3 { - orderId?: string; - loanCoin?: string; - pledgeCoin?: string; - startTime: string; - endTime: string; - pageNum?: string; - pageSize?: string; +export interface FuturesTransactionRecordV2 { + id: string; + symbol: string; + marginCoin: string; + futureTaxType: string; + amount: string; + fee: string; + ts: string; } ⋮---- -export interface LoanRevisePledgeRequestV3 { - orderId: string; - amount: string; - pledgeCoin: string; - reviseType?: 'OUT' | 'IN'; -} -⋮---- -export interface GetLoanPledgeRateHistoryRequestV3 { - orderId?: string; - reviseSide?: 'down' | 'up'; - pledgeCoin?: string; - startTime: string; - endTime: string; - pageNum?: string; - pageSize?: string; +export interface MarginTransactionRecordV2 { + id: string; + coin: string; + marginTaxType: string; + amount: string; + fee: string; + total: string; + symbol: string; + ts: string; } ⋮---- -export interface GetLoanReducesRequestV3 { - orderId?: string; - loanCoin?: string; - pledgeCoin?: string; - status?: 'COMPLETE' | 'WAIT'; - startTime: string; - endTime: string; - pageNum?: string; - pageSize?: string; +export interface P2PMerchantOrdersV2 { + id: string; + coin: string; + p2pTaxType: string; + total: string; + ts: string; } - -================ -File: src/types/request/v3/p2p.ts -================ -export type P2pSideV3 = 'buy' | 'sell'; ⋮---- -export type P2pPriceTypeV3 = 'fixed' | 'floating'; -⋮---- -export type P2pMarketTypeV3 = 'public' | 'private'; -⋮---- -export type P2pAdStatusV3 = 'publish' | 'delist' | 'remove'; -⋮---- -export type P2pAdOperationV3 = 'publish' | 'delist' | 'remove'; +/** + * + * * Common | P2P + * + */ ⋮---- -export type P2pOrderStatusV3 = - | 'pending_payment' - | 'pending_release' - | 'completed' - | 'cancelled' - | 'in_appeal'; +export interface P2PMerchantV2 { + registerTime: string; + nickName: string; + isOnline: string; + avgPaymentTime: string; + avgReleaseTime: string; + totalTrades: string; + totalBuy: string; + totalSell: string; + totalCompletionRate: string; + trades30d: string; + sell30d: string; + buy30d: string; + completionRate30d: string; +} ⋮---- -export interface P2pPayMethodIdRefV3 { - payMethodId: string; - userPayMethodId?: string; +export interface P2PMerchantInfoV2 { + registerTime: string; + nickName: string; + merchantId: string; + avgPaymentTime: string; + avgReleaseTime: string; + totalTrades: string; + totalBuy: string; + totalSell: string; + totalCompletionRate: string; + trades30d: string; + sell30d: string; + buy30d: string; + completionRate30d: string; + kycStatus: boolean; + emailBindStatus: boolean; + mobileBindStatus: boolean; + email: string; + mobile: string; } ⋮---- -export interface GetP2pAdListRequestV3 { - token: string; +export interface P2PMerchantOrderV2 { + orderId: string; + orderNo: string; + advNo: string; + side: string; + count: string; + coin: string; + price: string; fiat: string; - side: P2pSideV3; - amount?: string; - pageNum: string; - limit: string; + withdrawTime: string; + representTime: string; + releaseTime: string; + paymentTime: string; + amount: string; + status: string; + buyerRealName: string; + sellerRealName: string; + ctime: string; + utime: string; + paymentInfo: { + paymethodName: string; + paymethodId: string; + paymethodInfo: { + name: string; + required: string; + type: string; + value: string; + }[]; + }; } ⋮---- -export interface GetP2pExchangeRateRequestV3 { - token: string; +export interface P2PMerchantAdvertismentV2 { + advId: string; + advNo: string; + side: string; + advSize: string; + size: string; + coin: string; + price: string; + coinPrecision: string; fiat: string; + fiatPrecision: string; + fiatSymbol: string; + status: string; + hide: string; + maxTradeAmount: string; + minTradeAmount: string; + payDuration: string; + turnoverNum: string; + turnoverRate: string; + label: string | null; + userLimitList: { + minCompleteNum: string; + maxCompleteNum: string; + placeOrderNum: string; + allowMerchantPlace: string; + completeRate30d: string; + country: string; + }; + paymentMethodList: { + paymentMethod: string; + paymentId: string; + paymentInfo: { + name: string; + required: boolean; + type: string; + }[]; + }[]; + merchantCertifiedList: { + imageUrl: string; + desc: string; + }[]; + utime: string; + ctime: string; } ⋮---- -export interface P2pFeeSimulateRequestV3 { - token: string; - fiat: string; - side: P2pSideV3; - marketType: P2pMarketTypeV3; - amount: string; +/** + * + * * Common | Trading insights + * + */ +⋮---- +export interface SpotWhaleNetFlowV2 { + volume: string; + date: string; } ⋮---- -export interface GetP2pAdLimitRequestV3 { - token: string; - fiat: string; - side: P2pSideV3; +export interface FuturesActiveBuySellVolumeV2 { + buyVolume: string; + sellVolume: string; + ts: string; } ⋮---- -export interface CreateP2pAdRequestV3 { - token: string; - fiat: string; - side: P2pSideV3; - priceType: P2pPriceTypeV3; - price?: string; - premium?: string; - minAmount: string; - maxAmount: string; - quantity: string; - payMethodIds: P2pPayMethodIdRefV3[]; - remark?: string; - tradeTerms?: string; - payTimeLimit: string; +export interface FuturesActiveLongShortPositionV2 { + longPositionRatio: string; + shortPositionRatio: string; + longShortPositionRatio: string; + ts: string; } ⋮---- -export interface UpdateP2pAdRequestV3 { - advId: string; - priceType?: P2pPriceTypeV3; - price?: string; - premium?: string; - minAmount?: string; - maxAmount?: string; - quantity?: string; - payMethodIds?: P2pPayMethodIdRefV3[]; - payTimeLimit?: string; - remark?: string; - tradeTerms?: string; +export interface LeveragedLongShortRatioV2 { + ts: string; + longShortRatio: string; } ⋮---- -export interface OperateP2pAdRequestV3 { - advId: string; - operation: P2pAdOperationV3; +export interface MarginLoanGrowthRateV2 { + ts: string; + growthRate: string; } ⋮---- -export interface GetP2pAdInfoRequestV3 { - advId: string; +export interface IsolatedMarginBorrowingRatioV2 { + ts: string; + borrowRate: string; } ⋮---- -export interface GetP2pMyAdsRequestV3 { - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; - advId?: string; - token?: string; - fiat?: string; - status?: P2pAdStatusV3; +export interface FuturesLongShortRatioV2 { + longRatio: string; + shortRatio: string; + longShortRatio: string; + ts: string; } ⋮---- -export interface GetP2pPendingOrdersRequestV3 { - orderId?: string; - side?: P2pSideV3; - startTime?: string; - endTime?: string; - cursor?: string; - limit?: string; +export interface SpotFundFlowV2 { + whaleBuyVolume: string; + dolphinBuyVolume: string; + fishBuyVolume: string; + whaleSellVolume: string; + dolphinSellVolume: string; + fishSellVolume: string; + whaleBuyRatio: string; + dolphinBuyRatio: string; + fishBuyRatio: string; + whaleSellRatio: string; + dolphinSellRatio: string; + fishSellRatio: string; } ⋮---- -export interface GetP2pAllOrdersRequestV3 { - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; - orderId?: string; - side?: P2pSideV3; - status?: P2pOrderStatusV3; +export interface FuturesActiveLongShortAccountV2 { + longAccountRatio: string; + shortAccountRatio: string; + longShortAccountRatio: string; + ts: string; } ⋮---- -export interface GetP2pOrderInfoRequestV3 { - orderId: string; -} +/** + * + * * Common | Virtual Subaccount + * + */ ⋮---- -export interface P2pOrderActionRequestV3 { - orderId: string; +export interface CreateVirtualSubAccountV2 { + failureList: { + subaAccountName: string; + }[]; + successList: { + subaAccountUid: string; + subaAccountName: string; + status: string; + label: string; + permList: string[]; + cTime: string; + uTime: string; + }[]; } ⋮---- -export interface GetP2pBalanceRequestV3 { - token: string; -} - -================ -File: src/types/request/v3/reality.ts -================ -export interface GetRealityCompanyOverviewRequestV3 { - code: string; +export interface CreateVirtualSubAccountAndApiKeyV2 { + subAccountUid: string; + subAccountName: string; + label: string; + subAccountApiKey: string; + secretKey: string; + permList: string[]; + ipList: string[]; } ⋮---- -export interface GetRealityValuationIndicatorsRequestV3 { - code: string; +export interface VirtualSubAccountV2 { + subAccountUid: string; + subAccountName: string; + status: string; + permList: string[]; + label: string; + accountType: string; + bindingTime: string; + cTime: string; + uTime: string; } ⋮---- -export interface GetRealityEarningsForecastRequestV3 { - code: string; +export interface CreateVirtualSubAccountApiKeyV2 { + subAccountUid: string; + label: string; + subAccountApiKey: string; + secretKey: string; + permList: string[]; + ipList: string[]; } ⋮---- -export interface GetRealitySuspensionResumptionInfoRequestV3 { - code: string; +export interface ModifyVirtualSubAccountApiKeyV2 { + subAccountUid: string; + label: string; + subAccountApiKey: string; + secretKey: string; + permList: string[]; + ipList: string[]; } ⋮---- -export interface GetRealityDividendsRequestV3 { - code: string; - limit?: string; - cursor?: string; +export interface CreateAgentSubaccountV2 { + username: string; + subUid: string; + apiKey: string; + secret: string; + note: string; + createdTime: string; } ⋮---- -export interface GetRealityShareCapitalChangeRequestV3 { - code: string; +export interface SubAccountApiKeyItemV2 { + subAccountUid: string; + label: string; + subAccountApiKey: string; + permList: string[]; + ipList: string[]; } ⋮---- -export interface GetRealityInnerTradesRequestV3 { - code: string; - limit?: string; - cursor?: string; -} +/** + * + * * Common | Assets + * + */ ⋮---- -export interface GetRealityExecutiveShareholdingsRequestV3 { - code: string; - limit?: string; - cursor?: string; +export interface FundingAssetV2 { + coin: string; + available: string; + frozen: string; + usdtValue: string; } ⋮---- -export interface GetRealityShareholdDetailRequestV3 { - code: string; - limit?: string; - cursor?: string; +export interface BotAssetV2 { + coin: string; + available: string; + equity: string; + bonus: string; + frozen: string; + usdtValue: string; } ⋮---- -export interface GetRealityStockInfoRequestV3 { - symbol?: string; -} - -================ -File: src/types/request/v3/stockplus.ts -================ /** * - * - * Stock+ (UTA) - * + * * Common | Convert * */ ⋮---- -export interface GetStockPlusOptionQuoteRequestV3 { - symbol: string; +export interface ConvertCurrencyV2 { + coin: string; + available: string; + maxAmount: string; + minAmount: string; } ⋮---- -export interface GetStockPlusOptionChainInfoRequestV3 { - symbol: string; - expiryDate: string; +export interface ConvertQuotedPriceV2 { + fee: string; + fromCoinSize: string; + fromCoin: string; + cnvtPrice: string; + toCoinSize: string; + toCoin: string; + traceId: string; } ⋮---- -export interface GetStockPlusOptionExpiryDateRequestV3 { - symbol: string; +export interface ConvertTradeResponseV2 { + ts: string; + cnvtPrice: string; + toCoinSize: string; + toCoin: string; } ⋮---- -export interface GetStockPlusOptionVolumeRequestV3 { - symbol: string; +export interface ConvertRecordV2 { + id: string; + ts: string; + cnvtPrice: string; + fee: string; + fromCoinSize: string; + fromCoin: string; + toCoinSize: string; + toCoin: string; } ⋮---- -export interface GetStockPlusStaticInfoRequestV3 { - symbol: string; -} +/** + * + * * Common | BGB Convert + * + */ ⋮---- -export interface GetStockPlusQuoteRequestV3 { - symbol: string; +export interface BGBConvertCoinV2 { + coin: string; + available: string; + bgbEstAmount: string; + precision: string; + feeDetail: { + feeRate: string; + fee: string; + }[]; + cTime: string; } ⋮---- -export interface GetStockPlusTradeDetailRequestV3 { - symbol: string; - count?: string; +export interface ConvertBGBResponseV2 { + orderList: { + coin: string; + orderId: string; + }[]; } ⋮---- -export interface GetStockPlusIntradayRequestV3 { - symbol: string; +export interface BGBConvertHistoryV2 { + orderId: string; + fromCoin: string; + fromAmount: string; + fromCoinPrice: string; + toCoin: string; + toAmount: string; + toCoinPrice: string; + feeDetail: { + feeCoin: string; + fee: string; + }[]; + status: string; + ctime: string; } + +================ +File: src/types/response/v2/earn.ts +================ +/** + * + * + * Earn | Savings + * + * + */ ⋮---- -export interface GetStockPlusHistoryCandlestickRequestV3 { - symbol: string; - period: string; - count?: string; - adjustType?: string; - forward?: boolean; - time?: string; - tradeSessions?: string; -} -⋮---- -export interface GetStockPlusCandlestickRequestV3 { - symbol: string; +export interface EarnSavingsProductsV2 { + productId: string; + coin: string; + periodType: string; period: string; - count?: string; - adjustType?: string; - tradeSessions?: string; -} -⋮---- -export interface GetStockPlusDepthRequestV3 { - symbol: string; -} -⋮---- -export interface PlaceStockPlusOrderRequestV3 { - symbol: string; - orderType: 'LO' | 'MO' | 'LIT' | 'MIT' | 'TSLPAMT' | 'TSLPPCT'; - side: 'Buy' | 'Sell'; - submittedQuantity: string; - timeInForce: 'Day' | 'GoodTilCanceled' | 'GoodTilDate'; - submittedPrice?: string; - triggerPrice?: string; - limitOffset?: string; - trailingAmount?: string; - trailingPercent?: string; - expireDate?: string; - outsideRth?: 'RTHOnly' | 'AnyTime' | 'Overnight'; - limitDepthLevel?: number; - triggerCount?: number; - monitorPrice?: string; - remark?: string; + apyType: string; + advanceRedeem: string; + settleMethod: string; + apyList: { + rateLevel: string; + minStepVal: string; + maxStepVal: string; + currentApy: string; + }[]; + status: string; + productLevel: string; } ⋮---- -export interface CancelStockPlusOrderRequestV3 { - symbol: string; - orderId?: string; - clientOid?: string; +export interface EarnSavingsAccountV2 { + btcAmount: string; + usdtAmount: string; + btc24hEarning: string; + usdt24hEarning: string; + btcTotalEarning: string; + usdtTotalEarning: string; } ⋮---- -export interface ModifyStockPlusOrderRequestV3 { +export interface EarnSavingsAssetV2 { + productId: string; orderId: string; - quantity: string; - price?: string; - triggerPrice?: string; - limitOffset?: string; - trailingAmount?: string; - trailingPercent?: string; - limitDepthLevel?: number; - triggerCount?: number; - monitorPrice?: string; - remark?: string; -} -⋮---- -export interface GetStockPlusTodayOrdersRequestV3 { - symbol?: string; - status?: string | string[]; - side?: string; - market?: string; - orderId?: string; + productCoin: string; + interestCoin: string; + periodType: string; + period: string; + holdAmount: string; + lastProfit: string; + totalProfit: string; + holdDays: string; + status: string; + allowRedemption: string; + productLevel: string; + apy: { + rateLevel: string; + minApy: string; + maxApy: string; + currentApy: string; + }[]; } ⋮---- -export interface GetStockPlusHistoryOrdersRequestV3 { - symbol?: string; - status?: string | string[]; - side?: string; - market?: string; - startAt?: string; - endAt?: string; +export interface EarnSavingsAssetsV2 { + resultList: EarnSavingsAssetV2[]; + endId: string; } ⋮---- -export interface GetStockPlusOrderDetailRequestV3 { +export interface EarnSavingsRecordV2 { orderId: string; + coinName: string; + settleCoinName: string; + productType: string; + period: string; + productLevel: string; + amount: string; + ts: string; + orderType: string; } ⋮---- -export interface GetStockPlusTodayExecutionsRequestV3 { - symbol?: string; - orderId?: string; -} -⋮---- -export interface GetStockPlusHistoryExecutionsRequestV3 { - symbol?: string; - startAt?: string; - endAt?: string; -} -⋮---- -export interface GetStockPlusAccountRequestV3 { - currency?: string; -} -⋮---- -export interface GetStockPlusCashFlowRequestV3 { - startTime: string; - endTime: string; - businessType?: string; - symbol?: string; - page?: string; - size?: string; -} -⋮---- -export interface GetStockPlusStockPositionRequestV3 { - symbol?: string; +export interface EarnSavingsRecordsV2 { + resultList: EarnSavingsRecordV2[]; + endId: string; } ⋮---- -export interface StockPlusTransferRequestV3 { - coin?: string; - amount?: string; - direction?: 'in' | 'out'; +export interface EarnSavingsSubscriptionDetailV2 { + singleMinAmount: string; + singleMaxAmount: string; + remainingAmount: string; + subscribePrecision: string; + profitPrecision: string; + subscribeTime: string; + interestTime: string; + settleTime: string; + expireTime: string; + redeemTime: string; + settleMethod: string; + apyList: { + rateLevel: string; + minStepVal: string; + maxStepVal: string; + currentApy: string; + }[]; + redeemDelay: string; } ⋮---- -export interface GetStockPlusTransferRecordsRequestV3 { - transferId?: string; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; -} - -================ -File: src/types/response/v2/common.ts -================ /** * - * * Common | Notice * - */ -⋮---- -export interface AnnouncementV2 { - annId: string; - annTitle: string; - annDesc: string; - cTime: string; - language: string; - annUrl: string; -} -⋮---- -/** + * Earn | Earn Account * - * * Common | Public * */ ⋮---- /** * - * * Common | Tax + * + * Earn | Shark Fin + * * */ ⋮---- -export interface SpotTransactionRecordV2 { - id: string; - coin: string; - spotTaxType: string; - amount: string; - fee: string; - balance: string; - ts: string; +export interface EarnSharkfinProductV2 { + productId: string; + productName: string; + productCoin: string; + subscribeCoin: string; + farmingStartTime: string; + farmingEndTime: string; + lowerRate: string; + defaultRate: string; + upperRate: string; + period: string; + interestStartTime: string; + status: string; + minAmount: string; + limitAmount: string; + soldAmount: string; + endTime: string; + startTime: string; } ⋮---- -export interface FuturesTransactionRecordV2 { - id: string; - symbol: string; - marginCoin: string; - futureTaxType: string; - amount: string; - fee: string; - ts: string; +export interface EarnSharkfinProductsV2 { + resultList: EarnSharkfinProductV2[]; + endId: string; } ⋮---- -export interface MarginTransactionRecordV2 { - id: string; - coin: string; - marginTaxType: string; - amount: string; - fee: string; - total: string; - symbol: string; - ts: string; +export interface EarnSharkfinAccountV2 { + btcSubscribeAmount: string; + usdtSubscribeAmount: string; + btcHistoricalAmount: string; + usdtHistoricalAmount: string; + btcTotalEarning: string; + usdtTotalEarning: string; } ⋮---- -export interface P2PMerchantOrdersV2 { - id: string; - coin: string; - p2pTaxType: string; - total: string; - ts: string; -} -⋮---- -/** - * - * * Common | P2P - * - */ -⋮---- -export interface P2PMerchantV2 { - registerTime: string; - nickName: string; - isOnline: string; - avgPaymentTime: string; - avgReleaseTime: string; - totalTrades: string; - totalBuy: string; - totalSell: string; - totalCompletionRate: string; - trades30d: string; - sell30d: string; - buy30d: string; - completionRate30d: string; +export interface EarnSharkfinAssetV2 { + productId: string; + interestStartTime: string; + interestEndTime: string; + productCoin: string; + subscribeCoin: string; + trend: string; + settleTime: string; + interestAmount: string; + productStatus: string; } ⋮---- -export interface P2PMerchantInfoV2 { - registerTime: string; - nickName: string; - merchantId: string; - avgPaymentTime: string; - avgReleaseTime: string; - totalTrades: string; - totalBuy: string; - totalSell: string; - totalCompletionRate: string; - trades30d: string; - sell30d: string; - buy30d: string; - completionRate30d: string; - kycStatus: boolean; - emailBindStatus: boolean; - mobileBindStatus: boolean; - email: string; - mobile: string; +export interface EarnSharkfinAssetsV2 { + resultList: EarnSharkfinAssetV2[]; + endId: string; } ⋮---- -export interface P2PMerchantOrderV2 { +export interface EarnSharkfinRecordV2 { orderId: string; - orderNo: string; - advNo: string; - side: string; - count: string; - coin: string; - price: string; - fiat: string; - withdrawTime: string; - representTime: string; - releaseTime: string; - paymentTime: string; + product: string; + period: string; amount: string; - status: string; - buyerRealName: string; - sellerRealName: string; - ctime: string; - utime: string; - paymentInfo: { - paymethodName: string; - paymethodId: string; - paymethodInfo: { - name: string; - required: string; - type: string; - value: string; - }[]; - }; + ts: string; + type: string; +} +export interface EarnSharkfinRecordsV2 { + resultList: EarnSharkfinRecordV2[]; + endId: string; } ⋮---- -export interface P2PMerchantAdvertismentV2 { - advId: string; - advNo: string; - side: string; - advSize: string; - size: string; - coin: string; - price: string; - coinPrecision: string; - fiat: string; - fiatPrecision: string; - fiatSymbol: string; - status: string; - hide: string; - maxTradeAmount: string; - minTradeAmount: string; - payDuration: string; - turnoverNum: string; - turnoverRate: string; - label: string | null; - userLimitList: { - minCompleteNum: string; - maxCompleteNum: string; - placeOrderNum: string; - allowMerchantPlace: string; - completeRate30d: string; - country: string; - }; - paymentMethodList: { - paymentMethod: string; - paymentId: string; - paymentInfo: { - name: string; - required: boolean; - type: string; - }[]; - }[]; - merchantCertifiedList: { - imageUrl: string; - desc: string; - }[]; - utime: string; - ctime: string; +export interface EarnSharkfinSubscriptionDetailV2 { + productCoin: string; + subscribeCoin: string; + interestTime: string; + expirationTime: string; + minPrice: string; + currentPrice: string; + maxPrice: string; + minRate: string; + defaultRate: string; + maxRate: string; + period: string; + productMinAmount: string; + availableBalance: string; + userAmount: string; + remainingAmount: string; + profitPrecision: string; + subscribePrecision: string; } ⋮---- /** * - * * Common | Trading insights + * + * Earn | Loan + * * */ ⋮---- -export interface SpotWhaleNetFlowV2 { - volume: string; - date: string; +export interface EarnLoanCurrencyLoanInfoV2 { + coin: string; + hourRate7D: string; + rate7D: string; + hourRate30D: string; + rate30D: string; + minUsdt: string; + maxUsdt: string; + min: string; + max: string; +} +export interface EarnLoanCurrencyPledgeInfoV2 { + coin: string; + initRate: string; + supRate: string; + forceRate: string; + minUsdt: string; + maxUsdt: string; } ⋮---- -export interface FuturesActiveBuySellVolumeV2 { - buyVolume: string; - sellVolume: string; - ts: string; +export interface EarnLoanCurrenciesV2 { + loanInfos: EarnLoanCurrencyLoanInfoV2[]; + pledgeInfos: EarnLoanCurrencyPledgeInfoV2[]; } ⋮---- -export interface FuturesActiveLongShortPositionV2 { - longPositionRatio: string; - shortPositionRatio: string; - longShortPositionRatio: string; - ts: string; +export interface EarnLoanOrdersV2 { + orderId: string; + loanCoin: string; + loanAmount: string; + interestAmount: string; + hourInterestRate: string; + pledgeCoin: string; + pledgeAmount: string; + pledgeRate: string; + supRate: string; + forceRate: string; + borrowTime: string; + expireTime: string; } ⋮---- -export interface LeveragedLongShortRatioV2 { - ts: string; - longShortRatio: string; +export interface EarnLoanRepayResponseV2 { + loanCoin: string; + pledgeCoin: string; + repayAmount: string; + payInterest: string; + repayLoanAmount: string; + repayUnlockAmount: string; } ⋮---- -export interface MarginLoanGrowthRateV2 { - ts: string; - growthRate: string; +export interface EarnLoanRepayHistoryV2 { + orderId: string; + loanCoin: string; + pledgeCoin: string; + repayAmount: string; + payInterest: string; + repayLoanAmount: string; + repayUnlockAmount: string; + repayTime: string; } ⋮---- -export interface IsolatedMarginBorrowingRatioV2 { - ts: string; - borrowRate: string; +export interface EarnLoanPledgeRateHistoryV2 { + loanCoin: string; + pledgeCoin: string; + orderId: string; + reviseTime: string; + reviseSide: string; + reviseAmount: string; + afterPledgeRate: string; + beforePledgeRate: string; } ⋮---- -export interface FuturesLongShortRatioV2 { - longRatio: string; - shortRatio: string; - longShortRatio: string; - ts: string; +export interface EarnLoanHistoryV2 { + orderId: string; + loanCoin: string; + pledgeCoin: string; + initPledgeAmount: string; + initLoanAmount: string; + hourRate: string; + daily: string; + borrowTime: string; + status: string; } ⋮---- -export interface SpotFundFlowV2 { - whaleBuyVolume: string; - dolphinBuyVolume: string; - fishBuyVolume: string; - whaleSellVolume: string; - dolphinSellVolume: string; - fishSellVolume: string; - whaleBuyRatio: string; - dolphinBuyRatio: string; - fishBuyRatio: string; - whaleSellRatio: string; - dolphinSellRatio: string; - fishSellRatio: string; -} -⋮---- -export interface FuturesActiveLongShortAccountV2 { - longAccountRatio: string; - shortAccountRatio: string; - longShortAccountRatio: string; - ts: string; +export interface EarnLoanDebtPledgeInfoV2 { + coin: string; + amount: string; + amountUsdt: string; } ⋮---- -/** - * - * * Common | Virtual Subaccount - * - */ -⋮---- -export interface CreateVirtualSubAccountV2 { - failureList: { - subaAccountName: string; - }[]; - successList: { - subaAccountUid: string; - subaAccountName: string; - status: string; - label: string; - permList: string[]; - cTime: string; - uTime: string; - }[]; +export interface EarnLoanDebtLoanInfoV2 { + coin: string; + amount: string; + amountUsdt: string; } ⋮---- -export interface CreateVirtualSubAccountAndApiKeyV2 { - subAccountUid: string; - subAccountName: string; - label: string; - subAccountApiKey: string; - secretKey: string; - permList: string[]; - ipList: string[]; +export interface EarnLoanDebtsV2 { + pledgeInfos: EarnLoanDebtPledgeInfoV2[]; + loanInfos: EarnLoanDebtLoanInfoV2[]; } ⋮---- -export interface VirtualSubAccountV2 { - subAccountUid: string; - subAccountName: string; +export interface EarnLoanLiquidationRecordsV2 { + orderId: string; + loanCoin: string; + pledgeCoin: string; + reduceTime: string; + pledgeRate: string; + pledgePrice: string; status: string; - permList: string[]; - label: string; - accountType: string; - bindingTime: string; - cTime: string; - uTime: string; -} -⋮---- -export interface CreateVirtualSubAccountApiKeyV2 { - subAccountUid: string; - label: string; - subAccountApiKey: string; - secretKey: string; - permList: string[]; - ipList: string[]; -} -⋮---- -export interface ModifyVirtualSubAccountApiKeyV2 { - subAccountUid: string; - label: string; - subAccountApiKey: string; - secretKey: string; - permList: string[]; - ipList: string[]; -} -⋮---- -export interface CreateAgentSubaccountV2 { - username: string; - subUid: string; - apiKey: string; - secret: string; - note: string; - createdTime: string; -} -⋮---- -export interface SubAccountApiKeyItemV2 { - subAccountUid: string; - label: string; - subAccountApiKey: string; - permList: string[]; - ipList: string[]; + pledgeAmount: string; + reduceFee: string; + residueAmount: string; + runlockAmount: string; + repayLoanAmount: string; } ⋮---- /** * - * * Common | Assets + * + * Earn | On-Chain Elite + * * */ ⋮---- -export interface FundingAssetV2 { - coin: string; - available: string; - frozen: string; - usdtValue: string; +export interface EarnEliteSubscriptionCoinV2 { + subscriptionCoin: string; + precision: string; + feeRate: string; + exchangeRate: string; + remainQuota?: string; + minAmount?: string; } ⋮---- -export interface BotAssetV2 { +export interface EarnEliteProductV2 { + productId: string; coin: string; - available: string; - equity: string; - bonus: string; - frozen: string; - usdtValue: string; + minApr: string; + maxApr: string; + subscriptionCoinList: EarnEliteSubscriptionCoinV2[]; + sellOut: 'YES' | 'NO' | string; } ⋮---- -/** - * - * * Common | Convert - * - */ -⋮---- -export interface ConvertCurrencyV2 { - coin: string; - available: string; - maxAmount: string; - minAmount: string; +export interface EarnEliteAssetProjectV2 { + projectName: string; } ⋮---- -export interface ConvertQuotedPriceV2 { - fee: string; - fromCoinSize: string; - fromCoin: string; - cnvtPrice: string; - toCoinSize: string; - toCoin: string; - traceId: string; +export interface EarnEliteAssetV2 { + productId: string; + productCoin: string; + holdingAmount: string; + usdtHoldingAmount: string; + exchangeRate: string; + apr: string; + minApy?: string; + maxApy?: string; + subscriptionCoin: string; + exchangeAmount: string; + projectList?: EarnEliteAssetProjectV2[]; + unsettledBGPoints: string; + interestCoin: string; + totalProfit: string; } ⋮---- -export interface ConvertTradeResponseV2 { - ts: string; - cnvtPrice: string; - toCoinSize: string; - toCoin: string; +export interface EarnEliteAssetsV2 { + resultList: EarnEliteAssetV2[]; } ⋮---- -export interface ConvertRecordV2 { - id: string; - ts: string; - cnvtPrice: string; +export interface EarnEliteRecordV2 { + recordId: string; + productId: string; + coin: string; + status: string; + exchangeRate: string; + receivedCoin: string; + receivedAmount: string; + investAmount: string; + feeRate: string; + redeemType?: string | string[]; + receivingAccount: string; + actualReceivingAccount: string; + paymentAccount?: string[]; + settlePoints: string; fee: string; - fromCoinSize: string; - fromCoin: string; - toCoinSize: string; - toCoin: string; } ⋮---- -/** - * - * * Common | BGB Convert - * - */ +export interface EarnEliteRecordsV2 { + recordList: EarnEliteRecordV2[]; + endId: string; +} ⋮---- -export interface BGBConvertCoinV2 { - coin: string; - available: string; - bgbEstAmount: string; +export interface EarnEliteSubscribeInfoV2 { + productSubId: string; + minAmount: string; + remainQuota: string; + exchangeRate: string; + productCoin: string; + interestTime: string; + settleTime: string; precision: string; - feeDetail: { - feeRate: string; - fee: string; - }[]; - cTime: string; + feeRate: string; + /** Present for BGUSD per API docs. */ + subscriptionCoinList?: EarnEliteSubscriptionCoinV2[]; } ⋮---- -export interface ConvertBGBResponseV2 { - orderList: { - coin: string; - orderId: string; - }[]; -} +/** Present for BGUSD per API docs. */ ⋮---- -export interface BGBConvertHistoryV2 { +export interface EarnEliteSubscribeResultV2 { orderId: string; - fromCoin: string; - fromAmount: string; - fromCoinPrice: string; - toCoin: string; - toAmount: string; - toCoinPrice: string; - feeDetail: { - feeCoin: string; - fee: string; - }[]; - status: string; - ctime: string; } - -================ -File: src/types/response/v2/earn.ts -================ -/** - * - * - * Earn | Savings - * - * - */ ⋮---- -export interface EarnSavingsProductsV2 { - productId: string; - coin: string; - periodType: string; - period: string; - apyType: string; - advanceRedeem: string; - settleMethod: string; - apyList: { - rateLevel: string; - minStepVal: string; - maxStepVal: string; - currentApy: string; - }[]; - status: string; - productLevel: string; +export interface EarnEliteSubscribeStatusV2 { + result: 'settled' | 'pending' | 'rejected' | string; } ⋮---- -export interface EarnSavingsAccountV2 { - btcAmount: string; - usdtAmount: string; - btc24hEarning: string; - usdt24hEarning: string; - btcTotalEarning: string; - usdtTotalEarning: string; +export interface EarnEliteRedeemInfoBgusdReceiveCoinV2 { + bgusdReceiveCoin: string; + bgusdExchangeRate: string; } ⋮---- -export interface EarnSavingsAssetV2 { - productId: string; - orderId: string; - productCoin: string; - interestCoin: string; - periodType: string; - period: string; - holdAmount: string; - lastProfit: string; - totalProfit: string; - holdDays: string; - status: string; - allowRedemption: string; - productLevel: string; - apy: { - rateLevel: string; - minApy: string; - maxApy: string; - currentApy: string; - }[]; +export interface EarnEliteRedeemModeV2 { + redeemFeeRate: string; + remainQuota: string; + redeemType: 'fast' | 'standard' | string; + redeemScale: string; + redeemDelayDate: string; + minRedeemAmount: string; + redeemTime: string; } ⋮---- -export interface EarnSavingsAssetsV2 { - resultList: EarnSavingsAssetV2[]; - endId: string; +export interface EarnEliteRedeemInfoV2 { + productId: string; + productSubId: string; + productCoin: string; + subscriptionCoin: string; + profitCoin: string; + exchangeRate: string; + totalUnPayInterestAmount: string; + preSettleApr: string; + receivedCoin: string; + unsettledPoints: string; + bgusdReceiveCoinList: EarnEliteRedeemInfoBgusdReceiveCoinV2[]; + redeemModeList: EarnEliteRedeemModeV2[]; } ⋮---- -export interface EarnSavingsRecordV2 { +export interface RedeemEarnEliteResultV2 { orderId: string; - coinName: string; - settleCoinName: string; - productType: string; - period: string; - productLevel: string; - amount: string; - ts: string; - orderType: string; } -⋮---- -export interface EarnSavingsRecordsV2 { - resultList: EarnSavingsRecordV2[]; - endId: string; + +================ +File: src/types/response/v2/instloan.ts +================ +export interface InstLoanProductInfoV2 { + productId: string; + leverage: string; + transferLine: string; + spotBuyLine: string; + liquidationLine: string; + stopLiquidationLine: string; } ⋮---- -export interface EarnSavingsSubscriptionDetailV2 { - singleMinAmount: string; - singleMaxAmount: string; - remainingAmount: string; - subscribePrecision: string; - profitPrecision: string; - subscribeTime: string; - interestTime: string; - settleTime: string; - expireTime: string; - redeemTime: string; - settleMethod: string; - apyList: { - rateLevel: string; - minStepVal: string; - maxStepVal: string; - currentApy: string; - }[]; - redeemDelay: string; +export interface InstLoanSymbolsV2 { + productId: string; + spotSymbols: string[]; } ⋮---- -/** - * - * - * Earn | Earn Account - * - * - */ -⋮---- -/** - * - * - * Earn | Shark Fin - * - * - */ +export interface InstLoanRepaidHistoryItemV2 { + repayOrderId: string; + businessType: string; + repayType: string; + repaidTime: string; + coin: string; + repaidAmount: string; + repaidInterest: string; +} ⋮---- -export interface EarnSharkfinProductV2 { - productId: string; - productName: string; - productCoin: string; - subscribeCoin: string; - farmingStartTime: string; - farmingEndTime: string; - lowerRate: string; - defaultRate: string; - upperRate: string; - period: string; - interestStartTime: string; +export interface InstLoanOrderV2 { + orderId: string; + orderProductId: string; + uid: string; + loanTime: string; + loanCoin: string; + loanAmount: string; + unpaidAmount: string; + unpaidInterest: string; + repaidAmount: string; + repaidInterest: string; status: string; - minAmount: string; - limitAmount: string; - soldAmount: string; - endTime: string; - startTime: string; } ⋮---- -export interface EarnSharkfinProductsV2 { - resultList: EarnSharkfinProductV2[]; - endId: string; +export interface InstLoanCoinInfoV2 { + coin: string; + convertRatio: string; + maxConvertValue: string; } ⋮---- -export interface EarnSharkfinAccountV2 { - btcSubscribeAmount: string; - usdtSubscribeAmount: string; - btcHistoricalAmount: string; - usdtHistoricalAmount: string; - btcTotalEarning: string; - usdtTotalEarning: string; +export interface InstLoanLTVConvertV2 { + ltv: string; + subAccountUids: string[]; + unpaidUsdtAmount: string; + usdtBalance: string; + unpaidInfo: { + coin: string; + unpaidQty: string; + unpaidInterest: string; + }[]; + balanceInfo: { + coin: string; + price: string; + amount: string; + convertedUsdtAmount: string; + }[]; } + +================ +File: src/types/response/v3/grid.ts +================ +import type { GridIndicatorParamsV3 } from '../../request/v3/grid.js'; ⋮---- -export interface EarnSharkfinAssetV2 { - productId: string; - interestStartTime: string; - interestEndTime: string; - productCoin: string; - subscribeCoin: string; - trend: string; - settleTime: string; - interestAmount: string; - productStatus: string; +export interface GridBotIdResponseV3 { + botId: string; } ⋮---- -export interface EarnSharkfinAssetsV2 { - resultList: EarnSharkfinAssetV2[]; - endId: string; +export interface GridValidateResponseV3 { + valid: string; + reason?: string; + minInvestment?: string; } ⋮---- -export interface EarnSharkfinRecordV2 { +export interface GridBotOrderItemV3 { orderId: string; - product: string; - period: string; - amount: string; - ts: string; - type: string; + delegateCount: string; + delegatePrice: string; + changeRequired: number | string; } -export interface EarnSharkfinRecordsV2 { - resultList: EarnSharkfinRecordV2[]; - endId: string; +⋮---- +export interface GridBotOrderDetailsV3 { + botId: string; + symbol: string; + buyOrderList: GridBotOrderItemV3[]; + sellOrderList: GridBotOrderItemV3[]; } ⋮---- -export interface EarnSharkfinSubscriptionDetailV2 { - productCoin: string; - subscribeCoin: string; - interestTime: string; - expirationTime: string; +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; - currentPrice: 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; - minRate: string; - defaultRate: string; - maxRate: string; - period: string; - productMinAmount: string; - availableBalance: string; - userAmount: string; - remainingAmount: string; - profitPrecision: string; - subscribePrecision: 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/loan.ts +================ +export interface LoanTransfersV3 { + coin: string; + transfered: string; + userId: string; } ⋮---- -/** - * - * - * Earn | Loan - * - * - */ +export interface LoanSymbolSettingV3 { + symbol: string; + leverage: string; +} ⋮---- -export interface EarnLoanCurrencyLoanInfoV2 { +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; - minUsdt: string; - maxUsdt: string; - min: string; - max: string; + minBorrowAmount: string; + maxBorrowAmount: string; + minBorrowLimit: string; + maxBorrowLimit: string; } -export interface EarnLoanCurrencyPledgeInfoV2 { +⋮---- +export interface LoanPledgeInfoV3 { coin: string; initRate: string; supRate: string; forceRate: string; - minUsdt: string; - maxUsdt: string; + minPledgeAmount: string; + maxPledgeAmount: string; } ⋮---- -export interface EarnLoanCurrenciesV2 { - loanInfos: EarnLoanCurrencyLoanInfoV2[]; - pledgeInfos: EarnLoanCurrencyPledgeInfoV2[]; +export interface GetLoanCoinsResponseV3 { + loanInfos: LoanCoinInfoV3[]; + pledgeInfos: LoanPledgeInfoV3[]; } ⋮---- -export interface EarnLoanOrdersV2 { +export interface GetLoanInterestResponseV3 { + hourInterest: string; + loanAmount: string; +} +⋮---- +export interface LoanBorrowResponseV3 { + orderId: string; +} +⋮---- +export interface LoanBorrowOngoingItemV3 { orderId: string; loanCoin: string; loanAmount: string; @@ -4748,7 +4571,19 @@ export interface EarnLoanOrdersV2 { expireTime: string; } ⋮---- -export interface EarnLoanRepayResponseV2 { +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; @@ -4757,7 +4592,7 @@ export interface EarnLoanRepayResponseV2 { repayUnlockAmount: string; } ⋮---- -export interface EarnLoanRepayHistoryV2 { +export interface LoanRepayHistoryItemV3 { orderId: string; loanCoin: string; pledgeCoin: string; @@ -4768,7 +4603,13 @@ export interface EarnLoanRepayHistoryV2 { repayTime: string; } ⋮---- -export interface EarnLoanPledgeRateHistoryV2 { +export interface LoanRevisePledgeResponseV3 { + loanCoin: string; + pledgeCoin: string; + afterPledgeRate: string; +} +⋮---- +export interface LoanPledgeRateHistoryItemV3 { loanCoin: string; pledgeCoin: string; orderId: string; @@ -4779,36 +4620,18 @@ export interface EarnLoanPledgeRateHistoryV2 { beforePledgeRate: string; } ⋮---- -export interface EarnLoanHistoryV2 { - orderId: string; - loanCoin: string; - pledgeCoin: string; - initPledgeAmount: string; - initLoanAmount: string; - hourRate: string; - daily: string; - borrowTime: string; - status: string; -} -⋮---- -export interface EarnLoanDebtPledgeInfoV2 { - coin: string; - amount: string; - amountUsdt: string; -} -⋮---- -export interface EarnLoanDebtLoanInfoV2 { +export interface LoanDebtInfoV3 { coin: string; amount: string; amountUsdt: string; } ⋮---- -export interface EarnLoanDebtsV2 { - pledgeInfos: EarnLoanDebtPledgeInfoV2[]; - loanInfos: EarnLoanDebtLoanInfoV2[]; +export interface GetLoanDebtsResponseV3 { + pledgeInfos: LoanDebtInfoV3[]; + loanInfos: LoanDebtInfoV3[]; } ⋮---- -export interface EarnLoanLiquidationRecordsV2 { +export interface LoanReduceItemV3 { orderId: string; loanCoin: string; pledgeCoin: string; @@ -4822,1408 +4645,812 @@ export interface EarnLoanLiquidationRecordsV2 { runlockAmount: string; repayLoanAmount: string; } + +================ +File: src/types/response/v3/p2p.ts +================ +import type { + P2pAdStatusV3, + P2pMarketTypeV3, + P2pOrderStatusV3, + P2pPriceTypeV3, + P2pSideV3, +} from '../../request/v3/p2p.js'; ⋮---- -/** - * - * - * Earn | On-Chain Elite - * - * - */ -⋮---- -export interface EarnEliteSubscriptionCoinV2 { - subscriptionCoin: string; - precision: string; - feeRate: string; - exchangeRate: string; - remainQuota?: string; - minAmount?: string; -} -⋮---- -export interface EarnEliteProductV2 { - productId: string; - coin: string; - minApr: string; - maxApr: string; - subscriptionCoinList: EarnEliteSubscriptionCoinV2[]; - sellOut: 'YES' | 'NO' | string; -} -⋮---- -export interface EarnEliteAssetProjectV2 { - projectName: string; +export interface P2pPayMethodInfoFieldV3 { + name: string; + type: 'file' | 'number' | 'txt'; + value: string; } ⋮---- -export interface EarnEliteAssetV2 { - productId: string; - productCoin: string; - holdingAmount: string; - usdtHoldingAmount: string; - exchangeRate: string; - apr: string; - minApy?: string; - maxApy?: string; - subscriptionCoin: string; - exchangeAmount: string; - projectList?: EarnEliteAssetProjectV2[]; - unsettledBGPoints: string; - interestCoin: string; - totalProfit: string; +export interface P2pPayMethodV3 { + payMethodId: string; + payMethodName: string; + payMethodUserName: string; + userPayMethodId: string; + payMethodInfo: P2pPayMethodInfoFieldV3[]; } ⋮---- -export interface EarnEliteAssetsV2 { - resultList: EarnEliteAssetV2[]; +export interface P2pTokenDetailV3 { + token: string; + precision: string; } ⋮---- -export interface EarnEliteRecordV2 { - recordId: string; - productId: string; - coin: string; - status: string; - exchangeRate: string; - receivedCoin: string; - receivedAmount: string; - investAmount: string; - feeRate: string; - redeemType?: string | string[]; - receivingAccount: string; - actualReceivingAccount: string; - paymentAccount?: string[]; - settlePoints: string; - fee: string; +export interface P2pFiatPayMethodV3 { + payMethodName: string; + iconUrl: string; + payMethodId: string; } ⋮---- -export interface EarnEliteRecordsV2 { - recordList: EarnEliteRecordV2[]; - endId: string; +export interface P2pWithdrawalLimitV3 { + withdrawLimitKey: string; + withdrawLimitValue: string; } ⋮---- -export interface EarnEliteSubscribeInfoV2 { - productSubId: string; - minAmount: string; - remainQuota: string; - exchangeRate: string; - productCoin: string; - interestTime: string; - settleTime: string; +export interface P2pFiatDetailV3 { + fiat: string; precision: string; - feeRate: string; - /** Present for BGUSD per API docs. */ - subscriptionCoinList?: EarnEliteSubscriptionCoinV2[]; + floatRateMin: string; + floatRateMax: string; + fixedRateMin: string; + fixedRateMax: string; + adMinLimit: string; + adMaxLimit: string; + payMethods: P2pFiatPayMethodV3; + withdrawalLimit: P2pWithdrawalLimitV3; + payTimeLimit: number[]; } ⋮---- -/** Present for BGUSD per API docs. */ -⋮---- -export interface EarnEliteSubscribeResultV2 { - orderId: string; +export interface P2pCurrenciesV3 { + tokenDetailList: P2pTokenDetailV3[]; + fiatDetailList: P2pFiatDetailV3[]; } ⋮---- -export interface EarnEliteSubscribeStatusV2 { - result: 'settled' | 'pending' | 'rejected' | string; +export interface P2pUserEquityDetailV3 { + maxAdvSellNum: string; + maxAdvSellLimit: string; + maxAdvBuyNum: string; + maxAdvBuyLimit: string; + totalMaxPendingOrder: string; + advMaxPendingOrder: string; } ⋮---- -export interface EarnEliteRedeemInfoBgusdReceiveCoinV2 { - bgusdReceiveCoin: string; - bgusdExchangeRate: string; +export interface P2pUserInfoV3 { + uid: string; + nickName: string; + accountLevel: 'starter' | 'advanced' | 'master'; + completedOrderNum: string; + positiveRate: string; + completedOrderNum30D: string; + completedRate30D: string; + avgPayTime30D: string; + avgReleaseTime30D: string; + equityDetail: P2pUserEquityDetailV3; + registerTime: string; } ⋮---- -export interface EarnEliteRedeemModeV2 { - redeemFeeRate: string; - remainQuota: string; - redeemType: 'fast' | 'standard' | string; - redeemScale: string; - redeemDelayDate: string; - minRedeemAmount: string; - redeemTime: string; +export interface P2pBalanceV3 { + token: string; + totalBalance: string; + frozenBalance: string; + availableBalance: string; } ⋮---- -export interface EarnEliteRedeemInfoV2 { - productId: string; - productSubId: string; - productCoin: string; - subscriptionCoin: string; - profitCoin: string; - exchangeRate: string; - totalUnPayInterestAmount: string; - preSettleApr: string; - receivedCoin: string; - unsettledPoints: string; - bgusdReceiveCoinList: EarnEliteRedeemInfoBgusdReceiveCoinV2[]; - redeemModeList: EarnEliteRedeemModeV2[]; +export interface P2pExchangeRateV3 { + rate: string; } ⋮---- -export interface RedeemEarnEliteResultV2 { - orderId: string; +export interface P2pFeeSimulateV3 { + feeToken: string; + feeAmount: string; + taxToken: string; + taxAmount: string; } - -================ -File: src/types/response/v2/instloan.ts -================ -export interface InstLoanProductInfoV2 { - productId: string; - leverage: string; - transferLine: string; - spotBuyLine: string; - liquidationLine: string; - stopLiquidationLine: string; +⋮---- +export interface P2pAdLimitV3 { + buyMinTokenAmount: string; + buyMaxTokenAmount: string; + sellMinTokenAmount: string; + sellMaxTokenAmount: string; } ⋮---- -export interface InstLoanSymbolsV2 { - productId: string; - spotSymbols: string[]; +export interface P2pCreateAdResponseV3 { + advId: string; } ⋮---- -export interface InstLoanRepaidHistoryItemV2 { - repayOrderId: string; - businessType: string; - repayType: string; - repaidTime: string; - coin: string; - repaidAmount: string; - repaidInterest: string; +export interface P2pAdPayMethodRefV3 { + payMethodId: string; + userPayMethodId?: string; } ⋮---- -export interface InstLoanOrderV2 { - orderId: string; - orderProductId: string; - uid: string; - loanTime: string; - loanCoin: string; - loanAmount: string; - unpaidAmount: string; - unpaidInterest: string; - repaidAmount: string; - repaidInterest: string; - status: string; -} -⋮---- -export interface InstLoanCoinInfoV2 { - coin: string; - convertRatio: string; - maxConvertValue: string; +export interface P2pAdInfoV3 { + advId: string; + side: P2pSideV3; + priceType: P2pPriceTypeV3; + token: string; + fiat: string; + price: string; + amount: string; + minAmount: string; + maxAmount: string; + payDuration: string; + soldAmount: string; + lastAmount: string; + premium: string; + turnover: string; + remark: string; + tradeTerm: string; + payMethodIds: P2pAdPayMethodRefV3[]; + tokenPrecision: string; + fiatPrecision: string; + market: P2pMarketTypeV3; + avgTime: string; + createdTime: string; + updatedTime: string; } ⋮---- -export interface InstLoanLTVConvertV2 { - ltv: string; - subAccountUids: string[]; - unpaidUsdtAmount: string; - usdtBalance: string; - unpaidInfo: { - coin: string; - unpaidQty: string; - unpaidInterest: string; - }[]; - balanceInfo: { - coin: string; - price: string; - amount: string; - convertedUsdtAmount: string; +export interface P2pPublicAdListItemV3 { + advId: string; + merchantId: string; + merchantName: string; + token: string; + fiat: string; + side: P2pSideV3; + price: string; + minAmount: string; + maxAmount: string; + quantity: string; + payMethods: { + payMethodId: string; + payMethodName: string; }[]; + completedOrderNum: string; + completedRate: string; + avgReleaseTime: string; + createdTime: string; } - -================ -File: src/types/response/v3/grid.ts -================ -import type { GridIndicatorParamsV3 } from '../../request/v3/grid.js'; ⋮---- -export interface GridBotIdResponseV3 { - botId: string; +export interface P2pMyAdListItemV3 { + advId: string; + side: P2pSideV3; + priceType: P2pPriceTypeV3; + token: string; + fiat: string; + price: string; + soldAmount: string; + lastAmount: string; + payMethods: { payMethodId: string }[]; + status: P2pAdStatusV3; + createdTime: string; + updatedTime: string; } ⋮---- -export interface GridValidateResponseV3 { - valid: string; - reason?: string; - minInvestment?: string; +export interface P2pCursorListV3 { + items: T[]; + nextId?: string; } ⋮---- -export interface GridBotOrderItemV3 { +export interface P2pOrderListItemV3 { orderId: string; - delegateCount: string; - delegatePrice: string; - changeRequired: number | string; + side: P2pSideV3; + token: string; + fiat: string; + price: string; + amount: string; + quantity: string; + fee: string; + counterparty: string; + status: P2pOrderStatusV3; + createdTime: string; + updatedTime: string; } ⋮---- -export interface GridBotOrderDetailsV3 { - botId: string; - symbol: string; - buyOrderList: GridBotOrderItemV3[]; - sellOrderList: GridBotOrderItemV3[]; +export interface P2pOrderPayMethodDetailV3 { + payMethodId: string; + payMethodName: string; + payMethodUserName: string; + postscript: string; + payMethodInfo: P2pPayMethodInfoFieldV3[]; } ⋮---- -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 P2pOrderUserInfoV3 { + nickName: string; + realName: 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; +export interface P2pOrderInfoV3 { + orderId: string; + side: P2pSideV3; + token: string; + fiat: string; + price: string; + quantity: string; + amount: string; + status: P2pOrderStatusV3; + advId: string; + remark: string; + orderCancelCountdown: string; + fee: string; + verifyCapital: 'yes' | 'no'; + payMethodDetail?: P2pOrderPayMethodDetailV3; + sellUserInfo: P2pOrderUserInfoV3; + buyUserInfo: P2pOrderUserInfoV3; createdTime: string; - 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; + updatedTime: string; } ================ -File: src/types/response/v3/loan.ts +File: src/types/response/v3/reality.ts ================ -export interface LoanTransfersV3 { - coin: string; - transfered: string; - userId: string; -} -⋮---- -export interface LoanSymbolSettingV3 { - symbol: string; - leverage: string; -} -⋮---- -export interface LoanSymbolsV3 { - productId: string; - spotSymbols: string[]; - marginLeverage: string; - usdtContractLeverage: string; - coinContractLeverage: string; - usdcContractLeverage: string; - usdtContractSymbols: LoanSymbolSettingV3[]; - coinContractSymbols: LoanSymbolSettingV3[]; - usdcContractSymbols: LoanSymbolSettingV3[]; +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 RepaidHistoryItemV3 { - repayOrderId: string; - businessType: 'normal' | 'liquidation'; - repayType: 'all' | 'part'; - repaidTime: string; - coin: string; - repayAmount: string; - repayInterest: 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 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 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 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 RealitySuspensionResumptionInfoV3 { + code: string; + name: string; + suspensionDate: string; + suspensionTime: string; + suspensionReason: string; + suspensionPrice: string; + resumptionDate: string; + resumptionQuoteTime: string; + resumptionTradingTime: string; } ⋮---- -/** Tiered conversion rate item (when Tiered Discount Rate Model is enabled) */ -export interface ConvertRatioListItemV3 { - ladder: string; - convertRatio: 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 CoinInfoV3 { - coin: string; - convertRatio: string; - maxConvertValue: string; - /** Tiered conversion rate (when margin mode is Tiered Discount Rate Model) */ - convertRatioList?: ConvertRatioListItemV3[]; +export interface RealityShareCapitalChangeV3 { + announcementDate: string; + changeDate: string; + totalShares: string; + commonShares: string; + preferredShares: string; + otherShares: string; + specialExplain: string; + changeReason: string; } ⋮---- -/** Tiered conversion rate (when margin mode is Tiered Discount Rate Model) */ -⋮---- -export interface BindUidResponseV3 { - riskUnitId: string; - uid: string; - operate: 'bind' | 'unbind'; +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 UnpaidInfoV3 { - coin: string; - unpaidQty: string; - unpaidInterest: string; +export interface RealityExecutiveShareholdingItemV3 { + name: string; + holdingNum: string; + holdingRatio: string; + voteRatio: string; + period: string; + announcementDate: string; } ⋮---- -export interface BalanceInfoV3 { - coin: string; - price: string; - amount: string; - convertedUsdtAmount: string; +export interface RealityShareholdDetailItemV3 { + name: string; + holdingNum: string; + holdingRatio: string; } ⋮---- -export interface LTVConvertResponseV3 { - ltv: string; - subAccountUids: string[]; - unpaidUsdtAmount: string; - usdtBalance: string; - unpaidInfo: UnpaidInfoV3[]; - balanceInfo: BalanceInfoV3[]; +export interface RealityCursorListV3 { + list: T[]; + cursor?: string; } ⋮---- -/* Unified Account Staking & Lending (Crypto Loans) - /api/v3/loan/* */ -⋮---- -export interface LoanCoinInfoV3 { - coin: string; - hourRateFlexible: string; - rateFlexible: string; - hourRate7D: string; - rate7D: string; - hourRate30D: string; - rate30D: string; - minBorrowAmount: string; - maxBorrowAmount: string; - minBorrowLimit: string; - maxBorrowLimit: string; +export interface RealityStockInfoV3 { + symbol: string; + code: string; + name: string; + tradingPeriod: string[]; + weekendTradable: 'yes' | 'no' | string; } ⋮---- -export interface LoanPledgeInfoV3 { - coin: string; - initRate: string; - supRate: string; - forceRate: string; - minPledgeAmount: string; - maxPledgeAmount: string; +export interface RealityMarketSessionStateV3 { + state: string; + timeZone: string; + startTime: string; + endTime: string; } ⋮---- -export interface GetLoanCoinsResponseV3 { - loanInfos: LoanCoinInfoV3[]; - pledgeInfos: LoanPledgeInfoV3[]; +export interface RealityMarketStateV3 { + market: string; + daylightType: string; + stateList: RealityMarketSessionStateV3[]; } ⋮---- -export interface GetLoanInterestResponseV3 { - hourInterest: string; - loanAmount: string; +export interface RealityMarketSpecificConfigV3 { + remark: string; + startTime: string; + endTime: string; } ⋮---- -export interface LoanBorrowResponseV3 { - orderId: string; +export interface RealityMarketCalendarV3 { + timeZone: string; + specificConfig: RealityMarketSpecificConfigV3[]; + regularConfig: string[]; } + +================ +File: webpack/webpack.config.cjs +================ +function generateConfig(name) ⋮---- -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; -} +// Add '.ts' and '.tsx' as resolvable extensions. ⋮---- -export interface LoanBorrowHistoryItemV3 { - orderId: string; - loanCoin: string; - pledgeCoin: string; - initPledgeAmount: string; - initLoanAmount: string; - hourRate: string; - daily: string; - borrowTime: string; - status: string; -} +// Node.js core modules not available in browsers +// The REST client's https.Agent (for keepAlive) is Node.js-only and won't work in browsers ⋮---- -export interface LoanRepayResponseV3 { - loanCoin: string; - pledgeCoin: string; - repayAmount: string; - payInterest: string; - repayLoanAmount: string; - repayUnlockAmount: string; -} +// Code is already transpiled from TypeScript, no additional loaders needed + +================ +File: .npmrc +================ +min-release-age=30 +save-exact=true + +================ +File: .nvmrc +================ +v24.18.0 + +================ +File: examples/auth/fasterHmacSign.ts +================ +import { createHmac } from 'crypto'; ⋮---- -export interface LoanRepayHistoryItemV3 { - orderId: string; - loanCoin: string; - pledgeCoin: string; - repayAmount: string; - payInterest: string; - repayLoanAmount: string; - repayUnlockAmount: string; - repayTime: string; -} +import { + DefaultLogger, + RestClientV3, + WebsocketClientV3, +} from '../../src/index.js'; ⋮---- -export interface LoanRevisePledgeResponseV3 { - loanCoin: string; - pledgeCoin: string; - afterPledgeRate: string; -} +// or +// import { createHmac } from 'crypto'; +// import { DefaultLogger, RestClientV3, WebsocketClientV3 } from 'bitget-api'; ⋮---- -export interface LoanPledgeRateHistoryItemV3 { - loanCoin: string; - pledgeCoin: string; - orderId: string; - reviseTime: string; - reviseSide: string; - reviseAmount: string; - afterPledgeRate: string; - beforePledgeRate: string; -} +/** + * Injecting a custom signMessage function. + * + * As of version 3.0.0 of the bitget-api Node.js/TypeScript/JavaScript + * SDK for Bitget, the SDK uses the Web Crypto API for signing requests. + * While it is compatible with Node and Browser environments, it is + * slightly slower than using Node's native crypto module (only + * available in backend Node environments). + * + * For latency sensitive users, you can inject the previous node crypto sign + * method (or your own even faster implementation), if this change affects you. + * + * This example demonstrates how to inject a custom sign function, to achieve + * the same peformance as seen before the Web Crypto API was introduced. + * + * For context on standard usage, the "signMessage" function is used: + * - During every single API call + * - After opening a new private WebSocket connection + */ ⋮---- -export interface LoanDebtInfoV3 { - coin: string; - amount: string; - amountUsdt: string; -} +/** + * Set this to true to enable demo trading: + */ ⋮---- -export interface GetLoanDebtsResponseV3 { - pledgeInfos: LoanDebtInfoV3[]; - loanInfos: LoanDebtInfoV3[]; -} +/** + * Overkill in almost every case, but if you need any optimisation available, + * you can inject a faster sign mechanism such as node's native createHmac: + */ ⋮---- -export interface 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; -} +// Optional, uncomment the "trace" override to log a lot more info about what the WS client is doing +⋮---- +// trace: (...params) => console.log('trace', ...params), +⋮---- +/** + * Set this to true to enable demo trading for the private account data WS + * Topics: order,execution,position,wallet,greeks + */ +⋮---- +/** + * Overkill in almost every case, but if you need any optimisation available, + * you can inject a faster sign mechanism such as node's native createHmac: + */ +⋮---- +function setWsClientEventListeners( + websocketClient: WebsocketClientV3, + accountRef: string, +): Promise +⋮---- +// console.log('raw message received ', JSON.stringify(data, null, 2)); +⋮---- +// Simple promise to ensure we're subscribed before trying anything else +⋮---- +// Start trading ================ -File: src/types/response/v3/p2p.ts +File: examples/V2 - Classic/Rest/rest-trade-futures.ts ================ -import type { - P2pAdStatusV3, - P2pMarketTypeV3, - P2pOrderStatusV3, - P2pPriceTypeV3, - P2pSideV3, -} from '../../request/v3/p2p.js'; +import { + FuturesPlaceOrderRequestV2, + RestClientV2, + WebsocketClientV2, +} from '../../../src/index.js'; ⋮---- -export interface P2pPayMethodInfoFieldV3 { - name: string; - type: 'file' | 'number' | 'txt'; - value: string; -} +// or +// import { FuturesPlaceOrderRequestV2, RestClientV2, WebsocketClientV2 } from '../src'; ⋮---- -export interface P2pPayMethodV3 { - payMethodId: string; - payMethodName: string; - payMethodUserName: string; - userPayMethodId: string; - payMethodInfo: P2pPayMethodInfoFieldV3[]; -} +// read from environmental variables ⋮---- -export interface P2pTokenDetailV3 { - token: string; - precision: string; -} +// If running from CLI in unix, you can pass env vars as such: +// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/rest-trade-futures.ts ⋮---- -export interface P2pFiatPayMethodV3 { - payMethodName: string; - iconUrl: string; - payMethodId: string; -} +// note the single quotes, preventing special characters such as $ from being incorrectly passed ⋮---- -export interface P2pWithdrawalLimitV3 { - withdrawLimitKey: string; - withdrawLimitValue: string; -} +// apiKey: 'apiKeyHere', +// apiSecret: 'apiSecretHere', +// apiPass: 'apiPassHere', ⋮---- -export interface P2pFiatDetailV3 { - fiat: string; - precision: string; - floatRateMin: string; - floatRateMax: string; - fixedRateMin: string; - fixedRateMax: string; - adMinLimit: string; - adMaxLimit: string; - payMethods: P2pFiatPayMethodV3; - withdrawalLimit: P2pWithdrawalLimitV3; - payTimeLimit: number[]; -} +function logWSEvent(type: string, data: any) ⋮---- -export interface P2pCurrenciesV3 { - tokenDetailList: P2pTokenDetailV3[]; - fiatDetailList: P2pFiatDetailV3[]; -} +// simple sleep function +function promiseSleep(milliseconds: number) ⋮---- -export interface P2pUserEquityDetailV3 { - maxAdvSellNum: string; - maxAdvSellLimit: string; - maxAdvBuyNum: string; - maxAdvBuyLimit: string; - totalMaxPendingOrder: string; - advMaxPendingOrder: string; -} +/** + * This is a simple script wrapped in a immediately invoked function expression (to execute the below workflow immediately). + * + * It is designed to: + * - open a private websocket channel to log account events + * - check for any available USDT balance in the futures account + * - immediately open a minimum sized long position on BTCUSDT + * - check active positions + * - immediately send closing orders for any active futures positions + * - check positions again + * + */ ⋮---- -export interface P2pUserInfoV3 { - uid: string; - nickName: string; - accountLevel: 'starter' | 'advanced' | 'master'; - completedOrderNum: string; - positiveRate: string; - completedOrderNum30D: string; - completedRate30D: string; - avgPayTime30D: string; - avgReleaseTime30D: string; - equityDetail: P2pUserEquityDetailV3; - registerTime: string; -} +// Add event listeners to log websocket events on account ⋮---- -export interface P2pBalanceV3 { - token: string; - totalBalance: string; - frozenBalance: string; - availableBalance: string; -} +// futures private +// : account updates ⋮---- -export interface P2pExchangeRateV3 { - rate: string; -} +// : position updates ⋮---- -export interface P2pFeeSimulateV3 { - feeToken: string; - feeAmount: string; - taxToken: string; - taxAmount: string; -} +// : order updates ⋮---- -export interface P2pAdLimitV3 { - buyMinTokenAmount: string; - buyMaxTokenAmount: string; - sellMinTokenAmount: string; - sellMaxTokenAmount: string; -} +// wait briefly for ws to be ready (could also use the response or authenticated events, to make sure topics are subscribed to before starting) ⋮---- -export interface P2pCreateAdResponseV3 { - advId: string; -} +// const balances = allBalances.filter((bal) => Number(bal.available) != 0); ⋮---- -export interface P2pAdPayMethodRefV3 { - payMethodId: string; - userPayMethodId?: string; -} +// Loop through any active positions and send a closing market order on each position + +================ +File: examples/V2 - Classic/Rest/rest-trade-spot.ts +================ +import { + RestClientV2, + SpotOrderRequestV2, + WebsocketClientV2, +} from '../../../src/index.js'; ⋮---- -export interface P2pAdInfoV3 { - advId: string; - side: P2pSideV3; - priceType: P2pPriceTypeV3; - token: string; - fiat: string; - price: string; - amount: string; - minAmount: string; - maxAmount: string; - payDuration: string; - soldAmount: string; - lastAmount: string; - premium: string; - turnover: string; - remark: string; - tradeTerm: string; - payMethodIds: P2pAdPayMethodRefV3[]; - tokenPrecision: string; - fiatPrecision: string; - market: P2pMarketTypeV3; - avgTime: string; - createdTime: string; - updatedTime: string; -} +// import { RestClientV2, WebsocketClient } from '../src/index'; ⋮---- -export interface P2pPublicAdListItemV3 { - advId: string; - merchantId: string; - merchantName: string; - token: string; - fiat: string; - side: P2pSideV3; - price: string; - minAmount: string; - maxAmount: string; - quantity: string; - payMethods: { - payMethodId: string; - payMethodName: string; - }[]; - completedOrderNum: string; - completedRate: string; - avgReleaseTime: string; - createdTime: string; -} +// read from environmental variables ⋮---- -export interface P2pMyAdListItemV3 { - advId: string; - side: P2pSideV3; - priceType: P2pPriceTypeV3; - token: string; - fiat: string; - price: string; - soldAmount: string; - lastAmount: string; - payMethods: { payMethodId: string }[]; - status: P2pAdStatusV3; - createdTime: string; - updatedTime: string; -} +// If running from CLI in unix, you can pass env vars as such: +// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/rest-trade-spot.ts ⋮---- -export interface P2pCursorListV3 { - items: T[]; - nextId?: string; -} +// note the single quotes, preventing special characters such as $ from being incorrectly passed ⋮---- -export interface P2pOrderListItemV3 { - orderId: string; - side: P2pSideV3; - token: string; - fiat: string; - price: string; - amount: string; - quantity: string; - fee: string; - counterparty: string; - status: P2pOrderStatusV3; - createdTime: string; - updatedTime: string; -} +// apiKey: 'apiKeyHere', +// apiSecret: 'apiSecretHere', +// apiPass: 'apiPassHere', ⋮---- -export interface P2pOrderPayMethodDetailV3 { - payMethodId: string; - payMethodName: string; - payMethodUserName: string; - postscript: string; - payMethodInfo: P2pPayMethodInfoFieldV3[]; -} +function logWSEvent(type: string, data: any) ⋮---- -export interface P2pOrderUserInfoV3 { - nickName: string; - realName: string; -} +// simple sleep function +function promiseSleep(milliseconds: number) ⋮---- -export interface P2pOrderInfoV3 { - orderId: string; - side: P2pSideV3; - token: string; - fiat: string; - price: string; - quantity: string; - amount: string; - status: P2pOrderStatusV3; - advId: string; - remark: string; - orderCancelCountdown: string; - fee: string; - verifyCapital: 'yes' | 'no'; - payMethodDetail?: P2pOrderPayMethodDetailV3; - sellUserInfo: P2pOrderUserInfoV3; - buyUserInfo: P2pOrderUserInfoV3; - createdTime: string; - updatedTime: string; -} +/** This is a simple script wrapped in a immediately invoked function expression, designed to check for any available BTC balance and immediately sell the full amount for USDT */ +⋮---- +// Add event listeners to log websocket events on account +⋮---- +// Subscribe to private account topics +// spot private +// : account updates +⋮---- +// : order updates (note: symbol is required) +⋮---- +// wait briefly for ws to be ready (could also use the response or authenticated events, to make sure topics are subscribed to before starting) +⋮---- +// console.log('balance: ', JSON.stringify(balances, null, 2)); ================ -File: src/types/response/v3/reality.ts +File: examples/V2 - Classic/Websocket/ws-demo-trading.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; -} +import { DefaultLogger, WebsocketClientV2 } from '../../../src/index.js'; ⋮---- -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; -} +// or +// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; ⋮---- -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; -} +// 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 RealitySuspensionResumptionInfoV3 { - code: string; - name: string; - suspensionDate: string; - suspensionTime: string; - suspensionReason: string; - suspensionPrice: string; - resumptionDate: string; - resumptionQuoteTime: string; - resumptionTradingTime: string; -} +// restOptions: { +// optionally provide rest options, e.g. to pass through a proxy +// }, ⋮---- -export interface RealityDividendItemV3 { - type: string; - announcementDate: string; - recordDate: string; - exrightDate: string; - dividendDate: string; - dividendPerShare: string; - stockDividendPerShare: string; - splitValidDate: string; - splitNumerator: string; - splitDenominator: string; -} +// Set demoTrading to true, to route all connections to the demo trading wss URLs: ⋮---- -export interface RealityShareCapitalChangeV3 { - announcementDate: string; - changeDate: string; - totalShares: string; - commonShares: string; - preferredShares: string; - otherShares: string; - specialExplain: string; - changeReason: string; -} +// If using private topics, make sure to include API keys ⋮---- -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; -} +// console.log('WS raw message received ', JSON.stringify(data, null, 2)); ⋮---- -export interface RealityExecutiveShareholdingItemV3 { - name: string; - holdingNum: string; - holdingRatio: string; - voteRatio: string; - period: string; - announcementDate: string; -} +/** + * Public events + */ + +================ +File: examples/V2 - Classic/Websocket/ws-private.ts +================ +import { DefaultLogger, WebsocketClientV2 } from '../../../src/index.js'; ⋮---- -export interface RealityShareholdDetailItemV3 { - name: string; - holdingNum: string; - holdingRatio: string; -} +// or +// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; ⋮---- -export interface RealityCursorListV3 { - list: T[]; - cursor?: 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 RealityStockInfoV3 { - symbol: string; - code: string; - name: string; - tradingPeriod: string[]; - weekendTradable: 'yes' | 'no' | string; -} +// note the single quotes, preventing special characters such as $ from being incorrectly passed ⋮---- -export interface RealityMarketSessionStateV3 { - state: string; - timeZone: string; - startTime: string; - endTime: string; -} +// restOptions: { +// optionally provide rest options, e.g. to pass through a proxy +// }, ⋮---- -export interface RealityMarketStateV3 { - market: string; - daylightType: string; - stateList: RealityMarketSessionStateV3[]; -} +// console.log('WS raw message received ', JSON.stringify(data, null, 2)); ⋮---- -export interface RealityMarketSpecificConfigV3 { - remark: string; - startTime: string; - endTime: string; -} +// auth happens async after the ws connection opens +⋮---- +// wsClient.subscribePublicSpotTickers(['BTCUSDT', 'LTCUSDT']); ⋮---- -export interface RealityMarketCalendarV3 { - timeZone: string; - specificConfig: RealityMarketSpecificConfigV3[]; - regularConfig: string[]; -} - -================ -File: src/types/response/v3/stockplus.ts -================ /** - * - * - * Stock+ (UTA) - * - * - */ + * Private account updates + */ ⋮---- -export interface StockPlusOptionQuoteItemV3 { - symbol: string; - lastDone: string; - prevClose: string; - open: string; - high: string; - low: string; - timestamp: string; - volume: string; - turnover: string; - tradeStatus: string; - impliedVolatility: string; - openInterest: string; - expiryDate: string; - strikePrice: string; - contractMultipier: string; - contractType: string; - contractSize: string; - direction: string; - historicalVolatility: string; - underlyingSymbol: string; -} +// spot private +// : account updates ⋮---- -export interface StockPlusOptionQuoteV3 { - secuQuote: StockPlusOptionQuoteItemV3[]; -} +// : order updates (note: symbol is required) +// wsClient.subscribeTopic('SPOT', 'orders', 'BTCUSDT'); ⋮---- -export interface StockPlusOptionStrikePriceInfoV3 { - price: string; - callSymbol: string; - putSymbol: string; - standard: boolean; -} +// futures private +// : account updates ⋮---- -export interface StockPlusOptionChainInfoV3 { - strikePriceInfo: StockPlusOptionStrikePriceInfoV3[]; -} +// : position updates +// wsClient.subscribeTopic('USDT-FUTURES', 'positions'); ⋮---- -export interface StockPlusOptionExpiryDateV3 { - expiryDate: string[]; -} +// : order updates +// wsClient.subscribeTopic('USDT-FUTURES', 'orders'); ⋮---- -export interface StockPlusOptionVolumeV3 { - c: string; - p: string; -} +// : plan order updates +// wsClient.subscribeTopic('USDT-FUTURES', 'orders-algo'); ⋮---- -export interface StockPlusStaticInfoItemV3 { - symbol: string; - nameCn: string; - nameEn: string; - exchange: string; - currency: string; - lotSize: number | string; - totalShares: string | number; - circulatingShares: string | number; - eps: string | number; - epsTtm: string | number; - bps: string | number; - dividendYield: string | number; - stockDerivatives: string[]; - board: string; -} +// wsClient +// .getWsStore() +// .getKeys() +// .forEach((wsKey) => { +// const state = wsClient.getWsStore().get(wsKey); +// console.log(`${wsKey} state: `, state.subscribedTopics.values()); +// }); ⋮---- -export interface StockPlusStaticInfoV3 { - list: StockPlusStaticInfoItemV3[]; -} +// setTimeout(() => { +// wsClient.unsubscribeTopic('USDT-FUTURES', 'account'); +// }, 1000 * 2); ⋮---- -export interface StockPlusSessionQuoteV3 { - lastDone: string | number; - timestamp: string; - volume: string | number; - turnover: string | number; - high: string | number; - low: string | number; - prevClose: string | number; -} +// setTimeout(() => { +// wsClient +// .getWsStore() +// .getKeys() +// .forEach((wsKey) => { +// const state = wsClient.getWsStore().get(wsKey); +// console.log(`${wsKey} state: `, state.subscribedTopics.values()); +// }); +// }, 1000 * 5); + +================ +File: examples/V2 - Classic/Websocket/ws-public.ts +================ +import { + DefaultLogger, + WebsocketClientV2, + WS_KEY_MAP, +} from '../../../src/index.js'; ⋮---- -export interface StockPlusQuoteItemV3 { - symbol: string; - lastDone: string | number; - prevClose: string | number; - open: string | number; - high: string | number; - low: string | number; - timestamp: string; - volume: string | number; - turnover: string | number; - tradeStatus: string; - preMarketQuote?: StockPlusSessionQuoteV3 | null; - postMarketQuote?: StockPlusSessionQuoteV3 | null; - overnightQuote?: StockPlusSessionQuoteV3 | null; -} +// or +// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; ⋮---- -export interface StockPlusQuoteV3 { - list: StockPlusQuoteItemV3[]; -} +// restOptions: { +// optionally provide rest options, e.g. to pass through a proxy +// }, ⋮---- -export interface StockPlusTradeDetailItemV3 { - price: string | number; - volume: string | number; - timestamp: string; - tradeType: string; - direction: string; - tradeSession: string; -} +// console.log('WS raw message received ', JSON.stringify(data, null, 2)); ⋮---- -export type StockPlusTradeDetailV3 = StockPlusTradeDetailItemV3[]; +/** + * Public events + */ ⋮---- -export interface StockPlusIntradayItemV3 { - price: string | number; - timestamp: string; - volume: string | number; - turnover: string | number; - avgPrice: string | number; -} +// Spot public ⋮---- -export interface StockPlusIntradayV3 { - list: StockPlusIntradayItemV3[]; -} +// tickers ⋮---- -export interface StockPlusCandlestickItemV3 { - close: string; - open: string; - low: string; - high: string; - volume: string; - turnover: string; - timestamp: string; - tradeSession: string; -} +// candles +// wsClient.subscribeTopic('SPOT', 'candle1m', symbol); ⋮---- -export interface StockPlusCandlestickV3 { - list: StockPlusCandlestickItemV3[]; -} -⋮---- -export type StockPlusHistoryCandlestickV3 = StockPlusCandlestickV3; -⋮---- -export interface StockPlusDepthLevelV3 { - position: number; - price: string; - volume: string; - orderNum: number; -} -⋮---- -export interface StockPlusDepthV3 { - asks: StockPlusDepthLevelV3[]; - bids: StockPlusDepthLevelV3[]; -} -⋮---- -export interface StockPlusPlaceOrderResponseV3 { - orderId: string; - clientOid: string; - symbol: string; -} -⋮---- -export type StockPlusCancelOrderResponseV3 = StockPlusPlaceOrderResponseV3; -export type StockPlusModifyOrderResponseV3 = StockPlusPlaceOrderResponseV3; -⋮---- -export interface StockPlusOrderV3 { - orderId: string; - status: string; - stockName: string; - quantity: string | number; - executedQuantity: string | number; - price: string | number | null; - executedPrice: string | number | null; - submittedAt: string; - side: string; - symbol: string; - orderType: string; - lastDone: string | number | null; - triggerPrice: string | number | null; - msg: string; - tag: string; - timeInForce: string; - expireDate: string | null; - updatedAt: string | null; - triggerAt: string | null; - trailingAmount: string | number | null; - trailingPercent: string | number | null; - limitOffset: string | number | null; - triggerStatus: string | null; - currency: string; - outsideRth: string; - remark?: string; - limitDepthLevel: number | null; - triggerCount: number | null; - monitorPrice: string | null; -} +// orderbook updates +// wsClient.subscribeTopic('SPOT', 'books', symbol); ⋮---- -export interface StockPlusOrdersV3 { - orders: StockPlusOrderV3[]; -} +// trades +// wsClient.subscribeTopic('SPOT', 'trade', symbol); ⋮---- -export interface StockPlusHistoryOrdersV3 { - hasMore: boolean; - orders: StockPlusOrderV3[]; -} +// Futures public ⋮---- -export interface StockPlusOrderHistoryItemV3 { - price: string | number; - quantity: string | number; - status: string; - msg: string; - time: string; -} +// tickers +// wsClient.subscribeTopic('USDT-FUTURES', 'ticker', symbol); ⋮---- -export interface StockPlusChargeFeeItemV3 { - code: string; - name: string; - amount: number | string; - currency: string; -} +// candles +// wsClient.subscribeTopic('USDT-FUTURES', 'candle1m', symbol); ⋮---- -export interface StockPlusChargeCategoryV3 { - code: string; - name: string; - fees: StockPlusChargeFeeItemV3[]; -} +// orderbook updates +// wsClient.subscribeTopic('USDT-FUTURES', 'books', symbol); ⋮---- -export interface StockPlusChargeDetailV3 { - totalAmount: number | string; - currency: string; - items: StockPlusChargeCategoryV3[]; -} +// trades +// wsClient.subscribeTopic('USDT-FUTURES', 'trade', symbol); ⋮---- -export interface StockPlusOrderDetailV3 extends StockPlusOrderV3 { - freeStatus?: string; - freeAmount?: string | null; - freeCurrency?: string | null; - deductionsStatus?: string; - deductionsAmount?: string | null; - deductionsCurrency?: string | null; - platformDeductedStatus?: string; - platformDeductedAmount?: string | null; - platformDeductedCurrency?: string | null; - history?: StockPlusOrderHistoryItemV3[]; - chargeDetail?: StockPlusChargeDetailV3; -} +// Topics are tracked per websocket type +// Get a list of subscribed topics (e.g. all public topics) (after a 5 second delay) + +================ +File: examples/V3 - UTA/Rest/rest-trade-UTA-futures.ts +================ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import { + PlaceOrderRequestV3, + RestClientV3, + WebsocketClientV3, +} from '../../../src/index.js'; ⋮---- -export interface StockPlusExecutionV3 { - orderId: string; - tradeId: string; - symbol: string; - tradeDoneAt: string; - quantity: number | string; - price: number | string; -} +// or +// import { PlaceOrderRequestV3, RestClientV3, WebsocketClientV3 } from '../src'; ⋮---- -export interface StockPlusTodayExecutionsV3 { - trades: StockPlusExecutionV3[]; -} +// read from environmental variables ⋮---- -export interface StockPlusHistoryExecutionsV3 { - hasMore: boolean; - trades: StockPlusExecutionV3[]; -} +// If running from CLI in unix, you can pass env vars as such: +// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/V3/rest-trade-futures.ts ⋮---- -export interface StockPlusCashInfoV3 { - withdrawCash: number | string; - availableCash: number | string; - frozenCash: number | string; - settlingCash: number | string; - currency: string; -} +// note the single quotes, preventing special characters such as $ from being incorrectly passed ⋮---- -export interface StockPlusFrozenTransactionFeeV3 { - currency?: string; - amount?: number | string; - [key: string]: unknown; -} +// apiKey: 'apiKeyHere', +// apiSecret: 'apiSecretHere', +// apiPass: 'apiPassHere', ⋮---- -export interface StockPlusAccountItemV3 { - totalCash: number | string; - maxFinanceAmount: number | string; - remainingFinanceAmount: number | string; - riskLevel: number | string; - marginCall: number | string; - netAssets: number | string; - initMargin: number | string; - maintenanceMargin: number | string; - currency: string; - buyPower: number | string; - cashInfos: StockPlusCashInfoV3[]; - frozenTransactionFees: StockPlusFrozenTransactionFeeV3[]; -} +function logWSEvent(type: string, data: any) ⋮---- -export interface StockPlusAccountV3 { - list: StockPlusAccountItemV3[]; -} +// simple sleep function +function promiseSleep(milliseconds: number) ⋮---- -export interface StockPlusCashFlowItemV3 { - transactionFlowName: string; - direction: string; - businessType: string; - balance: number | string; - currency: string; - businessTime: string; - symbol: string | null; - description: string; -} +/** + * This is a simple script wrapped in a immediately invoked function expression (to execute the below workflow immediately). + * + * It is designed to: + * - open a private websocket channel to log account events + * - check for any available USDT balance in the account + * - immediately open a minimum sized long position on BTCUSDT + * - check active positions + * - immediately send closing orders for any active futures positions + * - check positions again + * + */ ⋮---- -export interface StockPlusCashFlowV3 { - list: StockPlusCashFlowItemV3[]; -} +// Add event listeners to log websocket events on account ⋮---- -export interface StockPlusPositionItemV3 { - symbol: string; - symbolName: string; - quantity: number | string; - availableQuantity: number | string; - currency: string; - costPrice: number | string; - market: string; - initQuantity: number | string; -} +// Subscribe to private topics for UTA account ⋮---- -export interface StockPlusPositionChannelV3 { - accountChannel: string; - positions: StockPlusPositionItemV3[]; -} +// Subscribe to position updates ⋮---- -export interface StockPlusStockPositionV3 { - channels: StockPlusPositionChannelV3[]; -} +// Subscribe to order updates ⋮---- -export interface StockPlusTransferResponseV3 { - transferId: string; -} +// wait briefly for ws to be ready (could also use the response or authenticated events, to make sure topics are subscribed to before starting) ⋮---- -export interface StockPlusTransferRecordsV3 { - transferId: string; - coin: string; - amount: string; - direction: string; - cursor: string; -} +// Loop through any active positions and send a closing market order on each position ================ -File: webpack/webpack.config.cjs +File: examples/V3 - UTA/Rest/rest-trade-UTA-spot.ts ================ -function generateConfig(name) +/* eslint-disable @typescript-eslint/no-unused-vars */ +import { + PlaceOrderRequestV3, + RestClientV3, + WebsocketClientV3, +} from '../../../src/index.js'; ⋮---- -// Add '.ts' and '.tsx' as resolvable extensions. +// import { RestClientV3, WebsocketClientV3 } from '../src/index'; ⋮---- -// Node.js core modules not available in browsers -// The REST client's https.Agent (for keepAlive) is Node.js-only and won't work in browsers -⋮---- -// Code is already transpiled from TypeScript, no additional loaders needed - -================ -File: .npmrc -================ -min-release-age=30 -save-exact=true - -================ -File: .nvmrc -================ -v24.18.0 - -================ -File: examples/auth/fasterHmacSign.ts -================ -import { createHmac } from 'crypto'; -⋮---- -import { - DefaultLogger, - RestClientV3, - WebsocketClientV3, -} from '../../src/index.js'; -⋮---- -// or -// import { createHmac } from 'crypto'; -// import { DefaultLogger, RestClientV3, WebsocketClientV3 } from 'bitget-api'; -⋮---- -/** - * Injecting a custom signMessage function. - * - * As of version 3.0.0 of the bitget-api Node.js/TypeScript/JavaScript - * SDK for Bitget, the SDK uses the Web Crypto API for signing requests. - * While it is compatible with Node and Browser environments, it is - * slightly slower than using Node's native crypto module (only - * available in backend Node environments). - * - * For latency sensitive users, you can inject the previous node crypto sign - * method (or your own even faster implementation), if this change affects you. - * - * This example demonstrates how to inject a custom sign function, to achieve - * the same peformance as seen before the Web Crypto API was introduced. - * - * For context on standard usage, the "signMessage" function is used: - * - During every single API call - * - After opening a new private WebSocket connection - */ -⋮---- -/** - * Set this to true to enable demo trading: - */ -⋮---- -/** - * Overkill in almost every case, but if you need any optimisation available, - * you can inject a faster sign mechanism such as node's native createHmac: - */ -⋮---- -// Optional, uncomment the "trace" override to log a lot more info about what the WS client is doing -⋮---- -// trace: (...params) => console.log('trace', ...params), -⋮---- -/** - * Set this to true to enable demo trading for the private account data WS - * Topics: order,execution,position,wallet,greeks - */ -⋮---- -/** - * Overkill in almost every case, but if you need any optimisation available, - * you can inject a faster sign mechanism such as node's native createHmac: - */ -⋮---- -function setWsClientEventListeners( - websocketClient: WebsocketClientV3, - accountRef: string, -): Promise -⋮---- -// console.log('raw message received ', JSON.stringify(data, null, 2)); -⋮---- -// Simple promise to ensure we're subscribed before trying anything else -⋮---- -// Start trading - -================ -File: examples/V2 - Classic/Rest/rest-trade-futures.ts -================ -import { - FuturesPlaceOrderRequestV2, - RestClientV2, - WebsocketClientV2, -} from '../../../src/index.js'; -⋮---- -// or -// import { FuturesPlaceOrderRequestV2, RestClientV2, WebsocketClientV2 } from '../src'; -⋮---- -// read from environmental variables +// read from environmental variables ⋮---- // If running from CLI in unix, you can pass env vars as such: -// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/rest-trade-futures.ts +// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/V3/rest-trade-spot.ts ⋮---- // note the single quotes, preventing special characters such as $ from being incorrectly passed ⋮---- @@ -6236,945 +5463,1205 @@ function logWSEvent(type: string, data: any) // simple sleep function function promiseSleep(milliseconds: number) ⋮---- -/** - * This is a simple script wrapped in a immediately invoked function expression (to execute the below workflow immediately). - * - * It is designed to: - * - open a private websocket channel to log account events - * - check for any available USDT balance in the futures account - * - immediately open a minimum sized long position on BTCUSDT - * - check active positions - * - immediately send closing orders for any active futures positions - * - check positions again - * - */ +/** This is a simple script wrapped in a immediately invoked function expression, designed to check for any available BTC balance and immediately sell the full amount for USDT */ ⋮---- // Add event listeners to log websocket events on account ⋮---- -// futures private -// : account updates -⋮---- -// : position updates +// Subscribe to private account topics +// Account updates for UTA (unified trading account) ⋮---- -// : order updates +// Order updates for spot ⋮---- // wait briefly for ws to be ready (could also use the response or authenticated events, to make sure topics are subscribed to before starting) -⋮---- -// const balances = allBalances.filter((bal) => Number(bal.available) != 0); -⋮---- -// Loop through any active positions and send a closing market order on each position ================ -File: examples/V2 - Classic/Rest/rest-trade-spot.ts +File: examples/V3 - UTA/Websocket/ws-private.ts ================ import { - RestClientV2, - SpotOrderRequestV2, - WebsocketClientV2, + DefaultLogger, + WebsocketClientV3, + WS_KEY_MAP, } from '../../../src/index.js'; ⋮---- -// import { RestClientV2, WebsocketClient } from '../src/index'; -⋮---- -// read from environmental variables +// or +// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; ⋮---- // If running from CLI in unix, you can pass env vars as such: -// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/rest-trade-spot.ts -⋮---- -// note the single quotes, preventing special characters such as $ from being incorrectly passed -⋮---- -// apiKey: 'apiKeyHere', -// apiSecret: 'apiSecretHere', -// apiPass: 'apiPassHere', -⋮---- -function logWSEvent(type: string, data: any) +// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/ws-private.ts ⋮---- -// simple sleep function -function promiseSleep(milliseconds: number) +// console.log('WS raw message received ', JSON.stringify(data, null, 2)); ⋮---- -/** This is a simple script wrapped in a immediately invoked function expression, designed to check for any available BTC balance and immediately sell the full amount for USDT */ +// You can subscribe to one topic at a time ⋮---- -// Add event listeners to log websocket events on account +instType: 'UTA', // Note: all account events go on the UTA instType ⋮---- -// Subscribe to private account topics -// spot private -// : account updates +WS_KEY_MAP.v3Private, // This parameter points to private or public ⋮---- -// : order updates (note: symbol is required) +// Note: all account events go on the UTA instType ⋮---- -// wait briefly for ws to be ready (could also use the response or authenticated events, to make sure topics are subscribed to before starting) +// Or multiple at once: ⋮---- -// console.log('balance: ', JSON.stringify(balances, null, 2)); +// Topics are tracked per websocket type +// The below example will pull a list of subscribed topics on that connection (e.g. all private topics), after a 5 second delay: ================ -File: examples/V2 - Classic/Websocket/ws-demo-trading.ts +File: examples/V3 - UTA/Websocket/ws-public.ts ================ -import { DefaultLogger, WebsocketClientV2 } from '../../../src/index.js'; +import { + DefaultLogger, + WebsocketClientV3, + WS_KEY_MAP, +} from '../../../src/index.js'; ⋮---- // or // import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; ⋮---- -// If running from CLI in unix, you can pass env vars as such: -// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/ws-private.ts -⋮---- -// restOptions: { -// optionally provide rest options, e.g. to pass through a proxy -// }, -⋮---- -// Set demoTrading to true, to route all connections to the demo trading wss URLs: -⋮---- -// If using private topics, make sure to include API keys -⋮---- // console.log('WS raw message received ', JSON.stringify(data, null, 2)); ⋮---- /** * Public events */ +⋮---- +// You can subscribe to one topic at a time +⋮---- +WS_KEY_MAP.v3Public, // This parameter points to private or public +⋮---- +// Or multiple at once: +⋮---- +// Topics are tracked per websocket type +// The below example will pull a list of subscribed topics on that connection (e.g. all public topics), after a 5 second delay: ================ -File: examples/V2 - Classic/Websocket/ws-private.ts +File: examples/V3 - UTA/WS-API/ws-api-trade-raw.ts ================ -import { DefaultLogger, WebsocketClientV2 } from '../../../src/index.js'; +import { + DefaultLogger, + WebsocketClientV3, + WS_KEY_MAP, +} from '../../../src/index.js'; ⋮---- // or -// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; +// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV3 } from 'bitget-api'; ⋮---- // If running from CLI in unix, you can pass env vars as such: // API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/ws-private.ts ⋮---- -// note the single quotes, preventing special characters such as $ from being incorrectly passed -⋮---- -// restOptions: { -// optionally provide rest options, e.g. to pass through a proxy -// }, -⋮---- // console.log('WS raw message received ', JSON.stringify(data, null, 2)); ⋮---- -// auth happens async after the ws connection opens +/** + * Bitget's WebSocket API can be used via the sendWSAPIRequest() method. + * + * Use the `WS_KEY_MAP.v3Private` connection key for any requests. + * + * Note: this requires V3/UTA API keys! + * Note: for a better user experience, it is recommended to use the WebsocketAPIClient. + */ ⋮---- -// wsClient.subscribePublicSpotTickers(['BTCUSDT', 'LTCUSDT']); +// Use the V3 private wss connection URL ⋮---- /** - * Private account updates + * Place Order + * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters */ ⋮---- -// spot private -// : account updates -⋮---- -// : order updates (note: symbol is required) -// wsClient.subscribeTopic('SPOT', 'orders', 'BTCUSDT'); +/** + 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" + }; + */ ⋮---- -// futures private -// : account updates +/** + * Batch Place Order Channel + * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel + */ ⋮---- -// : position updates -// wsClient.subscribeTopic('USDT-FUTURES', 'positions'); +/** + * 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. + */ ⋮---- -// : order updates -// wsClient.subscribeTopic('USDT-FUTURES', 'orders'); -⋮---- -// : plan order updates -// wsClient.subscribeTopic('USDT-FUTURES', 'orders-algo'); -⋮---- -// wsClient -// .getWsStore() -// .getKeys() -// .forEach((wsKey) => { -// const state = wsClient.getWsStore().get(wsKey); -// console.log(`${wsKey} state: `, state.subscribedTopics.values()); -// }); -⋮---- -// setTimeout(() => { -// wsClient.unsubscribeTopic('USDT-FUTURES', 'account'); -// }, 1000 * 2); -⋮---- -// setTimeout(() => { -// wsClient -// .getWsStore() -// .getKeys() -// .forEach((wsKey) => { -// const state = wsClient.getWsStore().get(wsKey); -// console.log(`${wsKey} state: `, state.subscribedTopics.values()); -// }); -// }, 1000 * 5); - -================ -File: examples/V2 - Classic/Websocket/ws-public.ts -================ -import { - DefaultLogger, - WebsocketClientV2, - WS_KEY_MAP, -} from '../../../src/index.js'; -⋮---- -// or -// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; -⋮---- -// restOptions: { -// optionally provide rest options, e.g. to pass through a proxy -// }, -⋮---- -// console.log('WS raw message received ', JSON.stringify(data, null, 2)); +/** + 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" + } + */ ⋮---- /** - * Public events + * Cancel Order + * https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel */ ⋮---- -// Spot public -⋮---- -// tickers -⋮---- -// candles -// wsClient.subscribeTopic('SPOT', 'candle1m', symbol); -⋮---- -// orderbook updates -// wsClient.subscribeTopic('SPOT', 'books', symbol); -⋮---- -// trades -// wsClient.subscribeTopic('SPOT', 'trade', symbol); -⋮---- -// Futures public -⋮---- -// tickers -// wsClient.subscribeTopic('USDT-FUTURES', 'ticker', symbol); -⋮---- -// candles -// wsClient.subscribeTopic('USDT-FUTURES', 'candle1m', symbol); -⋮---- -// orderbook updates -// wsClient.subscribeTopic('USDT-FUTURES', 'books', symbol); +/** + const res = { + "event": "trade", + "id": "1750034870205", + "topic": "cancel-order", + "args": [ + { + "orderId": "xxxxxxxx", + "clientOid": "xxxxxxxx" + } + ], + "code": "0", + "msg": "Success", + "ts": "1750034870597" + } + */ ⋮---- -// trades -// wsClient.subscribeTopic('USDT-FUTURES', 'trade', symbol); +/** + * Batch Cancel Order + * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Cancel-Order-Channel + */ ⋮---- -// Topics are tracked per websocket type -// Get a list of subscribed topics (e.g. all public topics) (after a 5 second delay) +/** + 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: examples/V3 - UTA/Rest/rest-trade-UTA-futures.ts +File: src/types/request/v2/common.ts ================ -/* eslint-disable @typescript-eslint/no-unused-vars */ -import { - PlaceOrderRequestV3, - RestClientV3, - WebsocketClientV3, -} from '../../../src/index.js'; -⋮---- -// or -// import { PlaceOrderRequestV3, RestClientV3, WebsocketClientV3 } from '../src'; -⋮---- -// read from environmental variables +import { FuturesProductTypeV2, MarginType } from '../shared.js'; ⋮---- -// If running from CLI in unix, you can pass env vars as such: -// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/V3/rest-trade-futures.ts +/** + * + * * Common | Notice + * + */ ⋮---- -// note the single quotes, preventing special characters such as $ from being incorrectly passed +export interface GetAnnouncementsRequestV2 { + annType?: string; + startTime?: string; + endTime?: string; + language: string; +} ⋮---- -// apiKey: 'apiKeyHere', -// apiSecret: 'apiSecretHere', -// apiPass: 'apiPassHere', +/** + * + * * Common | Public + * + */ ⋮---- -function logWSEvent(type: string, data: any) +export interface GetTradeRateRequestV2 { + symbol: string; + businessType: string; +} ⋮---- -// simple sleep function -function promiseSleep(milliseconds: number) +export interface GetAllTradeRatesRequestV2 { + businessType: string; +} ⋮---- /** - * This is a simple script wrapped in a immediately invoked function expression (to execute the below workflow immediately). * - * It is designed to: - * - open a private websocket channel to log account events - * - check for any available USDT balance in the account - * - immediately open a minimum sized long position on BTCUSDT - * - check active positions - * - immediately send closing orders for any active futures positions - * - check positions again + * * Common | Tax * */ ⋮---- -// Add event listeners to log websocket events on account -⋮---- -// Subscribe to private topics for UTA account +export interface GetSpotTransactionsRequestV2 { + coin?: string; + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; +} ⋮---- -// Subscribe to position updates +export interface GetFuturesTransactionsRequestV2 { + productType?: FuturesProductTypeV2; + marginCoin?: string; + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; +} ⋮---- -// Subscribe to order updates +export interface GetMarginTransactionsRequestV2 { + marginType?: MarginType; + coin?: string; + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; +} ⋮---- -// wait briefly for ws to be ready (could also use the response or authenticated events, to make sure topics are subscribed to before starting) +export interface GetP2PTransactionsRequestV2 { + coin?: string; + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; +} ⋮---- -// Loop through any active positions and send a closing market order on each position - -================ -File: examples/V3 - UTA/Rest/rest-trade-UTA-spot.ts -================ -/* eslint-disable @typescript-eslint/no-unused-vars */ -import { - PlaceOrderRequestV3, - RestClientV3, - WebsocketClientV3, -} from '../../../src/index.js'; +/** + * + * * Common | P2P + * + */ ⋮---- -// import { RestClientV3, WebsocketClientV3 } from '../src/index'; +export interface GetP2PMerchantsRequestV2 { + online?: 'yes' | 'no'; + idLessThan?: string; + limit?: string; +} ⋮---- -// read from environmental variables -⋮---- -// If running from CLI in unix, you can pass env vars as such: -// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/V3/rest-trade-spot.ts -⋮---- -// note the single quotes, preventing special characters such as $ from being incorrectly passed -⋮---- -// apiKey: 'apiKeyHere', -// apiSecret: 'apiSecretHere', -// apiPass: 'apiPassHere', -⋮---- -function logWSEvent(type: string, data: any) +export interface GetMerchantP2POrdersRequestV2 { + startTime: string; + endTime?: string; + idLessThan?: string; + limit?: string; + status?: string; + advNo: string; + side?: string; + coin?: string; + language: string; + fiat?: string; + orderNo?: string; +} ⋮---- -// simple sleep function -function promiseSleep(milliseconds: number) +export interface GetMerchantAdvertisementsRequestV2 { + startTime: string; + endTime?: string; + idLessThan?: string; + limit?: string; + status: string; + advNo?: string; + side: string; + coin: string; + language?: string; + fiat: string; + orderBy?: string; + payMethodId?: string; + sourceType?: string; +} ⋮---- -/** This is a simple script wrapped in a immediately invoked function expression, designed to check for any available BTC balance and immediately sell the full amount for USDT */ +/** + * + * * Common | Virtual Subaccount + * + */ ⋮---- -// Add event listeners to log websocket events on account +export interface ModifyVirtualSubRequestV2 { + subAccountUid: string; + permList: string[]; + status: string; +} ⋮---- -// Subscribe to private account topics -// Account updates for UTA (unified trading account) +export interface CreateVirtualSubRequestV2 { + subAccountName: string; + passphrase: string; + label: string; + ipList?: string[]; + permList?: string[]; +} ⋮---- -// Order updates for spot +export interface CreateVirtualSubApiKeyRequestV2 { + subAccountUid: string; + passphrase: string; + label: string; + ipList?: string[]; + permList?: string[]; +} ⋮---- -// wait briefly for ws to be ready (could also use the response or authenticated events, to make sure topics are subscribed to before starting) - -================ -File: examples/V3 - UTA/Websocket/ws-private.ts -================ -import { - DefaultLogger, - WebsocketClientV3, - WS_KEY_MAP, -} from '../../../src/index.js'; +export interface ModifyVirtualSubApiKeyRequestV2 { + subAccountUid: string; + subAccountApiKey: string; + passphrase: string; + label: string; + ipList?: string[]; + permList?: string[]; +} ⋮---- -// or -// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; +export interface CreateAgentSubaccountRequestV2 { + /** Lowercase letters only; max 20 characters */ + username: string; + /** 8–32 characters, letters and numbers */ + passphrase: string; + note?: 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 +/** Lowercase letters only; max 20 characters */ ⋮---- -// console.log('WS raw message received ', JSON.stringify(data, null, 2)); +/** 8–32 characters, letters and numbers */ ⋮---- -// You can subscribe to one topic at a time +/** + * + * * Common | Convert + * + */ ⋮---- -instType: 'UTA', // Note: all account events go on the UTA instType +export interface ConvertQuoteRequestV2 { + fromCoin: string; + fromCoinSize?: string; + toCoin: string; + toCoinSize?: string; +} ⋮---- -WS_KEY_MAP.v3Private, // This parameter points to private or public +export interface ConvertRequestV2 { + fromCoin: string; + fromCoinSize: string; + cnvtPrice: string; + toCoin: string; + toCoinSize: string; + traceId: string; +} ⋮---- -// Note: all account events go on the UTA instType +export interface GetConvertHistoryRequestV2 { + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; +} ⋮---- -// Or multiple at once: +/** + * + * * Common | BGB Convert + * + */ ⋮---- -// Topics are tracked per websocket type -// The below example will pull a list of subscribed topics on that connection (e.g. all private topics), after a 5 second delay: +export interface GetConvertBGBHistoryRequestV2 { + orderId?: string; + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; +} ================ -File: examples/V3 - UTA/Websocket/ws-public.ts +File: src/types/request/v2/futures.ts ================ -import { - DefaultLogger, - WebsocketClientV3, - WS_KEY_MAP, -} from '../../../src/index.js'; +import { FuturesPlanTypeV2, FuturesProductTypeV2 } from '../shared.js'; ⋮---- -// or -// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; +export type FuturesKlineInterval = + | '1m' + | '3m' + | '5m' + | '15m' + | '30m' + | '1H' + | '2H' + | '4H' + | '6H' + | '12H' + | '1D' + | '3D' + | '1W' + | '1M' + | '6Hutc' + | '12Hutc' + | '1Dutc' + | '3Dutc' + | '1Wutc' + | '1Mutc'; ⋮---- -// console.log('WS raw message received ', JSON.stringify(data, null, 2)); +export type FuturesKlineTypeV2 = 'MARKET' | 'MARK' | 'INDEX'; ⋮---- -/** - * Public events - */ +export interface FuturesAccountBillRequestV2 { + productType: FuturesProductTypeV2; + symbol?: string; + coin?: string; + businessType?: string; + idLessThan?: string; + startTime?: string; + endTime?: string; + limit?: string; +} ⋮---- -// You can subscribe to one topic at a time +/** + * + * * Futures | Market + * + */ ⋮---- -WS_KEY_MAP.v3Public, // This parameter points to private or public +export interface FuturesMergeDepthRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + precision?: 'scale0' | 'scale1' | 'scale2' | 'scale3'; + limit?: '1' | '5' | '15' | '50' | 'max'; +} ⋮---- -// Or multiple at once: +export interface FuturesOiLimitRequestV2 { + productType: FuturesProductTypeV2; + symbol?: string; +} ⋮---- -// Topics are tracked per websocket type -// The below example will pull a list of subscribed topics on that connection (e.g. all public topics), after a 5 second delay: - -================ -File: examples/V3 - UTA/WS-API/ws-api-trade-raw.ts -================ -import { - DefaultLogger, - WebsocketClientV3, - WS_KEY_MAP, -} from '../../../src/index.js'; +export interface FuturesPositionAdlRankRequestV2 { + productType: FuturesProductTypeV2; +} ⋮---- -// or -// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV3 } from 'bitget-api'; +export interface FuturesRecentTradesRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + limit?: 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 FuturesHistoricTradesRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + limit?: string; + idLessThan?: string; + startTime?: string; + endTime?: string; +} ⋮---- -// console.log('WS raw message received ', JSON.stringify(data, null, 2)); -⋮---- -/** - * Bitget's WebSocket API can be used via the sendWSAPIRequest() method. - * - * Use the `WS_KEY_MAP.v3Private` connection key for any requests. - * - * Note: this requires V3/UTA API keys! - * Note: for a better user experience, it is recommended to use the WebsocketAPIClient. - */ -⋮---- -// Use the V3 private wss connection URL -⋮---- -/** - * 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/request/v2/common.ts -================ -import { FuturesProductTypeV2, MarginType } from '../shared.js'; +export interface FuturesCandlesRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + granularity: FuturesKlineInterval; + startTime?: string; + endTime?: string; + kLineType?: FuturesKlineTypeV2; + limit?: string; +} ⋮---- /** * - * * Common | Notice + * * Futures | Account * */ ⋮---- -export interface GetAnnouncementsRequestV2 { - annType?: string; +export interface FuturesSingleAccountRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + marginCoin: string; +} +⋮---- +export interface FuturesInterestHistoryRequestV2 { + productType: 'USDT-FUTURES' | 'SUSDT-FUTURES'; + coin?: string; + idLessThan?: string; startTime?: string; endTime?: string; - language: string; + limit?: string; } ⋮---- -/** - * - * * Common | Public - * - */ -⋮---- -export interface GetTradeRateRequestV2 { +export interface FuturesOpenCountRequestV2 { symbol: string; - businessType: string; -} -⋮---- -export interface GetAllTradeRatesRequestV2 { - businessType: string; + productType: FuturesProductTypeV2; + marginCoin: string; + openAmount: string; + openPrice: string; + leverage?: string; } ⋮---- -/** - * - * * Common | Tax - * - */ -⋮---- -export interface GetSpotTransactionsRequestV2 { - coin?: string; - startTime: string; - endTime: string; - limit?: string; - idLessThan?: string; +export interface FuturesSetAutoMarginRequestV2 { + symbol: string; + autoMargin: 'on' | 'off'; + marginCoin: string; + amount: string; + holdSide?: 'long' | 'short'; } ⋮---- -export interface GetFuturesTransactionsRequestV2 { - productType?: FuturesProductTypeV2; - marginCoin?: string; - startTime: string; - endTime: string; - limit?: string; - idLessThan?: string; +export interface FuturesSetLeverageRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + marginCoin: string; + leverage: string; + holdSide?: 'long' | 'short'; } ⋮---- -export interface GetMarginTransactionsRequestV2 { - marginType?: MarginType; - coin?: string; - startTime: string; - endTime: string; - limit?: string; - idLessThan?: string; +export interface FuturesSetPositionMarginRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + marginCoin: string; + holdSide: 'long' | 'short'; + amount: string; } ⋮---- -export interface GetP2PTransactionsRequestV2 { - coin?: string; - startTime: string; - endTime: string; - limit?: string; - idLessThan?: string; +export interface FuturesSetMarginModeRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + marginCoin: string; + marginMode: 'isolated' | 'crossed'; } ⋮---- /** * - * * Common | P2P + * * Futures | Position * */ ⋮---- -export interface GetP2PMerchantsRequestV2 { - online?: 'yes' | 'no'; - idLessThan?: string; - limit?: string; -} -⋮---- -export interface GetMerchantP2POrdersRequestV2 { - startTime: string; - endTime?: string; +export interface FuturesHistoricalPositionsRequestV2 { + symbol?: string; + productType?: FuturesProductTypeV2; idLessThan?: string; - limit?: string; - status?: string; - advNo: string; - side?: string; - coin?: string; - language: string; - fiat?: string; - orderNo?: string; -} -⋮---- -export interface GetMerchantAdvertisementsRequestV2 { - startTime: string; + startTime?: string; endTime?: string; - idLessThan?: string; limit?: string; - status: string; - advNo?: string; - side: string; - coin: string; - language?: string; - fiat: string; - orderBy?: string; - payMethodId?: string; - sourceType?: string; } ⋮---- /** * - * * Common | Virtual Subaccount + * * Futures | Trade * */ ⋮---- -export interface ModifyVirtualSubRequestV2 { - subAccountUid: string; - permList: string[]; - status: string; -} -⋮---- -export interface CreateVirtualSubRequestV2 { - subAccountName: string; - passphrase: string; - label: string; - ipList?: string[]; - permList?: string[]; -} -⋮---- -export interface CreateVirtualSubApiKeyRequestV2 { - subAccountUid: string; - passphrase: string; - label: string; - ipList?: string[]; - permList?: string[]; +export interface FuturesPlaceOrderRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + marginMode: 'isolated' | 'crossed'; + marginCoin: string; + size: string; + price?: string; + side: 'buy' | 'sell'; + tradeSide?: 'open' | 'close'; + orderType: 'limit' | 'market'; + force?: 'ioc' | 'fok' | 'gtc' | 'post_only'; + clientOid?: string; + reduceOnly?: 'YES' | 'NO'; + presetStopSurplusPrice?: string; + presetStopLossPrice?: string; + stpMode?: 'none' | 'cancel_taker' | 'cancel_maker' | 'cancel_both'; } ⋮---- -export interface ModifyVirtualSubApiKeyRequestV2 { - subAccountUid: string; - subAccountApiKey: string; - passphrase: string; - label: string; - ipList?: string[]; - permList?: string[]; +export interface FuturesReversalOrderRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + marginCoin: string; + size: string; + side?: 'buy' | 'sell'; + tradeSide?: 'open' | 'close'; + clientOid?: string; } ⋮---- -export interface CreateAgentSubaccountRequestV2 { - /** Lowercase letters only; max 20 characters */ - username: string; - /** 8–32 characters, letters and numbers */ - passphrase: string; - note?: string; +interface FuturesBatchOrderItem { + size: string; + price?: string; + side: 'buy' | 'sell'; + tradeSide?: 'open' | 'close'; + orderType: 'limit' | 'market'; + force?: 'ioc' | 'fok' | 'gtc' | 'post_only'; + clientOid?: string; + reduceOnly?: 'YES' | 'NO'; + presetStopSurplusPrice?: string; + presetStopLossPrice?: string; + stpMode?: 'none' | 'cancel_taker' | 'cancel_maker' | 'cancel_both'; } ⋮---- -/** Lowercase letters only; max 20 characters */ -⋮---- -/** 8–32 characters, letters and numbers */ -⋮---- -/** - * - * * Common | Convert - * - */ -⋮---- -export interface ConvertQuoteRequestV2 { - fromCoin: string; - fromCoinSize?: string; - toCoin: string; - toCoinSize?: string; +export interface FuturesBatchOrderRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + marginCoin: string; + marginMode: 'isolated' | 'crossed'; + orderList: FuturesBatchOrderItem[]; } ⋮---- -export interface ConvertRequestV2 { - fromCoin: string; - fromCoinSize: string; - cnvtPrice: string; - toCoin: string; - toCoinSize: string; - traceId: string; +export interface FuturesModifyOrderRequestV2 { + orderId?: string; + clientOid?: string; + symbol: string; + productType: FuturesProductTypeV2; + newClientOid: string; + newSize?: string; + newPrice?: string; + newPresetStopSurplusPrice?: string; + newPresetStopLossPrice?: string; } ⋮---- -export interface GetConvertHistoryRequestV2 { - startTime: string; - endTime: string; - limit?: string; - idLessThan?: string; +export interface FuturesCancelOrderRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + marginCoin?: string; + orderId?: string; + clientOid?: string; } ⋮---- -/** - * - * * Common | BGB Convert - * - */ -⋮---- -export interface GetConvertBGBHistoryRequestV2 { +interface FuturesBatchCancelOrderItem { orderId?: string; - startTime: string; - endTime: string; - limit?: string; - idLessThan?: string; -} - -================ -File: src/types/request/v3/broker.ts -================ -export interface CreateBrokerSubAccountRequestV3 { - subaccountName: string; - label: string; + clientOid?: string; } ⋮---- -export interface GetBrokerSubAccountListRequestV3 { - limit?: string; - cursor?: string; - status?: 'normal' | 'freeze'; +export interface FuturesBatchCancelOrderRequestV2 { + orderIdList?: FuturesBatchCancelOrderItem[]; + symbol?: string; + productType: FuturesProductTypeV2; + marginCoin?: string; } ⋮---- -export interface ModifyBrokerSubAccountRequestV3 { - subUid: string; - status?: 'normal' | 'freeze'; - permList?: string[]; +export interface FuturesFlashClosePositionsRequestV2 { + symbol?: string; + productType: FuturesProductTypeV2; + holdSide?: 'long' | 'short'; } ⋮---- -export interface BrokerSubWithdrawalRequestV3 { - subUid: string; - coin: string; - dest: 'on_chain' | 'internal_transfer'; - address: string; - amount: string; - chain?: string; - tag?: string; +export interface FuturesGetOrderRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + orderId?: string; clientOid?: string; } ⋮---- -export interface GetBrokerSubDepositAddressRequestV3 { - subUid: string; - coin: string; - chain?: string; +export interface FuturesGetOrderFillsRequestV2 { + orderId?: string; + symbol?: string; + productType: FuturesProductTypeV2; + idLessThan?: string; + startTime?: string; + endTime?: string; + limit?: string; } ⋮---- -export interface GetBrokerAllSubDepositWithdrawalRequestV3 { +export interface FuturesGetHistoricalFillsRequestV2 { + orderId?: string; + symbol?: string; + productType: FuturesProductTypeV2; startTime?: string; endTime?: string; + idLessThan?: string; limit?: string; - cursor?: string; - status?: 'pending' | 'fail' | 'success'; } ⋮---- -export interface GetBrokerCommissionRequestV3 { +export interface FuturesGetOpenOrdersRequestV2 { + orderId?: string; + clientOid?: string; + symbol?: string; + productType: FuturesProductTypeV2; + /** Defaults to live; query partially_filled separately to include partially filled orders. */ + status?: 'live' | 'partially_filled'; + idLessThan?: string; startTime?: string; endTime?: string; - pageSize?: string; - pageNo?: string; - bizType?: 'spot' | 'futures'; - subBizType?: - | 'spot_trade' - | 'spot_margin' - | 'usdt_futures' - | 'usdc_futures' - | 'coin_futures'; + limit?: string; } ⋮---- -export interface CreateBrokerSubApiKeyRequestV3 { - subUid: string; - passphrase: string; - label: string; - ipList?: string[]; - permType: 'read_write' | 'read_only'; - permList: string[]; -} +/** Defaults to live; query partially_filled separately to include partially filled orders. */ ⋮---- -export interface ModifyBrokerSubApiKeyRequestV3 { - subUid: string; - passphrase: string; - apiKey: string; - label?: string; - ipList?: string[]; - permType?: 'read_write' | 'read_only'; - permList?: string[]; +export type FuturesOrderSourceV2 = + | 'normal' + | 'market' + | 'profit_market' + | 'loss_market' + | 'Trader_delegate' + | 'trader_profit' + | 'trader_loss' + | 'reverse' + | 'trader_reverse' + | 'profit_limit' + | 'loss_limit' + | 'liquidation' + | 'delivery_close_long' + | 'delivery_close_short' + | 'pos_profit_limit' + | 'pos_profit_market' + | 'pos_loss_limit' + | 'pos_loss_market'; +⋮---- +export interface FuturesGetHistoryOrdersRequestV2 { + orderId?: string; + clientOid?: string; + symbol?: string; + productType: FuturesProductTypeV2; + idLessThan?: string; + orderSource?: FuturesOrderSourceV2; + startTime?: string; + endTime?: string; + limit?: string; } ⋮---- -export interface DeleteBrokerSubApiKeyRequestV3 { - subUid: string; - apiKey: string; +export interface FuturesCancelAllOrdersRequestV2 { + symbol?: string; + productType: FuturesProductTypeV2; + marginCoin?: string; + requestTime?: string; + receiveWindow?: string; } ⋮---- -export interface GetBrokerSubApiKeyRequestV3 { - subUid: 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'; +/** + * + * * Futures | Trigger Orders + * + */ ⋮---- -export type CfdTransferAccountTypeV3 = 'funding' | 'uta'; +export type FuturesTriggerTypeV2 = 'fill_price' | 'mark_price'; ⋮---- -export type CfdTransferDirectionV3 = 'in' | 'out'; +export type FuturesStpModeV2 = + | 'none' + | 'cancel_taker' + | 'cancel_maker' + | 'cancel_both'; ⋮---- -export interface GetCfdTickersRequestV3 { - symbol?: string; +export interface FuturesTPSLOrderRequestV2 { + marginCoin: string; + productType: FuturesProductTypeV2; + symbol: string; + planType: FuturesPlanTypeV2; + triggerPrice: string; + triggerType?: FuturesTriggerTypeV2; + executePrice?: string; + holdSide: 'long' | 'short' | 'buy' | 'sell'; + size: string; + rangeRate?: string; + clientOid?: string; + stpMode?: FuturesStpModeV2; } ⋮---- -export interface GetCfdHistoryCandlestickRequestV3 { +export interface FuturesPositionTPSLOrderRequestV2 { + marginCoin: string; + productType: FuturesProductTypeV2; symbol: string; - interval: CfdKlineIntervalV3; - side?: CfdSideV3; - startTime?: string; - endTime?: string; - limit?: string; + stopSurplusTriggerPrice?: string; + stopSurplusSize?: string; + stopSurplusTriggerType?: FuturesTriggerTypeV2; + stopSurplusExecutePrice?: string; + stopLossTriggerPrice?: string; + stopLossSize?: string; + stopLossTriggerType?: FuturesTriggerTypeV2; + stopLossExecutePrice?: string; + holdSide: 'long' | 'short' | 'buy' | 'sell'; + stpMode?: FuturesStpModeV2; + stopSurplusClientOid?: string; + stopLossClientOid?: string; } ⋮---- -export interface PlaceCfdOrderRequestV3 { +export type FuturesTriggerPriceTypeV2 = + | 'fill_price' + | 'mark_price' + | 'index_price'; +⋮---- +export interface FuturesPlanOrderRequestV2 { + planType: 'normal_plan' | 'track_plan'; symbol: string; - orderType: CfdOrderTypeV3; - side: CfdSideV3; - qty: string; + productType: FuturesProductTypeV2; + marginMode: 'isolated' | 'crossed'; + marginCoin: string; + size: string; price?: string; - takeProfit?: string; - stopLoss?: string; + callbackRatio?: string; + triggerPrice: string; + triggerType: 'mark_price' | 'fill_price'; + side: 'buy' | 'sell'; + tradeSide?: 'open' | 'close'; + orderType: 'limit' | 'market'; + clientOid?: string; + reduceOnly?: 'YES' | 'NO'; + stopSurplusTriggerPrice?: string; + stopSurplusExecutePrice?: string; + stopSurplusTriggerType?: FuturesTriggerPriceTypeV2; + stopLossTriggerPrice?: string; + stopLossExecutePrice?: string; + stopLossTriggerType?: FuturesTriggerPriceTypeV2; + stpMode?: FuturesStpModeV2; } ⋮---- -export interface ModifyCfdOrderRequestV3 { - orderId: string; - price?: string; - takeProfit?: string; - stopLoss?: string; +export interface FuturesModifyTPSLOrderRequestV2 { + orderId?: string; + clientOid?: string; + marginCoin: string; + productType: FuturesProductTypeV2; + symbol: string; + triggerPrice: string; + triggerType?: 'fill_price' | 'mark_price'; + executePrice?: string; + size: string; + rangeRate?: string; } ⋮---- -export interface CancelCfdOrderRequestV3 { - orderId: string; +export interface FuturesModifyPlanOrderRequestV2 { + planType: 'normal_plan' | 'track_plan'; + orderId?: string; + clientOid?: string; + symbol: string; + productType: FuturesProductTypeV2; + newSize?: string; + newPrice?: string; + newCallbackRatio?: string; + newTriggerPrice?: string; + newTriggerType?: 'fill_price' | 'mark_price'; + newStopSurplusTriggerPrice?: string; + newStopSurplusExecutePrice?: string; + newStopSurplusTriggerType?: FuturesTriggerPriceTypeV2; + newStopLossTriggerPrice?: string; + newStopLossExecutePrice?: string; + newStopLossTriggerType?: FuturesTriggerPriceTypeV2; } ⋮---- -export interface CancelAllCfdOrdersRequestV3 { +export interface FuturesGetPlanOrdersRequestV2 { + orderId?: string; + clientOid?: string; symbol?: string; + /** A single plan type per request; comma-separated values are not supported. */ + planType: 'normal_plan' | 'track_plan' | 'profit_loss'; + productType: FuturesProductTypeV2; + idLessThan?: string; + startTime?: string; + endTime?: string; + limit?: string; } ⋮---- -export interface CloseCfdPositionsRequestV3 { - positionId: string; - qty: string; -} +/** A single plan type per request; comma-separated values are not supported. */ ⋮---- -export interface CloseAllCfdPositionsRequestV3 { - symbol?: string; +interface FuturesCancelPlanOrderItemV2 { + orderId?: string; + clientOid?: string; } ⋮---- -export interface GetCfdUnfilledOrdersRequestV3 { +export type FuturesPlanOrderTypeV2 = + | 'normal_plan' + | 'profit_plan' + | 'loss_plan' + | 'pos_profit' + | 'pos_loss' + | 'moving_plan'; +⋮---- +export interface FuturesCancelPlanOrderRequestV2 { + orderIdList?: FuturesCancelPlanOrderItemV2[]; symbol?: string; - subUid?: string; + productType: FuturesProductTypeV2; + marginCoin?: string; + planType?: FuturesPlanOrderTypeV2; } ⋮---- -export interface GetCfdOrderHistoryRequestV3 { - symbol: string; - subUid?: string; +export type FuturesPlanStatusV2 = 'executed' | 'fail_trigger' | 'cancelled'; +⋮---- +export interface FuturesGetHistoryPlanOrdersRequestV2 { + orderId?: string; + clientOid?: string; + planType: 'normal_plan' | 'track_plan' | 'profit_loss'; + planStatus?: FuturesPlanStatusV2; + symbol?: string; + productType: FuturesProductTypeV2; + idLessThan?: string; startTime?: string; endTime?: string; - /** Default 10, range [1, 50]. The first page may return more rows than limit. */ limit?: string; - pageNo?: string; - /** - * Not required for the first page. - * From the second page, pass the orderId of the last record from the previous page. - */ - cursor?: string; } ⋮---- -/** Default 10, range [1, 50]. The first page may return more rows than limit. */ -⋮---- /** - * Not required for the first page. - * From the second page, pass the orderId of the last record from the previous page. - */ + * + * * Futures | Union Margin + * + */ ⋮---- -export interface GetCfdCurrentPositionsRequestV3 { - symbol?: string; - subUid?: string; +export interface GetUnionTransferLimitsRequestV2 { + coin: string; } ⋮---- -export interface CfdTransferRequestV3 { +export interface UnionConvertRequestV2 { coin: string; amount: string; - accountType: CfdTransferAccountTypeV3; - direction: CfdTransferDirectionV3; } ⋮---- -export interface GetCfdTransferRecordsRequestV3 { - transferId?: string; - subUid?: string; - startTime?: string; - endTime?: string; - direction?: CfdTransferDirectionV3; - limit?: string; -} +/** + * + * * Futures | Account | Max Openable Quantity + * + */ ⋮---- -export interface GetCfdFinancialRecordsRequestV3 { - type?: string; - startTime?: string; - endTime?: string; - limit?: string; +export interface FuturesMaxOpenRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + marginCoin: string; + posSide: 'long' | 'short'; + orderType: 'limit' | 'market'; + openPrice?: string; } ⋮---- -export interface GetCfdInstrumentsRequestV3 { - symbol?: string; -} - -================ -File: src/types/request/v3/earn.ts -================ /** * - * - * Earn | On-Chain Elite (UTA) - * + * * Futures | Account | Liquidation Price * */ ⋮---- -export interface GetEarnEliteRecordsRequestV3 { - type: 'subscribe' | 'redeem' | 'interest'; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; -} -⋮---- -export interface GetEarnEliteSubscribeInfoRequestV3 { - productId: string; +export interface FuturesLiquidationPriceRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + marginCoin: string; + posSide: 'long' | 'short'; + orderType: 'limit' | 'market'; + openAmount: string; + openPrice?: string; +} +⋮---- +/** + * + * * Futures | Account | Isolated Symbols + * + */ +⋮---- +export interface FuturesIsolatedSymbolsRequestV2 { + productType: FuturesProductTypeV2; +} + +================ +File: src/types/request/v3/broker.ts +================ +export interface CreateBrokerSubAccountRequestV3 { + subaccountName: string; + label: string; +} +⋮---- +export interface GetBrokerSubAccountListRequestV3 { + limit?: string; + cursor?: string; + status?: 'normal' | 'freeze'; +} +⋮---- +export interface ModifyBrokerSubAccountRequestV3 { + subUid: string; + status?: 'normal' | 'freeze'; + permList?: string[]; +} +⋮---- +export interface BrokerSubWithdrawalRequestV3 { + subUid: string; + coin: string; + dest: 'on_chain' | 'internal_transfer'; + address: string; + amount: string; + chain?: string; + tag?: string; + clientOid?: string; +} +⋮---- +export interface GetBrokerSubDepositAddressRequestV3 { + subUid: string; + coin: string; + chain?: string; +} +⋮---- +export interface GetBrokerAllSubDepositWithdrawalRequestV3 { + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; + status?: 'pending' | 'fail' | 'success'; +} +⋮---- +export interface GetBrokerCommissionRequestV3 { + startTime?: string; + endTime?: string; + pageSize?: string; + pageNo?: string; + bizType?: 'spot' | 'futures'; + subBizType?: + | 'spot_trade' + | 'spot_margin' + | 'usdt_futures' + | 'usdc_futures' + | 'coin_futures'; +} +⋮---- +export interface CreateBrokerSubApiKeyRequestV3 { + subUid: string; + passphrase: string; + label: string; + ipList?: string[]; + permType: 'read_write' | 'read_only'; + permList: string[]; +} +⋮---- +export interface ModifyBrokerSubApiKeyRequestV3 { + subUid: string; + passphrase: string; + apiKey: string; + label?: string; + ipList?: string[]; + permType?: 'read_write' | 'read_only'; + permList?: string[]; +} +⋮---- +export interface DeleteBrokerSubApiKeyRequestV3 { + subUid: string; + apiKey: string; +} +⋮---- +export interface GetBrokerSubApiKeyRequestV3 { + subUid: 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; + /** Default 10, range [1, 50]. The first page may return more rows than limit. */ + limit?: string; + pageNo?: string; + /** + * Not required for the first page. + * From the second page, pass the orderId of the last record from the previous page. + */ + cursor?: string; +} +⋮---- +/** Default 10, range [1, 50]. The first page may return more rows than limit. */ +⋮---- +/** + * Not required for the first page. + * From the second page, pass the orderId of the last record from the previous page. + */ +⋮---- +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/earn.ts +================ +/** + * + * + * Earn | On-Chain Elite (UTA) + * + * + */ +⋮---- +export interface GetEarnEliteRecordsRequestV3 { + type: 'subscribe' | 'redeem' | 'interest'; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; +} +⋮---- +export interface GetEarnEliteSubscribeInfoRequestV3 { + productId: string; } ⋮---- export interface EarnEliteSubscribeRequestV3 { @@ -7277,21 +6764,199 @@ export interface GetEarnCashPlusHistoryOrdersRequestV3 { /** Pass nextCursor from the previous page. Omit on the first page */ ================ -File: src/types/response/v2/broker.ts +File: src/types/request/v3/stockplus.ts ================ /** * - * * Broker | Subaccount + * + * Stock+ (UTA) + * * */ ⋮---- -export interface CreateSubaccountResponseV2 { - subUid: string; - subaccountName: string; - status: string; - permList: string[]; - label: string; - cTime: string; +export interface GetStockPlusOptionQuoteRequestV3 { + symbol: string; +} +⋮---- +export interface GetStockPlusOptionChainInfoRequestV3 { + symbol: string; + expiryDate: string; +} +⋮---- +export interface GetStockPlusOptionExpiryDateRequestV3 { + symbol: string; +} +⋮---- +export interface GetStockPlusOptionVolumeRequestV3 { + symbol: string; +} +⋮---- +export interface GetStockPlusStaticInfoRequestV3 { + symbol: string; +} +⋮---- +export interface GetStockPlusQuoteRequestV3 { + symbol: string; +} +⋮---- +export interface GetStockPlusTradeDetailRequestV3 { + symbol: string; + count?: string; +} +⋮---- +export interface GetStockPlusIntradayRequestV3 { + symbol: string; +} +⋮---- +export interface GetStockPlusHistoryCandlestickRequestV3 { + symbol: string; + period: string; + count?: string; + adjustType?: string; + forward?: boolean; + time?: string; + tradeSessions?: string; +} +⋮---- +export interface GetStockPlusCandlestickRequestV3 { + symbol: string; + period: string; + count?: string; + adjustType?: string; + tradeSessions?: string; +} +⋮---- +export interface GetStockPlusDepthRequestV3 { + symbol: string; +} +⋮---- +export interface PlaceStockPlusOrderRequestV3 { + symbol: string; + orderType: 'LO' | 'MO' | 'LIT' | 'MIT' | 'TSLPAMT' | 'TSLPPCT'; + side: 'Buy' | 'Sell'; + submittedQuantity: string; + timeInForce: 'Day' | 'GoodTilCanceled' | 'GoodTilDate'; + submittedPrice?: string; + triggerPrice?: string; + limitOffset?: string; + trailingAmount?: string; + trailingPercent?: string; + expireDate?: string; + outsideRth?: 'RTHOnly' | 'AnyTime' | 'Overnight'; + limitDepthLevel?: number; + triggerCount?: number; + monitorPrice?: string; + remark?: string; +} +⋮---- +export interface CancelStockPlusOrderRequestV3 { + symbol: string; + orderId?: string; + clientOid?: string; +} +⋮---- +export interface ModifyStockPlusOrderRequestV3 { + orderId: string; + quantity: string; + price?: string; + triggerPrice?: string; + limitOffset?: string; + trailingAmount?: string; + trailingPercent?: string; + limitDepthLevel?: number; + triggerCount?: number; + monitorPrice?: string; + remark?: string; +} +⋮---- +export interface GetStockPlusTodayOrdersRequestV3 { + symbol?: string; + status?: string | string[]; + side?: string; + market?: string; + orderId?: string; +} +⋮---- +export interface GetStockPlusHistoryOrdersRequestV3 { + symbol?: string; + status?: string | string[]; + side?: string; + market?: string; + startAt?: string; + endAt?: string; +} +⋮---- +export interface GetStockPlusOrderDetailRequestV3 { + orderId: string; +} +⋮---- +export interface GetStockPlusMaxPurchaseRequestV3 { + symbol: string; + orderType: 'LO' | 'MO' | 'LIT' | 'MIT' | 'TSLPAMT' | 'TSLPPCT'; + side: 'Buy' | 'Sell'; + price?: string; + currency?: string; + orderId?: string; +} +⋮---- +export interface GetStockPlusTodayExecutionsRequestV3 { + symbol?: string; + orderId?: string; +} +⋮---- +export interface GetStockPlusHistoryExecutionsRequestV3 { + symbol?: string; + startAt?: string; + endAt?: string; +} +⋮---- +export interface GetStockPlusAccountRequestV3 { + currency?: string; +} +⋮---- +export interface GetStockPlusCashFlowRequestV3 { + startTime: string; + endTime: string; + businessType?: string; + symbol?: string; + page?: string; + size?: string; +} +⋮---- +export interface GetStockPlusStockPositionRequestV3 { + symbol?: string; +} +⋮---- +export interface StockPlusTransferRequestV3 { + coin?: string; + amount?: string; + direction?: 'in' | 'out'; +} +⋮---- +export interface GetStockPlusTransferRecordsRequestV3 { + transferId?: string; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; +} + +================ +File: src/types/response/v2/broker.ts +================ +/** + * + * * Broker | Subaccount + * + */ +⋮---- +export interface CreateSubaccountResponseV2 { + subUid: string; + subaccountName: string; + status: string; + permList: string[]; + label: string; + cTime: string; } ⋮---- export interface BrokerSubaccountV2 { @@ -9096,969 +8761,988 @@ export interface CfdInstrumentV3 { } ================ -File: src/websocket-api-client.ts +File: src/types/response/v3/stockplus.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 + * Stock+ (UTA) + * + * */ -export class WebsocketAPIClient -⋮---- -constructor( - options?: WSClientConfigurableOptions & - Partial, - logger?: DefaultLogger, -) -⋮---- -public getWSClient(): WebsocketClientV3 -⋮---- -public setTimeOffsetMs(newOffset: number): void -⋮---- -/* - * Bitget WebSocket API Methods - * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel - */ ⋮---- -/** - * Submit a new order - * - * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel - * - * Sends top-level apiCode (SDK broker code, unless params.apiCode is set). - * - * @returns - */ -submitNewOrder( - category: BitgetInstTypeV3, - params: WSAPIPlaceOrderRequestV3, -): Promise> +export interface StockPlusOptionQuoteItemV3 { + symbol: string; + lastDone: string; + prevClose: string; + open: string; + high: string; + low: string; + timestamp: string; + volume: string; + turnover: string; + tradeStatus: string; + impliedVolatility: string; + openInterest: string; + expiryDate: string; + strikePrice: string; + contractMultipier: string; + contractType: string; + contractSize: string; + direction: string; + historicalVolatility: string; + underlyingSymbol: string; +} ⋮---- -/** - * Submit a batch of orders - * - * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel - * - * Sends the same top-level apiCode as place-order. - * If any order sets apiCode, the first one is used for the request. - * - * @returns - */ -placeBatchOrders( - category: BitgetInstTypeV3, - params: WSAPIPlaceOrderRequestV3[], -): Promise> +export interface StockPlusOptionQuoteV3 { + secuQuote: StockPlusOptionQuoteItemV3[]; +} ⋮---- -/* - * Bitget WebSocket API Methods - * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel - */ +export interface StockPlusOptionStrikePriceInfoV3 { + price: string; + callSymbol: string; + putSymbol: string; + standard: boolean; +} ⋮---- -/** - * Cancel Order - * - * https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel - * - * @returns - */ -cancelOrder( - category: BitgetInstTypeV3, - params: CancelOrderRequestV3, -): Promise> +export interface StockPlusOptionChainInfoV3 { + strikePriceInfo: StockPlusOptionStrikePriceInfoV3[]; +} ⋮---- -/** - * Batch Cancel Order - * - * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Cancel-Order-Channel - * - * @returns - */ -cancelBatchOrders( - category: BitgetInstTypeV3, - params: CancelOrderRequestV3[], -): Promise> +export interface StockPlusOptionExpiryDateV3 { + expiryDate: string[]; +} ⋮---- -updateOrder( - category: BitgetInstTypeV3, - params: ModifyOrderRequestV3, -): Promise> +export interface StockPlusOptionVolumeV3 { + c: string; + p: string; +} ⋮---- -batchUpdateOrders( - category: BitgetInstTypeV3, - params: ModifyOrderRequestV3[], -): Promise> +export interface StockPlusStaticInfoItemV3 { + symbol: string; + nameCn: string; + nameEn: string; + exchange: string; + currency: string; + lotSize: number | string; + totalShares: string | number; + circulatingShares: string | number; + eps: string | number; + epsTtm: string | number; + bps: string | number; + dividendYield: string | number; + stockDerivatives: string[]; + board: string; +} ⋮---- -/** - * - * - * - * - * - * - * - * Private methods for handling some of the convenience/automation provided by the WS API Client - * - * - * - * - * - * - * - */ +export interface StockPlusStaticInfoV3 { + list: StockPlusStaticInfoItemV3[]; +} ⋮---- -private setupDefaultEventListeners() +export interface StockPlusSessionQuoteV3 { + lastDone: string | number; + timestamp: string; + volume: string | number; + turnover: string | number; + high: string | number; + low: string | number; + prevClose: string | number; +} ⋮---- -/** - * General event handlers for monitoring the WebsocketClient - */ +export interface StockPlusQuoteItemV3 { + symbol: string; + lastDone: string | number; + prevClose: string | number; + open: string | number; + high: string | number; + low: string | number; + timestamp: string; + volume: string | number; + turnover: string | number; + tradeStatus: string; + preMarketQuote?: StockPlusSessionQuoteV3 | null; + postMarketQuote?: StockPlusSessionQuoteV3 | null; + overnightQuote?: StockPlusSessionQuoteV3 | null; +} ⋮---- -// Blind JSON.stringify can fail on circular references +export interface StockPlusQuoteV3 { + list: StockPlusQuoteItemV3[]; +} ⋮---- -// JSON.stringify({ ...data, target: 'WebSocket' }), - -================ -File: examples/V3 - UTA/WS-API/ws-api-client-trade.ts -================ -import { DefaultLogger, WebsocketAPIClient } from '../../../src/index.js'; +export interface StockPlusTradeDetailItemV3 { + price: string | number; + volume: string | number; + timestamp: string; + tradeType: string; + direction: string; + tradeSession: string; +} ⋮---- -// or -// import { DefaultLogger, WS_KEY_MAP, WebsocketAPIClient } from 'bitget-api'; +export type StockPlusTradeDetailV3 = StockPlusTradeDetailItemV3[]; ⋮---- -// 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 StockPlusIntradayItemV3 { + price: string | number; + timestamp: string; + volume: string | number; + turnover: string | number; + avgPrice: string | number; +} ⋮---- -// 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 StockPlusIntradayV3 { + list: StockPlusIntradayItemV3[]; +} ⋮---- -// Whether to use the demo trading wss connection -// demoTrading: true, +export interface StockPlusCandlestickItemV3 { + close: string; + open: string; + low: string; + high: string; + volume: string; + turnover: string; + timestamp: string; + tradeSession: string; +} ⋮---- -// If you want your own event handlers instead of the default ones with logs, -// disable this setting and see the `attachEventHandlers` example below: -// attachEventListeners: false +export interface StockPlusCandlestickV3 { + list: StockPlusCandlestickItemV3[]; +} ⋮---- -logger, // Optional: inject a custom logger +export type StockPlusHistoryCandlestickV3 = StockPlusCandlestickV3; ⋮---- -// Optional, see above "attachEventListeners". Attach basic event handlers, so nothing is left unhandled -// attachEventHandlers(wsClient.getWSClient()); +export interface StockPlusDepthLevelV3 { + position: number; + price: string; + volume: string; + orderNum: number; +} ⋮---- -// 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 StockPlusDepthV3 { + asks: StockPlusDepthLevelV3[]; + bids: StockPlusDepthLevelV3[]; +} ⋮---- -/** - * 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 - */ +export interface StockPlusPlaceOrderResponseV3 { + orderId: string; + clientOid: string; + symbol: 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 type StockPlusCancelOrderResponseV3 = StockPlusPlaceOrderResponseV3; +export type StockPlusModifyOrderResponseV3 = StockPlusPlaceOrderResponseV3; ⋮---- -/** - * Batch Place Order Channel - * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel - */ +export interface StockPlusMaxPurchaseV3 { + cashMaxQty: string; + marginMaxQty: 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 StockPlusOrderV3 { + orderId: string; + status: string; + stockName: string; + quantity: string | number; + executedQuantity: string | number; + price: string | number | null; + executedPrice: string | number | null; + submittedAt: string; + side: string; + symbol: string; + orderType: string; + lastDone: string | number | null; + triggerPrice: string | number | null; + msg: string; + tag: string; + timeInForce: string; + expireDate: string | null; + updatedAt: string | null; + triggerAt: string | null; + trailingAmount: string | number | null; + trailingPercent: string | number | null; + limitOffset: string | number | null; + triggerStatus: string | null; + currency: string; + outsideRth: string; + remark?: string; + limitDepthLevel: number | null; + triggerCount: number | null; + monitorPrice: string | null; +} ⋮---- -/** - 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 StockPlusOrdersV3 { + orders: StockPlusOrderV3[]; +} ⋮---- -/** - * Cancel Order - * https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel - */ +export interface StockPlusHistoryOrdersV3 { + hasMore: boolean; + orders: StockPlusOrderV3[]; +} ⋮---- -/** - const res = { - "event": "trade", - "id": "1750034870205", - "topic": "cancel-order", - "args": [ - { - "orderId": "xxxxxxxx", - "clientOid": "xxxxxxxx" - } - ], - "code": "0", - "msg": "Success", - "ts": "1750034870597" - } - */ +export interface StockPlusOrderHistoryItemV3 { + price: string | number; + quantity: string | number; + status: string; + msg: string; + time: string; +} ⋮---- -/** - * Batch Cancel Order - * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Cancel-Order-Channel - */ +export interface StockPlusChargeFeeItemV3 { + code: string; + name: string; + amount: number | string; + currency: string; +} ⋮---- -/** - const res = { - "event": "trade", - "id": "bb553cc0-c1fa-454e-956d-c96c8d715760", - "topic": "batch-cancel", - "args": [ - { - "code": "0", - "msg": "Success", - "orderId": "xxxxxxxxxxxxx" - }, - { - "code": "25204", - "msg": "Order does not exist", - "orderId": "xxxxxxxxxxxxx" - } - ], - "code": "0", - "msg": "Success", - "ts": "1751980011084" - } - */ - -================ -File: src/types/request/v2/broker.ts -================ -/** - * - * * Broker | Subaccount - * - */ +export interface StockPlusChargeCategoryV3 { + code: string; + name: string; + fees: StockPlusChargeFeeItemV3[]; +} ⋮---- -export interface GetSubAccountsRequestV2 { - limit?: string; - idLessThan?: string; - status?: 'normal' | 'freeze' | 'del'; - startTime?: string; - endTime?: string; +export interface StockPlusChargeDetailV3 { + totalAmount: number | string; + currency: string; + items: StockPlusChargeCategoryV3[]; } ⋮---- -export type SubAccountPermissionV2 = - | 'withdraw' - | 'transfer' - | 'spot_trade' - | 'contract_trade' - | 'read' - | 'deposit' - | 'margin_trade'; +export interface StockPlusOrderDetailV3 extends StockPlusOrderV3 { + freeStatus?: string; + freeAmount?: string | null; + freeCurrency?: string | null; + deductionsStatus?: string; + deductionsAmount?: string | null; + deductionsCurrency?: string | null; + platformDeductedStatus?: string; + platformDeductedAmount?: string | null; + platformDeductedCurrency?: string | null; + history?: StockPlusOrderHistoryItemV3[]; + chargeDetail?: StockPlusChargeDetailV3; +} ⋮---- -export type SubAccountLanguageV2 = - | 'en_US' - | 'zh_CN' - | 'ja_JP' - | 'vi_VN' - | 'zh_TW' - | 'ru_RU' - | 'es_ES' - | 'tr_TR' - | 'fr_FR' - | 'de_DE' - | 'pt_PT' - | 'th_TH'; +export interface StockPlusExecutionV3 { + orderId: string; + tradeId: string; + symbol: string; + tradeDoneAt: string; + quantity: number | string; + price: number | string; +} ⋮---- -export type SubAccountStatusV2 = 'normal' | 'freeze'; +export interface StockPlusTodayExecutionsV3 { + trades: StockPlusExecutionV3[]; +} ⋮---- -export interface ModifySubRequestV2 { - subUid: string; - permList: SubAccountPermissionV2[]; - status: SubAccountStatusV2; - language?: SubAccountLanguageV2; +export interface StockPlusHistoryExecutionsV3 { + hasMore: boolean; + trades: StockPlusExecutionV3[]; } ⋮---- -export interface SubWithdrawalRequestV2 { - subUid: string; - coin: string; - dest: 'on_chain' | 'internal_transfer'; - chain?: string; - address: string; - amount: string; - tag?: string; - clientOid?: string; +export interface StockPlusCashInfoV3 { + withdrawCash: number | string; + availableCash: number | string; + frozenCash: number | string; + settlingCash: number | string; + currency: string; } ⋮---- -export interface SubDepositRecordsRequestV2 { - orderId?: string; - userId?: string; - startTime?: string; - endTime?: string; - limit?: string; - idLessThan?: string; +export interface StockPlusFrozenTransactionFeeV3 { + currency?: string; + amount?: number | string; + [key: string]: unknown; } ⋮---- -export interface SubWithdrawalRecordsRequestV2 { - orderId?: string; - userId?: string; - startTime?: string; - endTime?: string; - limit?: string; - idLessThan?: string; +export interface StockPlusAccountItemV3 { + totalCash: number | string; + maxFinanceAmount: number | string; + remainingFinanceAmount: number | string; + riskLevel: number | string; + marginCall: number | string; + netAssets: number | string; + initMargin: number | string; + maintenanceMargin: number | string; + currency: string; + buyPower: number | string; + cashInfos: StockPlusCashInfoV3[]; + frozenTransactionFees: StockPlusFrozenTransactionFeeV3[]; } ⋮---- -/** - * - * * Broker | Subaccount - * - */ +export interface StockPlusAccountV3 { + list: StockPlusAccountItemV3[]; +} ⋮---- -export interface CreateSubAccountApiKeyRequestV2 { - subUid: string; - passphrase: string; - label?: string; - ipList: string[]; - permType: string; - permList: string[]; +export interface StockPlusCashFlowItemV3 { + transactionFlowName: string; + direction: string; + businessType: string; + balance: number | string; + currency: string; + businessTime: string; + symbol: string | null; + description: string; } ⋮---- -export interface ModifySubAccountApiKeyRequestV2 { - subUid: string; - apiKey: string; - label?: string; - passphrase: string; - ipList?: string[]; - permType?: string; - permList: string[]; +export interface StockPlusCashFlowV3 { + list: StockPlusCashFlowItemV3[]; } ⋮---- -export interface DeleteSubAccountApiKeyRequestV2 { - subUid: string; - apiKey: string; +export interface StockPlusPositionItemV3 { + symbol: string; + symbolName: string; + quantity: number | string; + availableQuantity: number | string; + currency: string; + costPrice: number | string; + market: string; + initQuantity: number | string; } ⋮---- -/** - * - * * Broker | All Sub-accounts Deposit and Withdrawal Records - * - */ +export interface StockPlusPositionChannelV3 { + accountChannel: string; + positions: StockPlusPositionItemV3[]; +} ⋮---- -export interface GetAllSubDepositWithdrawalRequestV2 { - startTime?: string; - endTime?: string; - limit?: string; - idLessThan?: string; - type?: 'all' | 'deposit' | 'withdrawal'; +export interface StockPlusStockPositionV3 { + channels: StockPlusPositionChannelV3[]; } ⋮---- -/** - * - * * Broker | Subaccounts - * - */ +export interface StockPlusTransferResponseV3 { + transferId: string; +} ⋮---- -export interface GetBrokerSubaccountsRequestV2 { - startTime?: string; - endTime?: string; - pageSize?: string; - pageNo?: string; +export interface StockPlusTransferRecordsV3 { + transferId: string; + coin: string; + amount: string; + direction: string; + cursor: 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'; ⋮---- /** - * - * * Broker | Commissions - * + * Configurable options specific to only the REST-like WebsocketAPIClient */ -⋮---- -export interface GetBrokerCommissionsRequestV2 { - startTime?: string; - endTime?: string; - pageSize?: string; - pageNo?: string; - bizType?: 'spot' | 'futures'; - subBizType?: - | 'spot_trade' - | 'spot_margin' - | 'usdt_futures' - | 'usdc_futures' - | 'coin_futures'; +export interface 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; } ⋮---- /** - * - * * Broker | Trade Volume - * - */ -⋮---- -export interface GetBrokerTradeVolumeRequestV2 { - startTime?: string; - endTime?: string; - pageSize?: string; - pageNo?: 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(....)`. + */ ⋮---- /** + * This is a minimal Websocket API wrapper around the WebsocketClient. * - * * Broker | Total Commission + * 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 GetBrokerTotalCommissionRequestV2 { - startTime?: string; - endTime?: string; -} +constructor( + options?: WSClientConfigurableOptions & + Partial, + logger?: DefaultLogger, +) ⋮---- -/** - * - * * Broker | Order Commission - * - */ +public getWSClient(): WebsocketClientV3 ⋮---- -export interface GetBrokerOrderCommissionRequestV2 { - startTime?: string; - endTime?: string; - limit?: string; - uid?: string; - orderId?: string; - idLessThan?: string; -} +public setTimeOffsetMs(newOffset: number): void ⋮---- -/** - * - * * Broker | Rebate Info - * - */ +/* + * Bitget WebSocket API Methods + * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel + */ ⋮---- -export interface GetBrokerRebateInfoRequestV2 { - uid: string; -} +/** + * Submit a new order + * + * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel + * + * Sends top-level apiCode (SDK broker code, unless params.apiCode is set). + * + * @returns + */ +submitNewOrder( + category: BitgetInstTypeV3, + params: WSAPIPlaceOrderRequestV3, +): Promise> ⋮---- /** - * - * * Broker | Agent (affiliate) customer APIs - * - */ + * Submit a batch of orders + * + * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel + * + * Sends the same top-level apiCode as place-order. + * If any order sets apiCode, the first one is used for the request. + * + * @returns + */ +placeBatchOrders( + category: BitgetInstTypeV3, + params: WSAPIPlaceOrderRequestV3[], +): Promise> ⋮---- -export interface GetAgentCustomerCommissionsRequestV2 { - startTime?: string; - endTime?: string; - idLessThan?: string; - limit?: string; - uid?: string; - coin?: string; - symbol?: string; - showSub?: 'yes' | 'no'; -} +/* + * Bitget WebSocket API Methods + * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel + */ ⋮---- -export interface GetAgentSubCustomerListRequestV2 { - startTime?: string; - endTime?: string; - idLessThan?: string; - limit?: string; - uid?: string; - showSub?: 'yes' | 'no'; -} +/** + * Cancel Order + * + * https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel + * + * @returns + */ +cancelOrder( + category: BitgetInstTypeV3, + params: CancelOrderRequestV3, +): Promise> ⋮---- -export interface AgentCustomerTradeVolumeRequestV2 { - startTime?: string; - endTime?: string; - pageNo?: string; - pageSize?: string; - uid?: string; - showSub?: 'yes' | 'no'; -} +/** + * Batch Cancel Order + * + * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Cancel-Order-Channel + * + * @returns + */ +cancelBatchOrders( + category: BitgetInstTypeV3, + params: CancelOrderRequestV3[], +): Promise> ⋮---- -export interface AgentCustomerListRequestV2 { - startTime?: string; - endTime?: string; - pageNo?: string; - pageSize?: string; - uid?: string; - referralCode?: string; - showSub?: 'yes' | 'no'; -} +updateOrder( + category: BitgetInstTypeV3, + params: ModifyOrderRequestV3, +): Promise> ⋮---- -export interface GetAgentCustomerKycResultRequestV2 { - startTime?: string; - endTime?: string; - idLessThan?: string; - limit?: string; - uid?: string; - showSub?: 'yes' | 'no'; -} +batchUpdateOrders( + category: BitgetInstTypeV3, + params: ModifyOrderRequestV3[], +): Promise> ⋮---- -export interface AgentCustomerDepositRequestV2 { - startTime?: string; - endTime?: string; - pageNo?: string; - pageSize?: string; - uid?: string; - showSub?: 'yes' | 'no'; -} +/** + * + * + * + * + * + * + * + * Private methods for handling some of the convenience/automation provided by the WS API Client + * + * + * + * + * + * + * + */ ⋮---- -export interface AgentCustomerAssetRequestV2 { - pageNo?: string; - pageSize?: string; - uid?: string; - showSub?: 'yes' | 'no'; -} +private setupDefaultEventListeners() ⋮---- -export interface GetAgentCommissionDetailRequestV2 { - startTime?: string; - endTime?: string; - limit?: string; - idLessThan?: string; -} +/** + * General event handlers for monitoring the WebsocketClient + */ ⋮---- -export interface GetSubAffiliateInfoRequestV2 { - uid?: string; - startTime?: string; - endTime?: string; - idLessThan?: string; - limit?: string; - includeDownLine?: 'yes' | 'no'; -} +// Blind JSON.stringify can fail on circular references +⋮---- +// JSON.stringify({ ...data, target: 'WebSocket' }), ================ -File: src/types/response/v3/earn.ts +File: examples/V3 - UTA/WS-API/ws-api-client-trade.ts ================ -import type { EarnCashPlusRecordTypeV3 } from '../../request/v3/earn.js'; -⋮---- -/** - * - * - * Earn | On-Chain Elite (UTA) - * - * - */ +import { DefaultLogger, WebsocketAPIClient } from '../../../src/index.js'; ⋮---- -export interface EarnEliteSubscriptionCoinV3 { - subscriptionCoin: string; - precision: string; - feeRate: string; - exchangeRate: string; - remainQuota?: string; - minAmount?: string; -} +// or +// import { DefaultLogger, WS_KEY_MAP, WebsocketAPIClient } from 'bitget-api'; ⋮---- -export interface EarnEliteProductV3 { - productId: string; - coin: string; - minApr: string; - maxApr: string; - subscriptionCoinList: EarnEliteSubscriptionCoinV3[]; - sellOut: 'YES' | 'NO' | 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 EarnEliteAssetProjectV3 { - projectName: 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 EarnEliteAssetV3 { - productId: string; - productCoin: string; - holdingAmount: string; - usdtHoldingAmount: string; - exchangeRate: string; - apr: string; - minApy?: string; - maxApy?: string; - subscriptionCoin: string; - exchangeAmount: string; - projectList?: EarnEliteAssetProjectV3[]; - unsettledBGPoints: string; - interestCoin: string; - totalProfit: string; -} +// Whether to use the demo trading wss connection +// demoTrading: true, ⋮---- -export interface EarnEliteAssetsV3 { - resultList: EarnEliteAssetV3[]; -} +// If you want your own event handlers instead of the default ones with logs, +// disable this setting and see the `attachEventHandlers` example below: +// attachEventListeners: false ⋮---- -export interface EarnEliteRecordV3 { - recordId: string; - productId: string; - coin: string; - status: string; - exchangeRate: string; - receivedCoin: string; - receivedAmount: string; - investAmount: string; - feeRate: string; - redeemType?: string | string[]; - receivingAccount: string; - actualReceivingAccount: string; - paymentAccount?: string[]; - settlePoints: string; - fee: string; - /** Business time, Unix ms */ - bizTime?: string; -} +logger, // Optional: inject a custom logger ⋮---- -/** Business time, Unix ms */ +// Optional, see above "attachEventListeners". Attach basic event handlers, so nothing is left unhandled +// attachEventHandlers(wsClient.getWSClient()); ⋮---- -export interface EarnEliteRecordsV3 { - recordList: EarnEliteRecordV3[]; - endId: string; -} +// Optional: prepare the WebSocket API connection in advance. +// This happens automatically but you can do this early before making any API calls, to prevent delays from a cold start. ⋮---- -export interface EarnEliteSubscribeInfoV3 { - productSubId: string; - minAmount: string; - remainQuota: string; - exchangeRate: string; - productCoin: string; - interestTime: string; - settleTime: string; - precision: string; - feeRate: string; - subscriptionCoinList?: EarnEliteSubscriptionCoinV3[]; -} +/** + * 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 EarnEliteSubscribeResultV3 { - orderId: string; -} +/** + * Place Order + * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters + */ ⋮---- -export interface EarnEliteSubscribeStatusV3 { - result: 'settled' | 'pending' | 'rejected' | 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 EarnEliteRedeemInfoBgusdReceiveCoinV3 { - bgusdReceiveCoin: string; - bgusdExchangeRate: string; -} +/** + * Batch Place Order Channel + * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel + */ ⋮---- -export interface EarnEliteRedeemModeV3 { - redeemFeeRate: string; - remainQuota: string; - redeemType: 'fast' | 'standard' | string; - redeemScale: string; - redeemDelayDate: string; - minRedeemAmount: string; - redeemTime: 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 EarnEliteRedeemInfoV3 { - productId: string; - productSubId: string; - productCoin: string; - subscriptionCoin: string; - profitCoin: string; - exchangeRate: string; - totalUnPayInterestAmount: string; - preSettleApr: string; - receivedCoin: string; - unsettledPoints: string; - bgusdReceiveCoinList: EarnEliteRedeemInfoBgusdReceiveCoinV3[]; - redeemModeList: EarnEliteRedeemModeV3[]; -} +/** + 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 RedeemEarnEliteResultV3 { - orderId: string; -} +/** + * 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/request/v2/broker.ts +================ /** * - * - * Earn | Cash+ (UTA) - * + * * Broker | Subaccount * */ ⋮---- -export interface EarnCashPlusSubscribeCoinV3 { - /** Used for subscribe and redeem */ - productSubId: string; - coin: string; - /** Minimum subscription amount, in this coin */ - minAmount: string; - /** How much Cash+ 1 unit of this coin converts into. Default 1 */ - conversionRate: string; - /** Decimal places for the subscription amount */ - subscribeScale: string; - /** Decimal places for profit */ - profitScale: string; - soldOut: 'yes' | 'no'; +export interface GetSubAccountsRequestV2 { + limit?: string; + idLessThan?: string; + status?: 'normal' | 'freeze' | 'del'; + startTime?: string; + endTime?: string; } ⋮---- -/** Used for subscribe and redeem */ -⋮---- -/** Minimum subscription amount, in this coin */ -⋮---- -/** How much Cash+ 1 unit of this coin converts into. Default 1 */ +export type SubAccountPermissionV2 = + | 'withdraw' + | 'transfer' + | 'spot_trade' + | 'contract_trade' + | 'read' + | 'deposit' + | 'margin_trade'; ⋮---- -/** Decimal places for the subscription amount */ +export type SubAccountLanguageV2 = + | 'en_US' + | 'zh_CN' + | 'ja_JP' + | 'vi_VN' + | 'zh_TW' + | 'ru_RU' + | 'es_ES' + | 'tr_TR' + | 'fr_FR' + | 'de_DE' + | 'pt_PT' + | 'th_TH'; ⋮---- -/** Decimal places for profit */ +export type SubAccountStatusV2 = 'normal' | 'freeze'; ⋮---- -export interface EarnCashPlusSubscribeInfoV3 { - /** Profit source coin. Currently USDGO */ - profitSourceCoin: string; - /** Decimal APR. 0.04 means 4% */ - cashPlusApr: string; - subscribeCoinList: EarnCashPlusSubscribeCoinV3[]; - /** Unix ms */ - interestTime: string; - /** Unix ms */ - payInterestTime: string; - /** Unix ms */ - subscribeTime: string; +export interface ModifySubRequestV2 { + subUid: string; + permList: SubAccountPermissionV2[]; + status: SubAccountStatusV2; + language?: SubAccountLanguageV2; } ⋮---- -/** Profit source coin. Currently USDGO */ -⋮---- -/** Decimal APR. 0.04 means 4% */ -⋮---- -/** Unix ms */ -⋮---- -/** Unix ms */ -⋮---- -/** Unix ms */ -⋮---- -export interface EarnCashPlusSubscribeResultV3 { - orderId: string; +export interface SubWithdrawalRequestV2 { + subUid: string; + coin: string; + dest: 'on_chain' | 'internal_transfer'; + chain?: string; + address: string; + amount: string; + tag?: string; + clientOid?: string; } ⋮---- -export type EarnCashPlusOrderStatusV3 = 'processing' | 'success' | 'failed'; -⋮---- -export type EarnCashPlusAccountTypeV3 = 'funding' | 'uta' | 'otc'; +export interface SubDepositRecordsRequestV2 { + orderId?: string; + userId?: string; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} ⋮---- -export interface EarnCashPlusPaymentAccountV3 { - accountType: EarnCashPlusAccountTypeV3; - payAmount: string; +export interface SubWithdrawalRecordsRequestV2 { + orderId?: string; + userId?: string; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; } ⋮---- -export interface EarnCashPlusSubscribeStatusV3 { - orderId: string; - status: EarnCashPlusOrderStatusV3; - coin: string; - amount: string; - /** Unix ms */ - subscribeTime: string; - /** Unix ms */ - interestTime: string; - /** First interest distribution, Unix ms */ - dividendTime: string; - paymentAccountList: EarnCashPlusPaymentAccountV3[]; +/** + * + * * Broker | Subaccount + * + */ +⋮---- +export interface CreateSubAccountApiKeyRequestV2 { + subUid: string; + passphrase: string; + label?: string; + ipList: string[]; + permType: string; + permList: string[]; } ⋮---- -/** Unix ms */ +export interface ModifySubAccountApiKeyRequestV2 { + subUid: string; + apiKey: string; + label?: string; + passphrase: string; + ipList?: string[]; + permType?: string; + permList: string[]; +} ⋮---- -/** Unix ms */ +export interface DeleteSubAccountApiKeyRequestV2 { + subUid: string; + apiKey: string; +} ⋮---- -/** First interest distribution, Unix ms */ +/** + * + * * Broker | All Sub-accounts Deposit and Withdrawal Records + * + */ ⋮---- -export interface EarnCashPlusRedeemCoinV3 { - productSubId: string; - coin: string; - /** How much of this coin 1 unit of Cash+ equals */ - conversionRate: string; - /** Redeemable Cash+ position */ - redeemAvailable: string; - redeemMinAmount: string; - /** Decimal places for the redemption amount */ - redeemScale: string; - /** Unlock request time, Unix ms */ - redeemTime: string; - /** Estimated arrival, Unix ms */ - receivedTime: string; +export interface GetAllSubDepositWithdrawalRequestV2 { + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; + type?: 'all' | 'deposit' | 'withdrawal'; } ⋮---- -/** How much of this coin 1 unit of Cash+ equals */ +/** + * + * * Broker | Subaccounts + * + */ ⋮---- -/** Redeemable Cash+ position */ +export interface GetBrokerSubaccountsRequestV2 { + startTime?: string; + endTime?: string; + pageSize?: string; + pageNo?: string; +} ⋮---- -/** Decimal places for the redemption amount */ +/** + * + * * Broker | Commissions + * + */ ⋮---- -/** Unlock request time, Unix ms */ +export interface GetBrokerCommissionsRequestV2 { + startTime?: string; + endTime?: string; + pageSize?: string; + pageNo?: string; + bizType?: 'spot' | 'futures'; + subBizType?: + | 'spot_trade' + | 'spot_margin' + | 'usdt_futures' + | 'usdc_futures' + | 'coin_futures'; +} ⋮---- -/** Estimated arrival, Unix ms */ +/** + * + * * Broker | Trade Volume + * + */ ⋮---- -export interface EarnCashPlusRedeemInfoV3 { - redeemCoinList: EarnCashPlusRedeemCoinV3[]; - /** Remaining redemption quota for today */ - userRemainingQuota: string; +export interface GetBrokerTradeVolumeRequestV2 { + startTime?: string; + endTime?: string; + pageSize?: string; + pageNo?: string; } ⋮---- -/** Remaining redemption quota for today */ +/** + * + * * Broker | Total Commission + * + */ ⋮---- -export interface EarnCashPlusRedeemResultV3 { - orderId: string; - /** Unix ms */ - redeemTime: number; - /** Estimated arrival, Unix ms */ - receiveTime: number; +export interface GetBrokerTotalCommissionRequestV2 { + startTime?: string; + endTime?: string; } ⋮---- -/** Unix ms */ -⋮---- -/** Estimated arrival, Unix ms */ +/** + * + * * Broker | Order Commission + * + */ ⋮---- -export interface EarnCashPlusRedeemStatusV3 { - orderId: string; - status: EarnCashPlusOrderStatusV3; - /** Unix ms */ - redeemTime: string; - /** Estimated arrival, Unix ms */ - receiveTime: string; +export interface GetBrokerOrderCommissionRequestV2 { + startTime?: string; + endTime?: string; + limit?: string; + uid?: string; + orderId?: string; + idLessThan?: string; } ⋮---- -/** Unix ms */ -⋮---- -/** Estimated arrival, Unix ms */ +/** + * + * * Broker | Rebate Info + * + */ ⋮---- -export interface EarnCashPlusPositionV3 { - /** Holding, converted to USD */ - balance: string; - /** Cumulative profit, converted to USD */ - totalProfit: string; - /** Yesterday's profit, converted to USD */ - yesterdayProfit: string; - /** Compound annual rate, for reference */ - apr: string; +export interface GetBrokerRebateInfoRequestV2 { + uid: string; } ⋮---- -/** Holding, converted to USD */ +/** + * + * * Broker | Agent (affiliate) customer APIs + * + */ ⋮---- -/** Cumulative profit, converted to USD */ +export interface GetAgentCustomerCommissionsRequestV2 { + startTime?: string; + endTime?: string; + idLessThan?: string; + limit?: string; + uid?: string; + coin?: string; + symbol?: string; + showSub?: 'yes' | 'no'; +} ⋮---- -/** Yesterday's profit, converted to USD */ +export interface GetAgentSubCustomerListRequestV2 { + startTime?: string; + endTime?: string; + idLessThan?: string; + limit?: string; + uid?: string; + showSub?: 'yes' | 'no'; +} ⋮---- -/** Compound annual rate, for reference */ +export interface AgentCustomerTradeVolumeRequestV2 { + startTime?: string; + endTime?: string; + pageNo?: string; + pageSize?: string; + uid?: string; + showSub?: 'yes' | 'no'; +} ⋮---- -export interface EarnCashPlusHistoryOrderV3 { - recordId: string; - recordType: EarnCashPlusRecordTypeV3; - status: EarnCashPlusOrderStatusV3; - amount: string; - coin: string; - /** Unix ms */ - createdTime: number; - /** - * Debit account on a subscription. - * Credit account on interest or redemption. - */ - accountType: EarnCashPlusAccountTypeV3; +export interface AgentCustomerListRequestV2 { + startTime?: string; + endTime?: string; + pageNo?: string; + pageSize?: string; + uid?: string; + referralCode?: string; + showSub?: 'yes' | 'no'; } ⋮---- -/** Unix ms */ +export interface GetAgentCustomerKycResultRequestV2 { + startTime?: string; + endTime?: string; + idLessThan?: string; + limit?: string; + uid?: string; + showSub?: 'yes' | 'no'; +} ⋮---- -/** - * Debit account on a subscription. - * Credit account on interest or redemption. - */ +export interface AgentCustomerDepositRequestV2 { + startTime?: string; + endTime?: string; + pageNo?: string; + pageSize?: string; + uid?: string; + showSub?: 'yes' | 'no'; +} ⋮---- -export interface EarnCashPlusHistoryOrdersV3 { - items: EarnCashPlusHistoryOrderV3[]; - /** Pass back as cursor. Absent on the last page */ - nextCursor?: string; +export interface AgentCustomerAssetRequestV2 { + pageNo?: string; + pageSize?: string; + uid?: string; + showSub?: 'yes' | 'no'; } ⋮---- -/** Pass back as cursor. Absent on the last page */ - +export interface GetAgentCommissionDetailRequestV2 { + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} +⋮---- +export interface GetSubAffiliateInfoRequestV2 { + uid?: string; + startTime?: string; + endTime?: string; + idLessThan?: string; + limit?: string; + includeDownLine?: 'yes' | 'no'; +} + ================ File: src/websocket-client-v3.ts ================ @@ -11945,971 +11629,1022 @@ export interface GetCopyFuturesTpSlOrderHistoryRequestV3 { } ================ -File: src/types/response/v3/strategy.ts +File: src/types/response/v3/earn.ts ================ -import type { - StrategyIcebergParamsV3, - StrategyOcoParamsV3, - StrategyOrderStatusV3, - StrategyOrderTypeV3, - StrategyTrailingStopParamsV3, - StrategyTriggerByV3, - StrategyTriggerOrderTypeV3, - StrategyTwapParamsV3, -} from '../../request/v3/strategy.js'; +/** + * + * + * Earn | On-Chain Elite (UTA) + * + * + */ ⋮---- -export interface PlaceStrategyOrderResponseV3 { - orderId: string; - clientOid: string; +export interface EarnEliteSubscriptionCoinV3 { + subscriptionCoin: string; + precision: string; + feeRate: string; + exchangeRate: string; + remainQuota?: string; + minAmount?: string; } ⋮---- -export interface ModifyStrategyOrderResponseV3 { - orderId: string; - clientOid: string; +export interface EarnEliteProductV3 { + productId: string; + coin: string; + minApr: string; + maxApr: string; + subscriptionCoinList: EarnEliteSubscriptionCoinV3[]; + sellOut: 'YES' | 'NO' | string; } ⋮---- -export interface StrategyOrderV3 { - orderId: string; - clientOid: string; - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES' | string; - symbol: string; - qty: string; - /** buy / sell. Same field as the WS order push. */ - side?: 'buy' | 'sell'; - posSide: 'long' | 'short'; - status: StrategyOrderStatusV3; - type?: StrategyOrderTypeV3 | string; - triggerType?: 'takeProfit' | 'stopLoss'; - tpTriggerBy?: StrategyTriggerByV3; - slTriggerBy?: StrategyTriggerByV3; - takeProfit?: string; - stopLoss?: string; - tpOrderType?: StrategyTriggerOrderTypeV3; - slOrderType?: StrategyTriggerOrderTypeV3; - tpLimitPrice?: string; - slLimitPrice?: string; - triggerBy?: StrategyTriggerByV3; - triggerPrice?: string; - triggerOrderType?: StrategyTriggerOrderTypeV3; - triggerOrderPrice?: string; - ocoParams?: StrategyOcoParamsV3; - trailingStopParams?: StrategyTrailingStopParamsV3; - icebergParams?: StrategyIcebergParamsV3; - twapParams?: StrategyTwapParamsV3; - createdTime: string; - updatedTime: string; - /** crossed or isolated. Returned by unfilled and history strategy orders */ - marginMode?: 'crossed' | 'isolated'; +export interface EarnEliteAssetProjectV3 { + projectName: string; } ⋮---- -/** buy / sell. Same field as the WS order push. */ +export interface EarnEliteAssetV3 { + productId: string; + productCoin: string; + holdingAmount: string; + usdtHoldingAmount: string; + exchangeRate: string; + apr: string; + minApy?: string; + maxApy?: string; + subscriptionCoin: string; + exchangeAmount: string; + projectList?: EarnEliteAssetProjectV3[]; + unsettledBGPoints: string; + interestCoin: string; + totalProfit: string; +} ⋮---- -/** crossed or isolated. Returned by unfilled and history strategy orders */ +export interface EarnEliteAssetsV3 { + resultList: EarnEliteAssetV3[]; +} ⋮---- -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; +export interface EarnEliteRecordV3 { + recordId: string; + productId: string; + coin: string; + status: string; + exchangeRate: string; + receivedCoin: string; + receivedAmount: string; + investAmount: string; + feeRate: string; + redeemType?: string | string[]; + receivingAccount: string; + actualReceivingAccount: string; + paymentAccount?: string[]; + settlePoints: string; + fee: string; + /** Business time, Unix ms */ + bizTime?: string; } - -================ -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'; +/** Business time, Unix ms */ ⋮---- -// 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 EarnEliteRecordsV3 { + recordList: EarnEliteRecordV3[]; + endId: string; +} ⋮---- -export interface WSOperationLoginParams { - apiKey: string; - passphrase: string; - timestamp: number; - sign: string; +export interface EarnEliteSubscribeInfoV3 { + productSubId: string; + minAmount: string; + remainQuota: string; + exchangeRate: string; + productCoin: string; + interestTime: string; + settleTime: string; + precision: string; + feeRate: string; + subscriptionCoinList?: EarnEliteSubscriptionCoinV3[]; } ⋮---- -export interface WSAPIRequestBitgetV3 { - op: 'trade'; - id: string; - category: BitgetInstTypeV3; - topic: WSAPIOperation; - args: TWSParams | TWSParams[]; - /** - * Broker rebate code. Top-level, not inside args. - * Place-order docs name this field. Sent on place-order and batch-place. - * Defaults to the SDK broker code unless the caller sets apiCode. - */ - apiCode?: string; - /** Client-side request timestamp; required for receiveWindow on place-order */ - requestTime?: string; +export interface EarnEliteSubscribeResultV3 { + orderId: string; } ⋮---- -/** - * Broker rebate code. Top-level, not inside args. - * Place-order docs name this field. Sent on place-order and batch-place. - * Defaults to the SDK broker code unless the caller sets apiCode. - */ +export interface EarnEliteSubscribeStatusV3 { + result: 'settled' | 'pending' | 'rejected' | string; +} ⋮---- -/** Client-side request timestamp; required for receiveWindow on place-order */ +export interface EarnEliteRedeemInfoBgusdReceiveCoinV3 { + bgusdReceiveCoin: string; + bgusdExchangeRate: string; +} ⋮---- -export interface WSAPIRequestFlags { - /** If true, will skip auth requirement for WS API connection */ - authIsOptional?: boolean | undefined; +export interface EarnEliteRedeemModeV3 { + redeemFeeRate: string; + remainQuota: string; + redeemType: 'fast' | 'standard' | string; + redeemScale: string; + redeemDelayDate: string; + minRedeemAmount: string; + redeemTime: string; } ⋮---- -/** If true, will skip auth requirement for WS API connection */ +export interface EarnEliteRedeemInfoV3 { + productId: string; + productSubId: string; + productCoin: string; + subscriptionCoin: string; + profitCoin: string; + exchangeRate: string; + totalUnPayInterestAmount: string; + preSettleApr: string; + receivedCoin: string; + unsettledPoints: string; + bgusdReceiveCoinList: EarnEliteRedeemInfoBgusdReceiveCoinV3[]; + redeemModeList: EarnEliteRedeemModeV3[]; +} ⋮---- -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]; -}; +export interface RedeemEarnEliteResultV3 { + orderId: string; +} ⋮---- -// This part says: if there's any key that's not in T, it's an error -⋮---- -/** - /** - * V2 request looks like this: -{ - "op":"subscribe", - "args":[ - { - "instType":"SPOT", - "channel":"ticker", - "instId":"BTCUSDT" - }, - { - "instType":"SPOT", - "channel":"candle5m", - "instId":"BTCUSDT" - } - ] -} + * + * + * Earn | Cash+ (UTA) + * + * */ -export interface WsRequestOperationBitget { - op: WSOperation; - args?: (TWSRequestArg | string | number)[]; -} -export interface WSAPIRateLimitV3 { - limit: string; - remaining: string; -} ⋮---- -export interface WSAPIResponse< - TResponseData extends object = object, - TOperation extends WSAPIOperation = WSAPIOperation, -> { - wsKey: WsKey; - /** Auto-generated */ - id: string; - event: 'trade'; - category: BitgetInstTypeV3; - topic: TOperation; - args: TResponseData; - code: '0' | string; - msg: 'success' | string; - ts: string; - /** Connection ID (trade operation responses, May 2026+) */ - connId?: string; - /** Gateway receive time, Unix microseconds */ - receiveTime?: string; - /** Gateway push time, Unix microseconds */ - pushTime?: string; - rateLimit?: WSAPIRateLimitV3[]; +export interface EarnCashPlusSubscribeCoinV3 { + /** Used for subscribe and redeem */ + productSubId: string; + coin: string; + /** Minimum subscription amount, in this coin */ + minAmount: string; + /** How much Cash+ 1 unit of this coin converts into. Default 1 */ + conversionRate: string; + /** Decimal places for the subscription amount */ + subscribeScale: string; + /** Decimal places for profit */ + profitScale: string; + soldOut: 'yes' | 'no'; } ⋮---- -/** Auto-generated */ +/** Used for subscribe and redeem */ ⋮---- -/** Connection ID (trade operation responses, May 2026+) */ +/** Minimum subscription amount, in this coin */ ⋮---- -/** Gateway receive time, Unix microseconds */ +/** How much Cash+ 1 unit of this coin converts into. Default 1 */ ⋮---- -/** Gateway push time, Unix microseconds */ +/** Decimal places for the subscription amount */ ⋮---- -/** - * List of operations supported for this WsKey (connection) - */ -export interface WsAPIWsKeyTopicMap { - [WS_KEY_MAP.v3Private]: WSAPIOperation; -} +/** Decimal places for profit */ ⋮---- -/** - * Request parameters expected per operation - */ -export interface WsAPITopicRequestParamMap { - // https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters - 'place-order': WSAPIPlaceOrderRequestV3; - // https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel - 'batch-place': WSAPIPlaceOrderRequestV3[]; - // https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel - 'cancel-order': CancelOrderRequestV3; - // https://www.bitget.com/docs/uta/websocket/private/Batch-Cancel-Order-Channel - 'batch-cancel': CancelOrderRequestV3[]; - 'modify-order': ModifyOrderRequestV3; - 'batch-modify': ModifyOrderRequestV3[]; +export interface EarnCashPlusSubscribeInfoV3 { + /** Profit source coin. Currently USDGO */ + profitSourceCoin: string; + /** Decimal APR. 0.04 means 4% */ + cashPlusApr: string; + subscribeCoinList: EarnCashPlusSubscribeCoinV3[]; + /** Unix ms */ + interestTime: string; + /** Unix ms */ + payInterestTime: string; + /** Unix ms */ + subscribeTime: string; } ⋮---- -// https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters +/** Profit source coin. Currently USDGO */ ⋮---- -// https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel +/** Decimal APR. 0.04 means 4% */ ⋮---- -// https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel +/** Unix ms */ ⋮---- -// https://www.bitget.com/docs/uta/websocket/private/Batch-Cancel-Order-Channel +/** Unix ms */ ⋮---- -/** - * Response structure expected for each operation - */ -export interface WsAPIOperationResponseMap { - // https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters - 'place-order': WSAPIResponse<[WSAPIPlaceOrderResponseV3], 'place-order'>; - // https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel - 'batch-place': WSAPIResponse; - // https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel - 'cancel-order': WSAPIResponse<[CancelOrderResponseV3], 'cancel-order'>; - // https://www.bitget.com/docs/uta/websocket/private/Batch-Cancel-Order-Channel - 'batch-cancel': WSAPIResponse; - 'modify-order': WSAPIResponse<[ModifyOrderResponseV3], 'modify-order'>; - 'batch-modify': WSAPIResponse; +/** Unix ms */ +⋮---- +export interface EarnCashPlusSubscribeResultV3 { + orderId: string; } ⋮---- -// https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters +export type EarnCashPlusOrderStatusV3 = 'processing' | 'success' | 'failed'; ⋮---- -// https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel +export type EarnCashPlusAccountTypeV3 = 'funding' | 'uta' | 'otc'; ⋮---- -// https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel +export interface EarnCashPlusPaymentAccountV3 { + accountType: EarnCashPlusAccountTypeV3; + payAmount: string; +} ⋮---- -// https://www.bitget.com/docs/uta/websocket/private/Batch-Cancel-Order-Channel - -================ -File: src/types/websockets/ws-events.ts -================ -export interface MessageEventLike { - target: WebSocket; - type: 'message'; - data: string; +export interface EarnCashPlusSubscribeStatusV3 { + orderId: string; + status: EarnCashPlusOrderStatusV3; + coin: string; + amount: string; + /** Unix ms */ + subscribeTime: string; + /** Unix ms */ + interestTime: string; + /** First interest distribution, Unix ms */ + dividendTime: string; + paymentAccountList: EarnCashPlusPaymentAccountV3[]; } ⋮---- -export function isMessageEvent(msg: unknown): msg is MessageEventLike +/** Unix ms */ ⋮---- -export interface WsBaseEvent { - action: TAction; - arg: unknown; - data: TData[]; -} +/** Unix ms */ ⋮---- -export interface WsSnapshotChannelEvent extends WsBaseEvent<'snapshot'> { - arg: { - instType: string; - channel: string; - instId: string; - }; -} +/** First interest distribution, Unix ms */ ⋮---- -export interface WsSnapshotAccountEvent extends WsBaseEvent<'snapshot'> { - arg: { - instType: string; - channel: 'account'; - instId: string; - }; +export interface EarnCashPlusRedeemCoinV3 { + productSubId: string; + coin: string; + /** How much of this coin 1 unit of Cash+ equals */ + conversionRate: string; + /** Redeemable Cash+ position */ + redeemAvailable: string; + redeemMinAmount: string; + /** Decimal places for the redemption amount */ + redeemScale: string; + /** Unlock request time, Unix ms */ + redeemTime: string; + /** Estimated arrival, Unix ms */ + receivedTime: string; } ⋮---- -export interface WsSnapshotPositionsEvent extends WsBaseEvent<'snapshot'> { - arg: { - instType: string; - channel: 'positions'; - instId: string; - }; +/** How much of this coin 1 unit of Cash+ equals */ +⋮---- +/** Redeemable Cash+ position */ +⋮---- +/** Decimal places for the redemption amount */ +⋮---- +/** Unlock request time, Unix ms */ +⋮---- +/** Estimated arrival, Unix ms */ +⋮---- +export interface EarnCashPlusRedeemInfoV3 { + redeemCoinList: EarnCashPlusRedeemCoinV3[]; + /** Remaining redemption quota for today */ + userRemainingQuota: string; } ⋮---- -export interface WsAccountSnapshotDataUMCBL { - marginCoin: string; - locked: string; - available: string; - maxOpenPosAvailable: string; - maxTransferOut: string; - equity: string; - usdtEquity: string; +/** Remaining redemption quota for today */ +⋮---- +export interface EarnCashPlusRedeemResultV3 { + orderId: string; + /** Unix ms */ + redeemTime: number; + /** Estimated arrival, Unix ms */ + receiveTime: number; } ⋮---- -export interface WsAccountSnapshotUMCBL extends WsBaseEvent<'snapshot'> { - arg: { - instType: 'umcbl'; - channel: 'account'; - instId: string; - }; - data: WsAccountSnapshotDataUMCBL[]; +/** Unix ms */ +⋮---- +/** Estimated arrival, Unix ms */ +⋮---- +export interface EarnCashPlusRedeemStatusV3 { + orderId: string; + status: EarnCashPlusOrderStatusV3; + /** Unix ms */ + redeemTime: string; + /** Estimated arrival, Unix ms */ + receiveTime: string; } ⋮---- -export interface WsPositionSnapshotDataUMCBL { - posId: string; - instId: string; - instName: string; - marginCoin: string; - margin: string; - marginMode: string; - holdSide: string; - holdMode: string; - total: string; - available: string; - locked: string; - averageOpenPrice: string; - leverage: number; - achievedProfits: string; - upl: string; - uplRate: string; - liqPx: string; - keepMarginRate: string; - marginRate: string; - cTime: string; - uTime: string; - markPrice: string; - /** Cash dividend, USDT (Classic V2 positions channel) */ - cashDividend?: string; -} +/** Unix ms */ ⋮---- -/** Cash dividend, USDT (Classic V2 positions channel) */ +/** Estimated arrival, Unix ms */ ⋮---- -/** UTA reality-orderbook push (ts/seq/pseq removed July 2026). Every push is a full snapshot. */ -export interface WsRealityOrderBookDataV3 { - a: [string, string][]; - b: [string, string][]; +export interface EarnCashPlusPositionV3 { + /** Holding, converted to USD */ + balance: string; + /** Cumulative profit, converted to USD */ + totalProfit: string; + /** Yesterday's profit, converted to USD */ + yesterdayProfit: string; + /** Compound annual rate, for reference */ + apr: string; } ⋮---- -/** - * UTA reality-orderbook-segmented push. - * Each level is [price, onshoreQty, offshoreQty]. - * Every push is a full snapshot. Whitelist required. - * Go-live 20 Oct 2026. Pairs that have not finished the matching-engine upgrade do not push. - * A crossed book after the upgrade is expected. - */ -export interface WsRealityOrderBookSegmentedDataV3 { - a: [string, string, string][]; - b: [string, string, string][]; -} +/** Holding, converted to USD */ ⋮---- -export interface WSPositionSnapshotUMCBL extends WsBaseEvent<'snapshot'> { - arg: { - instType: 'umcbl'; - channel: 'positions'; - instId: string; - }; - data: WsPositionSnapshotDataUMCBL[]; -} +/** Cumulative profit, converted to USD */ ⋮---- -/** Classic V2 depth channel push data. checksum removed May 2026 - use seq instead */ -export interface WsDepthBookDataV2 { - asks: [string, string][]; - bids: [string, string][]; - ts: string; - seq: string; - /** Futures books channel only - previous push serial number */ - pseq?: string; -} +/** Yesterday's profit, converted to USD */ ⋮---- -/** Futures books channel only - previous push serial number */ +/** Compound annual rate, for reference */ ⋮---- -/** UTA account channel coin row */ -export interface WsAccountCoinV3 { +export interface EarnCashPlusHistoryOrderV3 { + recordId: string; + recordType: + | 'subscribe' + | 'redeem' + | 'compound_interest' + | 'liquidation_redeem'; + status: EarnCashPlusOrderStatusV3; + amount: string; coin: string; - balance: string; - /** Coin balance before borrowing-related amounts are deducted */ - balanceOriginal?: string; - available: string; - locked: string; - equity: string; - usdValue: string; - borrow: string; - debts: string; - bonus?: string; + /** Unix ms */ + createdTime: number; + /** + * Debit account on a subscription. + * Credit account on interest or redemption. + */ + accountType: EarnCashPlusAccountTypeV3; } ⋮---- -/** Coin balance before borrowing-related amounts are deducted */ -⋮---- -/** UTA account channel push. action is snapshot or update */ -export interface WsAccountDataV3 { - totalEquity: string; - effEquity: string; - mmr: string; - imr: string; - mgnRatio: string; - positionMgnRatio: string; - unrealisedPnL: string; - coin: WsAccountCoinV3[]; -} +/** Unix ms */ ⋮---- /** - * UTA depth push. - * books1 and books5: every message is a full snapshot. - * books and books50: the first message is a snapshot, later messages are incremental updates. - * Do not replace the local book with a books or books50 update. - * pseq is set on books and books50. - * rToken: books1 pushes at all times. books5, books50, and books push only outside US market hours. - */ -export interface WsOrderBookDataV3 { - a: [string, string][]; - b: [string, string][]; - seq: string | number; - pseq?: string | number; - /** Present on the books topic */ - maxDepth?: string; - ts: string; + * Debit account on a subscription. + * Credit account on interest or redemption. + */ +⋮---- +export interface EarnCashPlusHistoryOrdersV3 { + items: EarnCashPlusHistoryOrderV3[]; + /** Pass back as cursor. Absent on the last page */ + nextCursor?: string; } ⋮---- -/** Present on the books topic */ +/** Pass back as cursor. Absent on the last page */ ================ -File: src/types/response/v3/copytrading.ts +File: src/types/response/v3/strategy.ts ================ -/** - * - * - * Copy Trading | Futures (UTA) - * - * - */ +import type { + StrategyIcebergParamsV3, + StrategyOcoParamsV3, + StrategyOrderStatusV3, + StrategyOrderTypeV3, + StrategyTrailingStopParamsV3, + StrategyTriggerByV3, + StrategyTriggerOrderTypeV3, + StrategyTwapParamsV3, +} from '../../request/v3/strategy.js'; ⋮---- -export interface CopyFuturesMarginDetailV3 { - marginCoin: string; - maxLongCount: string; - remainingLongCount: string; - maxShortCount: string; - remainingShortCount: string; +export interface PlaceStrategyOrderResponseV3 { + orderId: string; + clientOid: string; } ⋮---- -export interface CopyFuturesTradingPairV3 { - symbol: string; - leverage: string; - marginDetails: CopyFuturesMarginDetailV3[]; +export interface ModifyStrategyOrderResponseV3 { + orderId: string; + clientOid: string; } ⋮---- -export interface CopyFuturesPositionSummaryV3 { - unrealizedPnl: string; - realizedPnl: string; - holdSize: string; - avgPrice: string; +export interface StrategyOrderV3 { + orderId: string; + clientOid: string; + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES' | string; symbol: string; - leverage: string; - marginMode: string; - liqPrice: string; - margin: string; - holdSide: string; - roi: string; - markPrice: string; - positionValue: string; + qty: string; + /** buy / sell. Same field as the WS order push. */ + side?: 'buy' | 'sell'; + posSide: 'long' | 'short'; + status: StrategyOrderStatusV3; + type?: StrategyOrderTypeV3 | string; + triggerType?: 'takeProfit' | 'stopLoss'; + tpTriggerBy?: StrategyTriggerByV3; + slTriggerBy?: StrategyTriggerByV3; + takeProfit?: string; + stopLoss?: string; + tpOrderType?: StrategyTriggerOrderTypeV3; + slOrderType?: StrategyTriggerOrderTypeV3; + tpLimitPrice?: string; + slLimitPrice?: string; + triggerBy?: StrategyTriggerByV3; + triggerPrice?: string; + triggerOrderType?: StrategyTriggerOrderTypeV3; + triggerOrderPrice?: string; + ocoParams?: StrategyOcoParamsV3; + trailingStopParams?: StrategyTrailingStopParamsV3; + icebergParams?: StrategyIcebergParamsV3; + twapParams?: StrategyTwapParamsV3; + createdTime: string; + updatedTime: string; + /** crossed or isolated. Returned by unfilled and history strategy orders */ + marginMode?: 'crossed' | 'isolated'; } ⋮---- -export interface CopyFuturesMaxTransferableV3 { - maxTransferable: string; - available: string; -} +/** buy / sell. Same field as the WS order push. */ ⋮---- -/** Follower copy account. Lead accounts use CopyFuturesMaxTransferableV3. */ -export interface CopyFuturesCopyMaxTransferableV3 { - maxTransferable: string; -} +/** crossed or isolated. Returned by unfilled and history strategy orders */ ⋮---- -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 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/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 interface CopyFuturesCurrentFollowersV3 { - list: CopyFuturesCurrentFollowerV3[]; -} +export type WSOperation = 'subscribe' | 'unsubscribe' | 'login'; ⋮---- -export interface CopyFuturesHistoryFollowerV3 { - followerName: string; - totalProfit: string; - totalShareProfit: string; - totalInvestment: string; - startTime: string; - endTime: 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' + | 'modify-order' + | 'batch-modify'; ⋮---- -export interface CopyFuturesHistoryFollowersV3 { - list: CopyFuturesHistoryFollowerV3[]; +export interface WSOperationLoginParams { + apiKey: string; + passphrase: string; + timestamp: number; + sign: string; } ⋮---- -export interface CopyFuturesProfitSummaryV3 { - totalProfit: string; - totalAllocatedProfit: string; - totalPendingProfit: string; +export interface WSAPIRequestBitgetV3 { + op: 'trade'; + id: string; + category: BitgetInstTypeV3; + topic: WSAPIOperation; + args: TWSParams | TWSParams[]; + /** + * Broker rebate code. Top-level, not inside args. + * Place-order docs name this field. Sent on place-order and batch-place. + * Defaults to the SDK broker code unless the caller sets apiCode. + */ + apiCode?: string; + /** Client-side request timestamp; required for receiveWindow on place-order */ + requestTime?: string; } ⋮---- -export interface CopyFuturesProfitDetailV3 { - followerName: string; - profit: string; - allocatedPnl: string; - pendingPnl: string; - shareRatio: string; - shareProfit: string; - reason: 'period' | 'unfollow' | string; - settleTime: string; -} +/** + * Broker rebate code. Top-level, not inside args. + * Place-order docs name this field. Sent on place-order and batch-place. + * Defaults to the SDK broker code unless the caller sets apiCode. + */ ⋮---- -export interface CopyFuturesProfitDetailsV3 { - list: CopyFuturesProfitDetailV3[]; - nextCursor: string; -} +/** Client-side request timestamp; required for receiveWindow on place-order */ ⋮---- -export interface CopyFuturesPortfolioOverviewV3 { - projectId: string; - asset: string; - roi: string; - totalProfit: string; - followerProfit: string; - maxDrawdown: string; +export interface WSAPIRequestFlags { + /** If true, will skip auth requirement for WS API connection */ + authIsOptional?: boolean | undefined; } ⋮---- -export interface CopyFuturesCopySettingsV3 { - type: 'fixed_ratio' | 'fixed_margin' | string; - amount: string; - tradingPairList: string[]; - marginPerOrder: string; - autoCopy: 'on' | 'off' | string; - leverage: string; - maxEntrySlippage: string; - maxMarginRatio: string; - /** API field name (Bitget spelling). */ - maxPostionValue: string; -} +/** If true, will skip auth requirement for WS API connection */ ⋮---- -/** API field name (Bitget spelling). */ +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]; +}; ⋮---- -export interface CopyFuturesFollowerTransferRecordV3 { - fromType: string; - toType: string; - amount: string; - coin: string; - status: string; - createdTime: string; -} +// This part says: if there's any key that's not in T, it's an error ⋮---- -export interface CopyFuturesFollowerTransferRecordListV3 { - list: CopyFuturesFollowerTransferRecordV3[]; - nextCursor?: string; +/** + +/** + * V2 request looks like this: +{ + "op":"subscribe", + "args":[ + { + "instType":"SPOT", + "channel":"ticker", + "instId":"BTCUSDT" + }, + { + "instType":"SPOT", + "channel":"candle5m", + "instId":"BTCUSDT" + } + ] } -⋮---- -export interface CopyFuturesCurrentCopyV3 { - eliteTrader: string; - estNetProfit: string; - profitShare: string; - estValue: string; - available: string; - currentInvestment: string; + */ +export interface WsRequestOperationBitget { + op: WSOperation; + args?: (TWSRequestArg | string | number)[]; } -⋮---- -export interface CopyFuturesCopyProfitDetailItemV3 { - settleTime: string; - profit: string; - allocatedPnl: string; - pendingPnl: string; - shareRatio: string; - shareProfit: string; +export interface WSAPIRateLimitV3 { + limit: string; + remaining: string; } ⋮---- -export interface CopyFuturesCopyProfitDetailsV3 { - list: CopyFuturesCopyProfitDetailItemV3[]; - nextCursor?: string; +export interface WSAPIResponse< + TResponseData extends object = object, + TOperation extends WSAPIOperation = WSAPIOperation, +> { + wsKey: WsKey; + /** Auto-generated */ + id: string; + event: 'trade'; + category: BitgetInstTypeV3; + topic: TOperation; + args: TResponseData; + code: '0' | string; + msg: 'success' | string; + ts: string; + /** Connection ID (trade operation responses, May 2026+) */ + connId?: string; + /** Gateway receive time, Unix microseconds */ + receiveTime?: string; + /** Gateway push time, Unix microseconds */ + pushTime?: string; + rateLimit?: WSAPIRateLimitV3[]; } ⋮---- -export interface CopyFuturesFollowerPositionV3 { - symbol: string; - marginCoin: string; - posSide: 'long' | 'short' | string; - total: string; - leverage: string; - avgPrice: string; - marginMode: string; - holdMode: string; - createdTime: string; - positionId: string; -} +/** Auto-generated */ ⋮---- -export interface CopyFuturesFollowerPositionsV3 { - list: CopyFuturesFollowerPositionV3[]; -} +/** Connection ID (trade operation responses, May 2026+) */ ⋮---- -export interface CopyFuturesTpSlOrderV3 { - strategyId: string; - category: string; - symbol: string; - qty: string; - posSide: string; - status: string; - tpTriggerBy: string; - slTriggerBy: string; - takeProfit: string; - stopLoss: string; - tpOrderType: string; - slOrderType: string; -} +/** Gateway receive time, Unix microseconds */ ⋮---- -export interface CopyFuturesTpSlResponseV3 { - strategyId: string; -} +/** Gateway push time, Unix microseconds */ ⋮---- -export interface CopyFuturesCurrentTpSlOrdersV3 { - list: CopyFuturesTpSlOrderV3[]; +/** + * List of operations supported for this WsKey (connection) + */ +export interface WsAPIWsKeyTopicMap { + [WS_KEY_MAP.v3Private]: WSAPIOperation; } ⋮---- -export interface CopyFuturesTpSlOrderHistoryV3 { - list: CopyFuturesTpSlOrderV3[]; - cursor?: string; -} - -================ -File: src/types/websockets/ws-general.ts -================ -import type { ClientRequestArgs } from 'http'; -import WebSocket from 'isomorphic-ws'; +/** + * Request parameters expected per operation + */ +export interface WsAPITopicRequestParamMap { + // https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters + 'place-order': WSAPIPlaceOrderRequestV3; + // https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel + 'batch-place': WSAPIPlaceOrderRequestV3[]; + // https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel + 'cancel-order': CancelOrderRequestV3; + // https://www.bitget.com/docs/uta/websocket/private/Batch-Cancel-Order-Channel + 'batch-cancel': CancelOrderRequestV3[]; + 'modify-order': ModifyOrderRequestV3; + 'batch-modify': ModifyOrderRequestV3[]; +} ⋮---- -import { RestClientOptions } from '../../util/requestUtils.js'; -import { WS_KEY_MAP } from '../../util/websocket-util.js'; -import { FuturesProductTypeV2 } from '../request/shared.js'; +// https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters ⋮---- -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'; +// https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel ⋮---- -| 'UTA' // for account-level topics +// https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel +⋮---- +// https://www.bitget.com/docs/uta/websocket/private/Batch-Cancel-Order-Channel ⋮---- /** - * - * V1 list of topics for WebSocket consumers - * + * Response structure expected for each operation */ +export interface WsAPIOperationResponseMap { + // https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters + 'place-order': WSAPIResponse<[WSAPIPlaceOrderResponseV3], 'place-order'>; + // https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel + 'batch-place': WSAPIResponse; + // https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel + 'cancel-order': WSAPIResponse<[CancelOrderResponseV3], 'cancel-order'>; + // https://www.bitget.com/docs/uta/websocket/private/Batch-Cancel-Order-Channel + 'batch-cancel': WSAPIResponse; + 'modify-order': WSAPIResponse<[ModifyOrderResponseV3], 'modify-order'>; + 'batch-modify': WSAPIResponse; +} ⋮---- -export type WsPublicSpotTopic = - | 'ticker' - | 'candle1W' - | 'candle1D' - | 'candle12H' - | 'candle4H' - | 'candle1H' - | 'candle30m' - | 'candle15m' - | 'candle5m' - | 'candle1m' - | 'books' - | 'books5' - | 'trade'; +// https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters ⋮---- -// Futures currently has the same public topics as spot -export type WsPublicFuturesTopic = WsPublicSpotTopic; -export type WsPrivateSpotTopic = 'account' | 'orders'; +// https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel ⋮---- -export type WsPrivateFuturesTopic = - | 'account' - | 'positions' - | 'orders' - | 'ordersAlgo'; +// https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel ⋮---- -export type WsPublicTopic = WsPublicSpotTopic | WsPublicFuturesTopic; +// https://www.bitget.com/docs/uta/websocket/private/Batch-Cancel-Order-Channel + +================ +File: src/types/websockets/ws-events.ts +================ +export interface MessageEventLike { + target: WebSocket; + type: 'message'; + data: string; +} ⋮---- -export type WsPrivateTopic = WsPrivateSpotTopic | WsPrivateFuturesTopic; -export type WsTopic = WsPublicTopic | WsPrivateTopic; +export function isMessageEvent(msg: unknown): msg is MessageEventLike ⋮---- -/** - * - * V2 list of topics for WebSocket consumers - * - */ +export interface WsBaseEvent { + action: TAction; + arg: unknown; + data: TData[]; +} ⋮---- -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'; +export interface WsSnapshotChannelEvent extends WsBaseEvent<'snapshot'> { + arg: { + instType: string; + channel: string; + instId: string; + }; +} ⋮---- -| 'index-price' // margin only +export interface WsSnapshotAccountEvent extends WsBaseEvent<'snapshot'> { + arg: { + instType: string; + channel: 'account'; + instId: string; + }; +} ⋮---- -// Also update PRIVATE_TOPICS_V2 if this is updated -export type WSPrivateTopicFuturesV2 = - | 'positions' - | 'orders-algo' - | 'positions-history'; +export interface WsSnapshotPositionsEvent extends WsBaseEvent<'snapshot'> { + arg: { + instType: string; + channel: 'positions'; + instId: string; + }; +} ⋮---- -// Also update PRIVATE_TOPICS_V2 if this is updated -export type WSPrivateTopicMarginV2 = - | 'orders-crossed' - | 'account-crossed' - | 'account-isolated' - | 'orders-isolated'; +export interface WsAccountSnapshotDataUMCBL { + marginCoin: string; + locked: string; + available: string; + maxOpenPosAvailable: string; + maxTransferOut: string; + equity: string; + usdtEquity: string; +} ⋮---- -// Also update PRIVATE_TOPICS_V2 if this is updated -export type WsPrivateTopicV2 = - | 'account' - | 'orders' - | WSPrivateTopicFuturesV2 - | WSPrivateTopicMarginV2; +export interface WsAccountSnapshotUMCBL extends WsBaseEvent<'snapshot'> { + arg: { + instType: 'umcbl'; + channel: 'account'; + instId: string; + }; + data: WsAccountSnapshotDataUMCBL[]; +} ⋮---- -export type WsTopicV2 = WsPublicTopicV2 | WsPrivateTopicV2; +export interface WsPositionSnapshotDataUMCBL { + posId: string; + instId: string; + instName: string; + marginCoin: string; + margin: string; + marginMode: string; + holdSide: string; + holdMode: string; + total: string; + available: string; + locked: string; + averageOpenPrice: string; + leverage: number; + achievedProfits: string; + upl: string; + uplRate: string; + liqPx: string; + keepMarginRate: string; + marginRate: string; + cTime: string; + uTime: string; + markPrice: string; + /** Cash dividend, USDT (Classic V2 positions channel) */ + cashDividend?: string; +} ⋮---- -/** - * - * V3 / UTA list of topics for WebSocket consumers - * - */ -export type WsPublicTopicV3 = - | 'ticker' - | 'kline' - | 'books' - | 'books1' - | 'books5' - | 'books50' - | 'publicTrade'; -// Also update PRIVATE_TOPICS_V3 if this is updated. -// `order` includes venue and rTokenTimeInForce for rToken orders. -export type WsPrivateTopicV3 = - | 'account' - | 'position' - | 'fill' - | 'order' - | 'strategy-order' - | 'reality-orderbook' - | 'reality-orderbook-segmented'; -export type WsTopicV3 = WsPublicTopicV3 | WsPrivateTopicV3; +/** Cash dividend, USDT (Classic V2 positions channel) */ ⋮---- -/** This is used to differentiate between each of the available websocket streams */ -export type WsKey = (typeof WS_KEY_MAP)[keyof typeof WS_KEY_MAP]; +/** UTA reality-orderbook push (ts/seq/pseq removed July 2026). Every push is a full snapshot. */ +export interface WsRealityOrderBookDataV3 { + a: [string, string][]; + b: [string, string][]; +} ⋮---- /** - * Event args for subscribing/unsubscribing + * UTA reality-orderbook-segmented push. + * Each level is [price, onshoreQty, offshoreQty]. + * Every push is a full snapshot. Whitelist required. + * Go-live 20 Oct 2026. Pairs that have not finished the matching-engine upgrade do not push. + * A crossed book after the upgrade is expected. */ -⋮---- -export interface WsTopicSubscribeEventArgs { - instType: BitgetInstType; - channel: WsTopic; - instId?: string; +export interface WsRealityOrderBookSegmentedDataV3 { + a: [string, string, string][]; + b: [string, string, string][]; } ⋮---- -export type WsTopicSubscribePublicArgsV2 = { - instType: BitgetInstTypeV2; - channel: WsPublicTopicV2; - /** The symbol, e.g. "BTCUSDT" */ - instId: string; -}; +export interface WSPositionSnapshotUMCBL extends WsBaseEvent<'snapshot'> { + arg: { + instType: 'umcbl'; + channel: 'positions'; + instId: string; + }; + data: WsPositionSnapshotDataUMCBL[]; +} ⋮---- -/** The symbol, e.g. "BTCUSDT" */ +/** Classic V2 depth channel push data. checksum removed May 2026 - use seq instead */ +export interface WsDepthBookDataV2 { + asks: [string, string][]; + bids: [string, string][]; + ts: string; + seq: string; + /** Futures books channel only - previous push serial number */ + pseq?: string; +} ⋮---- -export type WsInstIdChannelsV2 = - | 'orders' - | WSPrivateTopicFuturesV2 - | 'orders-crossed' - | 'orders-isolated'; +/** Futures books channel only - previous push serial number */ ⋮---- -export type WsTopicSubscribePrivateInstIdArgsV2 = { - instType: BitgetInstTypeV2; - channel: WsInstIdChannelsV2; - /** The symbol, e.g. "BTCUSDT" */ - instId?: string; -}; +/** UTA account channel coin row */ +export interface WsAccountCoinV3 { + coin: string; + balance: string; + /** Coin balance before borrowing-related amounts are deducted */ + balanceOriginal?: string; + available: string; + locked: string; + equity: string; + usdValue: string; + borrow: string; + debts: string; + bonus?: string; +} ⋮---- -/** The symbol, e.g. "BTCUSDT" */ +/** Coin balance before borrowing-related amounts are deducted */ ⋮---- -export type WsCoinChannelsV2 = - | 'account' - | 'account-crossed' - | 'account-isolated'; +/** UTA account channel push. action is snapshot or update */ +export interface WsAccountDataV3 { + totalEquity: string; + effEquity: string; + mmr: string; + imr: string; + mgnRatio: string; + positionMgnRatio: string; + unrealisedPnL: string; + coin: WsAccountCoinV3[]; +} ⋮---- -export type WsTopicSubscribePrivateCoinArgsV2 = { - instType: BitgetInstTypeV2; - channel: WsCoinChannelsV2; - coin: 'default' | string; -}; +/** + * UTA depth push. + * books1 and books5: every message is a full snapshot. + * books and books50: the first message is a snapshot, later messages are incremental updates. + * Do not replace the local book with a books or books50 update. + * pseq is set on books and books50. + * rToken: books1 pushes at all times. books5, books50, and books push only outside US market hours. + */ +export interface WsOrderBookDataV3 { + a: [string, string][]; + b: [string, string][]; + seq: string | number; + pseq?: string | number; + /** Present on the books topic */ + maxDepth?: string; + ts: string; +} ⋮---- -export type WsTopicSubscribePrivateArgsV2 = - | WsTopicSubscribePrivateInstIdArgsV2 - | WsTopicSubscribePrivateCoinArgsV2; +/** Present on the books topic */ + +================ +File: src/types/response/v3/copytrading.ts +================ +/** + * + * + * Copy Trading | Futures (UTA) + * + * + */ ⋮---- -export type WsTopicSubscribeEventArgsV2 = - | WsTopicSubscribePublicArgsV2 - | WsTopicSubscribePrivateArgsV2; +export interface CopyFuturesMarginDetailV3 { + marginCoin: string; + maxLongCount: string; + remainingLongCount: string; + maxShortCount: string; + remainingShortCount: string; +} ⋮---- -/** General configuration for the WebsocketClient */ -export interface WSClientConfigurableOptions { - /** Your API key */ - apiKey?: string; - - /** Your API secret */ - apiSecret?: string; - - /** The passphrase you set when creating the API Key (NOT your account password) */ - apiPass?: string; - - /** - * Set to `true` to connect to Bitget's demo trading WebSockets: - * - * - V2: https://www.bitget.com/api-doc/common/demotrading/websocket - * - V3/UTA: https://www.bitget.com/api-doc/uta/guide#demo-trading - */ - demoTrading?: boolean; - - /** Define a recv window when preparing a private websocket signature. This is in milliseconds, so 5000 == 5 seconds */ - recvWindow?: number; - - // Disable ping/pong ws heartbeat mechanism (not recommended) - disableHeartbeat?: boolean; - - /** How often to check if the connection is alive */ - pingInterval?: number; - - /** How long to wait for a pong (heartbeat reply) before assuming the connection is dead */ - pongTimeout?: number; - - /** Delay in milliseconds before respawning the connection */ - reconnectTimeout?: number; - - requestOptions?: RestClientOptions; - - wsOptions?: { - protocols?: string[]; - agent?: any; - } & ( - | 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; +export interface CopyFuturesTradingPairV3 { + symbol: string; + leverage: string; + marginDetails: CopyFuturesMarginDetailV3[]; } ⋮---- -/** Your API key */ +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; +} ⋮---- -/** Your API secret */ +export interface CopyFuturesMaxTransferableV3 { + maxTransferable: string; + available: string; +} ⋮---- -/** The passphrase you set when creating the API Key (NOT your account password) */ +/** Follower copy account. Lead accounts use CopyFuturesMaxTransferableV3. */ +export interface CopyFuturesCopyMaxTransferableV3 { + maxTransferable: string; +} ⋮---- -/** - * Set to `true` to connect to Bitget's demo trading WebSockets: - * - * - V2: https://www.bitget.com/api-doc/common/demotrading/websocket - * - V3/UTA: https://www.bitget.com/api-doc/uta/guide#demo-trading - */ +export interface CopyFuturesTransferResponseV3 { + transferId: string; +} ⋮---- -/** Define a recv window when preparing a private websocket signature. This is in milliseconds, so 5000 == 5 seconds */ +/** May be a single value or comma-separated values */ +export type CopyFuturesTransferAccountTypeV3 = + | 'spot' + | 'uta' + | 'lead' + | 'otc' + | string; ⋮---- -// Disable ping/pong ws heartbeat mechanism (not recommended) +export interface CopyFuturesTransferRecordV3 { + transferId: string; + fromType: CopyFuturesTransferAccountTypeV3; + toType: CopyFuturesTransferAccountTypeV3; + amount: string; + coin: string; + status: 'Successful' | 'Failed' | 'Processing'; + createdTime: string; +} ⋮---- -/** How often to check if the connection is alive */ +export interface CopyFuturesTransferRecordListV3 { + list: CopyFuturesTransferRecordV3[]; +} ⋮---- -/** How long to wait for a pong (heartbeat reply) before assuming the connection is dead */ +export interface CopyFuturesCurrentFollowerV3 { + followerName: string; + estimateAssets: string; + totalProfit: string; + totalShareProfit: string; + totalInvestment: string; + canRemove: 'yes' | 'no'; + followDays: string; + totalAssets: string; + startTime: string; +} ⋮---- -/** Delay in milliseconds before respawning the connection */ +export interface CopyFuturesCurrentFollowersV3 { + list: CopyFuturesCurrentFollowerV3[]; +} ⋮---- -/** - * 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 CopyFuturesHistoryFollowerV3 { + followerName: string; + totalProfit: string; + totalShareProfit: string; + totalInvestment: string; + startTime: string; + endTime: string; +} ⋮---- -export interface WebsocketClientOptions extends WSClientConfigurableOptions { - pingInterval: number; - pongTimeout: number; - reconnectTimeout: number; - recvWindow: number; - authPrivateConnectionsOnConnect: boolean; - authPrivateRequests: boolean; +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; +} +⋮---- +export interface CopyFuturesPortfolioOverviewV3 { + projectId: string; + asset: string; + roi: string; + totalProfit: string; + followerProfit: string; + maxDrawdown: string; +} +⋮---- +export interface CopyFuturesCopySettingsV3 { + type: 'fixed_ratio' | 'fixed_margin' | string; + amount: string; + tradingPairList: string[]; + marginPerOrder: string; + autoCopy: 'on' | 'off' | string; + leverage: string; + maxEntrySlippage: string; + maxMarginRatio: string; + /** API field name (Bitget spelling). */ + maxPostionValue: string; +} +⋮---- +/** API field name (Bitget spelling). */ +⋮---- +export interface CopyFuturesFollowerTransferRecordV3 { + fromType: string; + toType: string; + amount: string; + coin: string; + status: string; + createdTime: string; +} +⋮---- +export interface CopyFuturesFollowerTransferRecordListV3 { + list: CopyFuturesFollowerTransferRecordV3[]; + nextCursor?: string; +} +⋮---- +export interface CopyFuturesCurrentCopyV3 { + eliteTrader: string; + estNetProfit: string; + profitShare: string; + estValue: string; + available: string; + currentInvestment: string; +} +⋮---- +export interface CopyFuturesCopyProfitDetailItemV3 { + settleTime: string; + profit: string; + allocatedPnl: string; + pendingPnl: string; + shareRatio: string; + shareProfit: string; +} +⋮---- +export interface CopyFuturesCopyProfitDetailsV3 { + list: CopyFuturesCopyProfitDetailItemV3[]; + nextCursor?: string; +} +⋮---- +export interface CopyFuturesFollowerPositionV3 { + symbol: string; + marginCoin: string; + posSide: 'long' | 'short' | string; + total: string; + leverage: string; + avgPrice: string; + marginMode: string; + holdMode: string; + createdTime: string; + positionId: string; +} +⋮---- +export interface CopyFuturesFollowerPositionsV3 { + list: CopyFuturesFollowerPositionV3[]; +} +⋮---- +export interface CopyFuturesTpSlOrderV3 { + strategyId: string; + category: string; + symbol: string; + qty: string; + posSide: string; + status: string; + tpTriggerBy: string; + slTriggerBy: string; + takeProfit: string; + stopLoss: string; + tpOrderType: string; + slOrderType: string; +} +⋮---- +export interface CopyFuturesTpSlResponseV3 { + strategyId: string; +} +⋮---- +export interface CopyFuturesCurrentTpSlOrdersV3 { + list: CopyFuturesTpSlOrderV3[]; +} +⋮---- +export interface CopyFuturesTpSlOrderHistoryV3 { + list: CopyFuturesTpSlOrderV3[]; + cursor?: string; } ================ @@ -12918,5844 +12653,4248 @@ File: src/index.ts ================ -File: src/rest-client-v2.ts +File: src/types/request/v3/strategy.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, - GetSubAffiliateInfoRequestV2, - 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, - SubAffiliateInfoV2, -} 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> -⋮---- -getSubAffiliateInfo( - params?: GetSubAffiliateInfoRequestV2, -): 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); +export type StrategyOrderTypeV3 = + | 'tpsl' + | 'trigger' + | 'oco' + | 'trailing_stop' + | 'iceberg' + | 'twap'; ⋮---- -marginBatchSubmitOrders( - marginType: MarginType, - params: MarginBatchOrdersRequestV2, -): Promise> +export type StrategyOrderStatusV3 = + | 'pending' + | 'success' + | 'failed' + | 'cancelled' + | 'submitting'; ⋮---- -marginCancelOrder( - marginType: MarginType, - params: { - symbol: string; - orderId?: string; - clientOid?: string; - }, - ): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > { - assertMarginType(marginType); +export type StrategyTriggerByV3 = 'market' | 'mark'; ⋮---- -marginBatchCancelOrders( - marginType: MarginType, - params: { - symbol: string; - orderIdList: string[]; - }, -): Promise> +export type StrategyTriggerOrderTypeV3 = 'limit' | 'market'; ⋮---- -getMarginOpenOrders( - marginType: MarginType, - params: GetMarginCurrentOrdersRequestV2, - ): Promise< - APIResponse<{ - orderList: MarginCurrentOrderV2[]; - maxId: string; - minId: string; - }> - > { - assertMarginType(marginType); +export interface StrategyOcoParamsV3 { + ocoLimitPrice?: string; + ocoTriggerPrice?: string; + ocoOrderType?: StrategyTriggerOrderTypeV3; + ocoOrderPrice?: string; +} ⋮---- -getMarginHistoricOrders( - marginType: MarginType, - params: GetHistoryOrdersRequestV2, - ): Promise< - APIResponse<{ - orderList: MarginHistoryOrderV2[]; - maxId: string; - minId: string; - }> - > { - assertMarginType(marginType); +export interface StrategyTrailingStopParamsV3 { + activationPrice?: string; + activationType?: string; + trailType?: string; + trailVariance?: string; + preOrderType?: StrategyTriggerOrderTypeV3; + preOrderPrice?: string; +} ⋮---- -getMarginHistoricOrderFills( - marginType: MarginType, - params: GetMarginOrderFillsRequestV2, - ): Promise< - APIResponse<{ - fills: MarginOrderFillV2[]; - minId: string; - maxId: string; - }> - > { - assertMarginType(marginType); +export interface StrategyIcebergParamsV3 { + splitMode?: string; + qtyPerOrder?: string; + splitOrderNumbers?: string; + orderPreference?: string; + executionStrategy?: string; + fixedDistanceType?: string; + distance?: string; + fixedPrice?: string; + priceLimit?: string; +} ⋮---- -getMarginLiquidationOrders( - marginType: MarginType, - params: GetMarginLiquidationOrdersRequestV2, - ): Promise< - APIResponse<{ - resultList: MarginLiquidationOrderV2[]; - idLessThan: string; - }> - > { - assertMarginType(marginType); +export interface StrategyTwapParamsV3 { + duration?: string; + interval?: string; + orderType?: StrategyTriggerOrderTypeV3; + limitOffsetType?: string; + limitOffsetPercentage?: string; + limitOffsetSpread?: string; + twapTriggerPrice?: string; + twapTerminationPrice?: string; +} ⋮---- -/** - * - * - * Copy Trading - * - * +export interface PlaceStrategyOrderRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol: string; + clientOid?: string; + type?: StrategyOrderTypeV3; + tpslMode?: 'full' | 'partial'; + /** Required when tpslMode=partial or for trigger orders */ + qty?: string; + side?: 'buy' | 'sell'; + posSide?: 'long' | 'short'; + reduceOnly?: 'yes' | 'no'; + /** + * Margin mode. Defaults to crossed. Required for isolated positions + * (isolated TP/SL fails with 31008 if omitted). + * Not in Bitget's official API docs yet. Confirmed by Bitget API devs + * in their OpenAPI Telegram: https://t.me/bitgetOpenapi/152235 */ + marginMode?: 'isolated' | 'crossed'; + tpTriggerBy?: StrategyTriggerByV3; + slTriggerBy?: StrategyTriggerByV3; + takeProfit?: string; + stopLoss?: string; + tpOrderType?: StrategyTriggerOrderTypeV3; + slOrderType?: StrategyTriggerOrderTypeV3; + tpLimitPrice?: string; + slLimitPrice?: string; + triggerBy?: StrategyTriggerByV3; + triggerPrice?: string; + triggerOrderType?: StrategyTriggerOrderTypeV3; + triggerOrderPrice?: string; + ocoParams?: StrategyOcoParamsV3; + trailingStopParams?: StrategyTrailingStopParamsV3; + icebergParams?: StrategyIcebergParamsV3; + twapParams?: StrategyTwapParamsV3; +} +⋮---- +/** Required when tpslMode=partial or for trigger orders */ ⋮---- /** - * - * - * Copy Trading | Future copy trading | Trader Api - * - * + * Margin mode. Defaults to crossed. Required for isolated positions + * (isolated TP/SL fails with 31008 if omitted). + * Not in Bitget's official API docs yet. Confirmed by Bitget API devs + * in their OpenAPI Telegram: https://t.me/bitgetOpenapi/152235 */ ⋮---- -getFuturesTraderCurrentOrder( - params: GetFuturesTraderCurrentOrdersRequestV2, -): Promise> -⋮---- -getFuturesTraderHistoryOrders( - params: GetFuturesTraderHistoryOrdersRequestV2, -): Promise> +export interface ModifyStrategyOrderRequestV3 { + orderId?: string; + clientOid?: string; + qty: string; + tpTriggerBy?: StrategyTriggerByV3; + slTriggerBy?: StrategyTriggerByV3; + takeProfit?: string; + stopLoss?: string; + tpOrderType?: StrategyTriggerOrderTypeV3; + slOrderType?: StrategyTriggerOrderTypeV3; + tpLimitPrice?: string; + slLimitPrice?: string; + triggerBy?: StrategyTriggerByV3; + triggerPrice?: string; + triggerOrderType?: StrategyTriggerOrderTypeV3; + triggerOrderPrice?: string; +} ⋮---- -modifyFuturesTraderOrderTPSL( - params: ModifyFuturesTraderOrderTPSLRequestV2, -): Promise> +export interface CancelStrategyOrderRequestV3 { + orderId?: string; + clientOid?: string; +} ⋮---- -getFuturesTraderOrder(): Promise< - APIResponse - > { - return this.getPrivate('/api/v2/copy/mix-trader/order-total-detail'); +export interface GetUnfilledStrategyOrdersRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + type?: StrategyOrderTypeV3; +} ⋮---- -getFuturesTraderProfitHistory(): Promise< - APIResponse - > { - return this.getPrivate('/api/v2/copy/mix-trader/profit-history-summarys'); +export interface GetHistoryStrategyOrdersRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + type?: StrategyOrderTypeV3; + startTime?: string; + endTime?: string; + limit?: string; + /** Observed as a number though the docs say string. */ + cursor?: string | number; +} ⋮---- -getFuturesTraderProfitShareHistory( - params: GetFuturesTraderProfitShareDetailRequestV2, -): Promise> +/** Observed as a number though the docs say string. */ ⋮---- -closeFuturesTraderOrder(params: { - trackingNo: string; - symbol: string; - productType: CopyTradingProductTypeV2; - }): Promise< - APIResponse< - { - trackingNo: string; - symbol: string; - productType: string; - }[] - > - > { - return this.postPrivate( - '/api/v2/copy/mix-trader/order-close-positions', - params, - ); +export interface GetStrategySubOrdersRequestV3 { + orderId?: string; + clientOid?: string; + limit?: string; + cursor?: string; +} + +================ +File: src/types/response/v3/trade.ts +================ +export interface BatchModifyOrderResponseV3 { + orderId: string; + clientOid: string; +} ⋮---- -getFuturesTraderProfitShare(params?: { - coin?: string; - pageSize?: string; - pageNo?: string; - }): Promise< - APIResponse< - { - coin: string; - profit: string; - nickName: string; - }[] - > - > { - return this.getPrivate('/api/v2/copy/mix-trader/profit-details', params); +export interface CancelAllOrdersResponseV3 { + list: { + orderId: string; + clientOid: string; + code: string; + msg: string; + }[]; +} ⋮---- -getFuturesTraderProfitShareGroup(params?: { - pageSize?: string; - pageNo?: string; - }): Promise< - APIResponse< - { - coin: string; - profit: string; - profitTime: string; - }[] - > - > { - return this.getPrivate( - '/api/v2/copy/mix-trader/profits-group-coin-date', - params, - ); +export interface CancelBatchOrdersResponseV3 { + orderId: string; + clientOid: string; + code?: string; + msg?: string; +} ⋮---- -getFuturesTraderSymbolSettings(params: { - productType: CopyTradingProductTypeV2; -}): Promise> +export interface CloseAllPositionsResponseV3 { + list: { + orderId: string; + clientOid: string; + code: string; + msg: string; + }[]; +} ⋮---- -updateFuturesTraderSymbolSettings(params: { - settingList: FuturesTraderSymbolSettingRequestV2[]; -}): Promise> +export interface CancelOrderResponseV3 { + orderId: string; + clientOid: string; +} ⋮---- -updateFuturesTraderGlobalSettings(params?: { - enable?: 'YES' | 'NO'; - showTotalEquity?: 'YES' | 'NO'; - showTpsl?: 'YES' | 'NO'; -}): Promise> +export interface GetMaxOpenAvailableResponseV3 { + available: string; + maxOpen: string; + buyOpenCost: string; + sellOpenCost: string; + maxBuyOpen: string; + maxSellOpen: string; + maxBuyAvailable?: string; + maxSellAvailable?: string; +} ⋮---- -getFuturesTraderFollowers( - params?: GetFuturesTraderFollowersRequestV2, -): Promise> +export interface FeeDetailV3 { + feeCoin: string; + fee: string; +} ⋮---- -removeFuturesTraderFollower(params: { - followerUid: string; -}): Promise> +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; + /** + * rToken routing. internalization or lit_market. + * Also pushed on the WS order channel. + */ + venue?: 'internalization' | 'lit_market' | string; + /** rToken time in force. gtd = current session, gtc = 90 days. */ + rTokenTimeInForce?: 'gtd' | 'gtc' | string; + orderStatus: string; + posSide: string; + holdMode: string; + delegateType?: string; + reduceOnly: string; + feeDetail: FeeDetailV3[]; + cancelReason: string; + execType: string; + stpMode?: string; + createdTime: string; + updatedTime: string; +} ⋮---- /** - * - * - * Copy Trading | Future copy trading | Follower Api - * - * + * rToken routing. internalization or lit_market. + * Also pushed on the WS order channel. */ ⋮---- -getFuturesFollowerCurrentOrders( - params: GetFollowerFuturesCurrentTrackingOrdersRequestV2, -): Promise> +/** rToken time in force. gtd = current session, gtc = 90 days. */ ⋮---- -getFuturesFollowerHistoryOrders( - params: GetFollowerFuturesHistoryTrackingOrdersRequestV2, -): Promise> +export type FillCategoryV3 = + | 'spot' + | 'margin' + | 'usdt-futures' + | 'coin-futures' + | 'usdc-futures' + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; ⋮---- -updateFuturesFollowerTPSL( - params: UpdateFuturesFollowerTPSLRequestV2, -): Promise> +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; +} ⋮---- -updateFuturesFollowerSettings( - params: UpdateFuturesFollowerSettingsRequestV2, -): Promise> +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; +} ⋮---- -getFuturesFollowerSettings(params: { - traderId: string; -}): Promise> +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; +} ⋮---- -closeFuturesFollowerPositions( - params: CloseFuturesFollowerPositionsRequestV2, - ): Promise< - APIResponse<{ - orderIdList: string[]; - }> - > { - return this.postPrivate( - '/api/v2/copy/mix-follower/close-positions', - params, - ); +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[]; +} ⋮---- -getFuturesFollowerTraders( - params: GetFuturesFollowerTradersRequestV2, -): Promise> +export interface ModifyOrderResponseV3 { + orderId: string; + clientOid: string; +} ⋮---- -getFuturesFollowerFollowLimit(params: { - symbol: string; - productType: CopyTradingProductTypeV2; - }): Promise< - APIResponse< - { - maxFollowSize: string; - minFollowSize: string; - symbol: string; - }[] - > - > { - return this.getPrivate( - '/api/v2/copy/mix-follower/query-quantity-limit', - params, - ); +export interface PlaceBatchOrdersResponseV3 { + orderId: string; + clientOid: string; + code?: string; + msg?: string; +} ⋮---- -unfollowFuturesTrader(params: { - traderId: string; -}): Promise> +export interface PlaceOrderResponseV3 { + orderId: string; + clientOid: string; +} ⋮---- -/** - * - * - * Copy Trading | Future copy trading | Broker api - * - * +export interface PositionAdlRankV3 { + symbol: string; + marginCoin: string; + adlRank: string; + holdSide: 'long' | 'short'; +} + +================ +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'; + /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ + pxAmendType?: 'yes' | 'no'; + /** + * rToken routing. internalization or lit_market (default). + * Ignored for non-rToken symbols. + */ + venue?: 'internalization' | 'lit_market'; + /** rToken time in force. gtd (default) or gtc (90 days). */ + rTokenTimeInForce?: 'gtd' | 'gtc'; + /** + * Broker rebate code. Lifted onto the WS request envelope. + * It is not sent inside args. Omit it to use the SDK broker code. + * Place-order docs: top-level apiCode. Batch-place uses the same field. + * Staff-confirmed: t.me/bitgetOpenapi/153820. */ + apiCode?: string; +} ⋮---- -getBrokerTraders(params: object): Promise> +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 */ ⋮---- -getBrokerTradersHistoricalOrders(params: object): Promise> +/** Order TTL in ms [10, 60000]. Only effective when requestTime is also set on the envelope */ ⋮---- -getBrokerTradersPendingOrders(params: object): Promise> +/** Spot only. Default: no */ +⋮---- +/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ ⋮---- /** - * - * - * Copy Trading | Spot copy trading | Trader api - * - * + * rToken routing. internalization or lit_market (default). + * Ignored for non-rToken symbols. */ ⋮---- -getSpotTraderProfit(): Promise> -⋮---- -getSpotTraderHistoryProfit( - params: GetSpotTraderHistoryProfitRequestV2, -): Promise> +/** rToken time in force. gtd (default) or gtc (90 days). */ ⋮---- -getSpotTraderUnrealizedProfit(params?: { - coin?: string; - pageNo?: string; - pageSize?: string; -}): Promise> +/** + * Broker rebate code. Lifted onto the WS request envelope. + * It is not sent inside args. Omit it to use the SDK broker code. + * Place-order docs: top-level apiCode. Batch-place uses the same field. + * Staff-confirmed: t.me/bitgetOpenapi/153820. + */ + +================ +File: src/types/websockets/ws-general.ts +================ +import type { ClientRequestArgs } from 'http'; +import WebSocket from 'isomorphic-ws'; ⋮---- -getSpotTraderOrder(): Promise> +import { RestClientOptions } from '../../util/requestUtils.js'; +import { WS_KEY_MAP } from '../../util/websocket-util.js'; +import { FuturesProductTypeV2 } from '../request/shared.js'; ⋮---- -modifySpotTraderOrderTPSL(params: { - trackingNo: string; - stopSurplusPrice?: string; - stopLossPrice?: string; -}): Promise> +export type BitgetInstType = 'SP' | 'SPBL' | 'MC' | 'UMCBL' | 'DMCBL'; +export type BitgetInstTypeV2 = 'SPOT' | FuturesProductTypeV2; +export type BitgetInstTypeV3 = + | 'UTA' // for account-level topics + | 'uta' + | 'spot' + | 'usdt-futures' + | 'coin-futures' + | 'usdc-futures'; ⋮---- -getSpotTraderHistoryOrders( - params: GetSpotTraderHistoryOrdersRequestV2, -): Promise> +| 'UTA' // for account-level topics ⋮---- -getSpotTraderCurrentOrders( - params: GetSpotTraderCurrentOrdersRequestV2, -): Promise> +/** + * + * V1 list of topics for WebSocket consumers + * + */ ⋮---- -sellSpotTrader(params: { - trackingNoList: string[]; - symbol: string; -}): Promise> +export type WsPublicSpotTopic = + | 'ticker' + | 'candle1W' + | 'candle1D' + | 'candle12H' + | 'candle4H' + | 'candle1H' + | 'candle30m' + | 'candle15m' + | 'candle5m' + | 'candle1m' + | 'books' + | 'books5' + | 'trade'; ⋮---- -getSpotTraderSymbolSettings(params: { - symbolList: string[]; - settingType: 'add' | 'delete'; -}): Promise> +// Futures currently has the same public topics as spot +export type WsPublicFuturesTopic = WsPublicSpotTopic; +export type WsPrivateSpotTopic = 'account' | 'orders'; ⋮---- -removeSpotTraderFollowers(params: { - followerUid: string; -}): Promise> +export type WsPrivateFuturesTopic = + | 'account' + | 'positions' + | 'orders' + | 'ordersAlgo'; ⋮---- -getSpotTraderConfiguration(): Promise> +export type WsPublicTopic = WsPublicSpotTopic | WsPublicFuturesTopic; ⋮---- -getSpotTraderFollowers( - params: GetSpotTraderFollowersRequestV2, -): Promise> +export type WsPrivateTopic = WsPrivateSpotTopic | WsPrivateFuturesTopic; +export type WsTopic = WsPublicTopic | WsPrivateTopic; ⋮---- /** - * - * - * 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> + * + * V2 list of topics for WebSocket consumers + * + */ ⋮---- -updateSpotFollowerTPSL(params: { - trackingNo: string; - stopSurplusPrice?: string; - stopLossPrice?: string; -}): Promise> +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'; ⋮---- -getSpotFollowerTraders(params?: { - pageNo?: string; - pageSize?: string; - startTime?: string; - endTime?: string; -}): Promise> +| 'index-price' // margin only ⋮---- -getSpotFollowerCurrentTraderSymbols(params: { traderId: string }): Promise< - APIResponse<{ - currentTradingList: string[]; - }> - > { - return this.getPrivate( - '/api/v2/copy/spot-follower/query-trader-symbols', - params, - ); +// Also update PRIVATE_TOPICS_V2 if this is updated +export type WSPrivateTopicFuturesV2 = + | 'positions' + | 'orders-algo' + | 'positions-history'; ⋮---- -getSpotFollowerSettings(params: { - traderId: string; -}): Promise> +// Also update PRIVATE_TOPICS_V2 if this is updated +export type WSPrivateTopicMarginV2 = + | 'orders-crossed' + | 'account-crossed' + | 'account-isolated' + | 'orders-isolated'; ⋮---- -getSpotFollowerHistoryOrders( - params: GetSpotFollowerHistoryOrdersRequestV2, -): Promise> +// Also update PRIVATE_TOPICS_V2 if this is updated +export type WsPrivateTopicV2 = + | 'account' + | 'orders' + | WSPrivateTopicFuturesV2 + | WSPrivateTopicMarginV2; ⋮---- -getSpotFollowerOpenOrders( - params: GetSpotFollowerOpenOrdersRequestV2, -): Promise> +export type WsTopicV2 = WsPublicTopicV2 | WsPrivateTopicV2; ⋮---- -sellSpotFollower(params: { - trackingNoList: string[]; - symbol: string; -}): Promise> +/** + * + * V3 / UTA list of topics for WebSocket consumers + * + */ +export type WsPublicTopicV3 = + | 'ticker' + | 'kline' + | 'books' + | 'books1' + | 'books5' + | 'books50' + | 'publicTrade' + | 'instruments' + | 'open-interest-limit' + | 'position-tier' + | 'funding-rate' + | 'margin-loan' + | 'margin-coins'; +// Also update PRIVATE_TOPICS_V3 if this is updated. +// `order` includes venue and rTokenTimeInForce for rToken orders. +export type WsPrivateTopicV3 = + | 'account' + | 'position' + | 'fill' + | 'order' + | 'strategy-order' + | 'reality-orderbook' + | 'reality-orderbook-segmented'; +export type WsTopicV3 = WsPublicTopicV3 | WsPrivateTopicV3; ⋮---- -unfollowSpotTrader(params: { - traderId: string; -}): Promise> +/** This is used to differentiate between each of the available websocket streams */ +export type WsKey = (typeof WS_KEY_MAP)[keyof typeof WS_KEY_MAP]; ⋮---- /** - * - * - * Earn | Savings - * - * - */ -⋮---- -getEarnSavingsProducts(params?: { - coin?: string; - filter?: string; -}): Promise> + * Event args for subscribing/unsubscribing + */ ⋮---- -getEarnSavingsAccount(): Promise> +export interface WsTopicSubscribeEventArgs { + instType: BitgetInstType; + channel: WsTopic; + instId?: string; +} ⋮---- -getEarnSavingsAssets( - params: GetEarnSavingsAssetsRequestV2, -): Promise> +export type WsTopicSubscribePublicArgsV2 = { + instType: BitgetInstTypeV2; + channel: WsPublicTopicV2; + /** The symbol, e.g. "BTCUSDT" */ + instId: string; +}; ⋮---- -getEarnSavingsRecords( - params: GetEarnSavingsRecordsRequestV2, -): Promise> +/** The symbol, e.g. "BTCUSDT" */ ⋮---- -getEarnSavingsSubscription(params: { - productId: string; - periodType: string; -}): Promise> +export type WsInstIdChannelsV2 = + | 'orders' + | WSPrivateTopicFuturesV2 + | 'orders-crossed' + | 'orders-isolated'; ⋮---- -earnSubscribeSavings(params: { - productId: string; - periodType: string; - amount: string; - }): Promise< - APIResponse<{ - orderId: string; - status: string; - }> - > { - return this.postPrivate('/api/v2/earn/savings/subscribe', params); +export type WsTopicSubscribePrivateInstIdArgsV2 = { + instType: BitgetInstTypeV2; + channel: WsInstIdChannelsV2; + /** The symbol, e.g. "BTCUSDT" */ + instId?: string; +}; ⋮---- -getEarnSavingsSubscriptionResult(params: { - productId: string; - periodType: string; - }): Promise< - APIResponse<{ - result: 'success' | 'fail'; - msg: string; - }> - > { - return this.getPrivate('/api/v2/earn/savings/subscribe-result', params); +/** The symbol, e.g. "BTCUSDT" */ ⋮---- -earnRedeemSavings(params: RedeemSavingsRequestV2): Promise< - APIResponse<{ - orderId: string; - status: string; - }> - > { - return this.postPrivate('/api/v2/earn/savings/redeem', params); +export type WsCoinChannelsV2 = + | 'account' + | 'account-crossed' + | 'account-isolated'; ⋮---- -getEarnSavingsRedemptionResult(params: { - orderId: string; - periodType: string; - }): Promise< - APIResponse<{ - result: 'success' | 'fail'; - msg: string; - }> - > { - return this.getPrivate('/api/v2/earn/savings/redeem-result', params); +export type WsTopicSubscribePrivateCoinArgsV2 = { + instType: BitgetInstTypeV2; + channel: WsCoinChannelsV2; + coin: 'default' | string; +}; ⋮---- -/** - * - * - * Earn | Earn Account - * - * - */ +export type WsTopicSubscribePrivateArgsV2 = + | WsTopicSubscribePrivateInstIdArgsV2 + | WsTopicSubscribePrivateCoinArgsV2; ⋮---- -getEarnAccount(params?: { coin?: string }): Promise< - APIResponse< - { - coin: string; - amount: string; - }[] - > - > { - return this.getPrivate('/api/v2/earn/account/assets', params); +export type WsTopicSubscribeEventArgsV2 = + | WsTopicSubscribePublicArgsV2 + | WsTopicSubscribePrivateArgsV2; ⋮---- -/** - * - * - * Earn | On-Chain Elite - * +/** 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; +} ⋮---- -getEarnEliteProducts(): Promise> -⋮---- -getEarnEliteAssets(): Promise> -⋮---- -getEarnEliteRecords( - params: GetEarnEliteRecordsRequestV2, -): Promise> -⋮---- -getEarnEliteSubscribeInfo( - params: GetEarnEliteSubscribeInfoRequestV2, -): Promise> -⋮---- -subscribeEarnElite( - params: EarnEliteSubscribeRequestV2, -): Promise> -⋮---- -getEarnEliteSubscribeResult( - params: GetEarnEliteSubscribeResultRequestV2, -): Promise> +/** Your API key */ ⋮---- -getEarnEliteRedeemInfo( - params: GetEarnEliteRedeemInfoRequestV2, -): Promise> +/** Your API secret */ ⋮---- -redeemEarnElite( - params: RedeemEarnEliteRequestV2, -): Promise> +/** The passphrase you set when creating the API Key (NOT your account password) */ ⋮---- /** + * Set to `true` to connect to Bitget's demo trading WebSockets: * - * - * Earn | Shark Fin - * - * + * - V2: https://www.bitget.com/api-doc/common/demotrading/websocket + * - V3/UTA: https://www.bitget.com/api-doc/uta/guide#demo-trading */ ⋮---- -getSharkfinProducts(params: { - coin: string; - limit?: string; - idLessThan?: string; -}): Promise> -⋮---- -getSharkfinAccount(): Promise> -⋮---- -getSharkfinAssets( - params: GetSharkfinAssetsRequestV2, -): Promise> +/** Define a recv window when preparing a private websocket signature. This is in milliseconds, so 5000 == 5 seconds */ ⋮---- -getSharkfinRecords( - params: GetSharkfinRecordsRequestV2, -): Promise> +// Disable ping/pong ws heartbeat mechanism (not recommended) ⋮---- -getSharkfinSubscription(params: { - productId: string; -}): Promise> +/** How often to check if the connection is alive */ ⋮---- -subscribeSharkfin(params: { productId: string; amount: string }): Promise< - APIResponse<{ - orderId: string; - status: string; - }> - > { - return this.postPrivate('/api/v2/earn/sharkfin/subscribe', params); +/** How long to wait for a pong (heartbeat reply) before assuming the connection is dead */ ⋮---- -getSharkfinSubscriptionResult(params: { orderId: string }): Promise< - APIResponse<{ - result: 'success' | 'fail'; - msg: string; - }> - > { - return this.getPrivate('/api/v2/earn/sharkfin/subscribe-result', params); +/** 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 * - * - * Earn | Loan - * - * + * Look in the examples folder for a demonstration on using node's createHmac instead. */ ⋮---- -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> +export interface WebsocketClientOptions extends WSClientConfigurableOptions { + pingInterval: number; + pongTimeout: number; + reconnectTimeout: number; + recvWindow: number; + authPrivateConnectionsOnConnect: boolean; + authPrivateRequests: boolean; +} + +================ +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, + GetSubAffiliateInfoRequestV2, + 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, + SubAffiliateInfoV2, +} 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'; ⋮---- -repayLoan( - params: RepayLoanRequestV2, -): Promise> +/** + * REST API client for all V2 endpoints + */ +export class RestClientV2 extends BaseRestClient ⋮---- -getRepayHistory( - params: GetLoanRepayHistoryRequestV2, -): Promise> +getClientType() ⋮---- -updateLoanPledgeRate(params: ModifyLoanPledgeRateRequestV2): Promise< - APIResponse<{ - loanCoin: string; - pledgeCoin: string; - afterPledgeRate: string; - }> - > { - return this.postPrivate('/api/v2/earn/loan/revise-pledge', params); +/** + * + * Custom SDK functions + * + */ ⋮---- -getLoanPledgeRateHistory( - params: GetLoanPledgeRateHistoryRequestV2, -): Promise> +/** + * This method is used to get the latency and time sync between the client and the server. + * This is not official API endpoint and is only used for internal testing purposes. + * Use this method to check the latency and time sync between the client and the server. + * Final values might vary slightly, but it should be within few ms difference. + * If you have any suggestions or improvements to this measurement, please create an issue or pull request on GitHub. + */ +async fetchLatencySummary(): Promise ⋮---- -getLoanHistory( - params: GetLoanHistoryRequestV2, -): Promise> +// Adjust server time by adding estimated one-way latency ⋮---- -getLoanDebts(): Promise> +// Calculate time difference between adjusted server time and local time ⋮---- -getLoanLiquidationRecords( - params: GetLiquidationRecordsRequestV2, -): Promise> +async fetchServerTime(): Promise ⋮---- /** * - * * Inst Loan | Product Info + * Bitget misc functions * */ ⋮---- -getLoanProductInfo( - params: GetInstLoanProductInfoRequestV2, -): Promise> +/** + * + * + * Common + * + * + */ ⋮---- -getLoanSymbols( - params: GetInstLoanSymbolsRequestV2, -): Promise> +/** + * + * * Common | Notice + * + */ ⋮---- -getLoanMarginCoinInfo(params: GetInstLoanMarginCoinInfoRequestV2): Promise< - APIResponse<{ - productId: string; - coinInfo: InstLoanCoinInfoV2[]; - }> - > { - return this.getPrivate( - '/api/v2/spot/ins-loan/ensure-coins-convert', - params, - ); +getAnnouncements( + params?: GetAnnouncementsRequestV2, +): Promise> ⋮---- /** * - * * Inst Loan | Account + * * Common | Public * */ ⋮---- -getLoanRiskUnit(): Promise< +getServerTime(): Promise< APIResponse<{ - riskUnitId: string[]; + serverTime: string; }> > { - return this.getPrivate('/api/v2/spot/ins-loan/risk-unit'); + return this.get('/api/v2/public/time'); ⋮---- -getLoanLTVConvert( - params?: GetInstLoanLTVConvertRequestV2, -): Promise> +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); ⋮---- /** * - * * Inst Loan | Orders + * * Common | Tax * */ ⋮---- -getLoanRepaidHistory( - params?: GetInstLoanRepaidHistoryRequestV2, -): Promise> -⋮---- -getLoanOrder( - params?: GetInstLoanOrderRequestV2, -): Promise> - -================ -File: src/types/request/v3/strategy.ts -================ -export type StrategyOrderTypeV3 = - | 'tpsl' - | 'trigger' - | 'oco' - | 'trailing_stop' - | 'iceberg' - | 'twap'; -⋮---- -export type StrategyOrderStatusV3 = - | 'pending' - | 'success' - | 'failed' - | 'cancelled' - | 'submitting'; +getSpotTransactionRecords( + params: GetSpotTransactionsRequestV2, +): Promise> ⋮---- -export type StrategyTriggerByV3 = 'market' | 'mark'; +getFuturesTransactionRecords( + params: GetFuturesTransactionsRequestV2, +): Promise> ⋮---- -export type StrategyTriggerOrderTypeV3 = 'limit' | 'market'; +getMarginTransactionRecords( + params: GetMarginTransactionsRequestV2, +): Promise> ⋮---- -export interface StrategyOcoParamsV3 { - ocoLimitPrice?: string; - ocoTriggerPrice?: string; - ocoOrderType?: StrategyTriggerOrderTypeV3; - ocoOrderPrice?: string; -} +getP2PTransactionRecords( + params: GetP2PTransactionsRequestV2, +): Promise> ⋮---- -export interface StrategyTrailingStopParamsV3 { - activationPrice?: string; - activationType?: string; - trailType?: string; - trailVariance?: string; - preOrderType?: StrategyTriggerOrderTypeV3; - preOrderPrice?: string; -} +/** + * + * * Common | P2P + * + */ ⋮---- -export interface StrategyIcebergParamsV3 { - splitMode?: string; - qtyPerOrder?: string; - splitOrderNumbers?: string; - orderPreference?: string; - executionStrategy?: string; - fixedDistanceType?: string; - distance?: string; - fixedPrice?: string; - priceLimit?: string; -} +getP2PMerchantList(params?: GetP2PMerchantsRequestV2): Promise< + APIResponse<{ + merchantList: P2PMerchantV2[]; + minMerchantId: string; + }> + > { + return this.getPrivate('/api/v2/p2p/merchantList', params); ⋮---- -export interface StrategyTwapParamsV3 { - duration?: string; - interval?: string; - orderType?: StrategyTriggerOrderTypeV3; - limitOffsetType?: string; - limitOffsetPercentage?: string; - limitOffsetSpread?: string; - twapTriggerPrice?: string; - twapTerminationPrice?: string; -} +getP2PMerchantInfo(): Promise> ⋮---- -export interface PlaceStrategyOrderRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol: string; - clientOid?: string; - type?: StrategyOrderTypeV3; - tpslMode?: 'full' | 'partial'; - /** Required when tpslMode=partial or for trigger orders */ - qty?: string; - side?: 'buy' | 'sell'; - posSide?: 'long' | 'short'; - reduceOnly?: 'yes' | 'no'; - /** - * Margin mode. Defaults to crossed. Required for isolated positions - * (isolated TP/SL fails with 31008 if omitted). - * Not in Bitget's official API docs yet. Confirmed by Bitget API devs - * in their OpenAPI Telegram: https://t.me/bitgetOpenapi/152235 - */ - marginMode?: 'isolated' | 'crossed'; - tpTriggerBy?: StrategyTriggerByV3; - slTriggerBy?: StrategyTriggerByV3; - takeProfit?: string; - stopLoss?: string; - tpOrderType?: StrategyTriggerOrderTypeV3; - slOrderType?: StrategyTriggerOrderTypeV3; - tpLimitPrice?: string; - slLimitPrice?: string; - triggerBy?: StrategyTriggerByV3; - triggerPrice?: string; - triggerOrderType?: StrategyTriggerOrderTypeV3; - triggerOrderPrice?: string; - ocoParams?: StrategyOcoParamsV3; - trailingStopParams?: StrategyTrailingStopParamsV3; - icebergParams?: StrategyIcebergParamsV3; - twapParams?: StrategyTwapParamsV3; -} +getP2PMerchantOrders(params: GetMerchantP2POrdersRequestV2): Promise< + APIResponse<{ + orderList: P2PMerchantOrderV2[]; + minOrderId: string; + }> + > { + return this.getPrivate('/api/v2/p2p/orderList', params); ⋮---- -/** Required when tpslMode=partial or for trigger orders */ +getP2PMerchantAdvertisementList( + params: GetMerchantAdvertisementsRequestV2, + ): Promise< + APIResponse<{ + advList: P2PMerchantAdvertismentV2[]; + minAdvId: string; + }> + > { + return this.getPrivate('/api/v2/p2p/advList', params); ⋮---- /** - * Margin mode. Defaults to crossed. Required for isolated positions - * (isolated TP/SL fails with 31008 if omitted). - * Not in Bitget's official API docs yet. Confirmed by Bitget API devs - * in their OpenAPI Telegram: https://t.me/bitgetOpenapi/152235 + * + * * Common | Trading insights + * */ ⋮---- -export interface ModifyStrategyOrderRequestV3 { - orderId?: string; - clientOid?: string; - qty: string; - tpTriggerBy?: StrategyTriggerByV3; - slTriggerBy?: StrategyTriggerByV3; - takeProfit?: string; - stopLoss?: string; - tpOrderType?: StrategyTriggerOrderTypeV3; - slOrderType?: StrategyTriggerOrderTypeV3; - tpLimitPrice?: string; - slLimitPrice?: string; - triggerBy?: StrategyTriggerByV3; - triggerPrice?: string; - triggerOrderType?: StrategyTriggerOrderTypeV3; - triggerOrderPrice?: string; -} -⋮---- -export interface CancelStrategyOrderRequestV3 { - orderId?: string; - clientOid?: string; -} -⋮---- -export interface GetUnfilledStrategyOrdersRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - type?: StrategyOrderTypeV3; -} +getSpotWhaleNetFlowData(params: { + symbol: string; +}): Promise> ⋮---- -export interface GetHistoryStrategyOrdersRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - type?: StrategyOrderTypeV3; - startTime?: string; - endTime?: string; - limit?: string; - /** Observed as a number though the docs say string. */ - cursor?: string | number; -} +getFuturesActiveTakerBuySellVolumeData(params: { + symbol: string; + period?: string; +}): Promise> ⋮---- -/** Observed as a number though the docs say string. */ +getFuturesActiveLongShortPositionData(params: { + symbol: string; + period?: string; +}): Promise> ⋮---- -export interface GetStrategySubOrdersRequestV3 { - orderId?: string; - clientOid?: string; - limit?: string; - cursor?: string; -} - -================ -File: src/types/response/v3/trade.ts -================ -export interface BatchModifyOrderResponseV3 { - orderId: string; - clientOid: string; -} +getFuturesLongShortRatio(params: { + symbol: string; + period?: string; + coin?: string; +}): Promise> ⋮---- -export interface CancelAllOrdersResponseV3 { - list: { - orderId: string; - clientOid: string; - code: string; - msg: string; - }[]; -} +getMarginLoanGrowthRate(params: { + symbol: string; + period?: string; + coin?: string; +}): Promise> ⋮---- -export interface CancelBatchOrdersResponseV3 { - orderId: string; - clientOid: string; - code?: string; - msg?: string; -} +getIsolatedMarginBorrowingRatio(params: { + symbol: string; + period?: string; +}): Promise> ⋮---- -export interface CloseAllPositionsResponseV3 { - list: { - orderId: string; - clientOid: string; - code: string; - msg: string; - }[]; -} +getFuturesActiveBuySellVolumeData(params: { + symbol: string; + period?: string; +}): Promise> ⋮---- -export interface CancelOrderResponseV3 { - orderId: string; - clientOid: string; -} +getSpotFundFlow(params: { + symbol: string; + period?: string; +}): Promise> ⋮---- -export interface GetMaxOpenAvailableResponseV3 { - available: string; - maxOpen: string; - buyOpenCost: string; - sellOpenCost: string; - maxBuyOpen: string; - maxSellOpen: string; - maxBuyAvailable?: string; - maxSellAvailable?: string; -} +getTradeDataSupportSymbols(): Promise< + APIResponse<{ + spotList: string[]; + futureList: string[]; + }> + > { + return this.get('/api/v2/spot/market/support-symbols'); ⋮---- -export interface FeeDetailV3 { - feeCoin: string; - fee: string; -} +getSpotFundNetFlowData(params: { symbol: string }): Promise< + APIResponse< + { + netFlow: string; + ts: string; + }[] + > + > { + return this.get('/api/v2/spot/market/fund-net-flow', params); ⋮---- -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; - /** - * rToken routing. internalization or lit_market. - * Also pushed on the WS order channel. - */ - venue?: 'internalization' | 'lit_market' | string; - /** rToken time in force. gtd = current session, gtc = 90 days. */ - rTokenTimeInForce?: 'gtd' | 'gtc' | string; - orderStatus: string; - posSide: string; - holdMode: string; - delegateType?: string; - reduceOnly: string; - feeDetail: FeeDetailV3[]; - cancelReason: string; - execType: string; - stpMode?: string; - createdTime: string; - updatedTime: string; -} +getFuturesActiveLongShortAccountData(params: { + symbol: string; + period?: string; +}): Promise> ⋮---- /** - * rToken routing. internalization or lit_market. - * Also pushed on the WS order channel. + * + * * Common | Virtual Subaccount + * */ ⋮---- -/** rToken time in force. gtd = current session, gtc = 90 days. */ +createVirtualSubaccount(params: { + subAccountList: string[]; +}): Promise> ⋮---- -export type FillCategoryV3 = - | 'spot' - | 'margin' - | 'usdt-futures' - | 'coin-futures' - | 'usdc-futures' - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; +modifyVirtualSubaccount(params: ModifyVirtualSubRequestV2): Promise< + APIResponse<{ + result: string; + }> + > { + return this.postPrivate('/api/v2/user/modify-virtual-subaccount', params); ⋮---- -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; -} +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); ⋮---- -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; -} +createVirtualSubaccountAPIKey( + params: CreateVirtualSubApiKeyRequestV2, +): Promise> ⋮---- -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; -} +modifyVirtualSubaccountAPIKey( + params: ModifyVirtualSubApiKeyRequestV2, +): Promise> ⋮---- -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; -} +getVirtualSubaccountAPIKeys(params: { + subAccountUid: string; +}): Promise> ⋮---- -/** Cash dividend, USDT */ +/** + * 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> ⋮---- -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; -} +/** + * + * * Common | Assets + * + */ +getFundingAssets(params?: { + coin?: string; +}): Promise> ⋮---- -/** Cash dividend, USDT */ +getBotAccount(params?: { + accountType?: string; +}): Promise> ⋮---- -export interface LoanDataDebtCoinV3 { - coin: string; - debt: string; - interestFreeAmount: string; - interestRateNextHour: string; -} +/** Get assets overview */ +getBalances(): Promise< + APIResponse< + { + accountType: string; + usdtBalance: string; + }[] + > + > { + return this.getPrivate('/api/v2/account/all-account-balance'); ⋮---- -export interface LoanDataV3 { - currentLoans: string; - interestPaymentTime: string; - debtCoinList: LoanDataDebtCoinV3[]; -} +/** + * + * * Common | Convert + * + */ ⋮---- -export interface ModifyOrderResponseV3 { - orderId: string; - clientOid: string; -} +getConvertCoins(): Promise> ⋮---- -export interface PlaceBatchOrdersResponseV3 { - orderId: string; - clientOid: string; - code?: string; - msg?: string; -} +getConvertQuotedPrice( + params: ConvertQuoteRequestV2, +): Promise> ⋮---- -export interface PlaceOrderResponseV3 { - orderId: string; - clientOid: string; -} +convert( + params: ConvertRequestV2, +): Promise> ⋮---- -export interface PositionAdlRankV3 { - symbol: string; - marginCoin: string; - adlRank: string; - holdSide: 'long' | 'short'; -} - -================ -File: src/types/websockets/ws-api-request.ts -================ -import type { FuturesMarginModeV3 } from '../request/v3/trade.js'; +getConvertHistory(params: GetConvertHistoryRequestV2): Promise< + APIResponse<{ + dataList: ConvertRecordV2[]; + endId: string; + }> + > { + return this.getPrivate('/api/v2/convert/convert-record', params); ⋮---- -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'; - /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ - pxAmendType?: 'yes' | 'no'; - /** - * rToken routing. internalization or lit_market (default). - * Ignored for non-rToken symbols. +/** + * + * * Common | BGB Convert + * */ - venue?: 'internalization' | 'lit_market'; - /** rToken time in force. gtd (default) or gtc (90 days). */ - rTokenTimeInForce?: 'gtd' | 'gtc'; - /** - * Broker rebate code. Lifted onto the WS request envelope. - * It is not sent inside args. Omit it to use the SDK broker code. - * Place-order docs: top-level apiCode. Batch-place uses the same field. - * Staff-confirmed: t.me/bitgetOpenapi/153820. +⋮---- +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 + * + * */ - apiCode?: 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 */ +/** + * + * * Spot | Market + * + */ ⋮---- -/** Order TTL in ms [10, 60000]. Only effective when requestTime is also set on the envelope */ +getSpotCoinInfo(params?: { + coin?: string; +}): Promise> ⋮---- -/** Spot only. Default: no */ +getSpotSymbolInfo(params?: { + symbol?: string; +}): Promise> ⋮---- -/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ +getSpotVIPFeeRate(): Promise> ⋮---- -/** - * rToken routing. internalization or lit_market (default). - * Ignored for non-rToken symbols. - */ +getSpotTicker(params?: { + symbol?: string; +}): Promise> ⋮---- -/** rToken time in force. gtd (default) or gtc (90 days). */ +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> ⋮---- /** - * Broker rebate code. Lifted onto the WS request envelope. - * It is not sent inside args. Omit it to use the SDK broker code. - * Place-order docs: top-level apiCode. Batch-place uses the same field. - * Staff-confirmed: t.me/bitgetOpenapi/153820. + * + * * Spot | Trade + * */ - -================ -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; -} +spotSubmitOrder(params: SpotOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v2/spot/trade/place-order', params); ⋮---- -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; -} +spotCancelandSubmitOrder( + params: SpotCancelandSubmitOrderRequestV2, +): Promise> ⋮---- -export interface GetContractsOiRequestV3 { - symbol?: string; - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; -} +spotBatchCancelandSubmitOrder(params: { + orderList: SpotCancelandSubmitOrderRequestV2[]; +}): Promise> ⋮---- -export interface GetCurrentFundingRateRequestV3 { - category?: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; -} +spotCancelOrder(params: SpotCancelOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v2/spot/trade/cancel-order', params); ⋮---- -export interface GetLiquidationsRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - limit?: string; - cursor?: string; -} +spotBatchSubmitOrders( + params: SpotBatchOrderRequestV2, +): Promise> ⋮---- -export interface GetHistoryFundingRateRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol: string; - cursor?: string; - limit?: string; -} +spotBatchCancelOrders( + params: SpotBatchCancelOrderRequestV2, +): Promise> ⋮---- -export interface GetMarginLoansRequestV3 { - coin: string; - /** User level. Default: vip0 */ - level?: - | 'vip0' - | 'vip1' - | 'vip2' - | 'vip3' - | 'vip4' - | 'vip5' - | 'vip6' - | 'vip7' - | 'pro1' - | 'pro2' - | 'pro3' - | 'pro4' - | 'pro5' - | 'pro6'; -} +spotCancelSymbolOrder(params: { symbol: string }): Promise< + APIResponse<{ + symbol: string; + }> + > { + return this.postPrivate('/api/v2/spot/trade/cancel-symbol-order', params); ⋮---- -/** User level. Default: vip0 */ +getSpotOrder( + params?: GetSpotOrderInfoRequestV2, +): Promise> ⋮---- -export interface GetSplitRecordsRequestV3 { - symbol?: string; -} +getSpotOpenOrders( + params?: GetSpotOpenOrdersRequestV2, +): Promise> ⋮---- -export interface GetOpenInterestRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; -} +getSpotHistoricOrders( + params?: GetSpotHistoryOrdersRequestV2, +): Promise> ⋮---- -export type OpenInterestHistoryPeriodV3 = - | '5m' - | '15m' - | '30m' - | '1h' - | '2h' - | '4h' - | '6h' - | '12h' - | '1d'; +getSpotFills( + params: GetSpotFillsRequestV2, +): Promise> ⋮---- -export interface GetOpenInterestHistoryRequestV3 { - symbol: string; - /** Default 5m */ - period: OpenInterestHistoryPeriodV3; -} +/** + * + * * Spot | Trigger Orders + * + */ ⋮---- -/** Default 5m */ +spotSubmitPlanOrder(params: SpotPlanOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v2/spot/trade/place-plan-order', params); ⋮---- -export type InterestRateLevelV3 = - | 'vip0' - | 'vip1' - | 'vip2' - | 'vip3' - | 'vip4' - | 'vip5' - | 'vip6' - | 'vip7' - | 'pro1' - | 'pro2' - | 'pro3' - | 'pro4' - | 'pro5' - | 'pro6'; +spotModifyPlanOrder(params: SpotModifyPlanOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v2/spot/trade/modify-plan-order', params); ⋮---- -export interface GetMarginLoansAllRequestV3 { - /** Omit to return every supported coin */ - coin?: string; - /** User level. Default: vip0 */ - level?: InterestRateLevelV3; -} +spotCancelPlanOrder(params: { + clientOid?: string; + orderId?: string; + }): Promise< + APIResponse<{ + result: string; + }> + > { + return this.postPrivate('/api/v2/spot/trade/cancel-plan-order', params); ⋮---- -/** Omit to return every supported coin */ +getSpotCurrentPlanOrders(params: GetSpotCurrentPlanOrdersRequestV2): Promise< + APIResponse<{ + nextFlag: boolean; + idLessThan: string; + orderList: SpotCurrentPlanOrderV2[]; + }> + > { + return this.getPrivate('/api/v2/spot/trade/current-plan-order', params); ⋮---- -/** User level. Default: vip0 */ +getSpotPlanSubOrder(params: { + planOrderId: string; +}): Promise> ⋮---- -export interface GetInterestRateHistoryRequestV3 { - coin: string; - /** - * VIP tier. Query name is level, not vipLevel (vipLevel is ignored). - * Omitting it returns the vip0 series. - */ - level?: InterestRateLevelV3; - limit?: string; - /** Pass the cursor from the previous response. */ - cursor?: string; -} +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> ⋮---- /** - * VIP tier. Query name is level, not vipLevel (vipLevel is ignored). - * Omitting it returns the vip0 series. + * + * * Spot | Account + * */ ⋮---- -/** Pass the cursor from the previous response. */ +getSpotAccount(): Promise> ⋮---- -export type AnnouncementTypeV3 = - | 'latest_news' - | 'coin_listings' - | 'product_updates' - | 'security' - | 'api_trading' - | 'maintenance_system_updates' - | 'symbol_delisting'; +getSpotAccountAssets(params?: { + coin?: string; + assetType?: string; +}): Promise> ⋮---- -export interface GetAnnouncementsRequestV3 { - /** zh_CN or en_US. Unsupported languages fall back to English. */ - language: string; - annType?: AnnouncementTypeV3; - startTime?: string; - endTime?: string; - /** Last annId from the previous page. Omit on the first call. */ - cursor?: string; - /** Default 10. Maximum 10. */ - limit?: string; -} +getSpotSubAccountAssets(): Promise> ⋮---- -/** zh_CN or en_US. Unsupported languages fall back to English. */ +spotModifyDepositAccount(params: { + accountType: string; + coin: string; +}): Promise> ⋮---- -/** Last annId from the previous page. Omit on the first call. */ +getSpotAccountBills( + params?: GetSpotAccountBillsRequestV2, +): Promise> ⋮---- -/** Default 10. Maximum 10. */ +spotTransfer(params: SpotTransferRequestV2): Promise< + APIResponse<{ + transferId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v2/spot/wallet/transfer', params); ⋮---- -export interface GetCoinsRequestV3 { - /** Omit to return every coin. */ - coin?: string; -} +getSpotTransferableCoins(params: { + fromType: SpotAccountTypeV2; + toType: SpotAccountTypeV2; +}): Promise> ⋮---- -/** Omit to return every coin. */ +spotSubTransfer(params: SpotSubAccountTransferRequestV2): Promise< + APIResponse<{ + transferId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v2/spot/wallet/subaccount-transfer', params); ⋮---- -export interface GetPositionTierRequestV3 { - category: 'MARGIN' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - coin?: string; -} +spotWithdraw(params: SpotWithdrawalRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v2/spot/wallet/withdrawal', params); ⋮---- -export interface GetRiskReserveRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol: string; - marginCoin?: string; -} +getSpotMainSubTransferRecord( + params: SpotMainSubTransferRecordRequestV2, +): Promise> ⋮---- -export interface GetRiskReserveAllRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; -} +getSpotTransferHistory( + params: GetSpotTransferRecordRequestV2, +): Promise> ⋮---- -export interface GetInstrumentsRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol?: string; -} +spotSwitchBGBDeduct(params: { + deduct: boolean; +}): Promise> ⋮---- -export interface GetMarketFeeGroupRequestV3 { - category: 'SPOT' | 'FUTURES'; - group?: 'DEFAULT' | 'GROUP_A' | 'GROUP_B' | 'GROUP_C'; -} +getSpotDepositAddress(params: { + coin: string; + chain?: string; + size: string; +}): Promise> ⋮---- -export interface GetMarketScoreWeightsRequestV3 { - category?: 'SPOT' | 'FUTURES'; -} +getSpotSubDepositAddress(params: { + subUid: string; + coin: string; + chain?: string; + size: string; +}): Promise> ⋮---- -export interface GetOrderBookRequestV3 { - category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol: string; - limit?: string; -} +getSpotBGBDeductInfo(): Promise< + APIResponse<{ + deduct: string; + }> + > { + return this.getPrivate('/api/v2/spot/account/deduct-info'); ⋮---- -export interface GetTickersRequestV3 { - category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; -} +spotCancelWithdrawal(params: { + orderId: string; +}): Promise> ⋮---- -export interface GetIndexComponentsRequestV3 { - symbol: string; -} +getSubAccountDepositRecords( + params: GetSpotSubAccountDepositRecordRequestV2, +): Promise> ⋮---- -export interface GetRpiOrderBookRequestV3 { - category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol: string; - limit?: string; -} +getSpotWithdrawalHistory( + params: GetSpotWithdrawalRecordRequestV2, +): Promise> ⋮---- -export interface GetCashDividendRecordsRequestV3 { - symbol: string; - type: 'pending' | 'paid'; - cursor?: string; - limit?: string; -} +getSpotDepositHistory( + params: GetSpotDepositRecordRequestV2, +): Promise> ⋮---- -export interface GetSpotWhaleFlowRequestV3 { - symbol: string; -} +/** + * 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> ⋮---- -export interface GetSpotFundFlowRequestV3 { - symbol: string; - period?: string; -} +/** + * 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 + * + * + */ ⋮---- -export interface GetSpotNetFlowRequestV3 { - symbol: string; -} +/** + * + * * Futures | Market + * + */ ⋮---- -export interface GetMarginLongShortRequestV3 { - symbol: string; - period?: '24h' | '30d'; - coin?: string; -} +getFuturesVIPFeeRate(): Promise> ⋮---- -export interface GetMarginLoanGrowthRequestV3 { - symbol: string; - period?: string; - coin?: string; -} +getFuturesInterestRateHistory(params: { coin: string }): Promise< + APIResponse<{ + coin: string; + historyInterestRateList: FuturesHistoryInterestRateV2[]; + }> + > { + return this.get('/api/v2/mix/market/union-interest-rate-history', params); ⋮---- -export interface GetMarginIsolatedBorrowRequestV3 { - symbol: string; - period?: string; -} +getFuturesInterestExchangeRate(): Promise< + APIResponse< + { + coin: string; + exchangeRateList: FuturesInterestExchangeRateV2[]; + }[] + > + > { + return this.get('/api/v2/mix/market/exchange-rate'); ⋮---- -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; - /** Custom request ID. Numbers within 18 digits. */ - requestId?: number; - autoCancel?: 'yes' | 'no'; - /** Required since 30 Sep 2026 */ - symbol: string; - /** Required since 30 Sep 2026 */ - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ - pxAmendType?: 'yes' | 'no'; -} +getFuturesDiscountRate(): Promise> ⋮---- -/** Custom request ID. Numbers within 18 digits. */ +getFuturesMergeDepth( + params: FuturesMergeDepthRequestV2, +): Promise> ⋮---- -/** Required since 30 Sep 2026 */ +getFuturesTicker(params: { + symbol: string; + productType: FuturesProductTypeV2; +}): Promise> ⋮---- -/** Required since 30 Sep 2026 */ +getFuturesAllTickers(params: { + productType: FuturesProductTypeV2; +}): Promise> ⋮---- -/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ +getFuturesRecentTrades( + params: FuturesRecentTradesRequestV2, +): Promise> ⋮---- -export interface CancelAllOrdersRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol?: string; -} +getFuturesHistoricTrades( + params: FuturesHistoricTradesRequestV2, +): Promise> ⋮---- -export interface CancelBatchOrdersRequestV3 { - orderId?: string; - clientOid?: string; - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol: string; -} +getFuturesCandles( + params: FuturesCandlesRequestV2, +): Promise> ⋮---- -export interface CloseAllPositionsRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - posSide?: 'long' | 'short'; -} +getFuturesHistoricCandles( + params: FuturesCandlesRequestV2, +): Promise> ⋮---- -export interface CancelOrderRequestV3 { - orderId?: string; - clientOid?: string; - category?: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; -} +getFuturesHistoricIndexPriceCandles( + params: FuturesCandlesRequestV2, +): Promise> ⋮---- -export type FuturesMarginModeV3 = 'crossed' | 'isolated'; +getFuturesHistoricMarkPriceCandles( + params: FuturesCandlesRequestV2, +): Promise> ⋮---- -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'; - /** - * crossed (default) or isolated. - * Under isolated margin, available excludes futures trial funds. - */ - marginMode?: FuturesMarginModeV3; -} +getFuturesOpenInterest(params: { + symbol: string; + productType: FuturesProductTypeV2; + }): Promise< + APIResponse<{ + openInterestList: FuturesOpenInterestV2[]; + ts: string; + }> + > { + return this.get('/api/v2/mix/market/open-interest', params); ⋮---- -/** Spot only. Default: no */ +getFuturesNextFundingTime(params: { + symbol: string; + productType: FuturesProductTypeV2; +}): Promise> ⋮---- -/** - * crossed (default) or isolated. - * Under isolated margin, available excludes futures trial funds. - */ +getFuturesSymbolPrice(params: { + symbol: string; + productType: FuturesProductTypeV2; +}): Promise> ⋮---- -export interface GetOrderInfoRequestV3 { - orderId?: string; - clientOid?: string; -} +getFuturesHistoricFundingRates(params: { + symbol: string; + productType: FuturesProductTypeV2; + pageSize?: string; + pageNo?: string; +}): Promise> ⋮---- -export interface GetFillsRequestV3 { - category?: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - orderId?: string; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; -} +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); ⋮---- -export interface GetUnfilledOrdersRequestV3 { - category?: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol?: string; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; -} +fundingRate: string; // '0.0001'; +fundingRateInterval: string; // hours, example: '1' | '2' | '4' | '8'; +nextUpdate: string; // timestamp in milliseconds ⋮---- -export interface GetHistoryOrdersRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol?: string; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; -} +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); ⋮---- -export interface GetPositionHistoryRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; -} +/** + * + * * Futures | Account + * + */ ⋮---- -export interface GetCurrentPositionRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - posSide?: 'long' | 'short'; -} +getFuturesAccountAsset( + params: FuturesSingleAccountRequestV2, +): Promise> ⋮---- -export interface ModifyOrderRequestV3 { - orderId?: string; - clientOid?: string; - qty?: string; - price?: string; - /** Custom request ID. Numbers within 18 digits. */ - requestId?: number; - autoCancel?: 'yes' | 'no'; - /** Required since 30 Sep 2026 */ - symbol: string; - /** Required since 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; - /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ - pxAmendType?: 'yes' | 'no'; -} +getFuturesAccountAssets(params: { + productType: FuturesProductTypeV2; +}): Promise> ⋮---- -/** Custom request ID. Numbers within 18 digits. */ +getFuturesSubAccountAssets(params: { + productType: FuturesProductTypeV2; + }): Promise< + APIResponse< + { + userId: number; + assetList: FuturesSubAccountAssetV2[]; + }[] + > + > { + return this.getPrivate('/api/v2/mix/account/sub-account-assets', params); ⋮---- -/** Required since 30 Sep 2026 */ +getFuturesInterestHistory( + params: FuturesInterestHistoryRequestV2, +): Promise> ⋮---- -/** Required since 30 Sep 2026 */ +getFuturesOpenCount(params: FuturesOpenCountRequestV2): Promise< + APIResponse<{ + size: string; + }> + > { + return this.getPrivate('/api/v2/mix/account/open-count', params); ⋮---- -/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ +setFuturesPositionAutoMargin( + params: FuturesSetAutoMarginRequestV2, +): Promise> ⋮---- -export interface PlaceRealityOrderRequestV3 { - category?: 'SPOT' | 'MARGIN'; - symbol: string; - side: 'buy' | 'sell'; - orderType: 'limit' | 'market'; - qty: string; - price?: string; - clientOid?: string; - /** - * rToken routing. internalization = on-exchange pool only. - * lit_market (default) = internal first, then the public market. - * The 13 Oct changelog applies this to place-reality-order as well. - * The place-reality-order parameter table does not list it yet. - */ - venue?: 'internalization' | 'lit_market'; - /** - * rToken time in force. gtd (default) = current session. - * gtc = 90 days. Same changelog note as venue. - */ - rTokenTimeInForce?: 'gtd' | 'gtc'; -} +setFuturesLeverage( + params: FuturesSetLeverageRequestV2, +): Promise> ⋮---- -/** - * rToken routing. internalization = on-exchange pool only. - * lit_market (default) = internal first, then the public market. - * The 13 Oct changelog applies this to place-reality-order as well. - * The place-reality-order parameter table does not list it yet. - */ +setFuturesPositionMargin( + params: FuturesSetPositionMarginRequestV2, +): Promise> ⋮---- -/** - * rToken time in force. gtd (default) = current session. - * gtc = 90 days. Same changelog note as venue. - */ +setFuturesAssetMode(params: { + productType: 'USDT-FUTURES' | 'SUSDT-FUTURES'; + assetMode: 'single' | 'union'; +}): Promise> ⋮---- -export interface CancelRealityOrderRequestV3 { - category?: 'SPOT' | 'MARGIN'; - symbol: string; - orderId?: string; - clientOid?: string; -} +setFuturesMarginMode( + params: FuturesSetMarginModeRequestV2, +): Promise> ⋮---- -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'; - /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ - pxAmendType?: 'yes' | 'no'; - /** - * Unix ms. Used with receiveWindow. - * If omitted, receiveWindow has no effect. - * An order that reaches the matching engine after requestTime + receiveWindow is canceled. - */ - requestTime?: string; - /** Validity window in ms. Range [10, 60000]. Requires requestTime. */ - receiveWindow?: string; -} +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); ⋮---- -/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ +getFuturesAccountBills(params: FuturesAccountBillRequestV2): Promise< + APIResponse<{ + bills: FuturesAccountBillV2[]; + endId: string; + }> + > { + return this.getPrivate('/api/v2/mix/account/bill', params); ⋮---- /** - * Unix ms. Used with receiveWindow. - * If omitted, receiveWindow has no effect. - * An order that reaches the matching engine after requestTime + receiveWindow is canceled. + * Get Union Transfer Limits + * + * - Rate limit: 1 time/1s (uid) + * - Get union margin currency transfer limits */ +getUnionTransferLimits( + params: GetUnionTransferLimitsRequestV2, +): Promise> ⋮---- -/** Validity window in ms. Range [10, 60000]. Requires requestTime. */ -⋮---- -export interface PlaceOrderRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol: string; - /** - * Futures qty must be a multiple of quantityMultiplier - * and have at most quantityPrecision decimal places. - * Both come from /api/v3/market/instruments. Futures only. +/** + * 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) */ - qty: string; - price?: string; - side: 'buy' | 'sell'; - /** - * Market orders always run as IOC. - * Staff-confirmed: t.me/bitgetOpenapi/153169. - * timeInForce does not change that. +getUnionConfig(): Promise> +⋮---- +/** + * Get Switch Union USDT + * + * - Rate limit: 1 time/1s (uid) + * - Get USDT quota for switching from union margin to single margin */ - 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'; - /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ - pxAmendType?: 'yes' | 'no'; - /** Limit orders only. queue1, queue5, counterparty1, or counterparty5 */ - bboLevel?: 'queue1' | 'queue5' | 'counterparty1' | 'counterparty5'; - /** Market orders only. Decimal, default 0.02, range 0.01-0.05 */ - slippageTolerance?: string; - /** - * rToken routing. internalization = on-exchange pool only. - * lit_market (default) = internal first, then the public market. - * Ignored for non-rToken symbols. timeInForce is also ignored for rToken. +getSwitchUnionUsdt(): Promise> +⋮---- +/** + * Union Convert + * + * - Rate limit: 1 time/1s (uid) + * - Union margin exchange */ - venue?: 'internalization' | 'lit_market'; - /** - * rToken time in force. gtd (default) lasts the current session. - * gtc lasts 90 days. Ignored for non-rToken symbols. +unionConvert( + params: UnionConvertRequestV2, +): Promise> +⋮---- +/** + * Get Max Openable Quantity + * + * - Rate limit: 20 req/sec/UID + * - Get Max Openable Quantity */ - rTokenTimeInForce?: 'gtd' | 'gtc'; - /** - * Unix ms. Used with receiveWindow. - * If omitted, receiveWindow has no effect. - * An order that reaches the matching engine after requestTime + receiveWindow is canceled. +getFuturesMaxOpenableQuantity( + params: FuturesMaxOpenRequestV2, +): Promise> +⋮---- +/** + * Get Liquidation Price + * + * - Rate limit: 20 req/sec/UID + * - Get Liquidation Price */ - requestTime?: string; - /** Validity window in ms. Range [10, 60000]. Requires requestTime. */ - receiveWindow?: string; -} +getFuturesLiquidationPrice( + params: FuturesLiquidationPriceRequestV2, +): Promise> ⋮---- /** - * Futures qty must be a multiple of quantityMultiplier - * and have at most quantityPrecision decimal places. - * Both come from /api/v3/market/instruments. Futures only. + * Get Isolated Symbols + * + * - Rate limits: 10 time/1s (uid) + * - Retrieve trading pairs with isolated margin mode under the account. */ +getFuturesIsolatedSymbols( + params: FuturesIsolatedSymbolsRequestV2, +): Promise> ⋮---- /** - * Market orders always run as IOC. - * Staff-confirmed: t.me/bitgetOpenapi/153169. - * timeInForce does not change that. + * + * * Futures | Position + * */ ⋮---- -/** Futures only. Defaults to crossed */ +getFuturesPositionTier(params: { + productType: FuturesProductTypeV2; + symbol: string; +}): Promise> ⋮---- -/** Spot only. Default: no */ +getFuturesPosition(params: { + productType: FuturesProductTypeV2; + symbol: string; + marginCoin: string; +}): Promise> ⋮---- -/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ +getFuturesPositions(params: { + productType: FuturesProductTypeV2; + marginCoin?: string; +}): Promise> ⋮---- -/** Limit orders only. queue1, queue5, counterparty1, or counterparty5 */ +getFuturesHistoricPositions( + params?: FuturesHistoricalPositionsRequestV2, + ): Promise< + APIResponse<{ + list: FuturesHistoryPositionV2[]; + endId: string; + }> + > { + return this.getPrivate('/api/v2/mix/position/history-position', params); ⋮---- -/** Market orders only. Decimal, default 0.02, range 0.01-0.05 */ +getFuturesPositionAdlRank( + params: FuturesPositionAdlRankRequestV2, +): Promise> ⋮---- /** - * rToken routing. internalization = on-exchange pool only. - * lit_market (default) = internal first, then the public market. - * Ignored for non-rToken symbols. timeInForce is also ignored for rToken. + * + * * 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<{ + /** + * Undocumented but staff-confirmed: null and [] can both represent an empty page. + * @see https://t.me/bitgetOpenapi/153977 + */ + entrustedList: FuturesOpenOrderV2[] | null; + endId: string; + }> + > { + return this.getPrivate('/api/v2/mix/order/orders-pending', params); +⋮---- /** - * rToken time in force. gtd (default) lasts the current session. - * gtc lasts 90 days. Ignored for non-rToken symbols. - */ + * Undocumented but staff-confirmed: null and [] can both represent an empty page. + * @see https://t.me/bitgetOpenapi/153977 + */ +⋮---- +getFuturesHistoricOrders(params: FuturesGetHistoryOrdersRequestV2): Promise< + APIResponse<{ + entrustedList: FuturesHistoryOrderV2[]; + endId: string; + }> + > { + return this.getPrivate('/api/v2/mix/order/orders-history', params); +⋮---- +futuresCancelAllOrders( + params: FuturesCancelAllOrdersRequestV2, +): Promise> ⋮---- /** - * Unix ms. Used with receiveWindow. - * If omitted, receiveWindow has no effect. - * An order that reaches the matching engine after requestTime + receiveWindow is canceled. + * + * * Futures | Trigger Orders + * */ ⋮---- -/** Validity window in ms. Range [10, 60000]. Requires requestTime. */ +getFuturesTriggerSubOrder(params: { + planType: 'normal_plan' | 'track_plan'; + planOrderId: string; + productType: FuturesProductTypeV2; +}): Promise> ⋮---- -export interface CountdownCancelAllRequestV3 { - countdown: string; // seconds until auto-cancel (5-60, or 0 to disable) -} +futuresSubmitTPSLOrder(params: FuturesTPSLOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v2/mix/order/place-tpsl-order', params); ⋮---- -countdown: string; // seconds until auto-cancel (5-60, or 0 to disable) - -================ -File: src/types/request/v3/account.ts -================ -// Account Management Request Types +futuresSubmitPositionTPSL(params: FuturesPositionTPSLOrderRequestV2): Promise< + APIResponse< + { + orderId: string; + stopSurplusClientOid: string; + stopLossClientOid: string; + }[] + > + > { + return this.postPrivate('/api/v2/mix/order/place-pos-tpsl', params); ⋮---- -export type AccountAdjustModeV3 = 'basic' | 'advanced' | 'delta' | 'isolated'; +futuresSubmitPlanOrder(params: FuturesPlanOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v2/mix/order/place-plan-order', params); ⋮---- -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; -} +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<{ + /** + * Undocumented but staff-confirmed: null and [] can both represent an empty page. + * @see https://t.me/bitgetOpenapi/153977 + */ + entrustedList: FuturesPendingPlanOrderV2[] | null; + endId: string; + }> + > { + return this.getPrivate('/api/v2/mix/order/orders-plan-pending', params); +⋮---- +/** + * Undocumented but staff-confirmed: null and [] can both represent an empty page. + * @see https://t.me/bitgetOpenapi/153977 + */ ⋮---- -/** Enable/disable delta-neutral mode when mode is advanced. `delta` mode is deprecated. */ +futuresCancelPlanOrder( + params: FuturesCancelPlanOrderRequestV2, +): Promise> ⋮---- -/** Sub-account UID when the master account switches mode for a sub-account */ +getFuturesHistoricPlanOrders( + params: FuturesGetHistoryPlanOrdersRequestV2, + ): Promise< + APIResponse<{ + entrustedList: FuturesHistoryPlanOrderV2[]; + endId: string; + }> + > { + return this.getPrivate('/api/v2/mix/order/orders-plan-history', params); ⋮---- -export interface SetLeverageRequestV3 { - category: 'MARGIN' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - /** - * Error 25159 means a low-liquidity period capped leverage at 5x. - * There is no pre-check API for that cap. +/** + * + * + * Broker + * + * */ - 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; -} ⋮---- /** - * Error 25159 means a low-liquidity period capped leverage at 5x. - * There is no pre-check API for that cap. + * + * * Broker | Subaccount + * */ ⋮---- -/** Futures only. Defaults to crossed */ +modifySubaccountEmail(params: { + subUid: string; + subaccountEmail: string; +}): Promise> ⋮---- -/** Isolated two-way mode: long leverage. Takes priority over leverage when both set */ +getBrokerInfo(): Promise< + APIResponse<{ + subAccountSize: string; + maxSubAccountSize: string; + uTime: string; + }> + > { + return this.getPrivate('/api/v2/broker/account/info'); ⋮---- -/** Isolated two-way mode: short leverage. Takes priority over leverage when both set */ +createSubaccount(params: { + subaccountName: string; + label: string; +}): Promise> ⋮---- -export interface GetAllFeeRatesRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol?: string; -} +getSubaccounts(params?: GetSubAccountsRequestV2): Promise< + APIResponse<{ + hasNextPage: boolean; + idLessThan: number; + subList: BrokerSubaccountV2[]; + }> + > { + return this.getPrivate('/api/v2/broker/account/subaccount-list', params); ⋮---- -export interface GetConvertRecordsRequestV3 { - fromCoin?: string; - toCoin?: string; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; -} +modifySubaccount( + params: ModifySubRequestV2, +): Promise> ⋮---- -/** - * UTA account financial-record type. - * https://www.bitget.com/docs/uta/enum - * MARIN_BUY_DEAL and MARIN_SELL_DEAL keep Bitget's spelling. - */ -export type FinancialRecordTypeV3 = - | 'TRANSFER_IN' - | 'TRANSFER_OUT' - | 'CONVERSION_UPON_DELISTING' - | 'ORDER_DEALT_FROZEN_OUT' - | 'ORDER_DEALT_IN' - | 'ORDER_PLF_FEE_OUT' - | 'EXCHANGE_SOURCE_TOKEN_USER_OUT' - | 'EXCHANGE_TARGET_TOKEN_USER_IN' - | 'OPEN_LONG' - | 'OPEN_SHORT' - | 'BUY_DEAL' - | 'SELL_DEAL' - | 'CLOSE_LONG' - | 'CLOSE_SHORT' - | 'FORCE_CLOSE_LONG' - | 'FORCE_CLOSE_SHORT' - | 'BURST_CLOSE_LONG' - | 'BURST_CLOSE_SHORT' - | 'OFFSET_REDUCE_CLOSE_LONG' - | 'OFFSET_REDUCE_CLOSE_SHORT' - | 'FORCE_BUY_SSM' - | 'FORCE_SELL_SSM' - | 'BURST_BUY_SSM' - | 'BURST_SELL_SSM' - | 'RISK_LIQ_USER_IN' - | 'INTEREST_SETTLEMENT_OUT' - | 'CONTRACT_MAIN_SETTLE_FEE_USER_IN' - | 'CONTRACT_MAIN_SETTLE_FEE_USER_OUT' - | 'RISK_LIQ_USER_OUT' - | 'BORROW' - | 'RESERVE_TRANSFER_IN' - | 'RESERVE_TRANSFER_OUT' - | 'REPAYMENT' - | 'INTEREST_REPAYMENT' - | 'LIQ_FUND_OUT' - | 'LIQ_CONVERT_USER_OUT' - | 'LIQ_CONVERT_SYS_IN' - | 'LIQ_CONVERT_SYS_OUT' - | 'LIQ_CONVERT_USER_IN' - | 'LIQ_TRANSFER_IN' - | 'LIQ_TRANSFER_OUT' - | 'LIQ_FUND_IN' - | 'LIQ_FEE' - | 'LIQ_REPAYMENT' - | 'DELIST_MARGIN_TOKEN_SOURCE_USER_OUT' - | 'DELIST_MARGIN_TOKEN_SOURCE_SYS_IN' - | 'DELIST_MARGIN_TOKEN_TARGET_SYS_OUT' - | 'DELIST_MARGIN_TOKEN_TARGET_USER_IN' - | 'CONFISCATE_TOKEN_USER_OUT' - | 'CONFISCATE_TOKEN_SYS_IN' - | 'DELIST_SMALL_BALANCE_USER_OUT' - | 'DELIST_SMALL_BALANCE_SYS_IN' - | 'DELIST_SMALL_LIABILITY_SYS_OUT' - | 'DELIST_SMALL_LIABILITY_USER_IN' - | 'SMALL_ASSET_SOURCE_TOKEN_USER_OUT' - | 'SMALL_ASSET_SOURCE_TOKEN_SYS_IN' - | 'SMALL_ASSET_TARGET_TOKEN_SYS_OUT' - | 'SMALL_ASSET_TARGET_TOKEN_USER_IN' - | 'SMALL_ASSET_FEE_SYS_IN' - | 'TRACE_SHARE_BENEFIT_USER_OUT' - | 'TRACE_SHARE_BENEFIT_SYSTEM_IN' - | 'TRACE_SHARE_BENEFIT_SYSTEM_OUT' - | 'TRACE_SHARE_BENEFIT_USER_IN' - | 'MARGIN_OPEN_LONG' - | 'MARGIN_OPEN_SHORT' - | 'MARIN_BUY_DEAL' - | 'MARIN_SELL_DEAL' - | 'MARGIN_BACK' - | 'INCREASE_MARGIN' - | 'REDUCE_MARGIN' - | 'MARGIN_SETTLE_FEE_USER_IN' - | 'MARGIN_SETTLE_FEE_USER_OUT' - | 'MARGIN_LEVER_ORDER_REFROZEN' - | 'MARGIN_LEVER_ORDER_FROZEN' - | 'MARGIN_LEVER_POS_IN' - | 'MARGIN_OFFSET_IN_SSM_LONG' - | 'MARGIN_OFFSET_IN_SSM_SHORT' - | 'FIXED_OFFSET_IN_SSM_LONG' - | 'FIXED_OFFSET_IN_SSM_SHORT' - | 'FIXED_CLOSE_LONG' - | 'FIXED_CLOSE_SHORT' - | 'FIXED_FORCE_CLOSE_LONG' - | 'FIXED_FORCE_CLOSE_SHORT' - | 'FIXED_BURST_CLOSE_LONG' - | 'FIXED_BURST_CLOSE_SHORT' - | 'FIXED_ADL_CLOSE_LONG' - | 'FIXED_ADL_CLOSE_SHORT' - | 'FIXED_RISK_LIQ_USER_IN' - | 'FIXED_RISK_LIQ_USER_OUT' - | 'FIXED_FORCE_BUY_SSM' - | 'FIXED_FORCE_SELL_SSM' - | 'FIXED_BURST_BUY_SSM' - | 'FIXED_BURST_SELL_SSM' - | 'ON_CHAIN_TRANSFER_REFUND' - | 'ON_CHAIN_TRANSFER_OUT' - | 'MT5_TRANSFER_IN' - | 'MT5_REFUND_IN' - | 'MT5_TRANSFER_OUT' - | 'TRACE_LOCK_USER_OUT' - | 'TRACE_LOCK_USER_IN' - | 'TRACE_TRANSFER_USER_OUT' - | 'TRACE_TRANSFER_USER_IN' - | 'TRACE_TRANSFER_REFUND_IN' - | 'FINANCIAL_TRANSFER_OUT' - | 'FINANCIAL_TRANSFER_IN' - | 'CONVERT_TRANSFER_IN' - | 'CONVERT_TRANSFER_OUT' - | 'BGPAY_TRANSFER_OUT' - | 'BGPAY_REFUND_IN' - | 'RWA_FIXED_SETTLE_FEE_USER_IN' - | 'RWA_FIXED_SETTLE_FEE_USER_OUT' - | 'RWA_CONTRACT_MAIN_SETTLE_FEE_SYSTEM_IN' - | 'RWA_CONTRACT_MAIN_SETTLE_FEE_SYSTEM_OUT' - | 'RWA_CONTRACT_MAIN_SETTLE_FEE_SYSTEM_KEEP_IN' - | 'RWA_CONTRACT_MAIN_SETTLE_FEE_SYSTEM_KEEP_OUT' - | 'RWA_CONTRACT_MAIN_SETTLE_FEE_USER_IN' - | 'RWA_CONTRACT_MAIN_SETTLE_FEE_USER_OUT' - | 'RWA_CONTRACT_REBASE_USER_OPEN_LONG' - | 'RWA_CONTRACT_REBASE_USER_OPEN_SHORT' - | 'RWA_CONTRACT_REBASE_USER_CLOSE_LONG' - | 'RWA_CONTRACT_REBASE_USER_CLOSE_SHORT' - | 'RWA_CONTRACT_REBASE_USER_BUY_IN_SSM' - | 'RWA_CONTRACT_REBASE_USER_SELL_IN_SSM' - | 'RISK_LIQ_DEFAULT_USER_IN' - | 'FIXED_RISK_LIQ_DEFAULT_USER_IN' - | 'BONUS_GRANT_USER_IN' - | 'BONUS_EXPIRE_USER_OUT' - | 'BONUS_TRANSFER_USER_OUT' - | 'WITHDRAW_TRANSFER_OUT' - | 'WITHDRAW_TRANSFER_IN' - | 'DELIVERY_LONG' - | 'DELIVERY_SHORT' - | 'FIXED_DELIVERY_LONG' - | 'FIXED_DELIVERY_SHORT' - | 'REBASE_COIN_SPLIT_OUT' - | 'REBASE_COIN_SPLIT_IN' - | 'REBASE_COIN_MERGE_OUT' - | 'REBASE_COIN_MERGE_IN'; +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, + ); ⋮---- -export interface GetFinancialRecordsRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - coin?: string; - type?: FinancialRecordTypeV3; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; -} +createSubaccountDepositAddress(params: { + subUid: string; + coin: string; + chain?: string; +}): Promise> ⋮---- -export interface RepayRequestV3 { - repayableCoinList: string[]; - paymentCoinList: string[]; -} +subaccountWithdrawal(params: SubWithdrawalRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + return this.postPrivate( + '/api/v2/broker/account/subaccount-withdrawal', + params, + ); ⋮---- -// Sub-account Management Request Types +subaccountSetAutoTransfer(params: { + subUid: string; + coin: string; + toAccountType: string; +}): Promise> ⋮---- -export interface CreateSubAccountApiKeyRequestV3 { - subUid: string; - note: string; - type: 'read_write' | 'read_only'; - passphrase: string; - permissions: string[]; - ips: string[]; -} +/** + * Sub Deposit Records + * + * - Only applicable for ND broker main-account to get ND sub-accounts deposit record + */ +subaccountDepositRecords( + params: SubDepositRecordsRequestV2, +): Promise> ⋮---- -export interface DeleteSubAccountApiKeyRequestV3 { - apiKey: string; -} +/** + * 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); ⋮---- -export interface GetSubAccountApiKeysRequestV3 { - subUid: string; - limit?: string; - cursor?: string; -} +/** + * + * Broker | Api Key + * + */ ⋮---- -export interface UpdateSubAccountApiKeyRequestV3 { - apiKey: string; - passphrase: string; - type?: 'read_write' | 'read_only'; - permissions?: string[]; - ips?: string[]; -} +createSubaccountApiKey( + params: CreateSubAccountApiKeyRequestV2, +): Promise> ⋮---- -export interface CreateSubAccountRequestV3 { - username: string; - accountMode?: 'classic' | 'unified'; - note?: string; -} +getSubaccountApiKey(params: { + subUid: string; +}): Promise> ⋮---- -export interface FreezeSubAccountRequestV3 { - subUid: string; - operation: 'freeze' | 'unfreeze'; -} +modifySubaccountApiKey( + params: ModifySubAccountApiKeyRequestV2, +): Promise> ⋮---- -export interface GetSubAccountListRequestV3 { - limit?: string; - cursor?: string; -} +deleteSubaccountApiKey( + params: DeleteSubAccountApiKeyRequestV2, +): Promise> ⋮---- -// Transfer Request Types +/** + * 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); ⋮---- -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'; -} +/** + * 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> ⋮---- -/** Enable automatic margin borrowing when balance insufficient. yes | no */ +getSubAffiliateInfo( + params?: GetSubAffiliateInfoRequestV2, +): Promise> ⋮---- -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'; -} +getAgentCustomerTradeVolume( + params?: AgentCustomerTradeVolumeRequestV2, +): Promise> ⋮---- -export interface GetSubTransferRecordsRequestV3 { - subUid?: string; - role?: 'initiator' | 'receiver'; - coin?: string; - startTime?: string; - endTime?: string; - clientOid?: string; - limit?: string; - cursor?: string; -} +/** + * Without startTime/endTime, returns all registered customers (no time restriction). + */ +getAgentCustomerList( + params?: AgentCustomerListRequestV2, +): Promise> ⋮---- -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'; -} +getAgentCustomerKycResult( + params?: GetAgentCustomerKycResultRequestV2, +): Promise> ⋮---- -/** Enable automatic margin borrowing when balance insufficient. yes | no */ +getAgentCustomerDeposits( + params?: AgentCustomerDepositRequestV2, +): Promise> ⋮---- -export interface GetSubUnifiedAssetsRequestV3 { - subUid?: string; - cursor?: string; - limit?: string; -} +getAgentCustomerAssets( + params?: AgentCustomerAssetRequestV2, +): Promise> ⋮---- -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'; -} +getAgentCommissionDetail( + params?: GetAgentCommissionDetailRequestV2, +): Promise> ⋮---- -/** RPI fee rate flag for market maker users. Default: no */ +/** + * + * + * Margin + * + * + */ ⋮---- -export interface GetFundingAssetsRequestV3 { - coin?: string; -} +/** + * + * * Margin | Common + * + */ ⋮---- -export interface SwitchDeductRequestV3 { - deduct: 'on' | 'off'; -} +getMarginCurrencies(): Promise> ⋮---- -// Deposit Request Types +/** + * + * * Margin | Cross/Isolated | Order Record + * + */ ⋮---- -export interface GetDepositAddressRequestV3 { - coin: string; - chain?: string; - size?: string; -} +getMarginBorrowHistory( + marginType: MarginType, + params: GetBorrowHistoryRequestV2, + ): Promise< + APIResponse<{ + resultList: MarginBorrowHistoryItemV2[]; + maxId: string; + minId: string; + }> + > { + assertMarginType(marginType); ⋮---- -export interface GetSubDepositAddressRequestV3 { - subUid: string; - coin: string; - chain?: string; - size?: string; -} +getMarginRepayHistory( + marginType: MarginType, + params: GetRepayHistoryRequestV2, + ): Promise< + APIResponse<{ + resultList: MarginRepaymentHistoryItemV2[]; + maxId: string; + minId: string; + }> + > { + assertMarginType(marginType); ⋮---- -export interface GetDepositRecordsRequestV3 { - coin?: string; - orderId?: string; - startTime: string; - endTime: string; - limit?: string; - cursor?: string; -} +getMarginInterestHistory( + marginType: MarginType, + params: GetInterestHistoryRequestV2, + ): Promise< + APIResponse<{ + resultList: MarginInterestHistoryItemV2[]; + maxId: string; + minId: string; + }> + > { + assertMarginType(marginType); ⋮---- -export interface GetSubDepositRecordsRequestV3 { - coin?: string; - subUid: string; - startTime: string; - endTime: string; - limit?: string; - cursor?: string; -} +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); ⋮---- -// Withdraw Request Types +getMarginMaxBorrowable( + marginType: MarginType, + params: { coin: string }, + ): Promise< + APIResponse + > { + assertMarginType(marginType); ⋮---- -export interface WithdrawRequestV3 { - coin: string; - chain?: string; - /** Deduct from funding, uta, and/or otc accounts (comma-separated). Order: funding -> otc -> uta */ - accountType?: string; - transferType: 'on_chain' | 'internal_transfer'; - address: string; - innerToType?: 'uid' | 'email' | 'mobile'; - areaCode?: string; - tag?: string; - size: string; - remark?: string; - clientOid?: string; - memberCode?: 'bithumb' | 'korbit' | 'coinone'; - identityType?: 'company' | 'user'; - companyName?: string; - firstName?: string; - lastName?: string; -} +getMarginMaxTransferable( + marginType: MarginType, + params: { coin: string }, + ): Promise< + APIResponse< + CrossMaxTransferableResponseV2 | IsolatedMaxTransferableResponseV2 + > + > { + assertMarginType(marginType); ⋮---- -/** Deduct from funding, uta, and/or otc accounts (comma-separated). Order: funding -> otc -> uta */ +getMarginInterestRateAndMaxBorrowable( + marginType: MarginType, + params: { coin: string }, + ): Promise< + APIResponse< + | IsolatedInterestRateAndLimitResponseV2[] + | CrossInterestRateAndLimitResponseV2[] + > + > { + assertMarginType(marginType); ⋮---- -export interface GetWithdrawRecordsRequestV3 { - coin?: string; - orderId?: string; - clientOid?: string; - startTime: string; - endTime: string; - limit?: string; - cursor?: string; -} +getMarginTierConfiguration( + marginType: MarginType, + params: { coin: string }, + ): Promise< + APIResponse< + CrossTierConfigurationResponseV2[] | IsolatedTierConfigurationResponseV2[] + > + > { + assertMarginType(marginType); ⋮---- -export interface GetWithdrawAddressBookRequestV3 { - coin?: string; - type?: 'EVM' | 'regular' | 'universal' | 'internal'; - limit?: string; - cursor?: string; -} +marginFlashRepay( + marginType: MarginType, + params: { coin: string }, + ): Promise< + APIResponse<{ + repayId: string; + coin?: string; + symbol?: string; + result?: string; + }> + > { + assertMarginType(marginType); ⋮---- -export interface CancelWithdrawalRequestV3 { - orderId?: string; - clientOid?: string; -} +getMarginFlashRepayResult( + marginType: MarginType, + params: { idList: string }, + ): Promise< + APIResponse< + { + repayId: string; + status: string; + }[] + > + > { + assertMarginType(marginType); ⋮---- -export interface SetDepositAccountRequestV3 { - coin: string; - accountType: 'funding' | 'unified' | 'otc'; -} +/** + * + * * Margin | Cross/Isolated | Trade + * + */ ⋮---- -export interface GetMaxTransferableRequestV3 { - coin: string; -} +marginSubmitOrder( + marginType: MarginType, + params: MarginPlaceOrderRequestV2, + ): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + assertMarginType(marginType); ⋮---- -export interface GetOpenInterestLimitRequestV3 { - symbol: string; - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; -} +marginBatchSubmitOrders( + marginType: MarginType, + params: MarginBatchOrdersRequestV2, +): Promise> ⋮---- -export interface GetTaxRecordsRequestV3 { - bizType: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES' - | 'OTHER'; - marginType?: 'isolated' | 'crossed'; - coin?: string; - startTime: string; - endTime: string; - limit?: string; - cursor?: string; -} +marginCancelOrder( + marginType: MarginType, + params: { + symbol: string; + orderId?: string; + clientOid?: string; + }, + ): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + assertMarginType(marginType); ⋮---- -export type CollateralTypeV3 = 'mainstream' | 'all' | 'custom'; +marginBatchCancelOrders( + marginType: MarginType, + params: { + symbol: string; + orderIdList: string[]; + }, +): Promise> ⋮---- -export interface SetCollateralTypeRequestV3 { - collateralType: CollateralTypeV3; - /** Required when collateralType=custom. Comma-separated coin names */ - collateralCoins?: string; - /** Enable Cash+ as collateral. Official field name is allowCashPlus */ - allowCashPlus?: 'yes' | 'no'; -} +getMarginOpenOrders( + marginType: MarginType, + params: GetMarginCurrentOrdersRequestV2, + ): Promise< + APIResponse<{ + orderList: MarginCurrentOrderV2[]; + maxId: string; + minId: string; + }> + > { + assertMarginType(marginType); ⋮---- -/** Required when collateralType=custom. Comma-separated coin names */ +getMarginHistoricOrders( + marginType: MarginType, + params: GetHistoryOrdersRequestV2, + ): Promise< + APIResponse<{ + orderList: MarginHistoryOrderV2[]; + maxId: string; + minId: string; + }> + > { + assertMarginType(marginType); ⋮---- -/** Enable Cash+ as collateral. Official field name is allowCashPlus */ +getMarginHistoricOrderFills( + marginType: MarginType, + params: GetMarginOrderFillsRequestV2, + ): Promise< + APIResponse<{ + fills: MarginOrderFillV2[]; + minId: string; + maxId: string; + }> + > { + assertMarginType(marginType); ⋮---- -export interface BorrowRequestV3 { - coin: string; - amount: string; - clientOid?: string; -} +getMarginLiquidationOrders( + marginType: MarginType, + params: GetMarginLiquidationOrdersRequestV2, + ): Promise< + APIResponse<{ + resultList: MarginLiquidationOrderV2[]; + idLessThan: string; + }> + > { + assertMarginType(marginType); ⋮---- -export interface GetMaxBorrowableRequestV3 { - coin: string; -} +/** + * + * + * Copy Trading + * + * + */ ⋮---- -export interface SetRepayModeRequestV3 { - /** Account-level. Master and each sub-account keep their own setting */ - repayMode: 'auto' | 'manual'; -} +/** + * + * + * Copy Trading | Future copy trading | Trader Api + * + * + */ ⋮---- -/** Account-level. Master and each sub-account keep their own setting */ +getFuturesTraderCurrentOrder( + params: GetFuturesTraderCurrentOrdersRequestV2, +): Promise> ⋮---- -export interface DeleteSubAccountRequestV3 { - subUid: string; -} +getFuturesTraderHistoryOrders( + params: GetFuturesTraderHistoryOrdersRequestV2, +): Promise> ⋮---- -export interface PreSetLeverageRequestV3 { - category: 'MARGIN' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - coin?: string; - marginMode: 'isolated' | 'cross'; - leverage?: string; - longLeverage?: string; - shortLeverage?: string; -} +modifyFuturesTraderOrderTPSL( + params: ModifyFuturesTraderOrderTPSLRequestV2, +): Promise> ⋮---- -export interface SetMarginRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol: string; - posSide: 'long' | 'short'; - operation: 'add' | 'remove'; - amount: string; -} +getFuturesTraderOrder(): Promise< + APIResponse + > { + return this.getPrivate('/api/v2/copy/mix-trader/order-total-detail'); ⋮---- -export interface GetMaxWithdrawalRequestV3 { - coin: string; -} +getFuturesTraderProfitHistory(): Promise< + APIResponse + > { + return this.getPrivate('/api/v2/copy/mix-trader/profit-history-summarys'); ⋮---- -export interface GetRealityOrderBookRequestV3 { - symbol: string; -} +getFuturesTraderProfitShareHistory( + params: GetFuturesTraderProfitShareDetailRequestV2, +): Promise> ⋮---- -export interface GetRealityOrderBookSegmentedRequestV3 { - symbol: string; -} +closeFuturesTraderOrder(params: { + trackingNo: string; + symbol: string; + productType: CopyTradingProductTypeV2; + }): Promise< + APIResponse< + { + trackingNo: string; + symbol: string; + productType: string; + }[] + > + > { + return this.postPrivate( + '/api/v2/copy/mix-trader/order-close-positions', + params, + ); ⋮---- -export interface GetRealityFillsRequestV3 { - symbol: string; - limit?: string; -} +getFuturesTraderProfitShare(params?: { + coin?: string; + pageSize?: string; + pageNo?: string; + }): Promise< + APIResponse< + { + coin: string; + profit: string; + nickName: string; + }[] + > + > { + return this.getPrivate('/api/v2/copy/mix-trader/profit-details', params); ⋮---- -export interface SubMasterTransferRequestV3 { - fromType: 'spot' | 'uta'; - toType: 'spot' | 'p2p' | 'uta'; - amount: string; - coin: string; - clientOid?: string; -} +getFuturesTraderProfitShareGroup(params?: { + pageSize?: string; + pageNo?: string; + }): Promise< + APIResponse< + { + coin: string; + profit: string; + profitTime: string; + }[] + > + > { + return this.getPrivate( + '/api/v2/copy/mix-trader/profits-group-coin-date', + params, + ); ⋮---- -export interface CreateAgentSubAccountRequestV3 { - username: string; - passphrase: string; - note?: string; -} +getFuturesTraderSymbolSettings(params: { + productType: CopyTradingProductTypeV2; +}): Promise> ⋮---- -export interface MovePositionItemRequestV3 { - symbol: string; - side: 'buy' | 'sell'; - qty: string; -} +updateFuturesTraderSymbolSettings(params: { + settingList: FuturesTraderSymbolSettingRequestV2[]; +}): Promise> ⋮---- -export interface MovePositionsRequestV3 { - fromUid: string; - toUid: string; - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - positionList: MovePositionItemRequestV3[]; -} +updateFuturesTraderGlobalSettings(params?: { + enable?: 'YES' | 'NO'; + showTotalEquity?: 'YES' | 'NO'; + showTpsl?: 'YES' | 'NO'; +}): Promise> ⋮---- -export interface GetMovePositionHistoryRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - startTime?: string; - endTime?: string; - cursor?: string; - limit?: string; -} +getFuturesTraderFollowers( + params?: GetFuturesTraderFollowersRequestV2, +): Promise> ⋮---- -export interface GetEligibleSymbolsRequestV3 { - symbol?: string; -} +removeFuturesTraderFollower(params: { + followerUid: string; +}): Promise> ⋮---- -export interface GetEligibleMarginTierRequestV3 { - coin?: string; -} +/** + * + * + * Copy Trading | Future copy trading | Follower Api + * + * + */ ⋮---- -export interface GetEligibleLoanInfoRequestV3 { - coin?: string; -} +getFuturesFollowerCurrentOrders( + params: GetFollowerFuturesCurrentTrackingOrdersRequestV2, +): Promise> ⋮---- -export interface GetEligibleDiscountRateRequestV3 { - coin?: string; -} +getFuturesFollowerHistoryOrders( + params: GetFollowerFuturesHistoryTrackingOrdersRequestV2, +): Promise> ⋮---- -export interface GetFundingFinancialRecordsRequestV3 { - coin?: string; - type?: string; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; -} +updateFuturesFollowerTPSL( + params: UpdateFuturesFollowerTPSLRequestV2, +): Promise> ⋮---- -export interface GetSmallAssetsRequestV3 { - coin?: string; -} +updateFuturesFollowerSettings( + params: UpdateFuturesFollowerSettingsRequestV2, +): Promise> ⋮---- -export interface TradeSmallAssetsRequestV3 { - fromCoinList: string[]; - toCoin?: string; -} +getFuturesFollowerSettings(params: { + traderId: string; +}): Promise> ⋮---- -export interface GetSmallAssetsHistoryRequestV3 { - orderId?: string; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; -} +closeFuturesFollowerPositions( + params: CloseFuturesFollowerPositionsRequestV2, + ): Promise< + APIResponse<{ + orderIdList: string[]; + }> + > { + return this.postPrivate( + '/api/v2/copy/mix-follower/close-positions', + params, + ); ⋮---- -export interface GetRateLimitQuotaRequestV3 { - category: 'spot' | 'futures'; - /** - * Omit to list sub-accounts under the master. - * Ignored when a sub-account calls this for itself. - */ - uid?: string; - cursor?: string; - limit?: string; -} +getFuturesFollowerTraders( + params: GetFuturesFollowerTradersRequestV2, +): Promise> ⋮---- -/** - * Omit to list sub-accounts under the master. - * Ignored when a sub-account calls this for itself. - */ +getFuturesFollowerFollowLimit(params: { + symbol: string; + productType: CopyTradingProductTypeV2; + }): Promise< + APIResponse< + { + maxFollowSize: string; + minFollowSize: string; + symbol: string; + }[] + > + > { + return this.getPrivate( + '/api/v2/copy/mix-follower/query-quantity-limit', + params, + ); ⋮---- -export interface SetRateLimitQuotaRequestV3 { - category: 'spot' | 'futures'; - /** - * Required when the master account sets quotas. - * Not required, and ignored, when a sub-account sets its own quota. - */ - uids?: string[]; - quota: string; -} +unfollowFuturesTrader(params: { + traderId: string; +}): Promise> ⋮---- /** - * Required when the master account sets quotas. - * Not required, and ignored, when a sub-account sets its own quota. + * + * + * Copy Trading | Future copy trading | Broker api + * + * */ ⋮---- -export interface CreateStpGroupRequestV3 { - /** Max 32 characters. Must be unique. */ - groupName: string; -} +getBrokerTraders(params: object): Promise> ⋮---- -/** Max 32 characters. Must be unique. */ +getBrokerTradersHistoricalOrders(params: object): Promise> ⋮---- -export interface StpGroupMembersRequestV3 { - /** Comma-separated sub-account UIDs. Max 50. */ - uids: string; - groupId: string; -} +getBrokerTradersPendingOrders(params: object): Promise> ⋮---- -/** Comma-separated sub-account UIDs. Max 50. */ - -================ -File: src/types/response/v3/account.ts -================ -// Account Management Response Types -import type { - CollateralTypeV3, - FinancialRecordTypeV3, -} from '../../request/v3/account.js'; +/** + * + * + * Copy Trading | Spot copy trading | Trader api + * + * + */ ⋮---- -export interface AccountSymbolConfigV3 { - category: string; - symbol: string; - marginMode: string; - leverage: string; -} +getSpotTraderProfit(): Promise> ⋮---- -export interface AccountCoinConfigV3 { - coin: string; - leverage: string; -} +getSpotTraderHistoryProfit( + params: GetSpotTraderHistoryProfitRequestV2, +): Promise> ⋮---- -export type AccountPermissionV3 = - | 'uta_mgt' - | 'uta_trade' - | 'withdraw' - | 'copy_futures_position' - | 'copy_futures_order'; +getSpotTraderUnrealizedProfit(params?: { + coin?: string; + pageNo?: string; + pageSize?: string; +}): Promise> ⋮---- -export interface AccountInfoV3 { - userId: string; - inviterId: string; - /** - * Only set when the calling account is a sub-account. - * Confirmed by Bitget devs but not yet in their docs: the API returns - * parentId as an integer, not only the string shown in the docs. - */ - parentId: string | number; - channelCode: string; - channel: string; - ips: string; - /** - * Confirmed by Bitget devs but not yet in their docs: permType uses - * underscores (read_and_write). readonly is also possible on demo keys. - */ - permType: - | 'read-only' - | 'read-and-write' - | 'read_only' - | 'read_and_write' - | 'readonly'; - permissions: AccountPermissionV3[]; - regisTime: string; - traderType?: 'trader' | 'not_trader'; -} +getSpotTraderOrder(): Promise> ⋮---- -/** - * Only set when the calling account is a sub-account. - * Confirmed by Bitget devs but not yet in their docs: the API returns - * parentId as an integer, not only the string shown in the docs. - */ +modifySpotTraderOrderTPSL(params: { + trackingNo: string; + stopSurplusPrice?: string; + stopLossPrice?: string; +}): Promise> ⋮---- -/** - * Confirmed by Bitget devs but not yet in their docs: permType uses - * underscores (read_and_write). readonly is also possible on demo keys. - */ +getSpotTraderHistoryOrders( + params: GetSpotTraderHistoryOrdersRequestV2, +): Promise> ⋮---- -export type AccountLevelV3 = 'basic' | 'advanced' | 'isolated' | 'delta'; +getSpotTraderCurrentOrders( + params: GetSpotTraderCurrentOrdersRequestV2, +): Promise> ⋮---- -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'; - repayMode?: 'auto' | 'manual'; - symbolConfigList: AccountSymbolConfigV3[]; - coinConfigList: AccountCoinConfigV3[]; -} +sellSpotTrader(params: { + trackingNoList: string[]; + symbol: string; +}): Promise> ⋮---- -export interface AccountDeltaCoinPositionV3 { - coin: string; - positionRatio: string; -} +getSpotTraderSymbolSettings(params: { + symbolList: string[]; + settingType: 'add' | 'delete'; +}): Promise> ⋮---- -/** 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[]; -} +removeSpotTraderFollowers(params: { + followerUid: string; +}): Promise> ⋮---- -/** Deprecated, no longer used as a hedge-eligibility criterion */ +getSpotTraderConfiguration(): Promise> ⋮---- -/** Deprecated, no longer used as a hedge-eligibility criterion */ +getSpotTraderFollowers( + params: GetSpotTraderFollowersRequestV2, +): Promise> ⋮---- -export interface AccountAssetV3 { - coin: string; - equity: string; - usdValue: string; - balance: string; - /** Coin balance before borrowing-related amounts are deducted */ - balanceOriginal?: string; - available: string; - debt: string; - locked: string; - /** Position value in USD */ - positionValue?: string; - /** Account leverage (non-negative) */ - leverage?: string; - /** USDT bonus amount */ - bonus?: string; - /** Interest calculation base */ - interestBase?: string; -} +/** + * + * + * Copy Trading | Spot copy trading | Follower api + * + * + */ ⋮---- -/** Coin balance before borrowing-related amounts are deducted */ +cancelSpotFollowerOrder(params: { + trackingNoList: string[]; +}): Promise> ⋮---- -/** Position value in USD */ +updateSpotFollowerSettings(params: { + traderId: string; + autoCopy?: 'on' | 'off'; + mode?: 'basic' | 'advanced'; + settings: SpotFollowerCopyTradeSettingV2[]; +}): Promise> ⋮---- -/** Account leverage (non-negative) */ +updateSpotFollowerTPSL(params: { + trackingNo: string; + stopSurplusPrice?: string; + stopLossPrice?: string; +}): Promise> ⋮---- -/** USDT bonus amount */ +getSpotFollowerTraders(params?: { + pageNo?: string; + pageSize?: string; + startTime?: string; + endTime?: string; +}): Promise> ⋮---- -/** Interest calculation base */ +getSpotFollowerCurrentTraderSymbols(params: { traderId: string }): Promise< + APIResponse<{ + currentTradingList: string[]; + }> + > { + return this.getPrivate( + '/api/v2/copy/spot-follower/query-trader-symbols', + params, + ); ⋮---- -export interface BorrowResponseV3 { - orderId: string; - clientOid?: string; -} +getSpotFollowerSettings(params: { + traderId: string; +}): Promise> ⋮---- -export interface MaxBorrowableV3 { - maxBorrowable: string; -} +getSpotFollowerHistoryOrders( + params: GetSpotFollowerHistoryOrdersRequestV2, +): Promise> ⋮---- -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[]; -} +getSpotFollowerOpenOrders( + params: GetSpotFollowerOpenOrdersRequestV2, +): Promise> +⋮---- +sellSpotFollower(params: { + trackingNoList: string[]; + symbol: string; +}): Promise> +⋮---- +unfollowSpotTrader(params: { + traderId: string; +}): Promise> +⋮---- +/** + * + * + * Earn | Savings + * + * + */ ⋮---- -export interface ConvertRecordV3 { - fromCoin: string; - fromCoinSize: string; - toCoin: string; - toCoinSize: string; - price: string; - ts: string; -} +getEarnSavingsProducts(params?: { + coin?: string; + filter?: string; +}): Promise> ⋮---- -export interface FinancialRecordV3 { - category: string; - id: string; - symbol: string; - coin: string; - type: FinancialRecordTypeV3; - amount: string; - fee: string; - balance: string; - ts: string; - /** crossed | isolated */ - positionType?: string; - positionAmount?: string; - positionBalance?: string; -} +getEarnSavingsAccount(): Promise> ⋮---- -/** crossed | isolated */ +getEarnSavingsAssets( + params: GetEarnSavingsAssetsRequestV2, +): Promise> ⋮---- -export interface PaymentCoinV3 { - coin: string; - size: string; - amount: string; -} +getEarnSavingsRecords( + params: GetEarnSavingsRecordsRequestV2, +): Promise> ⋮---- -export interface RepayableCoinV3 { - coin: string; - size: string; - amount: string; -} +getEarnSavingsSubscription(params: { + productId: string; + periodType: string; +}): Promise> ⋮---- -export interface RepayResponseV3 { - result: string; - repayAmount: string; -} +earnSubscribeSavings(params: { + productId: string; + periodType: string; + amount: string; + }): Promise< + APIResponse<{ + orderId: string; + status: string; + }> + > { + return this.postPrivate('/api/v2/earn/savings/subscribe', params); ⋮---- -// Sub-account Management Response Types +getEarnSavingsSubscriptionResult(params: { + productId: string; + periodType: string; + }): Promise< + APIResponse<{ + result: 'success' | 'fail'; + msg: string; + }> + > { + return this.getPrivate('/api/v2/earn/savings/subscribe-result', params); ⋮---- -export interface 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; -} +earnRedeemSavings(params: RedeemSavingsRequestV2): Promise< + APIResponse<{ + orderId: string; + status: string; + }> + > { + return this.postPrivate('/api/v2/earn/savings/redeem', params); ⋮---- -export interface UpdateSubAccountApiKeyResponseV3 { - note: string; - apiKey: string; - type: string; - permissions: string[]; - ips: string[]; -} +getEarnSavingsRedemptionResult(params: { + orderId: string; + periodType: string; + }): Promise< + APIResponse<{ + result: 'success' | 'fail'; + msg: string; + }> + > { + return this.getPrivate('/api/v2/earn/savings/redeem-result', params); ⋮---- -export interface CreateSubAccountResponseV3 { - username: string; - subUid: string; - status: string; - note: string; - createdTime: string; - updatedTime: string; -} +/** + * + * + * Earn | Earn Account + * + * + */ ⋮---- -export interface CreateAgentSubAccountResponseV3 { - username: string; - subUid: string; - apiKey: string; - secret: string; - note: string; - createdTime: string; -} +getEarnAccount(params?: { coin?: string }): Promise< + APIResponse< + { + coin: string; + amount: string; + }[] + > + > { + return this.getPrivate('/api/v2/earn/account/assets', params); ⋮---- -export interface SubAccountV3 { - subUid: string; - username: string; - status: string; - accountMode: string; - type: 'normal' | 'virtual' | 'custodian' | 'fund_management'; - note: string; - createdTime: string; - updatedTime: string; -} +/** + * + * + * Earn | On-Chain Elite + * + * + */ ⋮---- -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; -} +getEarnEliteProducts(): Promise> ⋮---- -export interface WithdrawAddressBookV3 { - addressList: WithdrawAddressBookEntryV3[]; - cursor?: string; -} +getEarnEliteAssets(): Promise> ⋮---- -// Transfer Response Types +getEarnEliteRecords( + params: GetEarnEliteRecordsRequestV2, +): Promise> ⋮---- -export interface AllSymbolFeeRateV3 { - symbol: string; - makerFeeRate: string; - takerFeeRate: string; -} +getEarnEliteSubscribeInfo( + params: GetEarnEliteSubscribeInfoRequestV2, +): Promise> ⋮---- -export interface TransferResponseV3 { - transferId: string; - clientOid?: string; -} +subscribeEarnElite( + params: EarnEliteSubscribeRequestV2, +): Promise> ⋮---- -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; -} +getEarnEliteSubscribeResult( + params: GetEarnEliteSubscribeResultRequestV2, +): Promise> ⋮---- -export interface SubUnifiedAssetV3 { - coin: string; - equity: string; - usdValue: string; - balance: string; - available: string; - debt: string; - locked: string; -} +getEarnEliteRedeemInfo( + params: GetEarnEliteRedeemInfoRequestV2, +): Promise> ⋮---- -export interface SubUnifiedAssetV3 { - subUid: string; - cursor: string; - assets: SubUnifiedAssetV3[]; -} +redeemEarnElite( + params: RedeemEarnEliteRequestV2, +): Promise> +⋮---- +/** + * + * + * Earn | Shark Fin + * + * + */ +⋮---- +getSharkfinProducts(params: { + coin: string; + limit?: string; + idLessThan?: string; +}): Promise> ⋮---- -export interface GetFeeRateResponseV3 { - makerFeeRate: string; - takerFeeRate: string; -} +getSharkfinAccount(): Promise> ⋮---- -export interface FundingAssetV3 { - coin: string; - available: string; - frozen: string; - balance: string; -} +getSharkfinAssets( + params: GetSharkfinAssetsRequestV2, +): Promise> ⋮---- -// Deposit Response Types +getSharkfinRecords( + params: GetSharkfinRecordsRequestV2, +): Promise> ⋮---- -export interface DepositAddressV3 { - address: string; - chain: string; - coin: string; - tag: string; - url: string; -} +getSharkfinSubscription(params: { + productId: string; +}): Promise> ⋮---- -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; -} +subscribeSharkfin(params: { productId: string; amount: string }): Promise< + APIResponse<{ + orderId: string; + status: string; + }> + > { + return this.postPrivate('/api/v2/earn/sharkfin/subscribe', params); ⋮---- -// Withdraw Response Types +getSharkfinSubscriptionResult(params: { orderId: string }): Promise< + APIResponse<{ + result: 'success' | 'fail'; + msg: string; + }> + > { + return this.getPrivate('/api/v2/earn/sharkfin/subscribe-result', params); ⋮---- -export interface WithdrawResponseV3 { - orderId: string; - clientOid: string; -} +/** + * + * + * Earn | Loan + * + * + */ ⋮---- -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; -} +getLoanCurrencies(params?: { + coin?: string; +}): Promise> ⋮---- -export interface MaxTransferableV3 { - coin: string; - maxTransfer: string; - borrowMaxTransfer: string; -} +getLoanEstInterestAndBorrowable( + params: GetLoanEstInterestAndBorrowableRequestV2, + ): Promise< + APIResponse<{ + hourInterest: string; + loanAmount: string; + }> + > { + return this.get('/api/v2/earn/loan/public/hour-interest', params); ⋮---- -export interface OpenInterestLimitV3 { - symbol: string; - singleUserLimit: string; - masterSubLimit: string; - marketMakerLimit: string; -} +borrowLoan(params: BorrowLoanRequestV2): Promise< + APIResponse<{ + orderId: string; + }> + > { + return this.postPrivate('/api/v2/earn/loan/borrow', params); ⋮---- -export interface TaxRecordV3 { - id: string; - coin: string; - type: string; - amount: string; - fee: string; - balance: string; - ts: string; -} +getOngoingLoanOrders(params?: { + orderId?: string; + loanCoin?: string; + pledgeCoin?: string; +}): Promise> ⋮---- -export interface CollateralTypeConfigV3 { - collateralType: CollateralTypeV3; - /** Returned when collateralType=custom */ - collateralCoins?: string; -} +repayLoan( + params: RepayLoanRequestV2, +): Promise> ⋮---- -/** Returned when collateralType=custom */ +getRepayHistory( + params: GetLoanRepayHistoryRequestV2, +): Promise> ⋮---- -export interface CustomCollateralCoinV3 { - collateralCoin: string; -} +updateLoanPledgeRate(params: ModifyLoanPledgeRateRequestV2): Promise< + APIResponse<{ + loanCoin: string; + pledgeCoin: string; + afterPledgeRate: string; + }> + > { + return this.postPrivate('/api/v2/earn/loan/revise-pledge', params); ⋮---- -export interface PreSetLeverageV3 { - estMaxOpen?: string; - estMaxBorrowable?: string; - requiredMargin: string; - marginChange: string; -} +getLoanPledgeRateHistory( + params: GetLoanPledgeRateHistoryRequestV2, +): Promise> ⋮---- -export interface MaxWithdrawalV3 { - coin: string; - otcMaxWithdrawal: string; - spotMaxWithdrawal: string; - utaMaxWithdrawal: string; - totalMaxWithdrawal: string; -} +getLoanHistory( + params: GetLoanHistoryRequestV2, +): Promise> ⋮---- -export interface MovePositionOrderResultV3 { - orderId: string; - clientOid: string; - code: string; - msg: string; -} +getLoanDebts(): Promise> ⋮---- -export interface MovePositionsResponseV3 { - closePosition: MovePositionOrderResultV3[]; - openPosition: MovePositionOrderResultV3[]; -} +getLoanLiquidationRecords( + params: GetLiquidationRecordsRequestV2, +): Promise> ⋮---- -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; -} +/** + * + * * Inst Loan | Product Info + * + */ ⋮---- -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; -} +getLoanProductInfo( + params: GetInstLoanProductInfoRequestV2, +): Promise> ⋮---- -export interface EligibleMarginTierItemV3 { - tier: string; - minTierValue: string; - maxTierValue: string; - leverage: string; - mmr: string; -} +getLoanSymbols( + params: GetInstLoanSymbolsRequestV2, +): Promise> ⋮---- -export interface EligibleMarginTierV3 { - coin: string; - tiers: EligibleMarginTierItemV3[]; -} +getLoanMarginCoinInfo(params: GetInstLoanMarginCoinInfoRequestV2): Promise< + APIResponse<{ + productId: string; + coinInfo: InstLoanCoinInfoV2[]; + }> + > { + return this.getPrivate( + '/api/v2/spot/ins-loan/ensure-coins-convert', + params, + ); ⋮---- -export interface EligibleLoanInfoV3 { - limit: string; - masterSubLimit: string; - /** Bitget spelling */ - platformRemaingQuota: string; -} +/** + * + * * Inst Loan | Account + * + */ ⋮---- -/** Bitget spelling */ +getLoanRiskUnit(): Promise< + APIResponse<{ + riskUnitId: string[]; + }> + > { + return this.getPrivate('/api/v2/spot/ins-loan/risk-unit'); ⋮---- -export interface EligibleDiscountRateTierV3 { - tierStartValue: string; - discountRate: string; -} +getLoanLTVConvert( + params?: GetInstLoanLTVConvertRequestV2, +): Promise> ⋮---- -export interface EligibleDiscountRateV3 { - coin: string; - list: EligibleDiscountRateTierV3[]; -} +/** + * + * * Inst Loan | Orders + * + */ ⋮---- -export interface FundingFinancialRecordV3 { - id: string; - coin: string; - groupType: string; - type: string; - amount: string; - balance: string; - ts: string; -} +getLoanRepaidHistory( + params?: GetInstLoanRepaidHistoryRequestV2, +): Promise> ⋮---- -export interface SmallAssetFeeDetailV3 { - feeRate?: string; - fee?: string; - feeCoin?: string; +getLoanOrder( + params?: GetInstLoanOrderRequestV2, +): Promise> + +================ +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 SmallAssetV3 { - coin: string; - available?: string; - estimatedCoin?: string; - estimatedAmount?: string; - feeDetail?: SmallAssetFeeDetailV3; - cTime?: string; - size?: string; - usdtValue?: 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 SmallAssetsTradeResponseV3 { - fromCoin?: string; - toCoin?: string; - orderId?: string; - result?: 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 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 GetContractsOiRequestV3 { + symbol?: string; + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; } ⋮---- -export interface RateLimitQuotaItemV3 { - uid: string; - quota: string; +export interface GetCurrentFundingRateRequestV3 { + category?: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; } ⋮---- -export interface RateLimitQuotaV3 { - category: 'spot' | 'futures' | string; - quotaList: RateLimitQuotaItemV3[]; - masterSubQuota: string; - masterSubCap: string; - cursor: string; +export interface GetLiquidationsRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; + limit?: string; + cursor?: string; } ⋮---- -export interface StpGroupMemberV3 { - uid: string; - joinedTime: string; +export interface GetHistoryFundingRateRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol: string; + cursor?: string; + limit?: string; } ⋮---- -export interface StpGroupV3 { - groupId: string; - groupName: string; - createdTime: string; - members?: StpGroupMemberV3[]; +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 StpGroupListV3 { - groups: StpGroupV3[]; -} +/** User level. Default: vip0 */ ⋮---- -export interface CreateStpGroupResponseV3 { - groupId: string; - groupName: string; - createdTime: string; +export interface GetSplitRecordsRequestV3 { + symbol?: string; } ⋮---- -export interface StpGroupUidResultV3 { - uid: string; +export interface GetOpenInterestRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; } ⋮---- -export interface StpGroupMembersResponseV3 { - createdTime: string; - successUids: StpGroupUidResultV3[]; - failedUids: StpGroupUidResultV3[]; -} - -================ -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 type OpenInterestHistoryPeriodV3 = + | '5m' + | '15m' + | '30m' + | '1h' + | '2h' + | '4h' + | '6h' + | '12h' + | '1d'; ⋮---- -export interface CandlestickV3 extends Array { - 0: string; // timestamp - 1: string; // open price - 2: string; // high price - 3: string; // low price - 4: string; // close price - 5: string; // volume - 6: string; // turnover +export interface GetOpenInterestHistoryRequestV3 { + symbol: string; + /** Default 5m */ + period: OpenInterestHistoryPeriodV3; } ⋮---- -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 +/** Default 5m */ +⋮---- +export type InterestRateLevelV3 = + | 'vip0' + | 'vip1' + | 'vip2' + | 'vip3' + | 'vip4' + | 'vip5' + | 'vip6' + | 'vip7' + | 'pro1' + | 'pro2' + | 'pro3' + | 'pro4' + | 'pro5' + | 'pro6'; ⋮---- -export interface ContractOiV3 { - symbol: string; - notionalValue: string; - totalNotionalValue: string; - /** Single UID position ratio. Decimal, 0.1 means 10% */ - singlePositionRatio?: string; - /** Master and sub-account position ratio. Decimal, 0.1 means 10% */ - totalPositionRatio?: string; +export interface GetMarginLoansAllRequestV3 { + /** Omit to return every supported coin */ + coin?: string; + /** User level. Default: vip0 */ + level?: InterestRateLevelV3; } ⋮---- -/** Single UID position ratio. Decimal, 0.1 means 10% */ +/** Omit to return every supported coin */ ⋮---- -/** Master and sub-account position ratio. Decimal, 0.1 means 10% */ +/** User level. Default: vip0 */ ⋮---- -export interface CurrentFundingRateV3 { - symbol: string; - fundingRate: string; - fundingRateInterval: string; - nextUpdate: string; - minFundingRate: string; - maxFundingRate: string; - /** Previous settlement, decimal */ - lastFundingRate?: string; - /** Upcoming settlement, decimal */ - nextFundingRate?: string; - /** Decimal. 0.0001 means 0.01%. Docs name. Live rows still use baselnterestRate. */ - baseInterestRate?: string; +export interface GetInterestRateHistoryRequestV3 { + coin: string; /** - * Live spelling of baseInterestRate (lowercase L, not i). - * Decimal. 0.0001 means 0.01%. + * VIP tier. Query name is level, not vipLevel (vipLevel is ignored). + * Omitting it returns the vip0 series. */ - baselnterestRate?: string; - /** Quote-coin notional used for the impact price */ - impactMarginNotional?: string; - cashDividend?: string; - cashDividendNextUpdate?: string; + level?: InterestRateLevelV3; + limit?: string; + /** Pass the cursor from the previous response. */ + cursor?: string; } ⋮---- -/** Previous settlement, decimal */ -⋮---- -/** Upcoming settlement, decimal */ -⋮---- -/** Decimal. 0.0001 means 0.01%. Docs name. Live rows still use baselnterestRate. */ -⋮---- /** - * Live spelling of baseInterestRate (lowercase L, not i). - * Decimal. 0.0001 means 0.01%. + * VIP tier. Query name is level, not vipLevel (vipLevel is ignored). + * Omitting it returns the vip0 series. */ ⋮---- -/** Quote-coin notional used for the impact price */ +/** Pass the cursor from the previous response. */ ⋮---- -export interface DiscountRateTierV3 { - tierStartValue: string; - discountRate: string; -} +export type AnnouncementTypeV3 = + | 'latest_news' + | 'coin_listings' + | 'product_updates' + | 'security' + | 'api_trading' + | 'maintenance_system_updates' + | 'symbol_delisting'; ⋮---- -export interface DiscountRateV3 { - coin: string; - list: DiscountRateTierV3[]; +export interface GetAnnouncementsRequestV3 { + /** zh_CN or en_US. Unsupported languages fall back to English. */ + language: string; + annType?: AnnouncementTypeV3; + startTime?: string; + endTime?: string; + /** Last annId from the previous page. Omit on the first call. */ + cursor?: string; + /** Default 10. Maximum 10. */ + limit?: string; } ⋮---- -export interface HistoryFundingRateV3 { - symbol: string; - fundingRate: string; - fundingRateTimestamp: string; -} +/** zh_CN or en_US. Unsupported languages fall back to English. */ ⋮---- -export interface MarginLoanV3 { - dailyInterest: string; - annualInterest: string; - limit: string; - masterSubLimit?: string; - /** Bitget spelling */ - platformRemaingQuota?: string; -} +/** Last annId from the previous page. Omit on the first call. */ ⋮---- -/** Bitget spelling */ +/** Default 10. Maximum 10. */ ⋮---- -export interface MarginLoanAllV3 extends MarginLoanV3 { - coin: string; +export interface GetCoinsRequestV3 { + /** Omit to return every coin. */ + coin?: string; } ⋮---- -export interface OpenInterestItemV3 { - symbol: string; - openInterest: string; -} +/** Omit to return every coin. */ ⋮---- -export interface OpenInterestV3 { - list: OpenInterestItemV3[]; - ts: string; +export interface GetPositionTierRequestV3 { + category: 'MARGIN' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; + coin?: string; } ⋮---- -export interface OpenInterestHistoryItemV3 { +export interface GetRiskReserveRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; symbol: string; - openInterest: string; - oneSideOpenInterest: string; - openInterestValue: string; - oneSideOpenInterestValue: string; - timestamp: string; + marginCoin?: string; } ⋮---- -export interface OpenInterestHistoryV3 { - list: OpenInterestHistoryItemV3[]; +export interface GetRiskReserveAllRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; } ⋮---- -export interface InterestRateHistoryItemV3 { - coin: string; - dailyInterestRate: string; - annualInterestRate: string; - ts: string; +export interface GetInstrumentsRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol?: string; } ⋮---- -export interface InterestRateHistoryV3 { - list: InterestRateHistoryItemV3[]; - cursor?: string; +export interface GetMarketFeeGroupRequestV3 { + category: 'SPOT' | 'FUTURES'; + group?: 'DEFAULT' | 'GROUP_A' | 'GROUP_B' | 'GROUP_C'; } ⋮---- -export interface AnnouncementV3 { - annId: string; - annTitle: string; - language: string; - annUrl: string; - annType: string; - annSubType?: string; - /** Documented release time. The live payload uses cTime instead. */ - createdTime?: string; - /** Observed live. Unix ms. Docs call this createdTime. */ - cTime?: string; - /** Observed live. Not in the docs example. */ - annDesc?: string; +export interface GetMarketScoreWeightsRequestV3 { + category?: 'SPOT' | 'FUTURES'; } ⋮---- -/** Documented release time. The live payload uses cTime instead. */ -⋮---- -/** Observed live. Unix ms. Docs call this createdTime. */ -⋮---- -/** Observed live. Not in the docs example. */ -⋮---- -export interface MarketCoinChainV3 { - chain: string; - needTag: string; - withdrawable: string; - rechargeable: string; - withdrawFee: string; - extraWithdrawFee: string; - depositConfirm: string; - withdrawConfirm: string; - minDepositAmount: string; - minWithdrawAmount: string; - browserUrl: string; - contractAddress: string | null; - withdrawStep: string; - /** - * Live field. The docs example names this withdrawPrecision. - */ - withdrawMinScale: string; - congestion: string; +export interface GetOrderBookRequestV3 { + category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol: string; + limit?: string; } ⋮---- -/** - * Live field. The docs example names this withdrawPrecision. - */ +export interface GetTickersRequestV3 { + category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; +} ⋮---- -export interface MarketCoinV3 { - coinId?: string; - coin: string; - /** "true" / "false" */ - transfer: string; - areaCoin?: string; - chains: MarketCoinChainV3[]; +export interface GetIndexComponentsRequestV3 { + symbol: string; } ⋮---- -/** "true" / "false" */ +export interface GetRpiOrderBookRequestV3 { + category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol: string; + limit?: string; +} ⋮---- -export interface PositionTierV3 { - tier: string; - minTierValue: string; - maxTierValue: string; - leverage: string; - mmr: string; +export interface GetCashDividendRecordsRequestV3 { + symbol: string; + type: 'pending' | 'paid'; + cursor?: string; + limit?: string; } ⋮---- -export interface RiskReserveRecordV3 { - balance: string; - amount: string; - ts: string; - type?: string; +export interface GetSpotWhaleFlowRequestV3 { + symbol: string; } ⋮---- -export interface RiskReserveV3 { - totalBalance?: string; - coin: string; - riskReserveRecords: RiskReserveRecordV3[]; +export interface GetSpotFundFlowRequestV3 { + symbol: string; + period?: string; } ⋮---- -export interface RiskReserveHourRecordV3 { - amount: string; - balance: string; - ts: string; +export interface GetSpotNetFlowRequestV3 { + symbol: string; } ⋮---- -export interface RiskReserveHourV3 { - coin: string; - riskReserveRecords: RiskReserveHourRecordV3[]; +export interface GetMarginLongShortRequestV3 { + symbol: string; + period?: '24h' | '30d'; + coin?: string; } ⋮---- -export interface RiskReserveAllItemV3 { - symbols: string[]; - coin: string; - balance: string; +export interface GetMarginLoanGrowthRequestV3 { + symbol: string; + period?: string; + coin?: string; } ⋮---- -export interface RiskReserveAllV3 { - list: RiskReserveAllItemV3[]; +export interface GetMarginIsolatedBorrowRequestV3 { + symbol: string; + period?: string; } ⋮---- -export interface InstrumentV3 { +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; + /** Custom request ID. Numbers within 18 digits. */ + requestId?: number; + autoCancel?: 'yes' | 'no'; + /** Required since 30 Sep 2026 */ symbol: string; + /** Required since 30 Sep 2026 */ 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; - /** - * Max decimal places for qty. - * Futures qty must stay within this and be a multiple of quantityMultiplier. - * Spot qty is not bound by quantityMultiplier. - */ - quantityPrecision: string; - quotePrecision: string; - minOrderAmount: string; - maxSymbolOrderNum: string; - maxProductOrderNum: string; - status: - | 'listed' - | 'online' - | 'limit_open' - | 'limit_close' - | 'offline' - | 'restrictedAPI'; - offTime: string; - limitOpenTime: string; - maintainTime: string; - areaSymbol?: string; - - isRwa?: 'YES' | 'NO'; - /** yes = Reality stock token, no = non-Reality stock token */ - isReality?: 'yes' | 'no'; - - // Futures specific fields - makerFeeRate?: string; - takerFeeRate?: string; - openCostUpRatio?: string; - priceMultiplier?: string; - /** - * Futures only. Order qty must be a multiple of this, - * with at most quantityPrecision decimal places. - */ - quantityMultiplier?: string; - type?: 'perpetual' | 'delivery'; - symbolType?: 'crypto' | 'metal' | 'stock' | 'commodity'; - /** Display name. Returned alongside symbolType. */ - fullName?: string; - /** - * metal / energy / stock / etf / crypto. - * Independent of symbolType, which is still returned. - */ - instrumentType?: 'metal' | 'energy' | 'stock' | 'etf' | 'crypto'; - /** Set for traditional-finance pairs. Null for crypto. */ - marketRegion?: string | null; - /** ISIN for traditional-finance pairs. Null for crypto. */ - isin?: string | null; - maxPositionNum?: string; - deliveryTime?: string; - deliveryStartTime?: string; - deliveryPeriod?: string; - /** Launch time - Unix millisecond timestamp. Null for some margin pairs. */ - launchTime?: string | null; - fundInterval?: string; - minLeverage?: string; - maxLeverage?: string; - - // Margin specific fields - isIsolatedBaseBorrowable?: 'YES' | 'NO'; - isIsolatedQuotedBorrowable?: 'YES' | 'NO'; - warningRiskRatio?: string; - liquidationRiskRatio?: string; - maxCrossedLeverage?: string; - maxIsolatedLeverage?: string; - userMinBorrow?: string; + /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ + pxAmendType?: 'yes' | 'no'; } ⋮---- -/** Spot only. Max amount for a single market order. */ -⋮---- -/** - * Max decimal places for qty. - * Futures qty must stay within this and be a multiple of quantityMultiplier. - * Spot qty is not bound by quantityMultiplier. - */ -⋮---- -/** yes = Reality stock token, no = non-Reality stock token */ -⋮---- -// Futures specific fields -⋮---- -/** - * Futures only. Order qty must be a multiple of this, - * with at most quantityPrecision decimal places. - */ +/** Custom request ID. Numbers within 18 digits. */ ⋮---- -/** Display name. Returned alongside symbolType. */ +/** Required since 30 Sep 2026 */ ⋮---- -/** - * metal / energy / stock / etf / crypto. - * Independent of symbolType, which is still returned. - */ +/** Required since 30 Sep 2026 */ ⋮---- -/** Set for traditional-finance pairs. Null for crypto. */ +/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ ⋮---- -/** ISIN for traditional-finance pairs. Null for crypto. */ +export interface CancelAllOrdersRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol?: string; +} ⋮---- -/** Launch time - Unix millisecond timestamp. Null for some margin pairs. */ +export interface CancelBatchOrdersRequestV3 { + orderId?: string; + clientOid?: string; + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol: string; +} ⋮---- -// Margin specific fields +export interface CloseAllPositionsRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; + posSide?: 'long' | 'short'; +} ⋮---- -export interface MarketFeeGroupLabelV3 { - weight: string; - label: string; - symbols: string[]; +export interface CancelOrderRequestV3 { + orderId?: string; + clientOid?: string; + category?: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; } ⋮---- -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; +export type FuturesMarginModeV3 = 'crossed' | 'isolated'; +⋮---- +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'; + /** + * crossed (default) or isolated. + * Under isolated margin, available excludes futures trial funds. + */ + marginMode?: FuturesMarginModeV3; } ⋮---- -/** PRO1~PRO6 only. Taker fee rate in decimal form */ +/** Spot only. Default: no */ ⋮---- -/** Market maker RPI maker fee rate in decimal form */ +/** + * crossed (default) or isolated. + * Under isolated margin, available excludes futures trial funds. + */ ⋮---- -export interface MarketFeeGroupV3 { - category: string; - group: string; - labelList: MarketFeeGroupLabelV3[]; - tierList: MarketFeeGroupTierV3[]; +export interface GetOrderInfoRequestV3 { + orderId?: string; + clientOid?: string; } ⋮---- -export interface MarketScoreWeightV3 { - category: string; - label: string; - symbol: string; - requiredSpread: string; - minMakerVolume: string; - weight: 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 LiquidationV3 { - symbol: string; - side: 'buy' | 'sell'; - price: string; - amount: string; - ts: 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 LiquidationsV3 { - list: LiquidationV3[]; +export interface GetHistoryOrdersRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol?: string; + startTime?: string; + endTime?: string; + limit?: string; cursor?: string; } ⋮---- -export interface OrderBookV3 { - a: string[][]; // asks - [price, size] - b: string[][]; // bids - [price, size] - ts: string; +export interface GetPositionHistoryRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; } ⋮---- -a: string[][]; // asks - [price, size] -b: string[][]; // bids - [price, size] +export interface GetCurrentPositionRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; + posSide?: 'long' | 'short'; +} ⋮---- -export interface RealityOrderBookV3 { +export interface ModifyOrderRequestV3 { + orderId?: string; + clientOid?: string; + qty?: string; + price?: string; + /** Custom request ID. Numbers within 18 digits. */ + requestId?: number; + autoCancel?: 'yes' | 'no'; + /** Required since 30 Sep 2026 */ symbol: string; - a: string[][]; - b: string[][]; - ts: string; + /** Required since 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; + /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ + pxAmendType?: 'yes' | 'no'; } ⋮---- -/** [price, onshoreQty, offshoreQty] */ -export type RealitySegmentedLevelV3 = [string, string, string]; +/** Custom request ID. Numbers within 18 digits. */ ⋮---- -export interface RealityOrderBookSegmentedV3 { - symbol: string; - a: RealitySegmentedLevelV3[]; - b: RealitySegmentedLevelV3[]; - ts: string; -} +/** Required since 30 Sep 2026 */ ⋮---- -export interface RealityFillV3 { - execId: string; - price: string; - size: string; - side: 'buy' | 'sell'; - ts: string; -} +/** Required since 30 Sep 2026 */ ⋮---- -export interface TickerV3 { - category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; +/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ +⋮---- +export interface PlaceRealityOrderRequestV3 { + category?: 'SPOT' | 'MARGIN'; 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; + side: 'buy' | 'sell'; + orderType: 'limit' | 'market'; + qty: string; + price?: string; + clientOid?: string; + /** + * rToken routing. internalization = on-exchange pool only. + * lit_market (default) = internal first, then the public market. + * The 13 Oct changelog applies this to place-reality-order as well. + * The place-reality-order parameter table does not list it yet. + */ + venue?: 'internalization' | 'lit_market'; + /** + * rToken time in force. gtd (default) = current session. + * gtc = 90 days. Same changelog note as venue. + */ + rTokenTimeInForce?: 'gtd' | 'gtc'; } ⋮---- -/** 24h platform turnover; only available for rtoken */ -⋮---- -// Futures specific fields +/** + * rToken routing. internalization = on-exchange pool only. + * lit_market (default) = internal first, then the public market. + * The 13 Oct changelog applies this to place-reality-order as well. + * The place-reality-order parameter table does not list it yet. + */ ⋮---- -export interface ProofOfReservesV3 { - merkleRootHash: string; - totalReserveRatio: string; - list: { - coin: string; - userAssets: string; - platformAssets: string; - reserveRatio: string; - }[]; -} +/** + * rToken time in force. gtd (default) = current session. + * gtc = 90 days. Same changelog note as venue. + */ ⋮---- -export interface IndexComponentV3 { - exchange: string; - spotPair: string; - equivalentPrice: string; - weight: string; +export interface CancelRealityOrderRequestV3 { + category?: 'SPOT' | 'MARGIN'; + symbol: string; + orderId?: string; + clientOid?: string; } ⋮---- -export interface IndexPriceComponentsV3 { +export interface PlaceBatchOrdersRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; symbol: string; - componentList: IndexComponentV3[]; + qty: string; + price?: string; + side: 'buy' | 'sell'; + orderType: 'limit' | 'market'; + timeInForce?: 'ioc' | 'fok' | 'gtc' | 'post_only'; + posSide?: 'long' | 'short'; + clientOid?: string; + reduceOnly?: 'yes' | 'no'; + /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ + pxAmendType?: 'yes' | 'no'; + /** + * Unix ms. Used with receiveWindow. + * If omitted, receiveWindow has no effect. + * An order that reaches the matching engine after requestTime + receiveWindow is canceled. + */ + requestTime?: string; + /** Validity window in ms. Range [10, 60000]. Requires requestTime. */ + receiveWindow?: string; } ⋮---- -export interface RpiSymbolV3 { - category: 'spot' | 'usdt-futures' | 'coin-futures' | 'usdc-futures'; +/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ +⋮---- +/** + * Unix ms. Used with receiveWindow. + * If omitted, receiveWindow has no effect. + * An order that reaches the matching engine after requestTime + receiveWindow is canceled. + */ +⋮---- +/** Validity window in ms. Range [10, 60000]. Requires requestTime. */ +⋮---- +export interface PlaceOrderRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; symbol: string; + /** + * Futures qty must be a multiple of quantityMultiplier + * and have at most quantityPrecision decimal places. + * Both come from /api/v3/market/instruments. Futures only. + */ + qty: string; + price?: string; + side: 'buy' | 'sell'; + /** + * Market orders always run as IOC. + * Staff-confirmed: t.me/bitgetOpenapi/153169. + * timeInForce does not change that. + */ + 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'; + /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ + pxAmendType?: 'yes' | 'no'; + /** Limit orders only. queue1, queue5, counterparty1, or counterparty5 */ + bboLevel?: 'queue1' | 'queue5' | 'counterparty1' | 'counterparty5'; + /** Market orders only. Decimal, default 0.02, range 0.01-0.05 */ + slippageTolerance?: string; + /** + * rToken routing. internalization = on-exchange pool only. + * lit_market (default) = internal first, then the public market. + * Ignored for non-rToken symbols. timeInForce is also ignored for rToken. + */ + venue?: 'internalization' | 'lit_market'; + /** + * rToken time in force. gtd (default) lasts the current session. + * gtc lasts 90 days. Ignored for non-rToken symbols. + */ + rTokenTimeInForce?: 'gtd' | 'gtc'; + /** + * Unix ms. Used with receiveWindow. + * If omitted, receiveWindow has no effect. + * An order that reaches the matching engine after requestTime + receiveWindow is canceled. + */ + requestTime?: string; + /** Validity window in ms. Range [10, 60000]. Requires requestTime. */ + receiveWindow?: string; } ⋮---- -/** RPI order book depth: [price, nonRpiQty, rpiQty] */ -export interface RpiOrderBookV3 { - a: [string, string, string][]; - b: [string, string, string][]; - ts: string; -} +/** + * Futures qty must be a multiple of quantityMultiplier + * and have at most quantityPrecision decimal places. + * Both come from /api/v3/market/instruments. Futures only. + */ ⋮---- -export interface CashDividendRecordV3 { - symbol: string; - exDividendDate: string; - cashDividendPerShare: string; - cashDividendTimestamp: string; -} +/** + * Market orders always run as IOC. + * Staff-confirmed: t.me/bitgetOpenapi/153169. + * timeInForce does not change that. + */ ⋮---- -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; -} +/** Futures only. Defaults to crossed */ ⋮---- -export interface SpotWhaleFlowV3 { - volume: string; - date: string; -} +/** Spot only. Default: no */ ⋮---- -export interface SpotNetFlowV3 { - netFlow: string; - ts: string; -} +/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ ⋮---- -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; -} +/** Limit orders only. queue1, queue5, counterparty1, or counterparty5 */ ⋮---- -export interface MarginLongShortV3 { - longShortRatio: string; - ts: string; -} +/** Market orders only. Decimal, default 0.02, range 0.01-0.05 */ ⋮---- -export interface MarginLoanGrowthV3 { - growthRate: string; - ts: string; -} +/** + * rToken routing. internalization = on-exchange pool only. + * lit_market (default) = internal first, then the public market. + * Ignored for non-rToken symbols. timeInForce is also ignored for rToken. + */ ⋮---- -export interface MarginIsolatedBorrowV3 { - borrowRate: string; - ts: string; -} +/** + * rToken time in force. gtd (default) lasts the current session. + * gtc lasts 90 days. Ignored for non-rToken symbols. + */ ⋮---- -export interface FuturesActiveBuySellV3 { - buyVolume: string; - sellVolume: string; - ts: string; -} +/** + * Unix ms. Used with receiveWindow. + * If omitted, receiveWindow has no effect. + * An order that reaches the matching engine after requestTime + receiveWindow is canceled. + */ ⋮---- -export interface FuturesLongShortV3 { - longRatio: string; - shortRatio: string; - longShortRatio: string; - ts: string; -} +/** Validity window in ms. Range [10, 60000]. Requires requestTime. */ ⋮---- -export interface FuturesPositionLongShortV3 { - longPositionRatio: string; - shortPositionRatio: string; - longShortPositionRatio: string; - ts: string; +export interface CountdownCancelAllRequestV3 { + countdown: string; // seconds until auto-cancel (5-60, or 0 to disable) } ⋮---- -export interface FuturesAccountLongShortV3 { - longAccountRatio: string; - shortAccountRatio: string; - longShortAccountRatio: string; - ts: string; -} +countdown: string; // seconds until auto-cancel (5-60, or 0 to disable) ================ File: README.md @@ -19396,17 +17535,1925 @@ old ones: --> -### Contributions & Pull Requests +### Contributions & Pull Requests + +Contributions are encouraged, I will review any incoming pull requests. See the issues tab for todo items. + + + +## Star History + +[![Star History Chart](https://api.star-history.com/svg?repos=sieblyio/bybit-api,sieblyio/okx-api,sieblyio/binance,sieblyio/bitget-api,sieblyio/bitmart-api,sieblyio/gateio-api,sieblyio/kucoin-api,sieblyio/coinbase-api,sieblyio/orderbooks,sieblyio/accountstate,sieblyio/awesome-crypto-examples&type=Date)](https://star-history.com/#sieblyio/bybit-api&sieblyio/okx-api&sieblyio/binance&sieblyio/bitget-api&sieblyio/bitmart-api&sieblyio/gateio-api&sieblyio/kucoin-api&sieblyio/coinbase-api&sieblyio/orderbooks&sieblyio/accountstate&sieblyio/awesome-crypto-examples&Date) + + + +================ +File: src/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; + /** + * Error 25159 means a low-liquidity period capped leverage at 5x. + * There is no pre-check API for that cap. + */ + 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; +} +⋮---- +/** + * Error 25159 means a low-liquidity period capped leverage at 5x. + * There is no pre-check API for that cap. + */ +⋮---- +/** 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; +} +⋮---- +/** + * UTA account financial-record type. + * https://www.bitget.com/docs/uta/enum + * MARIN_BUY_DEAL and MARIN_SELL_DEAL keep Bitget's spelling. + */ +export type FinancialRecordTypeV3 = + | 'TRANSFER_IN' + | 'TRANSFER_OUT' + | 'CONVERSION_UPON_DELISTING' + | 'ORDER_DEALT_FROZEN_OUT' + | 'ORDER_DEALT_IN' + | 'ORDER_PLF_FEE_OUT' + | 'EXCHANGE_SOURCE_TOKEN_USER_OUT' + | 'EXCHANGE_TARGET_TOKEN_USER_IN' + | 'OPEN_LONG' + | 'OPEN_SHORT' + | 'BUY_DEAL' + | 'SELL_DEAL' + | 'CLOSE_LONG' + | 'CLOSE_SHORT' + | 'FORCE_CLOSE_LONG' + | 'FORCE_CLOSE_SHORT' + | 'BURST_CLOSE_LONG' + | 'BURST_CLOSE_SHORT' + | 'OFFSET_REDUCE_CLOSE_LONG' + | 'OFFSET_REDUCE_CLOSE_SHORT' + | 'FORCE_BUY_SSM' + | 'FORCE_SELL_SSM' + | 'BURST_BUY_SSM' + | 'BURST_SELL_SSM' + | 'RISK_LIQ_USER_IN' + | 'INTEREST_SETTLEMENT_OUT' + | 'CONTRACT_MAIN_SETTLE_FEE_USER_IN' + | 'CONTRACT_MAIN_SETTLE_FEE_USER_OUT' + | 'RISK_LIQ_USER_OUT' + | 'BORROW' + | 'RESERVE_TRANSFER_IN' + | 'RESERVE_TRANSFER_OUT' + | 'REPAYMENT' + | 'INTEREST_REPAYMENT' + | 'LIQ_FUND_OUT' + | 'LIQ_CONVERT_USER_OUT' + | 'LIQ_CONVERT_SYS_IN' + | 'LIQ_CONVERT_SYS_OUT' + | 'LIQ_CONVERT_USER_IN' + | 'LIQ_TRANSFER_IN' + | 'LIQ_TRANSFER_OUT' + | 'LIQ_FUND_IN' + | 'LIQ_FEE' + | 'LIQ_REPAYMENT' + | 'DELIST_MARGIN_TOKEN_SOURCE_USER_OUT' + | 'DELIST_MARGIN_TOKEN_SOURCE_SYS_IN' + | 'DELIST_MARGIN_TOKEN_TARGET_SYS_OUT' + | 'DELIST_MARGIN_TOKEN_TARGET_USER_IN' + | 'CONFISCATE_TOKEN_USER_OUT' + | 'CONFISCATE_TOKEN_SYS_IN' + | 'DELIST_SMALL_BALANCE_USER_OUT' + | 'DELIST_SMALL_BALANCE_SYS_IN' + | 'DELIST_SMALL_LIABILITY_SYS_OUT' + | 'DELIST_SMALL_LIABILITY_USER_IN' + | 'SMALL_ASSET_SOURCE_TOKEN_USER_OUT' + | 'SMALL_ASSET_SOURCE_TOKEN_SYS_IN' + | 'SMALL_ASSET_TARGET_TOKEN_SYS_OUT' + | 'SMALL_ASSET_TARGET_TOKEN_USER_IN' + | 'SMALL_ASSET_FEE_SYS_IN' + | 'TRACE_SHARE_BENEFIT_USER_OUT' + | 'TRACE_SHARE_BENEFIT_SYSTEM_IN' + | 'TRACE_SHARE_BENEFIT_SYSTEM_OUT' + | 'TRACE_SHARE_BENEFIT_USER_IN' + | 'MARGIN_OPEN_LONG' + | 'MARGIN_OPEN_SHORT' + | 'MARIN_BUY_DEAL' + | 'MARIN_SELL_DEAL' + | 'MARGIN_BACK' + | 'INCREASE_MARGIN' + | 'REDUCE_MARGIN' + | 'MARGIN_SETTLE_FEE_USER_IN' + | 'MARGIN_SETTLE_FEE_USER_OUT' + | 'MARGIN_LEVER_ORDER_REFROZEN' + | 'MARGIN_LEVER_ORDER_FROZEN' + | 'MARGIN_LEVER_POS_IN' + | 'MARGIN_OFFSET_IN_SSM_LONG' + | 'MARGIN_OFFSET_IN_SSM_SHORT' + | 'FIXED_OFFSET_IN_SSM_LONG' + | 'FIXED_OFFSET_IN_SSM_SHORT' + | 'FIXED_CLOSE_LONG' + | 'FIXED_CLOSE_SHORT' + | 'FIXED_FORCE_CLOSE_LONG' + | 'FIXED_FORCE_CLOSE_SHORT' + | 'FIXED_BURST_CLOSE_LONG' + | 'FIXED_BURST_CLOSE_SHORT' + | 'FIXED_ADL_CLOSE_LONG' + | 'FIXED_ADL_CLOSE_SHORT' + | 'FIXED_RISK_LIQ_USER_IN' + | 'FIXED_RISK_LIQ_USER_OUT' + | 'FIXED_FORCE_BUY_SSM' + | 'FIXED_FORCE_SELL_SSM' + | 'FIXED_BURST_BUY_SSM' + | 'FIXED_BURST_SELL_SSM' + | 'ON_CHAIN_TRANSFER_REFUND' + | 'ON_CHAIN_TRANSFER_OUT' + | 'MT5_TRANSFER_IN' + | 'MT5_REFUND_IN' + | 'MT5_TRANSFER_OUT' + | 'TRACE_LOCK_USER_OUT' + | 'TRACE_LOCK_USER_IN' + | 'TRACE_TRANSFER_USER_OUT' + | 'TRACE_TRANSFER_USER_IN' + | 'TRACE_TRANSFER_REFUND_IN' + | 'FINANCIAL_TRANSFER_OUT' + | 'FINANCIAL_TRANSFER_IN' + | 'CONVERT_TRANSFER_IN' + | 'CONVERT_TRANSFER_OUT' + | 'BGPAY_TRANSFER_OUT' + | 'BGPAY_REFUND_IN' + | 'RWA_FIXED_SETTLE_FEE_USER_IN' + | 'RWA_FIXED_SETTLE_FEE_USER_OUT' + | 'RWA_CONTRACT_MAIN_SETTLE_FEE_SYSTEM_IN' + | 'RWA_CONTRACT_MAIN_SETTLE_FEE_SYSTEM_OUT' + | 'RWA_CONTRACT_MAIN_SETTLE_FEE_SYSTEM_KEEP_IN' + | 'RWA_CONTRACT_MAIN_SETTLE_FEE_SYSTEM_KEEP_OUT' + | 'RWA_CONTRACT_MAIN_SETTLE_FEE_USER_IN' + | 'RWA_CONTRACT_MAIN_SETTLE_FEE_USER_OUT' + | 'RWA_CONTRACT_REBASE_USER_OPEN_LONG' + | 'RWA_CONTRACT_REBASE_USER_OPEN_SHORT' + | 'RWA_CONTRACT_REBASE_USER_CLOSE_LONG' + | 'RWA_CONTRACT_REBASE_USER_CLOSE_SHORT' + | 'RWA_CONTRACT_REBASE_USER_BUY_IN_SSM' + | 'RWA_CONTRACT_REBASE_USER_SELL_IN_SSM' + | 'RISK_LIQ_DEFAULT_USER_IN' + | 'FIXED_RISK_LIQ_DEFAULT_USER_IN' + | 'BONUS_GRANT_USER_IN' + | 'BONUS_EXPIRE_USER_OUT' + | 'BONUS_TRANSFER_USER_OUT' + | 'WITHDRAW_TRANSFER_OUT' + | 'WITHDRAW_TRANSFER_IN' + | 'DELIVERY_LONG' + | 'DELIVERY_SHORT' + | 'FIXED_DELIVERY_LONG' + | 'FIXED_DELIVERY_SHORT' + | 'REBASE_COIN_SPLIT_OUT' + | 'REBASE_COIN_SPLIT_IN' + | 'REBASE_COIN_MERGE_OUT' + | 'REBASE_COIN_MERGE_IN'; +⋮---- +export interface GetFinancialRecordsRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + coin?: string; + type?: FinancialRecordTypeV3; + 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; + /** Enable Cash+ as collateral. Official field name is allowCashPlus */ + allowCashPlus?: 'yes' | 'no'; +} +⋮---- +/** Required when collateralType=custom. Comma-separated coin names */ +⋮---- +/** Enable Cash+ as collateral. Official field name is allowCashPlus */ +⋮---- +export interface BorrowRequestV3 { + coin: string; + amount: string; + clientOid?: string; +} +⋮---- +export interface GetMaxBorrowableRequestV3 { + coin: string; +} +⋮---- +export interface SetRepayModeRequestV3 { + /** Account-level. Master and each sub-account keep their own setting */ + repayMode: 'auto' | 'manual'; +} +⋮---- +/** Account-level. Master and each sub-account keep their own setting */ +⋮---- +export interface DeleteSubAccountRequestV3 { + subUid: string; +} +⋮---- +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 GetRealityOrderBookSegmentedRequestV3 { + 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'; + /** + * Omit to list sub-accounts under the master. + * Ignored when a sub-account calls this for itself. + */ + uid?: string; + cursor?: string; + limit?: string; +} +⋮---- +/** + * Omit to list sub-accounts under the master. + * Ignored when a sub-account calls this for itself. + */ +⋮---- +export interface SetRateLimitQuotaRequestV3 { + category: 'spot' | 'futures'; + /** + * Required when the master account sets quotas. + * Not required, and ignored, when a sub-account sets its own quota. + */ + uids?: string[]; + quota: string; +} +⋮---- +/** + * Required when the master account sets quotas. + * Not required, and ignored, when a sub-account sets its own quota. + */ +⋮---- +export interface CreateStpGroupRequestV3 { + /** Max 32 characters. Must be unique. */ + groupName: string; +} +⋮---- +/** Max 32 characters. Must be unique. */ +⋮---- +export interface StpGroupMembersRequestV3 { + /** Comma-separated sub-account UIDs. Max 50. */ + uids: string; + groupId: string; +} +⋮---- +/** Comma-separated sub-account UIDs. Max 50. */ + +================ +File: src/types/response/v3/account.ts +================ +// Account Management Response Types +import type { + CollateralTypeV3, + FinancialRecordTypeV3, +} 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. + * Confirmed by Bitget devs but not yet in their docs: the API returns + * parentId as an integer, not only the string shown in the docs. + */ + parentId: string | number; + channelCode: string; + channel: string; + ips: string; + /** + * Confirmed by Bitget devs but not yet in their docs: permType uses + * underscores (read_and_write). readonly is also possible on demo keys. + */ + permType: + | 'read-only' + | 'read-and-write' + | 'read_only' + | 'read_and_write' + | 'readonly'; + permissions: AccountPermissionV3[]; + regisTime: string; + traderType?: 'trader' | 'not_trader'; +} +⋮---- +/** + * Only set when the calling account is a sub-account. + * Confirmed by Bitget devs but not yet in their docs: the API returns + * parentId as an integer, not only the string shown in the docs. + */ +⋮---- +/** + * Confirmed by Bitget devs but not yet in their docs: permType uses + * underscores (read_and_write). readonly is also possible on demo keys. + */ +⋮---- +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'; + repayMode?: 'auto' | 'manual'; + 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; + /** Coin balance before borrowing-related amounts are deducted */ + balanceOriginal?: string; + available: string; + debt: string; + locked: string; + /** Position value in USD */ + positionValue?: string; + /** Account leverage (non-negative) */ + leverage?: string; + /** USDT bonus amount */ + bonus?: string; + /** Interest calculation base */ + interestBase?: string; +} +⋮---- +/** Coin balance before borrowing-related amounts are deducted */ +⋮---- +/** Position value in USD */ +⋮---- +/** Account leverage (non-negative) */ +⋮---- +/** USDT bonus amount */ +⋮---- +/** Interest calculation base */ +⋮---- +export interface BorrowResponseV3 { + orderId: string; + clientOid?: string; +} +⋮---- +export interface MaxBorrowableV3 { + maxBorrowable: string; +} +⋮---- +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: FinancialRecordTypeV3; + 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; +} +⋮---- +export interface StpGroupMemberV3 { + uid: string; + joinedTime: string; +} +⋮---- +export interface StpGroupV3 { + groupId: string; + groupName: string; + createdTime: string; + members?: StpGroupMemberV3[]; +} +⋮---- +export interface StpGroupListV3 { + groups: StpGroupV3[]; +} +⋮---- +export interface CreateStpGroupResponseV3 { + groupId: string; + groupName: string; + createdTime: string; +} +⋮---- +export interface StpGroupUidResultV3 { + uid: string; +} +⋮---- +export interface StpGroupMembersResponseV3 { + createdTime: string; + successUids: StpGroupUidResultV3[]; + failedUids: StpGroupUidResultV3[]; +} -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; + /** Single UID position ratio. Decimal, 0.1 means 10% */ + singlePositionRatio?: string; + /** Master and sub-account position ratio. Decimal, 0.1 means 10% */ + totalPositionRatio?: string; +} +⋮---- +/** Single UID position ratio. Decimal, 0.1 means 10% */ +⋮---- +/** Master and sub-account position ratio. Decimal, 0.1 means 10% */ +⋮---- +export interface CurrentFundingRateV3 { + symbol: string; + fundingRate: string; + fundingRateInterval: string; + nextUpdate: string; + minFundingRate: string; + maxFundingRate: string; + /** Previous settlement, decimal */ + lastFundingRate?: string; + /** Upcoming settlement, decimal */ + nextFundingRate?: string; + /** Decimal. 0.0001 means 0.01%. Docs name. Live rows still use baselnterestRate. */ + baseInterestRate?: string; + /** + * Live spelling of baseInterestRate (lowercase L, not i). + * Decimal. 0.0001 means 0.01%. + */ + baselnterestRate?: string; + /** Quote-coin notional used for the impact price */ + impactMarginNotional?: string; + cashDividend?: string; + cashDividendNextUpdate?: string; +} +⋮---- +/** Previous settlement, decimal */ +⋮---- +/** Upcoming settlement, decimal */ +⋮---- +/** Decimal. 0.0001 means 0.01%. Docs name. Live rows still use baselnterestRate. */ +⋮---- +/** + * Live spelling of baseInterestRate (lowercase L, not i). + * Decimal. 0.0001 means 0.01%. + */ +⋮---- +/** Quote-coin notional used for the impact price */ +⋮---- +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 MarginLoanAllV3 extends MarginLoanV3 { + coin: string; +} +⋮---- +export interface OpenInterestItemV3 { + symbol: string; + openInterest: string; +} +⋮---- +export interface OpenInterestV3 { + list: OpenInterestItemV3[]; + ts: string; +} +⋮---- +export interface OpenInterestHistoryItemV3 { + symbol: string; + openInterest: string; + oneSideOpenInterest: string; + openInterestValue: string; + oneSideOpenInterestValue: string; + timestamp: string; +} +⋮---- +export interface OpenInterestHistoryV3 { + list: OpenInterestHistoryItemV3[]; +} +⋮---- +export interface InterestRateHistoryItemV3 { + coin: string; + dailyInterestRate: string; + annualInterestRate: string; + ts: string; +} +⋮---- +export interface InterestRateHistoryV3 { + list: InterestRateHistoryItemV3[]; + cursor?: string; +} +⋮---- +export interface AnnouncementV3 { + annId: string; + annTitle: string; + language: string; + annUrl: string; + annType: string; + annSubType?: string; + /** Documented release time. The live payload uses cTime instead. */ + createdTime?: string; + /** Observed live. Unix ms. Docs call this createdTime. */ + cTime?: string; + /** Observed live. Not in the docs example. */ + annDesc?: string; +} +⋮---- +/** Documented release time. The live payload uses cTime instead. */ +⋮---- +/** Observed live. Unix ms. Docs call this createdTime. */ +⋮---- +/** Observed live. Not in the docs example. */ +⋮---- +export interface MarketCoinChainV3 { + chain: string; + needTag: string; + withdrawable: string; + rechargeable: string; + withdrawFee: string; + extraWithdrawFee: string; + depositConfirm: string; + withdrawConfirm: string; + minDepositAmount: string; + minWithdrawAmount: string; + browserUrl: string; + contractAddress: string | null; + withdrawStep: string; + /** + * Live field. The docs example names this withdrawPrecision. + */ + withdrawMinScale: string; + congestion: string; +} +⋮---- +/** + * Live field. The docs example names this withdrawPrecision. + */ +⋮---- +export interface MarketCoinV3 { + coinId?: string; + coin: string; + /** "true" / "false" */ + transfer: string; + areaCoin?: string; + chains: MarketCoinChainV3[]; +} +⋮---- +/** "true" / "false" */ +⋮---- +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; + /** + * Max decimal places for qty. + * Futures qty must stay within this and be a multiple of quantityMultiplier. + * Spot qty is not bound by quantityMultiplier. + */ + 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; + /** + * Futures only. Order qty must be a multiple of this, + * with at most quantityPrecision decimal places. + */ + quantityMultiplier?: string; + type?: 'perpetual' | 'delivery'; + symbolType?: 'crypto' | 'metal' | 'stock' | 'commodity'; + /** Display name. Returned alongside symbolType. */ + fullName?: string; + /** + * metal / energy / stock / etf / crypto. + * Independent of symbolType, which is still returned. + */ + instrumentType?: 'metal' | 'energy' | 'stock' | 'etf' | 'crypto'; + /** Set for traditional-finance pairs. Null for crypto. */ + marketRegion?: string | null; + /** ISIN for traditional-finance pairs. Null for crypto. */ + isin?: string | null; + 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. */ +⋮---- +/** + * Max decimal places for qty. + * Futures qty must stay within this and be a multiple of quantityMultiplier. + * Spot qty is not bound by quantityMultiplier. + */ +⋮---- +/** yes = Reality stock token, no = non-Reality stock token */ +⋮---- +// Futures specific fields +⋮---- +/** + * Futures only. Order qty must be a multiple of this, + * with at most quantityPrecision decimal places. + */ +⋮---- +/** Display name. Returned alongside symbolType. */ +⋮---- +/** + * metal / energy / stock / etf / crypto. + * Independent of symbolType, which is still returned. + */ +⋮---- +/** Set for traditional-finance pairs. Null for crypto. */ +⋮---- +/** ISIN for traditional-finance pairs. Null for crypto. */ +⋮---- +/** 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; +} +⋮---- +/** [price, onshoreQty, offshoreQty] */ +export type RealitySegmentedLevelV3 = [string, string, string]; +⋮---- +export interface RealityOrderBookSegmentedV3 { + symbol: string; + a: RealitySegmentedLevelV3[]; + b: RealitySegmentedLevelV3[]; + 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 @@ -19650,6 +19697,7 @@ import { GetStockPlusHistoryExecutionsRequestV3, GetStockPlusHistoryOrdersRequestV3, GetStockPlusIntradayRequestV3, + GetStockPlusMaxPurchaseRequestV3, GetStockPlusOptionChainInfoRequestV3, GetStockPlusOptionExpiryDateRequestV3, GetStockPlusOptionQuoteRequestV3, @@ -19922,6 +19970,7 @@ import { StockPlusHistoryExecutionsV3, StockPlusHistoryOrdersV3, StockPlusIntradayV3, + StockPlusMaxPurchaseV3, StockPlusModifyOrderResponseV3, StockPlusOptionChainInfoV3, StockPlusOptionExpiryDateV3, @@ -20596,6 +20645,10 @@ getStockPlusOrderDetail( params: GetStockPlusOrderDetailRequestV3, ): Promise> ⋮---- +getStockPlusMaxPurchase( + params: GetStockPlusMaxPurchaseRequestV3, +): Promise> +⋮---- getStockPlusTodayExecutions( params?: GetStockPlusTodayExecutionsRequestV3, ): Promise> @@ -20793,12 +20846,24 @@ getMaxWithdrawal( */ getFinancialRecords(params: GetFinancialRecordsRequestV3): Promise< APIResponse<{ - list: FinancialRecordV3[]; - cursor: string; + /** + * Undocumented but staff-confirmed: null when there are no records. + * @see https://t.me/bitgetOpenapi/153704 + */ + list: FinancialRecordV3[] | null; + /** Undocumented but staff-confirmed: null when pagination is exhausted. */ + cursor: string | null; }> > { return this.getPrivate('/api/v3/account/financial-records', params); ⋮---- +/** + * Undocumented but staff-confirmed: null when there are no records. + * @see https://t.me/bitgetOpenapi/153704 + */ +⋮---- +/** Undocumented but staff-confirmed: null when pagination is exhausted. */ +⋮---- getFundingFinancialRecords( params?: GetFundingFinancialRecordsRequestV3, ): Promise< @@ -21389,11 +21454,20 @@ getTradeFills(params?: GetFillsRequestV3): Promise< */ getCurrentPosition(params: GetCurrentPositionRequestV3): Promise< APIResponse<{ - list: CurrentPositionV3[]; + /** + * Undocumented but staff-confirmed: null when there are no matching positions. + * @see https://t.me/bitgetOpenapi/153786 + */ + list: CurrentPositionV3[] | null; }> > { return this.getPrivate('/api/v3/position/current-position', params); ⋮---- +/** + * Undocumented but staff-confirmed: null when there are no matching positions. + * @see https://t.me/bitgetOpenapi/153786 + */ +⋮---- /** * Get Positions History */ @@ -21993,7 +22067,7 @@ File: package.json ================ { "name": "bitget-api", - "version": "3.2.7", + "version": "3.2.8", "description": "Complete Node.js & JavaScript SDK for Bitget V1-V3 REST APIs & WebSockets, with TypeScript & end-to-end tests.", "scripts": { "test": "jest", From 942e4023e693af1754037a46df8e73df6f818553 Mon Sep 17 00:00:00 2001 From: JJ-Cro Date: Tue, 3 Nov 2026 12:45:26 +0100 Subject: [PATCH 4/9] chore: drop added tests --- test/v2/response-types.test.ts | 57 ----------------------------- test/v3/response-types.test.ts | 61 ------------------------------- test/v3/stockplus.test.ts | 55 ---------------------------- test/websockets/v3-topics.test.ts | 47 ------------------------ test/ws.util.ts | 14 ++----- 5 files changed, 4 insertions(+), 230 deletions(-) delete mode 100644 test/v2/response-types.test.ts delete mode 100644 test/v3/response-types.test.ts delete mode 100644 test/v3/stockplus.test.ts delete mode 100644 test/websockets/v3-topics.test.ts diff --git a/test/v2/response-types.test.ts b/test/v2/response-types.test.ts deleted file mode 100644 index fca7cf46..00000000 --- a/test/v2/response-types.test.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { RestClientV2 } from '../../src/rest-client-v2.js'; - -describe('Bitget V2 empty pending orders', () => { - const api = new RestClientV2(); - - afterEach(() => jest.restoreAllMocks()); - - it.each([null, []])( - 'accepts an empty order list: %p', - async (entrustedList) => { - const response: Awaited< - ReturnType - > = { - code: '00000', - msg: 'success', - requestTime: 1, - data: { entrustedList, endId: '' }, - }; - const request = jest.spyOn(api, 'getPrivate').mockResolvedValue(response); - const params = { productType: 'USDT-FUTURES' as const }; - - expect(await api.getFuturesOpenOrders(params)).toBe(response); - expect(request).toHaveBeenCalledWith( - '/api/v2/mix/order/orders-pending', - params, - ); - }, - ); - - it.each([null, []])( - 'accepts an empty plan order list: %p', - async (entrustedList) => { - const response: Awaited< - ReturnType - > = { - code: '00000', - msg: 'success', - requestTime: 1, - data: { entrustedList, endId: '' }, - }; - const request = jest.spyOn(api, 'getPrivate').mockResolvedValue(response); - for (const planType of [ - 'normal_plan', - 'track_plan', - 'profit_loss', - ] as const) { - const params = { productType: 'USDT-FUTURES' as const, planType }; - - expect(await api.getFuturesPlanOrders(params)).toBe(response); - expect(request).toHaveBeenLastCalledWith( - '/api/v2/mix/order/orders-plan-pending', - params, - ); - } - }, - ); -}); diff --git a/test/v3/response-types.test.ts b/test/v3/response-types.test.ts deleted file mode 100644 index d2d6860b..00000000 --- a/test/v3/response-types.test.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { RestClientV3 } from '../../src/rest-client-v3.js'; - -describe('Bitget V3 empty responses', () => { - const api = new RestClientV3(); - - afterEach(() => jest.restoreAllMocks()); - - it.each([null, []])('accepts an empty position list: %p', async (list) => { - const response: Awaited> = { - code: '00000', - msg: 'success', - requestTime: 1, - data: { list }, - }; - const request = jest.spyOn(api, 'getPrivate').mockResolvedValue(response); - const params = { category: 'USDT-FUTURES' as const, symbol: 'BTCUSDT' }; - - expect(await api.getCurrentPosition(params)).toBe(response); - expect(request).toHaveBeenCalledWith( - '/api/v3/position/current-position', - params, - ); - }); - - it.each([ - { list: null, cursor: null }, - { list: [], cursor: null }, - { list: [], cursor: '' }, - { - list: [ - { - category: 'USDT-FUTURES', - id: '1', - symbol: 'BTCUSDT', - coin: 'USDT', - type: 'TRANSFER_IN' as const, - amount: '10', - fee: '0', - balance: '10', - ts: '1', - }, - ], - cursor: '1', - }, - ])('preserves financial record pagination: %p', async (data) => { - const response: Awaited> = { - code: '00000', - msg: 'success', - requestTime: 1, - data, - }; - const request = jest.spyOn(api, 'getPrivate').mockResolvedValue(response); - const params = { category: 'USDT-FUTURES' as const }; - - expect(await api.getFinancialRecords(params)).toBe(response); - expect(request).toHaveBeenCalledWith( - '/api/v3/account/financial-records', - params, - ); - }); -}); diff --git a/test/v3/stockplus.test.ts b/test/v3/stockplus.test.ts deleted file mode 100644 index bc2d8a51..00000000 --- a/test/v3/stockplus.test.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { InternalAxiosRequestConfig } from 'axios'; - -import { - GetStockPlusMaxPurchaseRequestV3, - RestClientV3, - StockPlusMaxPurchaseV3, -} from '../../src/index.js'; - -describe('Bitget Stock+ max purchase', () => { - it.each<{ - params: GetStockPlusMaxPurchaseRequestV3; - data: StockPlusMaxPurchaseV3; - }>([ - { - params: { symbol: 'AAPL.US', orderType: 'MO', side: 'Buy' }, - data: { cashMaxQty: '', marginMaxQty: '' }, - }, - { - params: { - symbol: 'AAPL.US', - orderType: 'LO', - side: 'Sell', - price: '200', - currency: 'USD', - orderId: '1', - }, - data: { cashMaxQty: '100', marginMaxQty: '300' }, - }, - ])('queries max purchase with $params', async ({ params, data }) => { - const response = { code: '00000', msg: 'success', requestTime: 1, data }; - const adapter = jest.fn(async (config: InternalAxiosRequestConfig) => ({ - data: response, - status: 200, - statusText: 'OK', - headers: {}, - config, - })); - const api = new RestClientV3({}, { adapter }); - const privateRequest = jest.spyOn(api, 'getPrivate'); - - const result = await api.getStockPlusMaxPurchase(params); - - expect(result).toEqual(response); - expect(privateRequest).toHaveBeenCalledWith( - '/api/v3/stockplus/trade/max-purchase', - params, - ); - expect(adapter).toHaveBeenCalledTimes(1); - expect(adapter.mock.calls[0][0]).toMatchObject({ - method: 'get', - url: 'https://api.bitget.com/api/v3/stockplus/trade/max-purchase', - params, - }); - }); -}); diff --git a/test/websockets/v3-topics.test.ts b/test/websockets/v3-topics.test.ts deleted file mode 100644 index 1c576e6d..00000000 --- a/test/websockets/v3-topics.test.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { - BitgetInstTypeV3, - WsPublicTopicV3, -} from '../../src/types/websockets/ws-general.js'; -import { isPrivateChannel } from '../../src/util/websocket-util.js'; -import { WebsocketClientV3 } from '../../src/websocket-client-v3.js'; - -class TestWebsocketClientV3 extends WebsocketClientV3 { - public subscribeTopicsForWsKey = jest.fn().mockResolvedValue(undefined); -} - -describe('Bitget V3 financial parameter channels', () => { - const subscriptions: { - topic: WsPublicTopicV3; - payload: { instType: BitgetInstTypeV3; symbol?: string; coin?: string }; - }[] = [ - { topic: 'instruments', payload: { instType: 'usdt-futures' } }, - { - topic: 'open-interest-limit', - payload: { instType: 'usdt-futures', symbol: 'BTCUSDT' }, - }, - { - topic: 'position-tier', - payload: { instType: 'usdt-futures', symbol: 'BTCUSDT' }, - }, - { - topic: 'funding-rate', - payload: { instType: 'usdt-futures', symbol: 'BTCUSDT' }, - }, - { topic: 'margin-loan', payload: { instType: 'uta', coin: 'BTC' } }, - { topic: 'margin-coins', payload: { instType: 'uta', coin: 'BTC' } }, - ]; - - it.each(subscriptions)( - 'subscribes to $topic without authentication', - async (request) => { - const api = new TestWebsocketClientV3(); - - expect(isPrivateChannel(request.topic)).toBe(false); - await api.subscribe(request, 'v3Public'); - expect(api.subscribeTopicsForWsKey).toHaveBeenCalledWith( - [request], - 'v3Public', - ); - }, - ); -}); diff --git a/test/ws.util.ts b/test/ws.util.ts index dfe4e763..4f69ea6d 100644 --- a/test/ws.util.ts +++ b/test/ws.util.ts @@ -1,9 +1,5 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ -import { - DefaultLogger, - WebsocketClientV2, - WebsocketClientV3, -} from '../src/index.js'; +import { DefaultLogger, WebsocketClientLegacyV1 } from '../src/index.js'; // eslint-disable-next-line @typescript-eslint/no-unused-vars export function getSilentLogger(_logHint?: string): DefaultLogger { @@ -31,7 +27,7 @@ type WsClientEvent = /** Resolves a promise if an event is seen before a timeout (defaults to 4.5 seconds) */ export function waitForSocketEvent( - wsClient: WebsocketClientV2 | WebsocketClientV3, + wsClient: WebsocketClientLegacyV1, event: WsClientEvent, timeoutMs: number = 10 * 1000, ) { @@ -78,9 +74,7 @@ export function waitForSocketEvent( }); } -export function listenToSocketEvents( - wsClient: WebsocketClientV2 | WebsocketClientV3, -) { +export function listenToSocketEvents(wsClient: WebsocketClientLegacyV1) { const retVal: Record< 'update' | 'open' | 'response' | 'close' | 'error', typeof jest.fn @@ -110,7 +104,7 @@ export function listenToSocketEvents( }; } -export function logAllEvents(wsClient: WebsocketClientV2 | WebsocketClientV3) { +export function logAllEvents(wsClient: WebsocketClientLegacyV1) { wsClient.on('update', (_data) => { // console.log('wsUpdate: ', JSON.stringify(data, null, 2)); }); From 8b4bb685c76f48176cda6a03041327f766540411 Mon Sep 17 00:00:00 2001 From: JJ-Cro Date: Fri, 6 Nov 2026 09:22:18 +0100 Subject: [PATCH 5/9] fix(v3): remap rToken venue enum (internal_market, lit_market, default) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bitget UTA 5 Nov 2026: internalization → internal_market; place accepts internal_market | lit_market (omit = default); order details may return default for the former lit_market meaning. Types + JSDoc only. --- src/types/request/v3/trade.ts | 20 ++++++++++++-------- src/types/response/v3/trade.ts | 7 ++++--- src/types/websockets/ws-api-request.ts | 8 +++++--- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/types/request/v3/trade.ts b/src/types/request/v3/trade.ts index d6541a73..74ff344d 100644 --- a/src/types/request/v3/trade.ts +++ b/src/types/request/v3/trade.ts @@ -181,12 +181,13 @@ export interface PlaceRealityOrderRequestV3 { price?: string; clientOid?: string; /** - * rToken routing. internalization = on-exchange pool only. - * lit_market (default) = internal first, then the public market. - * The 13 Oct changelog applies this to place-reality-order as well. - * The place-reality-order parameter table does not list it yet. + * rToken routing. Accepted: internal_market | lit_market. Omit for default. + * internal_market = on-exchange only (not submitted to the U.S. stock broker). + * lit_market = broker only (not matched on-exchange). + * Omit / default = internal first at best price, then unfilled to broker. + * Live since 5 Nov 2026 (internalization renamed; old lit_market meaning is now default). */ - venue?: 'internalization' | 'lit_market'; + venue?: 'internal_market' | 'lit_market'; /** * rToken time in force. gtd (default) = current session. * gtc = 90 days. Same changelog note as venue. @@ -275,11 +276,14 @@ export interface PlaceOrderRequestV3 { /** Market orders only. Decimal, default 0.02, range 0.01-0.05 */ slippageTolerance?: string; /** - * rToken routing. internalization = on-exchange pool only. - * lit_market (default) = internal first, then the public market. + * rToken routing. Accepted: internal_market | lit_market. Omit for default. + * internal_market = on-exchange only (not submitted to the U.S. stock broker). + * lit_market = broker only (not matched on-exchange). + * Omit / default = internal first at best price, then unfilled to broker. * Ignored for non-rToken symbols. timeInForce is also ignored for rToken. + * Live since 5 Nov 2026 (internalization renamed; old lit_market meaning is now default). */ - venue?: 'internalization' | 'lit_market'; + venue?: 'internal_market' | 'lit_market'; /** * rToken time in force. gtd (default) lasts the current session. * gtc lasts 90 days. Ignored for non-rToken symbols. diff --git a/src/types/response/v3/trade.ts b/src/types/response/v3/trade.ts index 9f100878..46b60fbe 100644 --- a/src/types/response/v3/trade.ts +++ b/src/types/response/v3/trade.ts @@ -64,10 +64,11 @@ export interface OrderInfoV3 { avgPrice: string; timeInForce: string; /** - * rToken routing. internalization or lit_market. - * Also pushed on the WS order channel. + * rToken routing returned on order details / WS order channel. + * internal_market = on-exchange only; lit_market = broker only; + * default = internal first then broker (former lit_market meaning, since 5 Nov 2026). */ - venue?: 'internalization' | 'lit_market' | string; + venue?: 'internal_market' | 'lit_market' | 'default' | string; /** rToken time in force. gtd = current session, gtc = 90 days. */ rTokenTimeInForce?: 'gtd' | 'gtc' | string; orderStatus: string; diff --git a/src/types/websockets/ws-api-request.ts b/src/types/websockets/ws-api-request.ts index b3894555..659d8092 100644 --- a/src/types/websockets/ws-api-request.ts +++ b/src/types/websockets/ws-api-request.ts @@ -28,10 +28,12 @@ export interface WSAPIPlaceOrderRequestV3 { /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ pxAmendType?: 'yes' | 'no'; /** - * rToken routing. internalization or lit_market (default). - * Ignored for non-rToken symbols. + * rToken routing. Accepted: internal_market | lit_market. Omit for default. + * internal_market = on-exchange only; lit_market = broker only. + * Omit / default = internal first, then broker. Ignored for non-rToken symbols. + * Live since 5 Nov 2026. */ - venue?: 'internalization' | 'lit_market'; + venue?: 'internal_market' | 'lit_market'; /** rToken time in force. gtd (default) or gtc (90 days). */ rTokenTimeInForce?: 'gtd' | 'gtc'; /** From 92ecdc740e6618aa8e3c47dbb36c92f995cd6136 Mon Sep 17 00:00:00 2001 From: JJ-Cro sync bot Date: Fri, 6 Nov 2026 09:22:43 +0100 Subject: [PATCH 6/9] chore: regenerate endpoint docs and examples --- llms.txt | 1452 +++++++++++++++++++++++++++--------------------------- 1 file changed, 733 insertions(+), 719 deletions(-) diff --git a/llms.txt b/llms.txt index 430ea383..2ff923cb 100644 --- a/llms.txt +++ b/llms.txt @@ -12820,348 +12820,6 @@ export interface GetStrategySubOrdersRequestV3 { cursor?: string; } -================ -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; - /** - * rToken routing. internalization or lit_market. - * Also pushed on the WS order channel. - */ - venue?: 'internalization' | 'lit_market' | string; - /** rToken time in force. gtd = current session, gtc = 90 days. */ - rTokenTimeInForce?: 'gtd' | 'gtc' | string; - orderStatus: string; - posSide: string; - holdMode: string; - delegateType?: string; - reduceOnly: string; - feeDetail: FeeDetailV3[]; - cancelReason: string; - execType: string; - stpMode?: string; - createdTime: string; - updatedTime: string; -} -⋮---- -/** - * rToken routing. internalization or lit_market. - * Also pushed on the WS order channel. - */ -⋮---- -/** rToken time in force. gtd = current session, gtc = 90 days. */ -⋮---- -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/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'; - /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ - pxAmendType?: 'yes' | 'no'; - /** - * rToken routing. internalization or lit_market (default). - * Ignored for non-rToken symbols. - */ - venue?: 'internalization' | 'lit_market'; - /** rToken time in force. gtd (default) or gtc (90 days). */ - rTokenTimeInForce?: 'gtd' | 'gtc'; - /** - * Broker rebate code. Lifted onto the WS request envelope. - * It is not sent inside args. Omit it to use the SDK broker code. - * Place-order docs: top-level apiCode. Batch-place uses the same field. - * Staff-confirmed: t.me/bitgetOpenapi/153820. - */ - apiCode?: 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 */ -⋮---- -/** Spot only. Default: no */ -⋮---- -/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ -⋮---- -/** - * rToken routing. internalization or lit_market (default). - * Ignored for non-rToken symbols. - */ -⋮---- -/** rToken time in force. gtd (default) or gtc (90 days). */ -⋮---- -/** - * Broker rebate code. Lifted onto the WS request envelope. - * It is not sent inside args. Omit it to use the SDK broker code. - * Place-order docs: top-level apiCode. Batch-place uses the same field. - * Staff-confirmed: t.me/bitgetOpenapi/153820. - */ - ================ File: src/types/websockets/ws-general.ts ================ @@ -16494,323 +16152,306 @@ export interface GetMarginLoanGrowthRequestV3 { 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; - /** Custom request ID. Numbers within 18 digits. */ - requestId?: number; - autoCancel?: 'yes' | 'no'; - /** Required since 30 Sep 2026 */ - symbol: string; - /** Required since 30 Sep 2026 */ - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ - pxAmendType?: 'yes' | 'no'; -} -⋮---- -/** Custom request ID. Numbers within 18 digits. */ -⋮---- -/** Required since 30 Sep 2026 */ +export interface GetMarginIsolatedBorrowRequestV3 { + symbol: string; + period?: string; +} ⋮---- -/** Required since 30 Sep 2026 */ +export interface GetFuturesTradingDataRequestV3 { + symbol: string; + period?: string; +} + +================ +File: src/types/response/v3/trade.ts +================ +export interface BatchModifyOrderResponseV3 { + orderId: string; + clientOid: string; +} ⋮---- -/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ +export interface CancelAllOrdersResponseV3 { + list: { + orderId: string; + clientOid: string; + code: string; + msg: string; + }[]; +} ⋮---- -export interface CancelAllOrdersRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol?: string; +export interface CancelBatchOrdersResponseV3 { + orderId: string; + clientOid: string; + code?: string; + msg?: string; } ⋮---- -export interface CancelBatchOrdersRequestV3 { - orderId?: string; - clientOid?: string; - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol: string; +export interface CloseAllPositionsResponseV3 { + list: { + orderId: string; + clientOid: string; + code: string; + msg: string; + }[]; } ⋮---- -export interface CloseAllPositionsRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - posSide?: 'long' | 'short'; +export interface CancelOrderResponseV3 { + orderId: string; + clientOid: string; } ⋮---- -export interface CancelOrderRequestV3 { - orderId?: string; - clientOid?: string; - category?: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; +export interface GetMaxOpenAvailableResponseV3 { + available: string; + maxOpen: string; + buyOpenCost: string; + sellOpenCost: string; + maxBuyOpen: string; + maxSellOpen: string; + maxBuyAvailable?: string; + maxSellAvailable?: string; } ⋮---- -export type FuturesMarginModeV3 = 'crossed' | 'isolated'; +export interface FeeDetailV3 { + feeCoin: string; + fee: string; +} ⋮---- -export interface GetMaxOpenAvailableRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; +export interface OrderInfoV3 { + orderId: string; + clientOid: string; + category: string; symbol: string; - orderType: 'limit' | 'market'; - side: 'buy' | 'sell'; - price?: string; - size?: string; - /** Spot only. Default: no */ - autoBorrow?: 'yes' | 'no'; + orderType: string; + side: string; + price: string; + qty: string; + amount: string; + cumExecQty: string; + cumExecValue: string; + avgPrice: string; + timeInForce: string; /** - * crossed (default) or isolated. - * Under isolated margin, available excludes futures trial funds. + * rToken routing returned on order details / WS order channel. + * internal_market = on-exchange only; lit_market = broker only; + * default = internal first then broker (former lit_market meaning, since 5 Nov 2026). */ - marginMode?: FuturesMarginModeV3; + venue?: 'internal_market' | 'lit_market' | 'default' | string; + /** rToken time in force. gtd = current session, gtc = 90 days. */ + rTokenTimeInForce?: 'gtd' | 'gtc' | string; + orderStatus: string; + posSide: string; + holdMode: string; + delegateType?: string; + reduceOnly: string; + feeDetail: FeeDetailV3[]; + cancelReason: string; + execType: string; + stpMode?: string; + createdTime: string; + updatedTime: string; } ⋮---- -/** Spot only. Default: no */ -⋮---- /** - * crossed (default) or isolated. - * Under isolated margin, available excludes futures trial funds. + * rToken routing returned on order details / WS order channel. + * internal_market = on-exchange only; lit_market = broker only; + * default = internal first then broker (former lit_market meaning, since 5 Nov 2026). */ ⋮---- -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; -} +/** rToken time in force. gtd = current session, gtc = 90 days. */ ⋮---- -export interface GetUnfilledOrdersRequestV3 { - category?: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol?: string; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; -} +export type FillCategoryV3 = + | 'spot' + | 'margin' + | 'usdt-futures' + | 'coin-futures' + | 'usdc-futures' + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; ⋮---- -export interface GetHistoryOrdersRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol?: string; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; +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 GetPositionHistoryRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: 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 GetCurrentPositionRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - posSide?: 'long' | 'short'; +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 ModifyOrderRequestV3 { - orderId?: string; - clientOid?: string; - qty?: string; - price?: string; - /** Custom request ID. Numbers within 18 digits. */ - requestId?: number; - autoCancel?: 'yes' | 'no'; - /** Required since 30 Sep 2026 */ +export interface PositionHistoryV3 { + positionId: string; + category: string; symbol: string; - /** Required since 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; - /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ - pxAmendType?: 'yes' | 'no'; + 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; } ⋮---- -/** Custom request ID. Numbers within 18 digits. */ -⋮---- -/** Required since 30 Sep 2026 */ -⋮---- -/** Required since 30 Sep 2026 */ -⋮---- -/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ +/** Cash dividend, USDT */ ⋮---- -export interface PlaceRealityOrderRequestV3 { - category?: 'SPOT' | 'MARGIN'; +export interface CurrentPositionV3 { + category: string; symbol: string; - side: 'buy' | 'sell'; - orderType: 'limit' | 'market'; - qty: string; - price?: string; - clientOid?: string; - /** - * rToken routing. internalization = on-exchange pool only. - * lit_market (default) = internal first, then the public market. - * The 13 Oct changelog applies this to place-reality-order as well. - * The place-reality-order parameter table does not list it yet. - */ - venue?: 'internalization' | 'lit_market'; - /** - * rToken time in force. gtd (default) = current session. - * gtc = 90 days. Same changelog note as venue. - */ - rTokenTimeInForce?: 'gtd' | 'gtc'; + 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; } ⋮---- -/** - * rToken routing. internalization = on-exchange pool only. - * lit_market (default) = internal first, then the public market. - * The 13 Oct changelog applies this to place-reality-order as well. - * The place-reality-order parameter table does not list it yet. - */ +/** Cash dividend, USDT */ ⋮---- -/** - * rToken time in force. gtd (default) = current session. - * gtc = 90 days. Same changelog note as venue. - */ +export interface LoanDataDebtCoinV3 { + coin: string; + debt: string; + interestFreeAmount: string; + interestRateNextHour: string; +} ⋮---- -export interface CancelRealityOrderRequestV3 { - category?: 'SPOT' | 'MARGIN'; - symbol: string; - orderId?: string; - clientOid?: string; +export interface LoanDataV3 { + currentLoans: string; + interestPaymentTime: string; + debtCoinList: LoanDataDebtCoinV3[]; } ⋮---- -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'; - /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ - pxAmendType?: 'yes' | 'no'; - /** - * Unix ms. Used with receiveWindow. - * If omitted, receiveWindow has no effect. - * An order that reaches the matching engine after requestTime + receiveWindow is canceled. - */ - requestTime?: string; - /** Validity window in ms. Range [10, 60000]. Requires requestTime. */ - receiveWindow?: string; +export interface ModifyOrderResponseV3 { + orderId: string; + clientOid: string; } ⋮---- -/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ +export interface PlaceBatchOrdersResponseV3 { + orderId: string; + clientOid: string; + code?: string; + msg?: string; +} ⋮---- -/** - * Unix ms. Used with receiveWindow. - * If omitted, receiveWindow has no effect. - * An order that reaches the matching engine after requestTime + receiveWindow is canceled. - */ +export interface PlaceOrderResponseV3 { + orderId: string; + clientOid: string; +} ⋮---- -/** Validity window in ms. Range [10, 60000]. Requires requestTime. */ +export interface PositionAdlRankV3 { + symbol: string; + marginCoin: string; + adlRank: string; + holdSide: 'long' | 'short'; +} + +================ +File: src/types/websockets/ws-api-request.ts +================ +import type { FuturesMarginModeV3 } from '../request/v3/trade.js'; ⋮---- -export interface PlaceOrderRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; +export interface WSAPIPlaceOrderRequestV3 { symbol: string; - /** - * Futures qty must be a multiple of quantityMultiplier - * and have at most quantityPrecision decimal places. - * Both come from /api/v3/market/instruments. Futures only. - */ + orderType: 'limit' | 'market'; qty: string; price?: string; side: 'buy' | 'sell'; - /** - * Market orders always run as IOC. - * Staff-confirmed: t.me/bitgetOpenapi/153169. - * timeInForce does not change that. - */ - orderType: 'limit' | 'market'; - timeInForce?: 'ioc' | 'fok' | 'gtc' | 'post_only' | 'rpi'; posSide?: 'long' | 'short'; - clientOid?: string; - reduceOnly?: 'yes' | 'no'; + 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'; @@ -16820,81 +16461,54 @@ export interface PlaceOrderRequestV3 { 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'; /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ pxAmendType?: 'yes' | 'no'; - /** Limit orders only. queue1, queue5, counterparty1, or counterparty5 */ - bboLevel?: 'queue1' | 'queue5' | 'counterparty1' | 'counterparty5'; - /** Market orders only. Decimal, default 0.02, range 0.01-0.05 */ - slippageTolerance?: string; - /** - * rToken routing. internalization = on-exchange pool only. - * lit_market (default) = internal first, then the public market. - * Ignored for non-rToken symbols. timeInForce is also ignored for rToken. - */ - venue?: 'internalization' | 'lit_market'; /** - * rToken time in force. gtd (default) lasts the current session. - * gtc lasts 90 days. Ignored for non-rToken symbols. + * rToken routing. Accepted: internal_market | lit_market. Omit for default. + * internal_market = on-exchange only; lit_market = broker only. + * Omit / default = internal first, then broker. Ignored for non-rToken symbols. + * Live since 5 Nov 2026. */ + venue?: 'internal_market' | 'lit_market'; + /** rToken time in force. gtd (default) or gtc (90 days). */ rTokenTimeInForce?: 'gtd' | 'gtc'; /** - * Unix ms. Used with receiveWindow. - * If omitted, receiveWindow has no effect. - * An order that reaches the matching engine after requestTime + receiveWindow is canceled. + * Broker rebate code. Lifted onto the WS request envelope. + * It is not sent inside args. Omit it to use the SDK broker code. + * Place-order docs: top-level apiCode. Batch-place uses the same field. + * Staff-confirmed: t.me/bitgetOpenapi/153820. */ - requestTime?: string; - /** Validity window in ms. Range [10, 60000]. Requires requestTime. */ - receiveWindow?: string; + apiCode?: string; } ⋮---- -/** - * Futures qty must be a multiple of quantityMultiplier - * and have at most quantityPrecision decimal places. - * Both come from /api/v3/market/instruments. Futures only. - */ -⋮---- -/** - * Market orders always run as IOC. - * Staff-confirmed: t.me/bitgetOpenapi/153169. - * timeInForce does not change that. - */ -⋮---- +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 */ ⋮---- -/** Spot only. Default: no */ -⋮---- -/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ -⋮---- -/** Limit orders only. queue1, queue5, counterparty1, or counterparty5 */ +/** Order TTL in ms [10, 60000]. Only effective when requestTime is also set on the envelope */ ⋮---- -/** Market orders only. Decimal, default 0.02, range 0.01-0.05 */ +/** Spot only. Default: no */ ⋮---- -/** - * rToken routing. internalization = on-exchange pool only. - * lit_market (default) = internal first, then the public market. - * Ignored for non-rToken symbols. timeInForce is also ignored for rToken. - */ +/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ ⋮---- /** - * rToken time in force. gtd (default) lasts the current session. - * gtc lasts 90 days. Ignored for non-rToken symbols. + * rToken routing. Accepted: internal_market | lit_market. Omit for default. + * internal_market = on-exchange only; lit_market = broker only. + * Omit / default = internal first, then broker. Ignored for non-rToken symbols. + * Live since 5 Nov 2026. */ ⋮---- +/** rToken time in force. gtd (default) or gtc (90 days). */ +⋮---- /** - * Unix ms. Used with receiveWindow. - * If omitted, receiveWindow has no effect. - * An order that reaches the matching engine after requestTime + receiveWindow is canceled. + * Broker rebate code. Lifted onto the WS request envelope. + * It is not sent inside args. Omit it to use the SDK broker code. + * Place-order docs: top-level apiCode. Batch-place uses the same field. + * Staff-confirmed: t.me/bitgetOpenapi/153820. */ -⋮---- -/** Validity window in ms. Range [10, 60000]. Requires requestTime. */ -⋮---- -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: README.md @@ -18149,102 +17763,502 @@ export interface MovePositionsRequestV3 { positionList: MovePositionItemRequestV3[]; } ⋮---- -export interface GetMovePositionHistoryRequestV3 { +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'; + /** + * Omit to list sub-accounts under the master. + * Ignored when a sub-account calls this for itself. + */ + uid?: string; + cursor?: string; + limit?: string; +} +⋮---- +/** + * Omit to list sub-accounts under the master. + * Ignored when a sub-account calls this for itself. + */ +⋮---- +export interface SetRateLimitQuotaRequestV3 { + category: 'spot' | 'futures'; + /** + * Required when the master account sets quotas. + * Not required, and ignored, when a sub-account sets its own quota. + */ + uids?: string[]; + quota: string; +} +⋮---- +/** + * Required when the master account sets quotas. + * Not required, and ignored, when a sub-account sets its own quota. + */ +⋮---- +export interface CreateStpGroupRequestV3 { + /** Max 32 characters. Must be unique. */ + groupName: string; +} +⋮---- +/** Max 32 characters. Must be unique. */ +⋮---- +export interface StpGroupMembersRequestV3 { + /** Comma-separated sub-account UIDs. Max 50. */ + uids: string; + groupId: string; +} +⋮---- +/** Comma-separated sub-account UIDs. Max 50. */ + +================ +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 since 30 Sep 2026 */ + symbol: string; + /** Required since 30 Sep 2026 */ + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ + pxAmendType?: 'yes' | 'no'; +} +⋮---- +/** Custom request ID. Numbers within 18 digits. */ +⋮---- +/** Required since 30 Sep 2026 */ +⋮---- +/** Required since 30 Sep 2026 */ +⋮---- +/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ +⋮---- +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 type FuturesMarginModeV3 = 'crossed' | 'isolated'; +⋮---- +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'; + /** + * crossed (default) or isolated. + * Under isolated margin, available excludes futures trial funds. + */ + marginMode?: FuturesMarginModeV3; +} +⋮---- +/** Spot only. Default: no */ +⋮---- +/** + * crossed (default) or isolated. + * Under isolated margin, available excludes futures trial funds. + */ +⋮---- +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; - cursor?: string; limit?: string; + cursor?: string; } ⋮---- -export interface GetEligibleSymbolsRequestV3 { +export interface GetCurrentPositionRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; symbol?: string; + posSide?: 'long' | 'short'; } ⋮---- -export interface GetEligibleMarginTierRequestV3 { - coin?: string; +export interface ModifyOrderRequestV3 { + orderId?: string; + clientOid?: string; + qty?: string; + price?: string; + /** Custom request ID. Numbers within 18 digits. */ + requestId?: number; + autoCancel?: 'yes' | 'no'; + /** Required since 30 Sep 2026 */ + symbol: string; + /** Required since 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; + /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ + pxAmendType?: 'yes' | 'no'; } ⋮---- -export interface GetEligibleLoanInfoRequestV3 { - coin?: string; -} +/** Custom request ID. Numbers within 18 digits. */ ⋮---- -export interface GetEligibleDiscountRateRequestV3 { - coin?: string; -} +/** Required since 30 Sep 2026 */ ⋮---- -export interface GetFundingFinancialRecordsRequestV3 { - coin?: string; - type?: string; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; -} +/** Required since 30 Sep 2026 */ ⋮---- -export interface GetSmallAssetsRequestV3 { - coin?: string; -} +/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ ⋮---- -export interface TradeSmallAssetsRequestV3 { - fromCoinList: string[]; - toCoin?: string; +export interface PlaceRealityOrderRequestV3 { + category?: 'SPOT' | 'MARGIN'; + symbol: string; + side: 'buy' | 'sell'; + orderType: 'limit' | 'market'; + qty: string; + price?: string; + clientOid?: string; + /** + * rToken routing. Accepted: internal_market | lit_market. Omit for default. + * internal_market = on-exchange only (not submitted to the U.S. stock broker). + * lit_market = broker only (not matched on-exchange). + * Omit / default = internal first at best price, then unfilled to broker. + * Live since 5 Nov 2026 (internalization renamed; old lit_market meaning is now default). + */ + venue?: 'internal_market' | 'lit_market'; + /** + * rToken time in force. gtd (default) = current session. + * gtc = 90 days. Same changelog note as venue. + */ + rTokenTimeInForce?: 'gtd' | 'gtc'; } ⋮---- -export interface GetSmallAssetsHistoryRequestV3 { +/** + * rToken routing. Accepted: internal_market | lit_market. Omit for default. + * internal_market = on-exchange only (not submitted to the U.S. stock broker). + * lit_market = broker only (not matched on-exchange). + * Omit / default = internal first at best price, then unfilled to broker. + * Live since 5 Nov 2026 (internalization renamed; old lit_market meaning is now default). + */ +⋮---- +/** + * rToken time in force. gtd (default) = current session. + * gtc = 90 days. Same changelog note as venue. + */ +⋮---- +export interface CancelRealityOrderRequestV3 { + category?: 'SPOT' | 'MARGIN'; + symbol: string; orderId?: string; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; + clientOid?: string; } ⋮---- -export interface GetRateLimitQuotaRequestV3 { - category: 'spot' | 'futures'; +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'; + /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ + pxAmendType?: 'yes' | 'no'; /** - * Omit to list sub-accounts under the master. - * Ignored when a sub-account calls this for itself. + * Unix ms. Used with receiveWindow. + * If omitted, receiveWindow has no effect. + * An order that reaches the matching engine after requestTime + receiveWindow is canceled. */ - uid?: string; - cursor?: string; - limit?: string; + requestTime?: string; + /** Validity window in ms. Range [10, 60000]. Requires requestTime. */ + receiveWindow?: string; } ⋮---- +/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ +⋮---- /** - * Omit to list sub-accounts under the master. - * Ignored when a sub-account calls this for itself. + * Unix ms. Used with receiveWindow. + * If omitted, receiveWindow has no effect. + * An order that reaches the matching engine after requestTime + receiveWindow is canceled. */ ⋮---- -export interface SetRateLimitQuotaRequestV3 { - category: 'spot' | 'futures'; +/** Validity window in ms. Range [10, 60000]. Requires requestTime. */ +⋮---- +export interface PlaceOrderRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol: string; /** - * Required when the master account sets quotas. - * Not required, and ignored, when a sub-account sets its own quota. + * Futures qty must be a multiple of quantityMultiplier + * and have at most quantityPrecision decimal places. + * Both come from /api/v3/market/instruments. Futures only. */ - uids?: string[]; - quota: string; + qty: string; + price?: string; + side: 'buy' | 'sell'; + /** + * Market orders always run as IOC. + * Staff-confirmed: t.me/bitgetOpenapi/153169. + * timeInForce does not change that. + */ + 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'; + /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ + pxAmendType?: 'yes' | 'no'; + /** Limit orders only. queue1, queue5, counterparty1, or counterparty5 */ + bboLevel?: 'queue1' | 'queue5' | 'counterparty1' | 'counterparty5'; + /** Market orders only. Decimal, default 0.02, range 0.01-0.05 */ + slippageTolerance?: string; + /** + * rToken routing. Accepted: internal_market | lit_market. Omit for default. + * internal_market = on-exchange only (not submitted to the U.S. stock broker). + * lit_market = broker only (not matched on-exchange). + * Omit / default = internal first at best price, then unfilled to broker. + * Ignored for non-rToken symbols. timeInForce is also ignored for rToken. + * Live since 5 Nov 2026 (internalization renamed; old lit_market meaning is now default). + */ + venue?: 'internal_market' | 'lit_market'; + /** + * rToken time in force. gtd (default) lasts the current session. + * gtc lasts 90 days. Ignored for non-rToken symbols. + */ + rTokenTimeInForce?: 'gtd' | 'gtc'; + /** + * Unix ms. Used with receiveWindow. + * If omitted, receiveWindow has no effect. + * An order that reaches the matching engine after requestTime + receiveWindow is canceled. + */ + requestTime?: string; + /** Validity window in ms. Range [10, 60000]. Requires requestTime. */ + receiveWindow?: string; } ⋮---- /** - * Required when the master account sets quotas. - * Not required, and ignored, when a sub-account sets its own quota. + * Futures qty must be a multiple of quantityMultiplier + * and have at most quantityPrecision decimal places. + * Both come from /api/v3/market/instruments. Futures only. */ ⋮---- -export interface CreateStpGroupRequestV3 { - /** Max 32 characters. Must be unique. */ - groupName: string; -} +/** + * Market orders always run as IOC. + * Staff-confirmed: t.me/bitgetOpenapi/153169. + * timeInForce does not change that. + */ ⋮---- -/** Max 32 characters. Must be unique. */ +/** Futures only. Defaults to crossed */ ⋮---- -export interface StpGroupMembersRequestV3 { - /** Comma-separated sub-account UIDs. Max 50. */ - uids: string; - groupId: string; +/** Spot only. Default: no */ +⋮---- +/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ +⋮---- +/** Limit orders only. queue1, queue5, counterparty1, or counterparty5 */ +⋮---- +/** Market orders only. Decimal, default 0.02, range 0.01-0.05 */ +⋮---- +/** + * rToken routing. Accepted: internal_market | lit_market. Omit for default. + * internal_market = on-exchange only (not submitted to the U.S. stock broker). + * lit_market = broker only (not matched on-exchange). + * Omit / default = internal first at best price, then unfilled to broker. + * Ignored for non-rToken symbols. timeInForce is also ignored for rToken. + * Live since 5 Nov 2026 (internalization renamed; old lit_market meaning is now default). + */ +⋮---- +/** + * rToken time in force. gtd (default) lasts the current session. + * gtc lasts 90 days. Ignored for non-rToken symbols. + */ +⋮---- +/** + * Unix ms. Used with receiveWindow. + * If omitted, receiveWindow has no effect. + * An order that reaches the matching engine after requestTime + receiveWindow is canceled. + */ +⋮---- +/** Validity window in ms. Range [10, 60000]. Requires requestTime. */ +⋮---- +export interface CountdownCancelAllRequestV3 { + countdown: string; // seconds until auto-cancel (5-60, or 0 to disable) } ⋮---- -/** Comma-separated sub-account UIDs. Max 50. */ +countdown: string; // seconds until auto-cancel (5-60, or 0 to disable) ================ File: src/types/response/v3/account.ts From d3c00bba43be2608e089d3f39f1e6d7546ddaadb Mon Sep 17 00:00:00 2001 From: JJ-Cro Date: Mon, 9 Nov 2026 09:18:59 +0100 Subject: [PATCH 7/9] feat(v3.2.8): add UTA affiliate, savings, SharkFin and broker APIs - Add typed UTA affiliate customer and commission methods - Add typed UTA savings and SharkFin methods - Add UTA broker email, volume and commission methods - Add WebSocket BBO and slippage options and liquidation subscriptions - Document candle and trade streams without subscription snapshots - Update sub-transfer ID limits and CFD trading timezone types - Allow null position sides in strategy order responses --- src/index.ts | 2 + src/rest-client-v3.ts | 369 +++++++++++++++++++++++++ src/types/request/v3/account.ts | 1 + src/types/request/v3/affiliate.ts | 91 ++++++ src/types/request/v3/broker.ts | 43 +++ src/types/request/v3/earn.ts | 109 ++++++++ src/types/response/v3/affiliate.ts | 134 +++++++++ src/types/response/v3/broker.ts | 74 +++++ src/types/response/v3/cfd.ts | 2 + src/types/response/v3/earn.ts | 225 +++++++++++++++ src/types/response/v3/strategy.ts | 3 +- src/types/websockets/ws-api-request.ts | 4 + src/types/websockets/ws-general.ts | 10 + 13 files changed, 1066 insertions(+), 1 deletion(-) create mode 100644 src/types/request/v3/affiliate.ts create mode 100644 src/types/response/v3/affiliate.ts diff --git a/src/index.ts b/src/index.ts index 4ea66740..e5454fe2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,6 +10,7 @@ export * from './types/request/v2/futures.js'; 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/affiliate.js'; export * from './types/request/v3/broker.js'; export * from './types/request/v3/cfd.js'; export * from './types/request/v3/copytrading.js'; @@ -30,6 +31,7 @@ export * from './types/response/v2/futures.js'; 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/affiliate.js'; export * from './types/response/v3/broker.js'; export * from './types/response/v3/cfd.js'; export * from './types/response/v3/copytrading.js'; diff --git a/src/rest-client-v3.ts b/src/rest-client-v3.ts index 1e33ba7d..c04d69cc 100644 --- a/src/rest-client-v3.ts +++ b/src/rest-client-v3.ts @@ -60,6 +60,17 @@ import { UpdateSubAccountApiKeyRequestV3, WithdrawRequestV3, } from './types/request/v3/account.js'; +import { + AgentCustomerAssetRequestV3, + AgentCustomerDepositRequestV3, + AgentCustomerListRequestV3, + AgentCustomerTradeVolumeRequestV3, + GetAgentCustomerCommissionsRequestV3, + GetAgentCustomerKycResultRequestV3, + GetAgentSubCustomerListRequestV3, + GetSubAffiliateCommissionRequestV3, + GetSubAffiliateInfoRequestV3, +} from './types/request/v3/affiliate.js'; import { BrokerSubWithdrawalRequestV3, CreateBrokerSubAccountRequestV3, @@ -67,11 +78,17 @@ import { DeleteBrokerSubApiKeyRequestV3, GetBrokerAllSubDepositWithdrawalRequestV3, GetBrokerCommissionRequestV3, + GetBrokerOrderCommissionRequestV3, + GetBrokerRebateInfoRequestV3, GetBrokerSubAccountListRequestV3, GetBrokerSubApiKeyRequestV3, GetBrokerSubDepositAddressRequestV3, + GetBrokerTotalCommissionRequestV3, + GetBrokerTradeVolumeRequestV3, + GetSubaccountEmailRequestV3, ModifyBrokerSubAccountRequestV3, ModifyBrokerSubApiKeyRequestV3, + ModifySubaccountEmailRequestV3, } from './types/request/v3/broker.js'; import { CancelAllCfdOrdersRequestV3, @@ -126,7 +143,21 @@ import { GetEarnEliteRedeemInfoRequestV3, GetEarnEliteSubscribeInfoRequestV3, GetEarnEliteSubscribeResultRequestV3, + GetEarnSavingsAssetsRequestV3, + GetEarnSavingsProductsRequestV3, + GetEarnSavingsRecordsRequestV3, + GetEarnSavingsRedemptionResultRequestV3, + GetEarnSavingsSubscriptionRequestV3, + GetEarnSavingsSubscriptionResultRequestV3, + GetSharkfinAssetsRequestV3, + GetSharkfinProductsRequestV3, + GetSharkfinRecordsRequestV3, + GetSharkfinSubscriptionRequestV3, + GetSharkfinSubscriptionResultRequestV3, RedeemEarnEliteRequestV3, + RedeemSavingsRequestV3, + SubscribeSavingsRequestV3, + SubscribeSharkfinRequestV3, } from './types/request/v3/earn.js'; import { AddGridInvestmentRequestV3, @@ -332,10 +363,25 @@ import { WithdrawRecordV3, WithdrawResponseV3, } from './types/response/v3/account.js'; +import { + AgentCustomerAssetItemV3, + AgentCustomerCommissionsV3, + AgentCustomerDepositItemV3, + AgentCustomerKycResultV3, + AgentCustomerListItemV3, + AgentCustomerTradeVolumeItemV3, + AgentSubCustomerListV3, + SubAffiliateCommissionV3, + SubAffiliateInfoV3, +} from './types/response/v3/affiliate.js'; import { BrokerCommissionRecordV3, + BrokerOrderCommissionV3, + BrokerRebateInfoV3, BrokerSubDepositAddressV3, BrokerSubWithdrawalResponseV3, + BrokerTotalCommissionV3, + BrokerTradeVolumeV3, CreateBrokerSubAccountResponseV3, CreateBrokerSubApiKeyResponseV3, GetBrokerAllSubDepositWithdrawalResponseV3, @@ -343,6 +389,8 @@ import { GetBrokerSubApiKeyResponseV3, ModifyBrokerSubAccountResponseV3, ModifyBrokerSubApiKeyResponseV3, + ModifySubaccountEmailResponseV3, + SubaccountEmailV3, } from './types/response/v3/broker.js'; import { CfdCandlestickV3, @@ -395,7 +443,23 @@ import { EarnEliteSubscribeInfoV3, EarnEliteSubscribeResultV3, EarnEliteSubscribeStatusV3, + EarnSavingsAccountV3, + EarnSavingsAssetsV3, + EarnSavingsProductV3, + EarnSavingsRecordsV3, + EarnSavingsRedemptionResultV3, + EarnSavingsSubscriptionDetailV3, + EarnSavingsSubscriptionResultV3, + EarnSharkfinAccountV3, + EarnSharkfinAssetsV3, + EarnSharkfinProductsV3, + EarnSharkfinRecordsV3, + EarnSharkfinSubscriptionDetailV3, + EarnSharkfinSubscriptionResultV3, RedeemEarnEliteResultV3, + RedeemSavingsResponseV3, + SubscribeSavingsResponseV3, + SubscribeSharkfinResponseV3, } from './types/response/v3/earn.js'; import { GridBotDetailV3, @@ -3002,6 +3066,159 @@ export class RestClientV3 extends BaseRestClient { return this.getPrivate('/api/v3/broker/query-sub-apikey', params); } + /** + * + * =====Affiliate===== + * + */ + + /** + * Get Agent Customer List. Rate limit: 10/sec/UID. + * Without startTime/endTime, returns all registered customers (no time restriction). + */ + getAgentCustomerList( + params?: AgentCustomerListRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/affiliate/customer-list', params); + } + + /** + * Get Agent Customer Asset. Rate limit: 10/sec/UID. + */ + getAgentCustomerAssets( + params?: AgentCustomerAssetRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/affiliate/customer-asset', params); + } + + /** + * Get Agent Customer Trade Volume. Rate limit: 10/sec/UID. + */ + getAgentCustomerTradeVolume( + params?: AgentCustomerTradeVolumeRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/affiliate/customer-trade-volume', params); + } + + /** + * Get Agent Customer Deposit. Rate limit: 10/sec/UID. + */ + getAgentCustomerDeposits( + params?: AgentCustomerDepositRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/affiliate/customer-deposit', params); + } + + /** + * Get Agent Customer Kyc Result. Rate limit: 10/sec/UID. + */ + getAgentCustomerKycResult( + params?: GetAgentCustomerKycResultRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/affiliate/customer-kyc-result', params); + } + + /** + * Get Agent Customer Commission. Rate limit: 10/sec/UID. + */ + getAgentCustomerCommissions( + params?: GetAgentCustomerCommissionsRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/affiliate/customer-commission', params); + } + + /** + * Get Agent Sub Customer List. Rate limit: 10/sec/UID. + * Without startTime/endTime, returns all registered customers (no time restriction). + */ + getAgentSubCustomerList( + params?: GetAgentSubCustomerListRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/affiliate/sub-customer-list', params); + } + + /** + * Get Sub Affiliate Info. Rate limit: 10/sec/UID. + */ + getSubAffiliateInfo( + params?: GetSubAffiliateInfoRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/affiliate/sub-affiliate-info', params); + } + + /** + * Get Sub Affiliate Commission. Rate limit: 10/sec/UID. + */ + getSubAffiliateCommission( + params?: GetSubAffiliateCommissionRequestV3, + ): Promise> { + return this.getPrivate( + '/api/v3/affiliate/sub-affiliate-commission', + params, + ); + } + + /** + * + * =====Broker | Email and Commissions===== + * + */ + + /** + * Modify Subaccount Email. Rate limit: 10/sec/UID. + */ + modifySubaccountEmail( + params: ModifySubaccountEmailRequestV3, + ): Promise> { + return this.postPrivate('/api/v3/broker/modify-subaccount-email', params); + } + + /** + * Get Subaccount Email. Rate limit: 10/sec/UID. + */ + getSubaccountEmail( + params: GetSubaccountEmailRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/broker/subaccount-email', params); + } + + /** + * Get Broker Trade Volume. Rate limit: 5/sec/UID. + * Contact your BD or RM to apply for access permissions. + */ + getBrokerTradeVolume( + params?: GetBrokerTradeVolumeRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/broker/trade-volume', params); + } + + /** + * Get Total Commission. Rate limit: 20/sec/UID. + */ + getBrokerTotalCommission( + params?: GetBrokerTotalCommissionRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/broker/total-commission', params); + } + + /** + * Get Order Commission. Rate limit: 20/sec/UID. + */ + getBrokerOrderCommission( + params?: GetBrokerOrderCommissionRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/broker/order-commission', params); + } + + /** + * Get Rebate Info. Rate limit: 20/sec/UID. + */ + getBrokerRebateInfo( + params: GetBrokerRebateInfoRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/broker/rebate-info', params); + } + /** * * =====P2P Merchant (UTA)===== @@ -3106,6 +3323,158 @@ export class RestClientV3 extends BaseRestClient { return this.getPrivate('/api/v3/p2p/balance', params); } + /** + * + * =====Earn | Savings (UTA)===== + * + */ + + /** + * Get Savings Product List. Rate limit: 10/sec/UID. + */ + getEarnSavingsProducts( + params?: GetEarnSavingsProductsRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/earn/savings/product', params); + } + + /** + * Savings Account. Rate limit: 10/sec/UID. + */ + getEarnSavingsAccount(): Promise> { + return this.getPrivate('/api/v3/earn/savings/account'); + } + + /** + * Savings Assets. Rate limit: 10/sec/UID. + */ + getEarnSavingsAssets( + params: GetEarnSavingsAssetsRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/earn/savings/assets', params); + } + + /** + * Savings Records. Rate limit: 10/sec/UID. + */ + getEarnSavingsRecords( + params: GetEarnSavingsRecordsRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/earn/savings/records', params); + } + + /** + * Savings Subscription Detail. Rate limit: 10/sec/UID. + */ + getEarnSavingsSubscription( + params: GetEarnSavingsSubscriptionRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/earn/savings/subscribe-info', params); + } + + /** + * Subscribe Savings. Rate limit: 10/sec/UID. + */ + earnSubscribeSavings( + params: SubscribeSavingsRequestV3, + ): Promise> { + return this.postPrivate('/api/v3/earn/savings/subscribe', params); + } + + /** + * Savings Subscription Result. Rate limit: 10/sec/UID. + */ + getEarnSavingsSubscriptionResult( + params: GetEarnSavingsSubscriptionResultRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/earn/savings/subscribe-result', params); + } + + /** + * Redeem Savings. Rate limit: 10/sec/UID. + */ + earnRedeemSavings( + params: RedeemSavingsRequestV3, + ): Promise> { + return this.postPrivate('/api/v3/earn/savings/redeem', params); + } + + /** + * Savings Redemption Results. Rate limit: 10/sec/UID. + */ + getEarnSavingsRedemptionResult( + params: GetEarnSavingsRedemptionResultRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/earn/savings/redeem-result', params); + } + + /** + * + * =====Earn | SharkFin (UTA)===== + * + */ + + /** + * Get Sharkfin Products. Rate limit: 10/sec/UID. + */ + getSharkfinProducts( + params: GetSharkfinProductsRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/earn/sharkfin/product', params); + } + + /** + * SharkFin Account. Rate limit: 10/sec/UID. + */ + getSharkfinAccount(): Promise> { + return this.getPrivate('/api/v3/earn/sharkfin/account'); + } + + /** + * SharkFin Assets. Rate limit: 10/sec/UID. + */ + getSharkfinAssets( + params: GetSharkfinAssetsRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/earn/sharkfin/assets', params); + } + + /** + * SharkFin Records. Rate limit: 10/sec/UID. + */ + getSharkfinRecords( + params: GetSharkfinRecordsRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/earn/sharkfin/records', params); + } + + /** + * SharkFin Subscription Detail. Rate limit: 10/sec/UID. + */ + getSharkfinSubscription( + params: GetSharkfinSubscriptionRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/earn/sharkfin/subscribe-info', params); + } + + /** + * Subscribe SharkFin. Rate limit: 10/sec/UID. + */ + subscribeSharkfin( + params: SubscribeSharkfinRequestV3, + ): Promise> { + return this.postPrivate('/api/v3/earn/sharkfin/subscribe', params); + } + + /** + * SharkFin Subscription Result. Rate limit: 5/sec/UID. + */ + getSharkfinSubscriptionResult( + params: GetSharkfinSubscriptionResultRequestV3, + ): Promise> { + return this.getPrivate('/api/v3/earn/sharkfin/subscribe-result', params); + } + /** * * =====Earn | On-Chain Elite (UTA)===== diff --git a/src/types/request/v3/account.ts b/src/types/request/v3/account.ts index f696f926..c5c44b34 100644 --- a/src/types/request/v3/account.ts +++ b/src/types/request/v3/account.ts @@ -339,6 +339,7 @@ export interface SubAccountTransferRequestV3 { coin: string; fromUserId: string; toUserId: string; + /** Custom order ID, max 50 characters */ clientOid: string; /** Enable automatic margin borrowing when balance insufficient. yes | no */ allowBorrow?: 'yes' | 'no'; diff --git a/src/types/request/v3/affiliate.ts b/src/types/request/v3/affiliate.ts new file mode 100644 index 00000000..1f9a0c58 --- /dev/null +++ b/src/types/request/v3/affiliate.ts @@ -0,0 +1,91 @@ +/** + * + * + * Affiliate + * + * + */ + +export interface AgentCustomerListRequestV3 { + startTime?: string; + endTime?: string; + pageNo?: string; + pageSize?: string; + uid?: string; + referralCode?: string; +} + +export interface AgentCustomerAssetRequestV3 { + pageNo?: string; + pageSize?: string; + uid?: string; + showSub?: 'yes' | 'no'; +} + +export interface AgentCustomerTradeVolumeRequestV3 { + startTime?: string; + endTime?: string; + pageNo?: string; + pageSize?: string; + uid?: string; + showSub?: 'yes' | 'no'; +} + +export interface AgentCustomerDepositRequestV3 { + startTime?: string; + endTime?: string; + pageNo?: string; + pageSize?: string; + uid?: string; + showSub?: 'yes' | 'no'; +} + +export interface GetAgentCustomerKycResultRequestV3 { + startTime?: string; + endTime?: string; + /** Pass endId from the previous response. Omit on the first page. */ + cursor?: string; + limit?: string; + uid?: string; + showSub?: 'yes' | 'no'; +} + +export interface GetAgentCustomerCommissionsRequestV3 { + startTime?: string; + endTime?: string; + /** Pass endId from the previous response. Omit on the first page. */ + cursor?: string; + limit?: string; + uid?: string; + coin?: string; + symbol?: string; + showSub?: 'yes' | 'no'; +} + +export interface GetAgentSubCustomerListRequestV3 { + startTime?: string; + endTime?: string; + /** Pass minId from the previous response. Omit on the first page. */ + cursor?: string; + limit?: string; + uid?: string; + showSub?: 'yes' | 'no'; +} + +export interface GetSubAffiliateInfoRequestV3 { + uid?: string; + startTime?: string; + endTime?: string; + /** Pass endId from the previous response. Omit on the first page. */ + idLessThan?: string; + limit?: string; + includeDownLine?: 'yes' | 'no'; +} + +export interface GetSubAffiliateCommissionRequestV3 { + startTime?: string; + endTime?: string; + limit?: string; + /** Pass endId from the previous response. Omit on the first page. */ + cursor?: string; +} diff --git a/src/types/request/v3/broker.ts b/src/types/request/v3/broker.ts index 7b2e74c5..4cdc0c82 100644 --- a/src/types/request/v3/broker.ts +++ b/src/types/request/v3/broker.ts @@ -81,3 +81,46 @@ export interface DeleteBrokerSubApiKeyRequestV3 { export interface GetBrokerSubApiKeyRequestV3 { subUid: string; } + +/** + * + * + * Broker | Email and Commissions + * + * + */ + +export interface ModifySubaccountEmailRequestV3 { + subUid: string; + subaccountEmail: string; +} + +export interface GetSubaccountEmailRequestV3 { + subUid: string; +} + +export interface GetBrokerTradeVolumeRequestV3 { + startTime?: string; + endTime?: string; + pageSize?: string; + pageNo?: string; +} + +export interface GetBrokerTotalCommissionRequestV3 { + startTime?: string; + endTime?: string; +} + +export interface GetBrokerOrderCommissionRequestV3 { + startTime?: string; + endTime?: string; + limit?: string; + uid?: string; + orderid?: string; + /** Pass endId from the previous response. Omit on the first page. */ + idLessThan?: string; +} + +export interface GetBrokerRebateInfoRequestV3 { + uid: string; +} diff --git a/src/types/request/v3/earn.ts b/src/types/request/v3/earn.ts index 12adfecd..004c1199 100644 --- a/src/types/request/v3/earn.ts +++ b/src/types/request/v3/earn.ts @@ -97,3 +97,112 @@ export interface GetEarnCashPlusHistoryOrdersRequestV3 { /** Pass nextCursor from the previous page. Omit on the first page */ cursor?: string; } + +/** + * + * + * Earn | Savings (UTA) + * + * + */ + +export interface GetEarnSavingsProductsRequestV3 { + coin?: string; + filter?: 'available' | 'held' | 'available_and_held' | 'all'; +} + +export interface GetEarnSavingsAssetsRequestV3 { + periodType: 'flexible' | 'fixed'; + startTime?: string; + endTime?: string; + limit?: string; + /** Pass endId from the previous response. Omit on the first page. */ + cursor?: string; +} + +export interface GetEarnSavingsRecordsRequestV3 { + coin?: string; + periodType: 'flexible' | 'fixed'; + orderType?: 'subscribe' | 'redeem' | 'pay_interest' | 'deduction'; + startTime?: string; + endTime?: string; + limit?: string; + /** Pass endId from the previous response. Omit on the first page. */ + cursor?: string; +} + +export interface GetEarnSavingsSubscriptionRequestV3 { + productId: string; + periodType: 'flexible' | 'fixed'; +} + +export interface SubscribeSavingsRequestV3 { + productId: string; + periodType: 'flexible' | 'fixed'; + amount: string; +} + +export interface GetEarnSavingsSubscriptionResultRequestV3 { + orderId: string; + periodType: 'flexible' | 'fixed'; +} + +export interface RedeemSavingsRequestV3 { + productId: string; + /** Assets order ID returned by getEarnSavingsAssets */ + orderId?: string; + periodType: 'flexible' | 'fixed'; + amount: string; +} + +export interface GetEarnSavingsRedemptionResultRequestV3 { + orderId: string; + periodType: 'flexible' | 'fixed'; +} + +/** + * + * + * Earn | SharkFin (UTA) + * + * + */ + +export interface GetSharkfinProductsRequestV3 { + coin: string; + limit?: string; + /** Pass endId from the previous response. Omit on the first page. */ + cursor?: string; +} + +export interface GetSharkfinAssetsRequestV3 { + status: 'subscribed' | 'settled'; + startTime?: string; + endTime?: string; + limit?: string; + /** Pass endId from the previous response. Omit on the first page. */ + cursor?: string; +} + +export interface GetSharkfinRecordsRequestV3 { + coin?: string; + type: 'subscription' | 'redemption' | 'interest'; + startTime?: string; + endTime?: string; + limit?: string; + /** Pass endId from the previous response. Omit on the first page. */ + cursor?: string; +} + +export interface GetSharkfinSubscriptionRequestV3 { + productId: string; +} + +export interface SubscribeSharkfinRequestV3 { + productId: string; + amount: string; +} + +export interface GetSharkfinSubscriptionResultRequestV3 { + orderId: string; +} diff --git a/src/types/response/v3/affiliate.ts b/src/types/response/v3/affiliate.ts new file mode 100644 index 00000000..fcfbc602 --- /dev/null +++ b/src/types/response/v3/affiliate.ts @@ -0,0 +1,134 @@ +/** + * + * + * Affiliate + * https://www.bitget.com/docs/catalog/affiliate/affiliate + * + * + */ + +export interface AgentCustomerListItemV3 { + uid: string; + registerTime: string; +} + +export interface AgentCustomerAssetItemV3 { + uid: string; + balance: string; + uTime: string; + remark: string; +} + +export interface AgentCustomerTradeVolumeItemV3 { + uid: string; + /** API field name (Bitget spelling). */ + volumn: string; + spotVolume: string; + futuresVolume: string; + time: string; +} + +export interface AgentCustomerDepositItemV3 { + uid: string; + orderId: string; + depositTime: string; + depositCoin: string; + depositAmount: string; +} + +export interface AgentCustomerKycResultItemV3 { + uid: string; + kycResult: 'passed' | 'not_passed'; +} + +/** Pagination wrapper follows the documented response example. */ +export interface AgentCustomerKycResultV3 { + userList: AgentCustomerKycResultItemV3[]; + endId: string; +} + +export interface AgentCustomerCommissionV3 { + uid: string; + date: string; + coin: string; + symbol: string; + productType: string; + dealAmount: string; + fee: string; + feeDeduction: string; + activityBonusDeduct: string; + spotCouponDeduct: string; + futuresCouponDeduct: string; + spotFeeDiscountDeduct: string; + negativeMakerFeeDeduct: string; + feePaid: string; + rebateAmount: string; + userTotalRebateAmount: string; + dayTotalRebateAmount: string; + totalRebateAmount: string; +} + +export interface AgentCustomerCommissionsV3 { + commissionList: AgentCustomerCommissionV3[]; + endId: string; +} + +/** Pagination wrapper follows the documented response example. */ +export interface AgentSubCustomerListV3 { + list: AgentCustomerListItemV3[]; + minId: string; +} + +export interface SubAffiliateRebateRateV3 { + rebateType: string; + rebateRate: string; +} + +export interface SubAffiliateInfoItemV3 { + uid: string; + uplineName: string; + rebateRateList: SubAffiliateRebateRateV3[]; + verificationStatus: string; + directReferrals: string; + subAffiliates: string; + subAffiliateDirectReferrals: string; + volume: string; + deposit: string; + transactionFee: string; + rebate: string; +} + +export interface SubAffiliateInfoV3 { + list: SubAffiliateInfoItemV3[]; + endId: string; +} + +export interface SubAffiliateCommissionItemV3 { + uid: string; + bizType: string; + subBizType: string; + symbol: string; + coin: string; + fee: string; + volume: string; + activityBonusDeduct: string; + spotCouponDeduct: string; + futuresCouponDeduct: string; + spotFeeDiscountDeduct: string; + negativeMakerFeeDeduct: string; + feePaid: string; + directCommission: string; + subCommission: string; + partnerCommission: string; + partnerActualCommission: string; + traderType: string; + apiType: string; + status: string; + startCalculationTime: string; + endCalculationTime: string; +} + +export interface SubAffiliateCommissionV3 { + commissionList: SubAffiliateCommissionItemV3[]; + endId: string; +} diff --git a/src/types/response/v3/broker.ts b/src/types/response/v3/broker.ts index 0a511efb..38143d0e 100644 --- a/src/types/response/v3/broker.ts +++ b/src/types/response/v3/broker.ts @@ -105,3 +105,77 @@ export interface GetBrokerSubApiKeyResponseV3 { permList: string[]; ipList: string[] | null; } + +/** + * + * + * Broker | Email and Commissions + * + * + */ + +export type ModifySubaccountEmailResponseV3 = string; + +export interface SubaccountEmailV3 { + subUid: string; + subaccountName: string; + subaccountEmail: string; + cTime: string; + uTime: string; +} + +export interface BrokerTradeVolumeV3 { + uid: string; + volume: string; + spotVolume: string; + futureVolume: string; +} + +export interface BrokerSpotCommissionV3 { + spotTradingVolume: string; + spotTradingFee: string; + spotPureTradingFee: string; + spotCommission: string; +} + +export interface BrokerFuturesCommissionV3 { + futuresTradingVolume: string; + futuresTradingFee: string; + futuresPureTradingFee: string; + futuresCommission: string; +} + +export interface BrokerTotalCommissionV3 { + date: string; + totalTradingVolume: string; + totalActiveTraders: string; + totalCommission: string; + spot: BrokerSpotCommissionV3; + futures: BrokerFuturesCommissionV3; +} + +export interface BrokerOrderCommissionItemV3 { + fillId: string; + orderId: string; + ts: string; + clientOid: string; + bizType: string; + subBizType: string; + symbol: string; + volume: string; + fee: string; + pureFee: string; + rebateAmount: string; +} + +export interface BrokerOrderCommissionV3 { + commissionlist: BrokerOrderCommissionItemV3[]; + endId: string; +} + +export interface BrokerRebateInfoV3 { + affiliationType: string; + userLevel: string; + clientSpotRebateRatio: string; + clientFuturesRebateRatio: string; +} diff --git a/src/types/response/v3/cfd.ts b/src/types/response/v3/cfd.ts index 5353071e..55e01939 100644 --- a/src/types/response/v3/cfd.ts +++ b/src/types/response/v3/cfd.ts @@ -157,6 +157,8 @@ export interface CfdInstrumentV3 { tickValue: string; leverage: string; tradeTime: string; + /** Instrument trading timezone as UTC offset hours, e.g. "+2" */ + currentTimezone: string; commissionType: string; commissionRate: string; symbolCategory: string; diff --git a/src/types/response/v3/earn.ts b/src/types/response/v3/earn.ts index a9ba120b..c952508e 100644 --- a/src/types/response/v3/earn.ts +++ b/src/types/response/v3/earn.ts @@ -267,3 +267,228 @@ export interface EarnCashPlusHistoryOrdersV3 { /** Pass back as cursor. Absent on the last page */ nextCursor?: string; } + +/** + * + * + * Earn | Savings (UTA) + * + * + */ + +export interface EarnSavingsApyV3 { + rateLevel: string; + minStepVal: string; + maxStepVal: string; + currentApy: string; +} + +export interface EarnSavingsProductV3 { + productId: string; + coin: string; + periodType: 'flexible' | 'fixed'; + /** Only returned for fixed-term savings */ + period?: string; + apyType: string; + advanceRedeem: string; + settleMethod: string; + apyList: EarnSavingsApyV3[]; + status: string; + productLevel: string; +} + +export interface EarnSavingsAccountV3 { + btcAmount: string; + usdtAmount: string; + btc24hEarning: string; + usdt24hEarning: string; + btcTotalEarning: string; + usdtTotalEarning: string; +} + +export interface EarnSavingsAssetApyV3 { + rateLevel: string; + minApy: string; + maxApy: string; + currentApy: string; +} + +export interface EarnSavingsAssetV3 { + productId: string; + /** Only returned for fixed-term savings */ + orderId?: string; + productCoin: string; + interestCoin: string; + periodType: 'flexible' | 'fixed'; + /** Only returned for fixed-term savings */ + period?: string; + holdAmount: string; + lastProfit: string; + totalProfit: string; + holdDays: string; + status: string; + allowRedemption: string; + productLevel: string; + apy: EarnSavingsAssetApyV3[]; +} + +export interface EarnSavingsAssetsV3 { + resultList: EarnSavingsAssetV3[]; + endId: string; +} + +export interface EarnSavingsRecordV3 { + orderId: string; + coinName: string; + settleCoinName: string; + productType: 'flexible' | 'fixed'; + /** Only returned for fixed-term savings */ + period?: string; + productLevel: string; + amount: string; + ts: string; + orderType: string; +} + +export interface EarnSavingsRecordsV3 { + resultList: EarnSavingsRecordV3[]; + endId: string; +} + +export interface EarnSavingsSubscriptionDetailV3 { + singleMinAmount: string; + singleMaxAmount: string; + remainingAmount: string; + subscribePrecision: string; + profitPrecision: string; + subscribeTime: string; + interestTime: string; + settleTime: string; + expireTime: string; + redeemTime: string; + settleMethod: string; + apyList: EarnSavingsApyV3[]; + redeemDelay: string; +} + +export interface SubscribeSavingsResponseV3 { + orderId: string; +} + +export interface EarnSavingsSubscriptionResultV3 { + result: 'success' | 'fail'; + msg: string; +} + +export interface RedeemSavingsResponseV3 { + orderId: string; + status: string; +} + +export interface EarnSavingsRedemptionResultV3 { + result: 'success' | 'fail'; + msg: string; +} + +/** + * + * + * Earn | SharkFin (UTA) + * + * + */ + +export interface EarnSharkfinProductV3 { + productId: string; + productName: string; + productCoin: string; + subscribeCoin: string; + farmingStartTime: string; + farmingEndTime: string; + lowerRate: string; + defaultRate: string; + upperRate: string; + period: string; + interestStartTime: string; + status: string; + minAmount: string; + limitAmount: string; + soldAmount: string; + startTime: string; + endTime: string; +} + +export interface EarnSharkfinProductsV3 { + resultList: EarnSharkfinProductV3[]; + endId: string; +} + +export interface EarnSharkfinAccountV3 { + btcSubscribeAmount: string; + usdtSubscribeAmount: string; + btcHistoricalAmount: string; + usdtHistoricalAmount: string; + btcTotalEarning: string; + usdtTotalEarning: string; +} + +export interface EarnSharkfinAssetV3 { + productId: string; + interestStartTime: string; + interestEndTime: string; + productCoin: string; + subscribeCoin: string; + trend: string; + settleTime: string; + interestAmount: string; + productStatus: string; +} + +export interface EarnSharkfinAssetsV3 { + resultList: EarnSharkfinAssetV3[]; + endId: string; +} + +export interface EarnSharkfinRecordV3 { + orderId: string; + product: string; + period: string; + amount: string; + ts: string; + type: string; +} + +export interface EarnSharkfinRecordsV3 { + resultList: EarnSharkfinRecordV3[]; + endId: string; +} + +export interface EarnSharkfinSubscriptionDetailV3 { + productCoin: string; + subscribeCoin: string; + interestTime: string; + expirationTime: string; + minPrice: string; + currentPrice: string; + maxPrice: string; + minRate: string; + defaultRate: string; + maxRate: string; + period: string; + productMinAmount: string; + availableBalance: string; + userAmount: string; + remainingAmount: string; + profitPrecision: string; + subscribePrecision: string; +} + +export interface SubscribeSharkfinResponseV3 { + orderId: string; + status: string; +} + +export interface EarnSharkfinSubscriptionResultV3 { + result: 'success' | 'fail'; + msg: string; +} diff --git a/src/types/response/v3/strategy.ts b/src/types/response/v3/strategy.ts index d0691840..f2f9eeb1 100644 --- a/src/types/response/v3/strategy.ts +++ b/src/types/response/v3/strategy.ts @@ -27,7 +27,8 @@ export interface StrategyOrderV3 { qty: string; /** buy / sell. Same field as the WS order push. */ side?: 'buy' | 'sell'; - posSide: 'long' | 'short'; + /** Can be null (seen live on unfilled trigger orders; user report t.me/bitgetOpenapi/153322, staff checking) */ + posSide: 'long' | 'short' | null; status: StrategyOrderStatusV3; type?: StrategyOrderTypeV3 | string; triggerType?: 'takeProfit' | 'stopLoss'; diff --git a/src/types/websockets/ws-api-request.ts b/src/types/websockets/ws-api-request.ts index 659d8092..b9b4dda7 100644 --- a/src/types/websockets/ws-api-request.ts +++ b/src/types/websockets/ws-api-request.ts @@ -27,6 +27,10 @@ export interface WSAPIPlaceOrderRequestV3 { autoBorrow?: 'yes' | 'no'; /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ pxAmendType?: 'yes' | 'no'; + /** Limit orders only. queue1, queue5, counterparty1, or counterparty5. Ignored for market orders */ + bboLevel?: 'queue1' | 'queue5' | 'counterparty1' | 'counterparty5'; + /** Market orders only. Decimal, default 0.02, range 0.01-0.05 */ + slippageTolerance?: string; /** * rToken routing. Accepted: internal_market | lit_market. Omit for default. * internal_market = on-exchange only; lit_market = broker only. diff --git a/src/types/websockets/ws-general.ts b/src/types/websockets/ws-general.ts index 0c2fd6e9..0237454d 100644 --- a/src/types/websockets/ws-general.ts +++ b/src/types/websockets/ws-general.ts @@ -55,6 +55,10 @@ export type WsTopic = WsPublicTopic | WsPrivateTopic; * * V2 list of topics for WebSocket consumers * + * Spot/futures candle and trade channels send only action=update, without a + * subscription snapshot, from 4 Nov 2026 on demo; live expected 17 Nov 2026. + * Use the corresponding REST API for historical candles and trades. + * https://www.bitget.com/docs/classic/changelog/2026-11 */ export type WsPublicTopicV2 = @@ -110,6 +114,10 @@ export type WsTopicV2 = WsPublicTopicV2 | WsPrivateTopicV2; * * V3 / UTA list of topics for WebSocket consumers * + * kline and publicTrade send only action=update, without a subscription snapshot, + * from 4 Nov 2026 on demo; live expected 17 Nov 2026. + * Use the corresponding REST API for historical candles and trades. + * https://www.bitget.com/docs/uta/update-preview */ export type WsPublicTopicV3 = | 'ticker' @@ -119,6 +127,8 @@ export type WsPublicTopicV3 = | 'books5' | 'books50' | 'publicTrade' + /** Futures public liquidations. Optional payload.symbol filters to that symbol */ + | 'liquidation' | 'instruments' | 'open-interest-limit' | 'position-tier' From 5da83791cd11e98782e28ca03b5c15e839eb03fa Mon Sep 17 00:00:00 2001 From: JJ-Cro sync bot Date: Mon, 9 Nov 2026 09:20:57 +0100 Subject: [PATCH 8/9] chore: regenerate endpoint docs and examples --- docs/endpointFunctionList.md | 631 +- llms.txt | 11082 ++++++++++++++++++--------------- 2 files changed, 6322 insertions(+), 5391 deletions(-) diff --git a/docs/endpointFunctionList.md b/docs/endpointFunctionList.md index ad435eaf..059201f4 100644 --- a/docs/endpointFunctionList.md +++ b/docs/endpointFunctionList.md @@ -362,306 +362,337 @@ 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#L647) | | GET | `/api/v3/market/time` | -| [getAnnouncements()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L661) | | GET | `/api/v3/public/annoucements` | -| [getInstruments()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L680) | | GET | `/api/v3/market/instruments` | -| [getMarketFeeGroup()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L689) | | GET | `/api/v3/market/fee-group` | -| [getLiquidations()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L698) | | GET | `/api/v3/market/liquidations` | -| [getRpiSymbols()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L707) | | GET | `/api/v3/market/rpi-symbols` | -| [getRpiOrderBook()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L714) | | GET | `/api/v3/market/rpi-orderbook` | -| [getCashDividendRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L723) | | GET | `/api/v3/market/cash-dividend-records` | -| [getSplitRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L729) | | GET | `/api/v3/market/split-records` | -| [getSpotWhaleFlow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L738) | | GET | `/api/v3/market/spot-whale-flow` | -| [getSpotFundFlow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L747) | | GET | `/api/v3/market/spot-fund-flow` | -| [getSpotNetFlow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L756) | | GET | `/api/v3/market/spot-net-flow` | -| [getMarginLongShort()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L765) | | GET | `/api/v3/market/margin-long-short` | -| [getMarginLoanGrowth()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L774) | | GET | `/api/v3/market/margin-loan-growth` | -| [getMarginIsolatedBorrow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L783) | | GET | `/api/v3/market/margin-isolated-borrow` | -| [getFuturesActiveBuySell()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L792) | | GET | `/api/v3/market/futures-active-buy-sell` | -| [getFuturesLongShort()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L801) | | GET | `/api/v3/market/futures-long-short` | -| [getFuturesPositionLongShort()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L810) | | GET | `/api/v3/market/futures-position-long-short` | -| [getFuturesAccountLongShort()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L819) | | GET | `/api/v3/market/futures-account-long-short` | -| [getMarketScoreWeights()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L828) | | GET | `/api/v3/market/score-weights` | -| [getTickers()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L837) | | GET | `/api/v3/market/tickers` | -| [getOrderBook()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L847) | | GET | `/api/v3/market/orderbook` | -| [getFills()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L856) | | GET | `/api/v3/market/fills` | -| [getProofOfReserves()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L865) | | GET | `/api/v3/market/proof-of-reserves` | -| [getOpenInterest()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L872) | | GET | `/api/v3/market/open-interest` | -| [getOpenInterestHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L882) | | GET | `/api/v3/market/open-interest-history` | -| [getCoins()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L893) | | GET | `/api/v3/market/coins` | -| [getCandles()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L901) | | GET | `/api/v3/market/candles` | -| [getHistoryCandles()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L910) | | GET | `/api/v3/market/history-candles` | -| [getCurrentFundingRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L919) | | GET | `/api/v3/market/current-fund-rate` | -| [getHistoryFundingRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L928) | | GET | `/api/v3/market/history-fund-rate` | -| [getRiskReserve()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L937) | | GET | `/api/v3/market/risk-reserve` | -| [getRiskReserveHour()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L946) | | GET | `/api/v3/market/risk-reserve-hour` | -| [getRiskReserveAll()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L955) | | GET | `/api/v3/market/risk-reserve-all` | -| [getDiscountRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L964) | | GET | `/api/v3/market/discount-rate` | -| [getInterestRateHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L973) | | GET | `/api/v3/market/interest-rate-history` | -| [getMarginLoans()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L982) | | GET | `/api/v3/market/margin-loans` | -| [getMarginLoansAll()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L992) | | GET | `/api/v3/market/margin-loans-all` | -| [getPositionTier()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1001) | | GET | `/api/v3/market/position-tier` | -| [getContractsOi()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1010) | | GET | `/api/v3/market/oi-limit` | -| [getIndexComponents()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1019) | | GET | `/api/v3/market/index-components` | -| [getRealityOrderBook()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1030) | :closed_lock_with_key: | GET | `/api/v3/account/reality-orderbook` | -| [getRealityOrderBookSegmented()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1043) | :closed_lock_with_key: | GET | `/api/v3/account/reality-orderbook-segmented` | -| [getRealityFills()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1055) | :closed_lock_with_key: | GET | `/api/v3/account/reality-fills` | -| [getRealityCompanyOverview()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1061) | | GET | `/api/v3/reality/market/company-overview` | -| [getRealityValuationIndicators()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1067) | | GET | `/api/v3/reality/market/valuation-indicators` | -| [getRealityEarningsForecast()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1073) | | GET | `/api/v3/reality/market/earnings-forecast` | -| [getRealitySuspensionResumptionInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1079) | | GET | `/api/v3/reality/market/suspension-resumption-info` | -| [getRealityDividends()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1088) | | GET | `/api/v3/reality/market/dividends` | -| [getRealityShareCapitalChange()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1094) | | GET | `/api/v3/reality/market/share-capital-change` | -| [getRealityInnerTrades()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1100) | | GET | `/api/v3/reality/market/inner-trades` | -| [getRealityExecutiveShareholdings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1106) | | GET | `/api/v3/reality/market/executive-shareholdings` | -| [getRealityShareholdDetail()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1114) | | GET | `/api/v3/reality/market/sharehold-detail` | -| [getRealityStockInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1120) | | GET | `/api/v3/reality/market/stock-info` | -| [getRealityMarketStates()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1126) | | GET | `/api/v3/reality/market/states` | -| [getRealityMarketCalendar()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1130) | | GET | `/api/v3/reality/market/calendar` | -| [getCopyFuturesTradingPairs()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1145) | :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#L1156) | :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#L1166) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/max-transferable` | -| [getCopyFuturesCopyMaxTransferable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1177) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/copy-max-transferable` | -| [copyFuturesTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1190) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/transfer` | -| [getCopyFuturesTransferRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1200) | :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#L1206) | :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#L1212) | :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#L1218) | :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#L1224) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/profit-details` | -| [getCopyFuturesPortfolioOverview()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1230) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/portfolio-overview` | -| [createCopyFutures()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1236) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/follower-settings` | -| [modifyCopyFuturesFollowerSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1242) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/modify-follower-settings` | -| [unfollowCopyFutures()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1251) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/unfollow` | -| [getCopyFuturesCopySettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1257) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/copy-settings` | -| [copyFuturesFollowerTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1263) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/copy-transfer` | -| [getCopyFuturesFollowerTransferRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1269) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/copy-transfer-record` | -| [getCopyFuturesCurrentCopy()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1275) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/current-copy` | -| [getCopyFuturesCopyProfitDetails()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1281) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/copy-profit-details` | -| [closeCopyFuturesPositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1287) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/close-positions` | -| [closeAllCopyFuturesPositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1293) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/close-all` | -| [getCopyFuturesCurrentPositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1299) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/current-positions` | -| [placeCopyFuturesTpSl()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1305) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/place-tpsl` | -| [modifyCopyFuturesTpSl()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1311) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/modify-tpsl` | -| [cancelCopyFuturesTpSl()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1317) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/cancel-tpsl` | -| [getCopyFuturesCurrentTpSlOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1323) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/current-tpsl-orders` | -| [getCopyFuturesTpSlOrderHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1329) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/tpsl-order-history` | -| [getStockPlusOptionQuote()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1341) | :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#L1347) | :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#L1356) | :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#L1365) | :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#L1371) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/static` | -| [getStockPlusQuote()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1377) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/quote` | -| [getStockPlusTradeDetail()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1383) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/trade` | -| [getStockPlusIntraday()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1389) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/intraday` | -| [getStockPlusHistoryCandlestick()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1395) | :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#L1404) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/candlestick` | -| [getStockPlusDepth()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1410) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/depth` | -| [placeStockPlusOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1416) | :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#L1422) | :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#L1428) | :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#L1434) | :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#L1440) | :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#L1446) | :closed_lock_with_key: | GET | `/api/v3/stockplus/trade/order-detail` | -| [getStockPlusMaxPurchase()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1452) | :closed_lock_with_key: | GET | `/api/v3/stockplus/trade/max-purchase` | -| [getStockPlusTodayExecutions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1458) | :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#L1464) | :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#L1473) | :closed_lock_with_key: | GET | `/api/v3/stockplus/asset/account` | -| [getStockPlusCashFlow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1479) | :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#L1485) | :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#L1491) | :closed_lock_with_key: | POST | `/api/v3/stockplus/asset/transfer` | -| [getStockPlusTransferRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1497) | :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#L1509) | :closed_lock_with_key: | GET | `/api/v3/cfd/market/tickers` | -| [getCfdHistoryCandlestick()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1515) | :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#L1521) | :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#L1527) | :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#L1533) | :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#L1537) | :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#L1543) | :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#L1549) | :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#L1555) | :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#L1566) | :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#L1572) | :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#L1578) | :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#L1582) | :closed_lock_with_key: | POST | `/api/v3/cfd/account/transfer` | -| [getCfdTransferRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1588) | :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#L1594) | :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#L1600) | :closed_lock_with_key: | GET | `/api/v3/cfd/account/instruments` | -| [getBalances()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1615) | :closed_lock_with_key: | GET | `/api/v3/account/assets` | -| [getFundingAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1622) | :closed_lock_with_key: | GET | `/api/v3/account/funding-assets` | -| [getAccountInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1632) | :closed_lock_with_key: | GET | `/api/v3/account/info` | -| [getAccountSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1640) | :closed_lock_with_key: | GET | `/api/v3/account/settings` | -| [adjustAccountMode()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1647) | :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#L1657) | :closed_lock_with_key: | GET | `/api/v3/account/delta-info` | -| [setLeverage()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1666) | :closed_lock_with_key: | POST | `/api/v3/account/set-leverage` | -| [setHoldMode()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1673) | :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#L1682) | :closed_lock_with_key: | GET | `/api/v3/account/collateral-type` | -| [setCollateralType()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1689) | :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#L1698) | | GET | `/api/v3/account/custom-collateral-coins` | -| [preSetLeverage()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1705) | :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#L1714) | :closed_lock_with_key: | POST | `/api/v3/account/set-margin` | -| [getMaxWithdrawal()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1721) | :closed_lock_with_key: | GET | `/api/v3/account/max-withdrawal` | -| [getFinancialRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1730) | :closed_lock_with_key: | GET | `/api/v3/account/financial-records` | -| [getFundingFinancialRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1744) | :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#L1758) | :closed_lock_with_key: | GET | `/api/v3/account/repayable-coins` | -| [getPaymentCoins()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1770) | :closed_lock_with_key: | GET | `/api/v3/account/payment-coins` | -| [submitRepay()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1782) | :closed_lock_with_key: | POST | `/api/v3/account/repay` | -| [borrow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1786) | :closed_lock_with_key: | POST | `/api/v3/account/borrow` | -| [getMaxBorrowable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1790) | :closed_lock_with_key: | GET | `/api/v3/account/max-borrowable` | -| [setRepayMode()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1796) | :closed_lock_with_key: | POST | `/api/v3/account/set-repay-mode` | -| [getConvertRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1805) | :closed_lock_with_key: | GET | `/api/v3/account/convert-records` | -| [getSmallAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1814) | :closed_lock_with_key: | GET | `/api/v3/convert/small-assets` | -| [tradeSmallAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1820) | :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#L1826) | :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#L1841) | :closed_lock_with_key: | POST | `/api/v3/account/deposit-account` | -| [switchDeduct()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1850) | :closed_lock_with_key: | POST | `/api/v3/account/switch-deduct` | -| [getDeductInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1857) | :closed_lock_with_key: | GET | `/api/v3/account/deduct-info` | -| [getFeeRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1868) | :closed_lock_with_key: | GET | `/api/v3/account/fee-rate` | -| [getAllFeeRates()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1880) | :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#L1893) | :closed_lock_with_key: | GET | `/api/v3/account/max-transferable` | -| [getOpenInterestLimit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1905) | :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#L1911) | :closed_lock_with_key: | GET | `/api/v3/account/eligible-symbols` | -| [getEligibleMarginTier()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1917) | :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#L1923) | :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#L1929) | :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#L1944) | :closed_lock_with_key: | POST | `/api/v3/account/switch` | -| [getUnifiedAccountSwitchStatus()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1952) | :closed_lock_with_key: | GET | `/api/v3/account/switch-status` | -| [getTaxRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1968) | :closed_lock_with_key: | GET | `/api/v3/tax/records` | -| [createSubAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1983) | :closed_lock_with_key: | POST | `/api/v3/user/create-sub` | -| [createAgentSubAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1992) | :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#L2001) | :closed_lock_with_key: | POST | `/api/v3/user/freeze-sub` | -| [deleteSubAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2007) | :closed_lock_with_key: | POST | `/api/v3/user/delete-sub` | -| [getSubUnifiedAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2016) | :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#L2025) | :closed_lock_with_key: | GET | `/api/v3/user/sub-list` | -| [createSubAccountApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2038) | :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#L2047) | :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#L2056) | :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#L2065) | :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#L2079) | :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#L2090) | :closed_lock_with_key: | POST | `/api/v3/user/set-rate-limit-quota` | -| [createStpGroup()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2100) | :closed_lock_with_key: | POST | `/api/v3/account/create-stp-groups` | -| [getStpGroups()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2110) | :closed_lock_with_key: | GET | `/api/v3/account/stp-groups` | -| [addStpGroupMembers()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2120) | :closed_lock_with_key: | POST | `/api/v3/account/add-groups-members` | -| [removeStpGroupMembers()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2132) | :closed_lock_with_key: | POST | `/api/v3/account/remove-groups-members` | -| [getTransferableCoins()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2147) | :closed_lock_with_key: | GET | `/api/v3/account/transferable-coins` | -| [submitTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2156) | :closed_lock_with_key: | POST | `/api/v3/account/transfer` | -| [subAccountTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2165) | :closed_lock_with_key: | POST | `/api/v3/account/sub-transfer` | -| [getSubTransferRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2177) | :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#L2189) | :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#L2207) | :closed_lock_with_key: | GET | `/api/v3/account/deposit-address` | -| [getSubDepositAddress()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2216) | :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#L2225) | :closed_lock_with_key: | GET | `/api/v3/account/deposit-records` | -| [getSubDepositRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2234) | :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#L2249) | :closed_lock_with_key: | POST | `/api/v3/account/withdraw` | -| [getWithdrawRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2258) | :closed_lock_with_key: | GET | `/api/v3/account/withdrawal-records` | -| [getWithdrawAddressBook()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2267) | :closed_lock_with_key: | GET | `/api/v3/account/withdraw-address` | -| [cancelWithdrawal()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2276) | :closed_lock_with_key: | POST | `/api/v3/account/cancel-withdrawal` | -| [submitNewOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2294) | :closed_lock_with_key: | POST | `/api/v3/trade/place-order` | -| [modifyOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2303) | :closed_lock_with_key: | POST | `/api/v3/trade/modify-order` | -| [placeRealityOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2312) | :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#L2321) | :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#L2330) | :closed_lock_with_key: | GET | `/api/v3/trade/loan-data` | -| [cancelOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2337) | :closed_lock_with_key: | POST | `/api/v3/trade/cancel-order` | -| [placeBatchOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2346) | :closed_lock_with_key: | POST | `/api/v3/trade/place-batch` | -| [batchModifyOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2355) | :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#L2364) | :closed_lock_with_key: | POST | `/api/v3/trade/cancel-batch` | -| [cancelAllOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2373) | :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#L2382) | :closed_lock_with_key: | POST | `/api/v3/trade/close-positions` | -| [getOrderInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2391) | :closed_lock_with_key: | GET | `/api/v3/trade/order-info` | -| [getUnfilledOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2400) | :closed_lock_with_key: | GET | `/api/v3/trade/unfilled-orders` | -| [getHistoryOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2412) | :closed_lock_with_key: | GET | `/api/v3/trade/history-orders` | -| [movePositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2424) | :closed_lock_with_key: | POST | `/api/v3/account/move-positions` | -| [getMovePositionHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2433) | :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#L2445) | :closed_lock_with_key: | GET | `/api/v3/trade/fills` | -| [getCurrentPosition()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2457) | :closed_lock_with_key: | GET | `/api/v3/position/current-position` | -| [getPositionHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2472) | :closed_lock_with_key: | GET | `/api/v3/position/history-position` | -| [getMaxOpenAvailable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2486) | :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#L2495) | :closed_lock_with_key: | GET | `/api/v3/position/adlRank` | -| [countdownCancelAll()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2502) | :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#L2517) | :closed_lock_with_key: | GET | `/api/v3/ins-loan/transfered` | -| [getLoanSymbols()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2526) | :closed_lock_with_key: | GET | `/api/v3/ins-loan/symbols` | -| [getLoanRiskUnit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2535) | :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#L2546) | :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#L2555) | :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#L2564) | :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#L2573) | :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#L2582) | :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#L2594) | :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#L2609) | :closed_lock_with_key: | GET | `/api/v3/loan/coins` | -| [getLoanInterest()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2618) | :closed_lock_with_key: | GET | `/api/v3/loan/interest` | -| [loanBorrow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2627) | :closed_lock_with_key: | POST | `/api/v3/loan/borrow` | -| [getLoanBorrowOngoing()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2636) | :closed_lock_with_key: | GET | `/api/v3/loan/borrow-ongoing` | -| [getLoanBorrowHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2645) | :closed_lock_with_key: | GET | `/api/v3/loan/borrow-history` | -| [loanRepay()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2654) | :closed_lock_with_key: | POST | `/api/v3/loan/repay` | -| [getLoanRepayHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2663) | :closed_lock_with_key: | GET | `/api/v3/loan/repay-history` | -| [loanRevisePledge()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2672) | :closed_lock_with_key: | POST | `/api/v3/loan/revise-pledge` | -| [getLoanPledgeRateHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2681) | :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#L2690) | :closed_lock_with_key: | GET | `/api/v3/loan/debts` | -| [getLoanReduces()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2697) | :closed_lock_with_key: | GET | `/api/v3/loan/reduces` | -| [submitStrategyOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2712) | :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#L2721) | :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#L2730) | :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#L2739) | :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#L2748) | :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#L2758) | :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#L2773) | :closed_lock_with_key: | POST | `/api/v3/trade/grid/validate` | -| [createGridBot()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2779) | :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#L2785) | :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#L2791) | :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#L2797) | :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#L2803) | :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#L2809) | :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#L2815) | :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#L2821) | :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#L2827) | :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#L2833) | :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#L2839) | :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#L2848) | :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#L2854) | :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#L2872) | :closed_lock_with_key: | POST | `/api/v3/broker/create-sub` | -| [getBrokerSubAccountList()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2884) | :closed_lock_with_key: | GET | `/api/v3/broker/sub-list` | -| [modifyBrokerSubAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2896) | :closed_lock_with_key: | POST | `/api/v3/broker/modify-sub` | -| [brokerSubWithdrawal()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2911) | :closed_lock_with_key: | POST | `/api/v3/broker/sub-withdrawal` | -| [getBrokerSubDepositAddress()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2923) | :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#L2935) | :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#L2947) | :closed_lock_with_key: | GET | `/api/v3/broker/commission` | -| [createBrokerSubApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2959) | :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#L2971) | :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#L2987) | :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#L2999) | :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#L3011) | :closed_lock_with_key: | GET | `/api/v3/p2p/ad-list` | -| [getP2pExchangeRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3017) | :closed_lock_with_key: | GET | `/api/v3/p2p/exchange-rate` | -| [simulateP2pFee()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3023) | :closed_lock_with_key: | POST | `/api/v3/p2p/fee-simulate` | -| [getP2pAdLimit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3029) | :closed_lock_with_key: | GET | `/api/v3/p2p/ad-limit` | -| [createP2pAd()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3035) | :closed_lock_with_key: | POST | `/api/v3/p2p/ad-create` | -| [updateP2pAd()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3041) | :closed_lock_with_key: | POST | `/api/v3/p2p/ad-update` | -| [operateP2pAd()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3045) | :closed_lock_with_key: | POST | `/api/v3/p2p/ad-operate` | -| [getP2pAdInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3049) | :closed_lock_with_key: | GET | `/api/v3/p2p/ad-info` | -| [getP2pMyAds()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3055) | :closed_lock_with_key: | GET | `/api/v3/p2p/my-ads` | -| [getP2pPendingOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3061) | :closed_lock_with_key: | GET | `/api/v3/p2p/pending-orders` | -| [getP2pAllOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3067) | :closed_lock_with_key: | GET | `/api/v3/p2p/all-orders` | -| [getP2pOrderInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3073) | :closed_lock_with_key: | GET | `/api/v3/p2p/order-info` | -| [confirmP2pOrderPayment()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3079) | :closed_lock_with_key: | POST | `/api/v3/p2p/order-pay` | -| [releaseP2pOrderAsset()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3085) | :closed_lock_with_key: | POST | `/api/v3/p2p/order-release` | -| [getP2pUserInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3091) | :closed_lock_with_key: | GET | `/api/v3/p2p/user-info` | -| [getP2pCurrencies()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3095) | :closed_lock_with_key: | GET | `/api/v3/p2p/currencies` | -| [getP2pPayMethods()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3099) | :closed_lock_with_key: | GET | `/api/v3/p2p/pay-method` | -| [getP2pBalance()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3103) | :closed_lock_with_key: | GET | `/api/v3/p2p/balance` | -| [getEarnEliteProducts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3115) | :closed_lock_with_key: | GET | `/api/v3/earn/elite-product` | -| [getEarnEliteAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3119) | :closed_lock_with_key: | GET | `/api/v3/earn/elite-assets` | -| [getEarnEliteRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3123) | :closed_lock_with_key: | GET | `/api/v3/earn/elite-records` | -| [getEarnEliteSubscribeInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3129) | :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#L3135) | :closed_lock_with_key: | POST | `/api/v3/earn/elite-subscribe` | -| [getEarnEliteSubscribeResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3141) | :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#L3147) | :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#L3153) | :closed_lock_with_key: | POST | `/api/v3/earn/elite-redeem` | -| [getEarnCashPlusSubscribeInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3170) | :closed_lock_with_key: | GET | `/api/v3/earn/cashplus/subscribe-info` | -| [subscribeEarnCashPlus()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3179) | :closed_lock_with_key: | POST | `/api/v3/earn/cashplus/subscribe` | -| [getEarnCashPlusSubscribeResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3188) | :closed_lock_with_key: | GET | `/api/v3/earn/cashplus/subscribe-result` | -| [getEarnCashPlusRedeemInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3198) | :closed_lock_with_key: | GET | `/api/v3/earn/cashplus/redeem-info` | -| [redeemEarnCashPlus()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3205) | :closed_lock_with_key: | POST | `/api/v3/earn/cashplus/redeem` | -| [getEarnCashPlusRedeemResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3214) | :closed_lock_with_key: | GET | `/api/v3/earn/cashplus/redeem-result` | -| [getEarnCashPlusPositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3223) | :closed_lock_with_key: | GET | `/api/v3/earn/cashplus/positions` | -| [getEarnCashPlusHistoryOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3230) | :closed_lock_with_key: | GET | `/api/v3/earn/cashplus/history-orders` | +| [getServerTime()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L711) | | GET | `/api/v3/market/time` | +| [getAnnouncements()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L725) | | GET | `/api/v3/public/annoucements` | +| [getInstruments()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L744) | | GET | `/api/v3/market/instruments` | +| [getMarketFeeGroup()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L753) | | GET | `/api/v3/market/fee-group` | +| [getLiquidations()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L762) | | GET | `/api/v3/market/liquidations` | +| [getRpiSymbols()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L771) | | GET | `/api/v3/market/rpi-symbols` | +| [getRpiOrderBook()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L778) | | GET | `/api/v3/market/rpi-orderbook` | +| [getCashDividendRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L787) | | GET | `/api/v3/market/cash-dividend-records` | +| [getSplitRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L793) | | GET | `/api/v3/market/split-records` | +| [getSpotWhaleFlow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L802) | | GET | `/api/v3/market/spot-whale-flow` | +| [getSpotFundFlow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L811) | | GET | `/api/v3/market/spot-fund-flow` | +| [getSpotNetFlow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L820) | | GET | `/api/v3/market/spot-net-flow` | +| [getMarginLongShort()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L829) | | GET | `/api/v3/market/margin-long-short` | +| [getMarginLoanGrowth()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L838) | | GET | `/api/v3/market/margin-loan-growth` | +| [getMarginIsolatedBorrow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L847) | | GET | `/api/v3/market/margin-isolated-borrow` | +| [getFuturesActiveBuySell()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L856) | | GET | `/api/v3/market/futures-active-buy-sell` | +| [getFuturesLongShort()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L865) | | GET | `/api/v3/market/futures-long-short` | +| [getFuturesPositionLongShort()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L874) | | GET | `/api/v3/market/futures-position-long-short` | +| [getFuturesAccountLongShort()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L883) | | GET | `/api/v3/market/futures-account-long-short` | +| [getMarketScoreWeights()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L892) | | GET | `/api/v3/market/score-weights` | +| [getTickers()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L901) | | GET | `/api/v3/market/tickers` | +| [getOrderBook()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L911) | | GET | `/api/v3/market/orderbook` | +| [getFills()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L920) | | GET | `/api/v3/market/fills` | +| [getProofOfReserves()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L929) | | GET | `/api/v3/market/proof-of-reserves` | +| [getOpenInterest()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L936) | | GET | `/api/v3/market/open-interest` | +| [getOpenInterestHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L946) | | GET | `/api/v3/market/open-interest-history` | +| [getCoins()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L957) | | GET | `/api/v3/market/coins` | +| [getCandles()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L965) | | GET | `/api/v3/market/candles` | +| [getHistoryCandles()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L974) | | GET | `/api/v3/market/history-candles` | +| [getCurrentFundingRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L983) | | GET | `/api/v3/market/current-fund-rate` | +| [getHistoryFundingRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L992) | | GET | `/api/v3/market/history-fund-rate` | +| [getRiskReserve()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1001) | | GET | `/api/v3/market/risk-reserve` | +| [getRiskReserveHour()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1010) | | GET | `/api/v3/market/risk-reserve-hour` | +| [getRiskReserveAll()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1019) | | GET | `/api/v3/market/risk-reserve-all` | +| [getDiscountRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1028) | | GET | `/api/v3/market/discount-rate` | +| [getInterestRateHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1037) | | GET | `/api/v3/market/interest-rate-history` | +| [getMarginLoans()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1046) | | GET | `/api/v3/market/margin-loans` | +| [getMarginLoansAll()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1056) | | GET | `/api/v3/market/margin-loans-all` | +| [getPositionTier()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1065) | | GET | `/api/v3/market/position-tier` | +| [getContractsOi()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1074) | | GET | `/api/v3/market/oi-limit` | +| [getIndexComponents()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1083) | | GET | `/api/v3/market/index-components` | +| [getRealityOrderBook()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1094) | :closed_lock_with_key: | GET | `/api/v3/account/reality-orderbook` | +| [getRealityOrderBookSegmented()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1107) | :closed_lock_with_key: | GET | `/api/v3/account/reality-orderbook-segmented` | +| [getRealityFills()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1119) | :closed_lock_with_key: | GET | `/api/v3/account/reality-fills` | +| [getRealityCompanyOverview()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1125) | | GET | `/api/v3/reality/market/company-overview` | +| [getRealityValuationIndicators()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1131) | | GET | `/api/v3/reality/market/valuation-indicators` | +| [getRealityEarningsForecast()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1137) | | GET | `/api/v3/reality/market/earnings-forecast` | +| [getRealitySuspensionResumptionInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1143) | | GET | `/api/v3/reality/market/suspension-resumption-info` | +| [getRealityDividends()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1152) | | GET | `/api/v3/reality/market/dividends` | +| [getRealityShareCapitalChange()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1158) | | GET | `/api/v3/reality/market/share-capital-change` | +| [getRealityInnerTrades()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1164) | | GET | `/api/v3/reality/market/inner-trades` | +| [getRealityExecutiveShareholdings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1170) | | GET | `/api/v3/reality/market/executive-shareholdings` | +| [getRealityShareholdDetail()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1178) | | GET | `/api/v3/reality/market/sharehold-detail` | +| [getRealityStockInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1184) | | GET | `/api/v3/reality/market/stock-info` | +| [getRealityMarketStates()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1190) | | GET | `/api/v3/reality/market/states` | +| [getRealityMarketCalendar()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1194) | | GET | `/api/v3/reality/market/calendar` | +| [getCopyFuturesTradingPairs()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1209) | :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#L1220) | :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#L1230) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/max-transferable` | +| [getCopyFuturesCopyMaxTransferable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1241) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/copy-max-transferable` | +| [copyFuturesTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1254) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/transfer` | +| [getCopyFuturesTransferRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1264) | :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#L1270) | :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#L1276) | :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#L1282) | :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#L1288) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/profit-details` | +| [getCopyFuturesPortfolioOverview()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1294) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/portfolio-overview` | +| [createCopyFutures()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1300) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/follower-settings` | +| [modifyCopyFuturesFollowerSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1306) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/modify-follower-settings` | +| [unfollowCopyFutures()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1315) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/unfollow` | +| [getCopyFuturesCopySettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1321) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/copy-settings` | +| [copyFuturesFollowerTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1327) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/copy-transfer` | +| [getCopyFuturesFollowerTransferRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1333) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/copy-transfer-record` | +| [getCopyFuturesCurrentCopy()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1339) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/current-copy` | +| [getCopyFuturesCopyProfitDetails()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1345) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/copy-profit-details` | +| [closeCopyFuturesPositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1351) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/close-positions` | +| [closeAllCopyFuturesPositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1357) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/close-all` | +| [getCopyFuturesCurrentPositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1363) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/current-positions` | +| [placeCopyFuturesTpSl()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1369) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/place-tpsl` | +| [modifyCopyFuturesTpSl()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1375) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/modify-tpsl` | +| [cancelCopyFuturesTpSl()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1381) | :closed_lock_with_key: | POST | `/api/v3/copy/futures/cancel-tpsl` | +| [getCopyFuturesCurrentTpSlOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1387) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/current-tpsl-orders` | +| [getCopyFuturesTpSlOrderHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1393) | :closed_lock_with_key: | GET | `/api/v3/copy/futures/tpsl-order-history` | +| [getStockPlusOptionQuote()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1405) | :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#L1411) | :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#L1420) | :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#L1429) | :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#L1435) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/static` | +| [getStockPlusQuote()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1441) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/quote` | +| [getStockPlusTradeDetail()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1447) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/trade` | +| [getStockPlusIntraday()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1453) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/intraday` | +| [getStockPlusHistoryCandlestick()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1459) | :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#L1468) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/candlestick` | +| [getStockPlusDepth()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1474) | :closed_lock_with_key: | GET | `/api/v3/stockplus/market/depth` | +| [placeStockPlusOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1480) | :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#L1486) | :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#L1492) | :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#L1498) | :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#L1504) | :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#L1510) | :closed_lock_with_key: | GET | `/api/v3/stockplus/trade/order-detail` | +| [getStockPlusMaxPurchase()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1516) | :closed_lock_with_key: | GET | `/api/v3/stockplus/trade/max-purchase` | +| [getStockPlusTodayExecutions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1522) | :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#L1528) | :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#L1537) | :closed_lock_with_key: | GET | `/api/v3/stockplus/asset/account` | +| [getStockPlusCashFlow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1543) | :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#L1549) | :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#L1555) | :closed_lock_with_key: | POST | `/api/v3/stockplus/asset/transfer` | +| [getStockPlusTransferRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1561) | :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#L1573) | :closed_lock_with_key: | GET | `/api/v3/cfd/market/tickers` | +| [getCfdHistoryCandlestick()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1579) | :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#L1585) | :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#L1591) | :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#L1597) | :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#L1601) | :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#L1607) | :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#L1613) | :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#L1619) | :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#L1630) | :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#L1636) | :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#L1642) | :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#L1646) | :closed_lock_with_key: | POST | `/api/v3/cfd/account/transfer` | +| [getCfdTransferRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1652) | :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#L1658) | :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#L1664) | :closed_lock_with_key: | GET | `/api/v3/cfd/account/instruments` | +| [getBalances()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1679) | :closed_lock_with_key: | GET | `/api/v3/account/assets` | +| [getFundingAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1686) | :closed_lock_with_key: | GET | `/api/v3/account/funding-assets` | +| [getAccountInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1696) | :closed_lock_with_key: | GET | `/api/v3/account/info` | +| [getAccountSettings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1704) | :closed_lock_with_key: | GET | `/api/v3/account/settings` | +| [adjustAccountMode()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1711) | :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#L1721) | :closed_lock_with_key: | GET | `/api/v3/account/delta-info` | +| [setLeverage()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1730) | :closed_lock_with_key: | POST | `/api/v3/account/set-leverage` | +| [setHoldMode()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1737) | :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#L1746) | :closed_lock_with_key: | GET | `/api/v3/account/collateral-type` | +| [setCollateralType()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1753) | :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#L1762) | | GET | `/api/v3/account/custom-collateral-coins` | +| [preSetLeverage()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1769) | :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#L1778) | :closed_lock_with_key: | POST | `/api/v3/account/set-margin` | +| [getMaxWithdrawal()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1785) | :closed_lock_with_key: | GET | `/api/v3/account/max-withdrawal` | +| [getFinancialRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1794) | :closed_lock_with_key: | GET | `/api/v3/account/financial-records` | +| [getFundingFinancialRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1808) | :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#L1822) | :closed_lock_with_key: | GET | `/api/v3/account/repayable-coins` | +| [getPaymentCoins()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1834) | :closed_lock_with_key: | GET | `/api/v3/account/payment-coins` | +| [submitRepay()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1846) | :closed_lock_with_key: | POST | `/api/v3/account/repay` | +| [borrow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1850) | :closed_lock_with_key: | POST | `/api/v3/account/borrow` | +| [getMaxBorrowable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1854) | :closed_lock_with_key: | GET | `/api/v3/account/max-borrowable` | +| [setRepayMode()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1860) | :closed_lock_with_key: | POST | `/api/v3/account/set-repay-mode` | +| [getConvertRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1869) | :closed_lock_with_key: | GET | `/api/v3/account/convert-records` | +| [getSmallAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1878) | :closed_lock_with_key: | GET | `/api/v3/convert/small-assets` | +| [tradeSmallAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1884) | :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#L1890) | :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#L1905) | :closed_lock_with_key: | POST | `/api/v3/account/deposit-account` | +| [switchDeduct()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1914) | :closed_lock_with_key: | POST | `/api/v3/account/switch-deduct` | +| [getDeductInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1921) | :closed_lock_with_key: | GET | `/api/v3/account/deduct-info` | +| [getFeeRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1932) | :closed_lock_with_key: | GET | `/api/v3/account/fee-rate` | +| [getAllFeeRates()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1944) | :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#L1957) | :closed_lock_with_key: | GET | `/api/v3/account/max-transferable` | +| [getOpenInterestLimit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1969) | :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#L1975) | :closed_lock_with_key: | GET | `/api/v3/account/eligible-symbols` | +| [getEligibleMarginTier()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L1981) | :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#L1987) | :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#L1993) | :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#L2008) | :closed_lock_with_key: | POST | `/api/v3/account/switch` | +| [getUnifiedAccountSwitchStatus()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2016) | :closed_lock_with_key: | GET | `/api/v3/account/switch-status` | +| [getTaxRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2032) | :closed_lock_with_key: | GET | `/api/v3/tax/records` | +| [createSubAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2047) | :closed_lock_with_key: | POST | `/api/v3/user/create-sub` | +| [createAgentSubAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2056) | :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#L2065) | :closed_lock_with_key: | POST | `/api/v3/user/freeze-sub` | +| [deleteSubAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2071) | :closed_lock_with_key: | POST | `/api/v3/user/delete-sub` | +| [getSubUnifiedAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2080) | :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#L2089) | :closed_lock_with_key: | GET | `/api/v3/user/sub-list` | +| [createSubAccountApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2102) | :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#L2111) | :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#L2120) | :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#L2129) | :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#L2143) | :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#L2154) | :closed_lock_with_key: | POST | `/api/v3/user/set-rate-limit-quota` | +| [createStpGroup()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2164) | :closed_lock_with_key: | POST | `/api/v3/account/create-stp-groups` | +| [getStpGroups()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2174) | :closed_lock_with_key: | GET | `/api/v3/account/stp-groups` | +| [addStpGroupMembers()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2184) | :closed_lock_with_key: | POST | `/api/v3/account/add-groups-members` | +| [removeStpGroupMembers()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2196) | :closed_lock_with_key: | POST | `/api/v3/account/remove-groups-members` | +| [getTransferableCoins()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2211) | :closed_lock_with_key: | GET | `/api/v3/account/transferable-coins` | +| [submitTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2220) | :closed_lock_with_key: | POST | `/api/v3/account/transfer` | +| [subAccountTransfer()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2229) | :closed_lock_with_key: | POST | `/api/v3/account/sub-transfer` | +| [getSubTransferRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2241) | :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#L2253) | :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#L2271) | :closed_lock_with_key: | GET | `/api/v3/account/deposit-address` | +| [getSubDepositAddress()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2280) | :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#L2289) | :closed_lock_with_key: | GET | `/api/v3/account/deposit-records` | +| [getSubDepositRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2298) | :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#L2313) | :closed_lock_with_key: | POST | `/api/v3/account/withdraw` | +| [getWithdrawRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2322) | :closed_lock_with_key: | GET | `/api/v3/account/withdrawal-records` | +| [getWithdrawAddressBook()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2331) | :closed_lock_with_key: | GET | `/api/v3/account/withdraw-address` | +| [cancelWithdrawal()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2340) | :closed_lock_with_key: | POST | `/api/v3/account/cancel-withdrawal` | +| [submitNewOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2358) | :closed_lock_with_key: | POST | `/api/v3/trade/place-order` | +| [modifyOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2367) | :closed_lock_with_key: | POST | `/api/v3/trade/modify-order` | +| [placeRealityOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2376) | :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#L2385) | :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#L2394) | :closed_lock_with_key: | GET | `/api/v3/trade/loan-data` | +| [cancelOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2401) | :closed_lock_with_key: | POST | `/api/v3/trade/cancel-order` | +| [placeBatchOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2410) | :closed_lock_with_key: | POST | `/api/v3/trade/place-batch` | +| [batchModifyOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2419) | :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#L2428) | :closed_lock_with_key: | POST | `/api/v3/trade/cancel-batch` | +| [cancelAllOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2437) | :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#L2446) | :closed_lock_with_key: | POST | `/api/v3/trade/close-positions` | +| [getOrderInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2455) | :closed_lock_with_key: | GET | `/api/v3/trade/order-info` | +| [getUnfilledOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2464) | :closed_lock_with_key: | GET | `/api/v3/trade/unfilled-orders` | +| [getHistoryOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2476) | :closed_lock_with_key: | GET | `/api/v3/trade/history-orders` | +| [movePositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2488) | :closed_lock_with_key: | POST | `/api/v3/account/move-positions` | +| [getMovePositionHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2497) | :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#L2509) | :closed_lock_with_key: | GET | `/api/v3/trade/fills` | +| [getCurrentPosition()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2521) | :closed_lock_with_key: | GET | `/api/v3/position/current-position` | +| [getPositionHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2536) | :closed_lock_with_key: | GET | `/api/v3/position/history-position` | +| [getMaxOpenAvailable()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2550) | :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#L2559) | :closed_lock_with_key: | GET | `/api/v3/position/adlRank` | +| [countdownCancelAll()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2566) | :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#L2581) | :closed_lock_with_key: | GET | `/api/v3/ins-loan/transfered` | +| [getLoanSymbols()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2590) | :closed_lock_with_key: | GET | `/api/v3/ins-loan/symbols` | +| [getLoanRiskUnit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2599) | :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#L2610) | :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#L2619) | :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#L2628) | :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#L2637) | :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#L2646) | :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#L2658) | :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#L2673) | :closed_lock_with_key: | GET | `/api/v3/loan/coins` | +| [getLoanInterest()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2682) | :closed_lock_with_key: | GET | `/api/v3/loan/interest` | +| [loanBorrow()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2691) | :closed_lock_with_key: | POST | `/api/v3/loan/borrow` | +| [getLoanBorrowOngoing()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2700) | :closed_lock_with_key: | GET | `/api/v3/loan/borrow-ongoing` | +| [getLoanBorrowHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2709) | :closed_lock_with_key: | GET | `/api/v3/loan/borrow-history` | +| [loanRepay()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2718) | :closed_lock_with_key: | POST | `/api/v3/loan/repay` | +| [getLoanRepayHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2727) | :closed_lock_with_key: | GET | `/api/v3/loan/repay-history` | +| [loanRevisePledge()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2736) | :closed_lock_with_key: | POST | `/api/v3/loan/revise-pledge` | +| [getLoanPledgeRateHistory()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2745) | :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#L2754) | :closed_lock_with_key: | GET | `/api/v3/loan/debts` | +| [getLoanReduces()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2761) | :closed_lock_with_key: | GET | `/api/v3/loan/reduces` | +| [submitStrategyOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2776) | :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#L2785) | :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#L2794) | :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#L2803) | :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#L2812) | :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#L2822) | :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#L2837) | :closed_lock_with_key: | POST | `/api/v3/trade/grid/validate` | +| [createGridBot()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2843) | :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#L2849) | :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#L2855) | :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#L2861) | :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#L2867) | :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#L2873) | :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#L2879) | :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#L2885) | :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#L2891) | :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#L2897) | :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#L2903) | :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#L2912) | :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#L2918) | :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#L2936) | :closed_lock_with_key: | POST | `/api/v3/broker/create-sub` | +| [getBrokerSubAccountList()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2948) | :closed_lock_with_key: | GET | `/api/v3/broker/sub-list` | +| [modifyBrokerSubAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2960) | :closed_lock_with_key: | POST | `/api/v3/broker/modify-sub` | +| [brokerSubWithdrawal()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2975) | :closed_lock_with_key: | POST | `/api/v3/broker/sub-withdrawal` | +| [getBrokerSubDepositAddress()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L2987) | :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#L2999) | :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#L3011) | :closed_lock_with_key: | GET | `/api/v3/broker/commission` | +| [createBrokerSubApiKey()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3023) | :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#L3035) | :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#L3051) | :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#L3063) | :closed_lock_with_key: | GET | `/api/v3/broker/query-sub-apikey` | +| [getAgentCustomerList()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3079) | :closed_lock_with_key: | GET | `/api/v3/affiliate/customer-list` | +| [getAgentCustomerAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3088) | :closed_lock_with_key: | GET | `/api/v3/affiliate/customer-asset` | +| [getAgentCustomerTradeVolume()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3097) | :closed_lock_with_key: | GET | `/api/v3/affiliate/customer-trade-volume` | +| [getAgentCustomerDeposits()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3106) | :closed_lock_with_key: | GET | `/api/v3/affiliate/customer-deposit` | +| [getAgentCustomerKycResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3115) | :closed_lock_with_key: | GET | `/api/v3/affiliate/customer-kyc-result` | +| [getAgentCustomerCommissions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3124) | :closed_lock_with_key: | GET | `/api/v3/affiliate/customer-commission` | +| [getAgentSubCustomerList()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3134) | :closed_lock_with_key: | GET | `/api/v3/affiliate/sub-customer-list` | +| [getSubAffiliateInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3143) | :closed_lock_with_key: | GET | `/api/v3/affiliate/sub-affiliate-info` | +| [getSubAffiliateCommission()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3152) | :closed_lock_with_key: | GET | `/api/v3/affiliate/sub-affiliate-commission` | +| [modifySubaccountEmail()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3170) | :closed_lock_with_key: | POST | `/api/v3/broker/modify-subaccount-email` | +| [getSubaccountEmail()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3179) | :closed_lock_with_key: | GET | `/api/v3/broker/subaccount-email` | +| [getBrokerTradeVolume()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3189) | :closed_lock_with_key: | GET | `/api/v3/broker/trade-volume` | +| [getBrokerTotalCommission()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3198) | :closed_lock_with_key: | GET | `/api/v3/broker/total-commission` | +| [getBrokerOrderCommission()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3207) | :closed_lock_with_key: | GET | `/api/v3/broker/order-commission` | +| [getBrokerRebateInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3216) | :closed_lock_with_key: | GET | `/api/v3/broker/rebate-info` | +| [getP2pAdList()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3228) | :closed_lock_with_key: | GET | `/api/v3/p2p/ad-list` | +| [getP2pExchangeRate()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3234) | :closed_lock_with_key: | GET | `/api/v3/p2p/exchange-rate` | +| [simulateP2pFee()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3240) | :closed_lock_with_key: | POST | `/api/v3/p2p/fee-simulate` | +| [getP2pAdLimit()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3246) | :closed_lock_with_key: | GET | `/api/v3/p2p/ad-limit` | +| [createP2pAd()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3252) | :closed_lock_with_key: | POST | `/api/v3/p2p/ad-create` | +| [updateP2pAd()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3258) | :closed_lock_with_key: | POST | `/api/v3/p2p/ad-update` | +| [operateP2pAd()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3262) | :closed_lock_with_key: | POST | `/api/v3/p2p/ad-operate` | +| [getP2pAdInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3266) | :closed_lock_with_key: | GET | `/api/v3/p2p/ad-info` | +| [getP2pMyAds()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3272) | :closed_lock_with_key: | GET | `/api/v3/p2p/my-ads` | +| [getP2pPendingOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3278) | :closed_lock_with_key: | GET | `/api/v3/p2p/pending-orders` | +| [getP2pAllOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3284) | :closed_lock_with_key: | GET | `/api/v3/p2p/all-orders` | +| [getP2pOrderInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3290) | :closed_lock_with_key: | GET | `/api/v3/p2p/order-info` | +| [confirmP2pOrderPayment()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3296) | :closed_lock_with_key: | POST | `/api/v3/p2p/order-pay` | +| [releaseP2pOrderAsset()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3302) | :closed_lock_with_key: | POST | `/api/v3/p2p/order-release` | +| [getP2pUserInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3308) | :closed_lock_with_key: | GET | `/api/v3/p2p/user-info` | +| [getP2pCurrencies()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3312) | :closed_lock_with_key: | GET | `/api/v3/p2p/currencies` | +| [getP2pPayMethods()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3316) | :closed_lock_with_key: | GET | `/api/v3/p2p/pay-method` | +| [getP2pBalance()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3320) | :closed_lock_with_key: | GET | `/api/v3/p2p/balance` | +| [getEarnSavingsProducts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3335) | :closed_lock_with_key: | GET | `/api/v3/earn/savings/product` | +| [getEarnSavingsAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3344) | :closed_lock_with_key: | GET | `/api/v3/earn/savings/account` | +| [getEarnSavingsAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3351) | :closed_lock_with_key: | GET | `/api/v3/earn/savings/assets` | +| [getEarnSavingsRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3360) | :closed_lock_with_key: | GET | `/api/v3/earn/savings/records` | +| [getEarnSavingsSubscription()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3369) | :closed_lock_with_key: | GET | `/api/v3/earn/savings/subscribe-info` | +| [earnSubscribeSavings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3378) | :closed_lock_with_key: | POST | `/api/v3/earn/savings/subscribe` | +| [getEarnSavingsSubscriptionResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3387) | :closed_lock_with_key: | GET | `/api/v3/earn/savings/subscribe-result` | +| [earnRedeemSavings()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3396) | :closed_lock_with_key: | POST | `/api/v3/earn/savings/redeem` | +| [getEarnSavingsRedemptionResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3405) | :closed_lock_with_key: | GET | `/api/v3/earn/savings/redeem-result` | +| [getSharkfinProducts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3420) | :closed_lock_with_key: | GET | `/api/v3/earn/sharkfin/product` | +| [getSharkfinAccount()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3429) | :closed_lock_with_key: | GET | `/api/v3/earn/sharkfin/account` | +| [getSharkfinAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3436) | :closed_lock_with_key: | GET | `/api/v3/earn/sharkfin/assets` | +| [getSharkfinRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3445) | :closed_lock_with_key: | GET | `/api/v3/earn/sharkfin/records` | +| [getSharkfinSubscription()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3454) | :closed_lock_with_key: | GET | `/api/v3/earn/sharkfin/subscribe-info` | +| [subscribeSharkfin()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3463) | :closed_lock_with_key: | POST | `/api/v3/earn/sharkfin/subscribe` | +| [getSharkfinSubscriptionResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3472) | :closed_lock_with_key: | GET | `/api/v3/earn/sharkfin/subscribe-result` | +| [getEarnEliteProducts()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3484) | :closed_lock_with_key: | GET | `/api/v3/earn/elite-product` | +| [getEarnEliteAssets()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3488) | :closed_lock_with_key: | GET | `/api/v3/earn/elite-assets` | +| [getEarnEliteRecords()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3492) | :closed_lock_with_key: | GET | `/api/v3/earn/elite-records` | +| [getEarnEliteSubscribeInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3498) | :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#L3504) | :closed_lock_with_key: | POST | `/api/v3/earn/elite-subscribe` | +| [getEarnEliteSubscribeResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3510) | :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#L3516) | :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#L3522) | :closed_lock_with_key: | POST | `/api/v3/earn/elite-redeem` | +| [getEarnCashPlusSubscribeInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3539) | :closed_lock_with_key: | GET | `/api/v3/earn/cashplus/subscribe-info` | +| [subscribeEarnCashPlus()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3548) | :closed_lock_with_key: | POST | `/api/v3/earn/cashplus/subscribe` | +| [getEarnCashPlusSubscribeResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3557) | :closed_lock_with_key: | GET | `/api/v3/earn/cashplus/subscribe-result` | +| [getEarnCashPlusRedeemInfo()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3567) | :closed_lock_with_key: | GET | `/api/v3/earn/cashplus/redeem-info` | +| [redeemEarnCashPlus()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3574) | :closed_lock_with_key: | POST | `/api/v3/earn/cashplus/redeem` | +| [getEarnCashPlusRedeemResult()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3583) | :closed_lock_with_key: | GET | `/api/v3/earn/cashplus/redeem-result` | +| [getEarnCashPlusPositions()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3592) | :closed_lock_with_key: | GET | `/api/v3/earn/cashplus/positions` | +| [getEarnCashPlusHistoryOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/rest-client-v3.ts#L3599) | :closed_lock_with_key: | GET | `/api/v3/earn/cashplus/history-orders` | # websocket-api-client.ts diff --git a/llms.txt b/llms.txt index 2ff923cb..4709b47c 100644 --- a/llms.txt +++ b/llms.txt @@ -97,6 +97,7 @@ src/ spot.ts v3/ account.ts + affiliate.ts broker.ts cfd.ts copytrading.ts @@ -122,6 +123,7 @@ src/ spot.ts v3/ account.ts + affiliate.ts broker.ts cfd.ts copytrading.ts @@ -1639,7 +1641,7 @@ private getSubRequest( instType: BitgetInstTypeV2, topic: WsTopicV2, coin: string = 'default', -): WsTopicRequest + ): WsTopicRequest ⋮---- /** * Subscribe to a topic @@ -1651,7 +1653,7 @@ public subscribeTopic( instType: BitgetInstTypeV2, topic: WsTopicV2, coin: string = 'default', -) + ) ⋮---- /** * Unsubscribe from a topic @@ -1663,7 +1665,7 @@ public unsubscribeTopic( instType: BitgetInstTypeV2, topic: WsTopicV2, coin: string = 'default', -) + ) ⋮---- /** * Request subscription to one or more topics. Pass topics as either an array of strings, @@ -1682,7 +1684,7 @@ public subscribe( | (WsTopicRequest | WsTopicV2) | (WsTopicRequest | WsTopicV2)[], wsKey: WsKey, -): Promise + ): Promise ⋮---- /** * Unsubscribe from one or more topics. Similar to subscribe() but in reverse. @@ -1695,7 +1697,7 @@ public unsubscribe( | (WsTopicRequest | WsTopicV2) | (WsTopicRequest | WsTopicV2)[], wsKey: WsKey, -) + ) ⋮---- /** * @@ -1716,7 +1718,7 @@ protected isWsPong(data: any): boolean protected isPrivateTopicRequest( _request: WsTopicRequest, wsKey: WsKey, -): boolean + ): boolean ⋮---- protected getPrivateWSKeys(): WsKey[] ⋮---- @@ -1732,7 +1734,7 @@ protected getMaxTopicsPerSubscribeEvent(wsKey: WsKey): number | null protected async getWsRequestEvents( operation: WSOperation, requests: WsTopicRequest[], -): Promise>[]> + ): Promise>[]> ⋮---- // Previously used to track topics in a request. Keeping this for subscribe/unsubscribe requests, no need for incremental values ⋮---- @@ -1767,18 +1769,18 @@ protected async getWsRequestEvents( ⋮---- private async getWsAuthSignature( wsKey: WsKey, -): Promise< + ): Promise<{ expiresAt: number; signature: string }> ⋮---- private async signMessage( paramsStr: string, secret: string, method: SignEncodeMethod, algorithm: SignAlgorithm, -): Promise + ): Promise ⋮---- protected async getWsAuthRequestEvent( wsKey: WsKey, -): Promise> + ): Promise> ⋮---- /** * Abstraction called to sort ws events into emittable event types (response to a request, data update, etc) @@ -1786,7 +1788,7 @@ protected async getWsAuthRequestEvent( protected resolveEmittableEvents( wsKey: WsKey, event: MessageEventLike, -): EmittableEvent[] + ): EmittableEvent[] ⋮---- // v2 event processing ⋮---- @@ -2875,6 +2877,111 @@ export interface GetSpotDepositRecordRequestV2 { limit?: string; } +================ +File: src/types/request/v3/affiliate.ts +================ +/** + * + * + * Affiliate + * + * + */ +⋮---- +export interface AgentCustomerListRequestV3 { + startTime?: string; + endTime?: string; + pageNo?: string; + pageSize?: string; + uid?: string; + referralCode?: string; +} +⋮---- +export interface AgentCustomerAssetRequestV3 { + pageNo?: string; + pageSize?: string; + uid?: string; + showSub?: 'yes' | 'no'; +} +⋮---- +export interface AgentCustomerTradeVolumeRequestV3 { + startTime?: string; + endTime?: string; + pageNo?: string; + pageSize?: string; + uid?: string; + showSub?: 'yes' | 'no'; +} +⋮---- +export interface AgentCustomerDepositRequestV3 { + startTime?: string; + endTime?: string; + pageNo?: string; + pageSize?: string; + uid?: string; + showSub?: 'yes' | 'no'; +} +⋮---- +export interface GetAgentCustomerKycResultRequestV3 { + startTime?: string; + endTime?: string; + /** Pass endId from the previous response. Omit on the first page. */ + cursor?: string; + limit?: string; + uid?: string; + showSub?: 'yes' | 'no'; +} +⋮---- +/** Pass endId from the previous response. Omit on the first page. */ +⋮---- +export interface GetAgentCustomerCommissionsRequestV3 { + startTime?: string; + endTime?: string; + /** Pass endId from the previous response. Omit on the first page. */ + cursor?: string; + limit?: string; + uid?: string; + coin?: string; + symbol?: string; + showSub?: 'yes' | 'no'; +} +⋮---- +/** Pass endId from the previous response. Omit on the first page. */ +⋮---- +export interface GetAgentSubCustomerListRequestV3 { + startTime?: string; + endTime?: string; + /** Pass minId from the previous response. Omit on the first page. */ + cursor?: string; + limit?: string; + uid?: string; + showSub?: 'yes' | 'no'; +} +⋮---- +/** Pass minId from the previous response. Omit on the first page. */ +⋮---- +export interface GetSubAffiliateInfoRequestV3 { + uid?: string; + startTime?: string; + endTime?: string; + /** Pass endId from the previous response. Omit on the first page. */ + idLessThan?: string; + limit?: string; + includeDownLine?: 'yes' | 'no'; +} +⋮---- +/** Pass endId from the previous response. Omit on the first page. */ +⋮---- +export interface GetSubAffiliateCommissionRequestV3 { + startTime?: string; + endTime?: string; + limit?: string; + /** Pass endId from the previous response. Omit on the first page. */ + cursor?: string; +} +⋮---- +/** Pass endId from the previous response. Omit on the first page. */ + ================ File: src/types/request/v3/grid.ts ================ @@ -4302,6 +4409,146 @@ export interface InstLoanLTVConvertV2 { }[]; } +================ +File: src/types/response/v3/affiliate.ts +================ +/** + * + * + * Affiliate + * https://www.bitget.com/docs/catalog/affiliate/affiliate + * + * + */ +⋮---- +export interface AgentCustomerListItemV3 { + uid: string; + registerTime: string; +} +⋮---- +export interface AgentCustomerAssetItemV3 { + uid: string; + balance: string; + uTime: string; + remark: string; +} +⋮---- +export interface AgentCustomerTradeVolumeItemV3 { + uid: string; + /** API field name (Bitget spelling). */ + volumn: string; + spotVolume: string; + futuresVolume: string; + time: string; +} +⋮---- +/** API field name (Bitget spelling). */ +⋮---- +export interface AgentCustomerDepositItemV3 { + uid: string; + orderId: string; + depositTime: string; + depositCoin: string; + depositAmount: string; +} +⋮---- +export interface AgentCustomerKycResultItemV3 { + uid: string; + kycResult: 'passed' | 'not_passed'; +} +⋮---- +/** Pagination wrapper follows the documented response example. */ +export interface AgentCustomerKycResultV3 { + userList: AgentCustomerKycResultItemV3[]; + endId: string; +} +⋮---- +export interface AgentCustomerCommissionV3 { + uid: string; + date: string; + coin: string; + symbol: string; + productType: string; + dealAmount: string; + fee: string; + feeDeduction: string; + activityBonusDeduct: string; + spotCouponDeduct: string; + futuresCouponDeduct: string; + spotFeeDiscountDeduct: string; + negativeMakerFeeDeduct: string; + feePaid: string; + rebateAmount: string; + userTotalRebateAmount: string; + dayTotalRebateAmount: string; + totalRebateAmount: string; +} +⋮---- +export interface AgentCustomerCommissionsV3 { + commissionList: AgentCustomerCommissionV3[]; + endId: string; +} +⋮---- +/** Pagination wrapper follows the documented response example. */ +export interface AgentSubCustomerListV3 { + list: AgentCustomerListItemV3[]; + minId: string; +} +⋮---- +export interface SubAffiliateRebateRateV3 { + rebateType: string; + rebateRate: string; +} +⋮---- +export interface SubAffiliateInfoItemV3 { + uid: string; + uplineName: string; + rebateRateList: SubAffiliateRebateRateV3[]; + verificationStatus: string; + directReferrals: string; + subAffiliates: string; + subAffiliateDirectReferrals: string; + volume: string; + deposit: string; + transactionFee: string; + rebate: string; +} +⋮---- +export interface SubAffiliateInfoV3 { + list: SubAffiliateInfoItemV3[]; + endId: string; +} +⋮---- +export interface SubAffiliateCommissionItemV3 { + uid: string; + bizType: string; + subBizType: string; + symbol: string; + coin: string; + fee: string; + volume: string; + activityBonusDeduct: string; + spotCouponDeduct: string; + futuresCouponDeduct: string; + spotFeeDiscountDeduct: string; + negativeMakerFeeDeduct: string; + feePaid: string; + directCommission: string; + subCommission: string; + partnerCommission: string; + partnerActualCommission: string; + traderType: string; + apiType: string; + status: string; + startCalculationTime: string; + endCalculationTime: string; +} +⋮---- +export interface SubAffiliateCommissionV3 { + commissionList: SubAffiliateCommissionItemV3[]; + endId: string; +} + ================ File: src/types/response/v3/grid.ts ================ @@ -6434,115 +6681,28 @@ export interface FuturesIsolatedSymbolsRequestV2 { } ================ -File: src/types/request/v3/broker.ts +File: src/types/request/v3/cfd.ts ================ -export interface CreateBrokerSubAccountRequestV3 { - subaccountName: string; - label: string; -} +export type CfdYesNoV3 = 'yes' | 'no'; ⋮---- -export interface GetBrokerSubAccountListRequestV3 { - limit?: string; - cursor?: string; - status?: 'normal' | 'freeze'; -} +export type CfdOrderTypeV3 = 'limit' | 'market'; ⋮---- -export interface ModifyBrokerSubAccountRequestV3 { - subUid: string; - status?: 'normal' | 'freeze'; - permList?: string[]; -} +export type CfdSideV3 = 'buy' | 'sell'; ⋮---- -export interface BrokerSubWithdrawalRequestV3 { - subUid: string; - coin: string; - dest: 'on_chain' | 'internal_transfer'; - address: string; - amount: string; - chain?: string; - tag?: string; - clientOid?: string; -} +export type CfdKlineIntervalV3 = '1m' | '15m' | '1h' | '4h' | '1d'; ⋮---- -export interface GetBrokerSubDepositAddressRequestV3 { - subUid: string; - coin: string; - chain?: string; +export type CfdTransferAccountTypeV3 = 'funding' | 'uta'; +⋮---- +export type CfdTransferDirectionV3 = 'in' | 'out'; +⋮---- +export interface GetCfdTickersRequestV3 { + symbol?: string; } ⋮---- -export interface GetBrokerAllSubDepositWithdrawalRequestV3 { - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; - status?: 'pending' | 'fail' | 'success'; -} -⋮---- -export interface GetBrokerCommissionRequestV3 { - startTime?: string; - endTime?: string; - pageSize?: string; - pageNo?: string; - bizType?: 'spot' | 'futures'; - subBizType?: - | 'spot_trade' - | 'spot_margin' - | 'usdt_futures' - | 'usdc_futures' - | 'coin_futures'; -} -⋮---- -export interface CreateBrokerSubApiKeyRequestV3 { - subUid: string; - passphrase: string; - label: string; - ipList?: string[]; - permType: 'read_write' | 'read_only'; - permList: string[]; -} -⋮---- -export interface ModifyBrokerSubApiKeyRequestV3 { - subUid: string; - passphrase: string; - apiKey: string; - label?: string; - ipList?: string[]; - permType?: 'read_write' | 'read_only'; - permList?: string[]; -} -⋮---- -export interface DeleteBrokerSubApiKeyRequestV3 { - subUid: string; - apiKey: string; -} -⋮---- -export interface GetBrokerSubApiKeyRequestV3 { - subUid: 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; +export interface GetCfdHistoryCandlestickRequestV3 { + symbol: string; + interval: CfdKlineIntervalV3; + side?: CfdSideV3; startTime?: string; endTime?: string; limit?: string; @@ -6641,128 +6801,6 @@ export interface GetCfdInstrumentsRequestV3 { symbol?: string; } -================ -File: src/types/request/v3/earn.ts -================ -/** - * - * - * Earn | On-Chain Elite (UTA) - * - * - */ -⋮---- -export interface GetEarnEliteRecordsRequestV3 { - type: 'subscribe' | 'redeem' | 'interest'; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; -} -⋮---- -export interface GetEarnEliteSubscribeInfoRequestV3 { - productId: string; -} -⋮---- -export interface EarnEliteSubscribeRequestV3 { - productSubId: string; - amount: string; - coin?: string; - paymentAccount?: 'spot' | 'unified'; -} -⋮---- -export interface GetEarnEliteSubscribeResultRequestV3 { - orderId: string; -} -⋮---- -export interface GetEarnEliteRedeemInfoRequestV3 { - productId: string; -} -⋮---- -export interface RedeemEarnEliteRequestV3 { - productId: string; - productSubId: string; - redeemType: 'fast' | 'standard'; - amount: string; - receiveAccount: 'spot' | 'unified'; - advancedSettle?: 'yes' | 'no'; - coin?: string; -} -⋮---- -/** - * - * - * Earn | Cash+ (UTA) - * Master and sub-accounts can call these. - * - * - */ -⋮---- -export type EarnCashPlusRecordTypeV3 = - | 'subscribe' - | 'redeem' - | 'compound_interest' - | 'liquidation_redeem'; -⋮---- -export interface EarnCashPlusSubscribeRequestV3 { - /** From subscribe-info */ - productSubId: string; - /** Subscription amount, in the subscription coin */ - amount: string; - /** - * Debit account. funding (default), uta, or otc. - * Comma-separated when more than one, e.g. funding,uta. - */ - accountType?: string; - /** Prevents a duplicate submit of the same subscription */ - idempotentNo?: string; -} -⋮---- -/** From subscribe-info */ -⋮---- -/** Subscription amount, in the subscription coin */ -⋮---- -/** - * Debit account. funding (default), uta, or otc. - * Comma-separated when more than one, e.g. funding,uta. - */ -⋮---- -/** Prevents a duplicate submit of the same subscription */ -⋮---- -export interface GetEarnCashPlusSubscribeResultRequestV3 { - orderId: string; -} -⋮---- -export interface EarnCashPlusRedeemRequestV3 { - productSubId: string; - /** Amount of Cash+ to redeem */ - amount: string; - /** Credit account. funding (default) or uta */ - accountType?: 'funding' | 'uta'; -} -⋮---- -/** Amount of Cash+ to redeem */ -⋮---- -/** Credit account. funding (default) or uta */ -⋮---- -export interface GetEarnCashPlusRedeemResultRequestV3 { - orderId: string; -} -⋮---- -export interface GetEarnCashPlusHistoryOrdersRequestV3 { - startTime?: string; - endTime?: string; - recordType?: EarnCashPlusRecordTypeV3; - /** Default 20, max 100 */ - limit?: string; - /** Pass nextCursor from the previous page. Omit on the first page */ - cursor?: string; -} -⋮---- -/** Default 20, max 100 */ -⋮---- -/** Pass nextCursor from the previous page. Omit on the first page */ - ================ File: src/types/request/v3/stockplus.ts ================ @@ -8479,628 +8517,346 @@ export interface SpotDepositRecordV2 { } ================ -File: src/types/response/v3/broker.ts +File: src/types/response/v3/stockplus.ts ================ -export interface CreateBrokerSubAccountResponseV3 { - subUid: string; - subaccountName: string; - subaccountEmail: string; - status: 'normal' | 'freeze'; - permList: string[]; - label: string; - cTime: string; +/** + * + * + * Stock+ (UTA) + * + * + */ +⋮---- +export interface StockPlusOptionQuoteItemV3 { + symbol: string; + lastDone: string; + prevClose: string; + open: string; + high: string; + low: string; + timestamp: string; + volume: string; + turnover: string; + tradeStatus: string; + impliedVolatility: string; + openInterest: string; + expiryDate: string; + strikePrice: string; + contractMultipier: string; + contractType: string; + contractSize: string; + direction: string; + historicalVolatility: string; + underlyingSymbol: string; } ⋮---- -export interface BrokerSubAccountV3 { - subUid: string; - subaccountName: string; - subaccountEmail: string | null; - status: 'normal' | 'freeze'; - permList: string[]; - label: string; - language: string; - cTime: string; - uTime: string; +export interface StockPlusOptionQuoteV3 { + secuQuote: StockPlusOptionQuoteItemV3[]; } ⋮---- -export interface GetBrokerSubAccountListResponseV3 { - subList: BrokerSubAccountV3[]; +export interface StockPlusOptionStrikePriceInfoV3 { + price: string; + callSymbol: string; + putSymbol: string; + standard: boolean; } ⋮---- -export interface ModifyBrokerSubAccountResponseV3 { - subUid: string; - subaccountName: string; - status: 'normal' | 'freeze'; - permList: string[]; - label: string; - cTime: string; - uTime: string; +export interface StockPlusOptionChainInfoV3 { + strikePriceInfo: StockPlusOptionStrikePriceInfoV3[]; } ⋮---- -export interface BrokerSubWithdrawalResponseV3 { - orderId: string; - clientOid: string; +export interface StockPlusOptionExpiryDateV3 { + expiryDate: 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 StockPlusOptionVolumeV3 { + c: string; + p: string; } ⋮---- -export interface GetBrokerAllSubDepositWithdrawalResponseV3 { - list: BrokerSubDepositWithdrawalRecordV3[]; - endId: string; +export interface StockPlusStaticInfoItemV3 { + symbol: string; + nameCn: string; + nameEn: string; + exchange: string; + currency: string; + lotSize: number | string; + totalShares: string | number; + circulatingShares: string | number; + eps: string | number; + epsTtm: string | number; + bps: string | number; + dividendYield: string | number; + stockDerivatives: string[]; + board: string; } ⋮---- -export interface BrokerCommissionRecordV3 { - uid: string; - coin: string; - symbol: string; - dealtAmount: string; - totalFee: string; - deductedFee: string; - paidFee: string; - markUpFee: string; - totalCommission: string; +export interface StockPlusStaticInfoV3 { + list: StockPlusStaticInfoItemV3[]; } ⋮---- -export interface CreateBrokerSubApiKeyResponseV3 { - subUid: string; - label: string; - apiKey: string; - secretKey: string; - permType: 'read_write' | 'read_only'; - permList: string[]; - ipList: string[] | null; +export interface StockPlusSessionQuoteV3 { + lastDone: string | number; + timestamp: string; + volume: string | number; + turnover: string | number; + high: string | number; + low: string | number; + prevClose: string | number; } ⋮---- -export interface ModifyBrokerSubApiKeyResponseV3 { - subUid: string; - label: string; - apiKey: string; - permType: 'read_write' | 'read_only'; - permList: string[]; - ipList: string[]; +export interface StockPlusQuoteItemV3 { + symbol: string; + lastDone: string | number; + prevClose: string | number; + open: string | number; + high: string | number; + low: string | number; + timestamp: string; + volume: string | number; + turnover: string | number; + tradeStatus: string; + preMarketQuote?: StockPlusSessionQuoteV3 | null; + postMarketQuote?: StockPlusSessionQuoteV3 | null; + overnightQuote?: StockPlusSessionQuoteV3 | null; } ⋮---- -export interface GetBrokerSubApiKeyResponseV3 { - subUid: string; - label: string; - apiKey: string; - secretKey: string; - permType: 'read_write' | 'read_only'; - permList: string[]; - ipList: string[] | null; +export interface StockPlusQuoteV3 { + list: StockPlusQuoteItemV3[]; } - -================ -File: src/types/response/v3/cfd.ts -================ -import type { CfdOrderTypeV3, CfdSideV3 } from '../../request/v3/cfd.js'; ⋮---- -export interface CfdTickerV3 { - symbol: string; - /** Replaced by askOpenPriceChange and bidOpenPriceChange */ - openPriceChange?: string; - askOpenPriceChange?: string; - bidOpenPriceChange?: string; - highPrice: string; - lowPrice: string; - quoteTime: string; - ask1?: string; - bid1?: string; +export interface StockPlusTradeDetailItemV3 { + price: string | number; + volume: string | number; + timestamp: string; + tradeType: string; + direction: string; + tradeSession: string; } ⋮---- -/** Replaced by askOpenPriceChange and bidOpenPriceChange */ +export type StockPlusTradeDetailV3 = StockPlusTradeDetailItemV3[]; ⋮---- -export interface CfdCandlestickV3 extends Array { - 0: string; - 1: string; - 2: string; - 3: string; - 4: string; +export interface StockPlusIntradayItemV3 { + price: string | number; + timestamp: string; + volume: string | number; + turnover: string | number; + avgPrice: string | number; } ⋮---- -export interface PlaceCfdOrderResponseV3 { - trxId: string; +export interface StockPlusIntradayV3 { + list: StockPlusIntradayItemV3[]; } ⋮---- -export interface ModifyCfdOrderResponseV3 { - orderId: string; +export interface StockPlusCandlestickItemV3 { + close: string; + open: string; + low: string; + high: string; + volume: string; + turnover: string; + timestamp: string; + tradeSession: 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 StockPlusCandlestickV3 { + list: StockPlusCandlestickItemV3[]; } ⋮---- -export interface CfdHistoryOrderV3 { - symbol: string; - orderType: CfdOrderTypeV3 | string; - side: CfdSideV3 | string; +export type StockPlusHistoryCandlestickV3 = StockPlusCandlestickV3; +⋮---- +export interface StockPlusDepthLevelV3 { + position: number; price: string; - qty: string; - cumExecQty?: string; - takeProfit?: string; - stopLoss?: string; - status: string; - trxId: string; - orderId: string; + volume: string; + orderNum: number; } ⋮---- -export interface CfdOrderHistoryV3 { - list: CfdHistoryOrderV3[]; +export interface StockPlusDepthV3 { + asks: StockPlusDepthLevelV3[]; + bids: StockPlusDepthLevelV3[]; } ⋮---- -export interface CfdCurrentPositionV3 { - positionId: string; +export interface StockPlusPlaceOrderResponseV3 { + orderId: string; + clientOid: 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 type StockPlusCancelOrderResponseV3 = StockPlusPlaceOrderResponseV3; +export type StockPlusModifyOrderResponseV3 = StockPlusPlaceOrderResponseV3; ⋮---- -export interface CfdTransferResponseV3 { - transferId: string; +export interface StockPlusMaxPurchaseV3 { + cashMaxQty: string; + marginMaxQty: string; } ⋮---- -export interface CfdTransferRecordV3 { - transferId: string; - coin: string; - amount: string; - direction: string; +export interface StockPlusOrderV3 { + orderId: string; status: string; - accountType: string; - createdTime: string; - updatedTime: string; + stockName: string; + quantity: string | number; + executedQuantity: string | number; + price: string | number | null; + executedPrice: string | number | null; + submittedAt: string; + side: string; + symbol: string; + orderType: string; + lastDone: string | number | null; + triggerPrice: string | number | null; + msg: string; + tag: string; + timeInForce: string; + expireDate: string | null; + updatedAt: string | null; + triggerAt: string | null; + trailingAmount: string | number | null; + trailingPercent: string | number | null; + limitOffset: string | number | null; + triggerStatus: string | null; + currency: string; + outsideRth: string; + remark?: string; + limitDepthLevel: number | null; + triggerCount: number | null; + monitorPrice: string | null; } ⋮---- -export interface CfdTransferRecordsV3 { - list: CfdTransferRecordV3[]; - cursor?: string; +export interface StockPlusOrdersV3 { + orders: StockPlusOrderV3[]; } ⋮---- -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 StockPlusHistoryOrdersV3 { + hasMore: boolean; + orders: StockPlusOrderV3[]; } ⋮---- -export interface CfdInstrumentV3 { - symbol: string; - onlineTime: string; +export interface StockPlusOrderHistoryItemV3 { + price: string | number; + quantity: string | number; + status: string; + msg: string; + time: string; +} +⋮---- +export interface StockPlusChargeFeeItemV3 { + code: string; + name: string; + amount: number | string; currency: string; - 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/stockplus.ts -================ -/** - * - * - * Stock+ (UTA) - * - * - */ ⋮---- -export interface StockPlusOptionQuoteItemV3 { - symbol: string; - lastDone: string; - prevClose: string; - open: string; - high: string; - low: string; - timestamp: string; - volume: string; - turnover: string; - tradeStatus: string; - impliedVolatility: string; - openInterest: string; - expiryDate: string; - strikePrice: string; - contractMultipier: string; - contractType: string; - contractSize: string; - direction: string; - historicalVolatility: string; - underlyingSymbol: string; +export interface StockPlusChargeCategoryV3 { + code: string; + name: string; + fees: StockPlusChargeFeeItemV3[]; } ⋮---- -export interface StockPlusOptionQuoteV3 { - secuQuote: StockPlusOptionQuoteItemV3[]; +export interface StockPlusChargeDetailV3 { + totalAmount: number | string; + currency: string; + items: StockPlusChargeCategoryV3[]; } ⋮---- -export interface StockPlusOptionStrikePriceInfoV3 { - price: string; - callSymbol: string; - putSymbol: string; - standard: boolean; +export interface StockPlusOrderDetailV3 extends StockPlusOrderV3 { + freeStatus?: string; + freeAmount?: string | null; + freeCurrency?: string | null; + deductionsStatus?: string; + deductionsAmount?: string | null; + deductionsCurrency?: string | null; + platformDeductedStatus?: string; + platformDeductedAmount?: string | null; + platformDeductedCurrency?: string | null; + history?: StockPlusOrderHistoryItemV3[]; + chargeDetail?: StockPlusChargeDetailV3; } ⋮---- -export interface StockPlusOptionChainInfoV3 { - strikePriceInfo: StockPlusOptionStrikePriceInfoV3[]; +export interface StockPlusExecutionV3 { + orderId: string; + tradeId: string; + symbol: string; + tradeDoneAt: string; + quantity: number | string; + price: number | string; } ⋮---- -export interface StockPlusOptionExpiryDateV3 { - expiryDate: string[]; +export interface StockPlusTodayExecutionsV3 { + trades: StockPlusExecutionV3[]; } ⋮---- -export interface StockPlusOptionVolumeV3 { - c: string; - p: string; +export interface StockPlusHistoryExecutionsV3 { + hasMore: boolean; + trades: StockPlusExecutionV3[]; } ⋮---- -export interface StockPlusStaticInfoItemV3 { - symbol: string; - nameCn: string; - nameEn: string; - exchange: string; +export interface StockPlusCashInfoV3 { + withdrawCash: number | string; + availableCash: number | string; + frozenCash: number | string; + settlingCash: number | string; currency: string; - lotSize: number | string; - totalShares: string | number; - circulatingShares: string | number; - eps: string | number; - epsTtm: string | number; - bps: string | number; - dividendYield: string | number; - stockDerivatives: string[]; - board: string; } ⋮---- -export interface StockPlusStaticInfoV3 { - list: StockPlusStaticInfoItemV3[]; +export interface StockPlusFrozenTransactionFeeV3 { + currency?: string; + amount?: number | string; + [key: string]: unknown; } ⋮---- -export interface StockPlusSessionQuoteV3 { - lastDone: string | number; - timestamp: string; - volume: string | number; - turnover: string | number; - high: string | number; - low: string | number; - prevClose: string | number; +export interface StockPlusAccountItemV3 { + totalCash: number | string; + maxFinanceAmount: number | string; + remainingFinanceAmount: number | string; + riskLevel: number | string; + marginCall: number | string; + netAssets: number | string; + initMargin: number | string; + maintenanceMargin: number | string; + currency: string; + buyPower: number | string; + cashInfos: StockPlusCashInfoV3[]; + frozenTransactionFees: StockPlusFrozenTransactionFeeV3[]; } ⋮---- -export interface StockPlusQuoteItemV3 { - symbol: string; - lastDone: string | number; - prevClose: string | number; - open: string | number; - high: string | number; - low: string | number; - timestamp: string; - volume: string | number; - turnover: string | number; - tradeStatus: string; - preMarketQuote?: StockPlusSessionQuoteV3 | null; - postMarketQuote?: StockPlusSessionQuoteV3 | null; - overnightQuote?: StockPlusSessionQuoteV3 | null; +export interface StockPlusAccountV3 { + list: StockPlusAccountItemV3[]; } ⋮---- -export interface StockPlusQuoteV3 { - list: StockPlusQuoteItemV3[]; +export interface StockPlusCashFlowItemV3 { + transactionFlowName: string; + direction: string; + businessType: string; + balance: number | string; + currency: string; + businessTime: string; + symbol: string | null; + description: string; } ⋮---- -export interface StockPlusTradeDetailItemV3 { - price: string | number; - volume: string | number; - timestamp: string; - tradeType: string; - direction: string; - tradeSession: string; +export interface StockPlusCashFlowV3 { + list: StockPlusCashFlowItemV3[]; } ⋮---- -export type StockPlusTradeDetailV3 = StockPlusTradeDetailItemV3[]; +export interface StockPlusPositionItemV3 { + symbol: string; + symbolName: string; + quantity: number | string; + availableQuantity: number | string; + currency: string; + costPrice: number | string; + market: string; + initQuantity: number | string; +} ⋮---- -export interface StockPlusIntradayItemV3 { - price: string | number; - timestamp: string; - volume: string | number; - turnover: string | number; - avgPrice: string | number; +export interface StockPlusPositionChannelV3 { + accountChannel: string; + positions: StockPlusPositionItemV3[]; } ⋮---- -export interface StockPlusIntradayV3 { - list: StockPlusIntradayItemV3[]; -} -⋮---- -export interface StockPlusCandlestickItemV3 { - close: string; - open: string; - low: string; - high: string; - volume: string; - turnover: string; - timestamp: string; - tradeSession: string; -} -⋮---- -export interface StockPlusCandlestickV3 { - list: StockPlusCandlestickItemV3[]; -} -⋮---- -export type StockPlusHistoryCandlestickV3 = StockPlusCandlestickV3; -⋮---- -export interface StockPlusDepthLevelV3 { - position: number; - price: string; - volume: string; - orderNum: number; -} -⋮---- -export interface StockPlusDepthV3 { - asks: StockPlusDepthLevelV3[]; - bids: StockPlusDepthLevelV3[]; -} -⋮---- -export interface StockPlusPlaceOrderResponseV3 { - orderId: string; - clientOid: string; - symbol: string; -} -⋮---- -export type StockPlusCancelOrderResponseV3 = StockPlusPlaceOrderResponseV3; -export type StockPlusModifyOrderResponseV3 = StockPlusPlaceOrderResponseV3; -⋮---- -export interface StockPlusMaxPurchaseV3 { - cashMaxQty: string; - marginMaxQty: string; -} -⋮---- -export interface StockPlusOrderV3 { - orderId: string; - status: string; - stockName: string; - quantity: string | number; - executedQuantity: string | number; - price: string | number | null; - executedPrice: string | number | null; - submittedAt: string; - side: string; - symbol: string; - orderType: string; - lastDone: string | number | null; - triggerPrice: string | number | null; - msg: string; - tag: string; - timeInForce: string; - expireDate: string | null; - updatedAt: string | null; - triggerAt: string | null; - trailingAmount: string | number | null; - trailingPercent: string | number | null; - limitOffset: string | number | null; - triggerStatus: string | null; - currency: string; - outsideRth: string; - remark?: string; - limitDepthLevel: number | null; - triggerCount: number | null; - monitorPrice: string | null; -} -⋮---- -export interface StockPlusOrdersV3 { - orders: StockPlusOrderV3[]; -} -⋮---- -export interface StockPlusHistoryOrdersV3 { - hasMore: boolean; - orders: StockPlusOrderV3[]; -} -⋮---- -export interface StockPlusOrderHistoryItemV3 { - price: string | number; - quantity: string | number; - status: string; - msg: string; - time: string; -} -⋮---- -export interface StockPlusChargeFeeItemV3 { - code: string; - name: string; - amount: number | string; - currency: string; -} -⋮---- -export interface StockPlusChargeCategoryV3 { - code: string; - name: string; - fees: StockPlusChargeFeeItemV3[]; -} -⋮---- -export interface StockPlusChargeDetailV3 { - totalAmount: number | string; - currency: string; - items: StockPlusChargeCategoryV3[]; -} -⋮---- -export interface StockPlusOrderDetailV3 extends StockPlusOrderV3 { - freeStatus?: string; - freeAmount?: string | null; - freeCurrency?: string | null; - deductionsStatus?: string; - deductionsAmount?: string | null; - deductionsCurrency?: string | null; - platformDeductedStatus?: string; - platformDeductedAmount?: string | null; - platformDeductedCurrency?: string | null; - history?: StockPlusOrderHistoryItemV3[]; - chargeDetail?: StockPlusChargeDetailV3; -} -⋮---- -export interface StockPlusExecutionV3 { - orderId: string; - tradeId: string; - symbol: string; - tradeDoneAt: string; - quantity: number | string; - price: number | string; -} -⋮---- -export interface StockPlusTodayExecutionsV3 { - trades: StockPlusExecutionV3[]; -} -⋮---- -export interface StockPlusHistoryExecutionsV3 { - hasMore: boolean; - trades: StockPlusExecutionV3[]; -} -⋮---- -export interface StockPlusCashInfoV3 { - withdrawCash: number | string; - availableCash: number | string; - frozenCash: number | string; - settlingCash: number | string; - currency: string; -} -⋮---- -export interface StockPlusFrozenTransactionFeeV3 { - currency?: string; - amount?: number | string; - [key: string]: unknown; -} -⋮---- -export interface StockPlusAccountItemV3 { - totalCash: number | string; - maxFinanceAmount: number | string; - remainingFinanceAmount: number | string; - riskLevel: number | string; - marginCall: number | string; - netAssets: number | string; - initMargin: number | string; - maintenanceMargin: number | string; - currency: string; - buyPower: number | string; - cashInfos: StockPlusCashInfoV3[]; - frozenTransactionFees: StockPlusFrozenTransactionFeeV3[]; -} -⋮---- -export interface StockPlusAccountV3 { - list: StockPlusAccountItemV3[]; -} -⋮---- -export interface StockPlusCashFlowItemV3 { - transactionFlowName: string; - direction: string; - businessType: string; - balance: number | string; - currency: string; - businessTime: string; - symbol: string | null; - description: string; -} -⋮---- -export interface StockPlusCashFlowV3 { - list: StockPlusCashFlowItemV3[]; -} -⋮---- -export interface StockPlusPositionItemV3 { - symbol: string; - symbolName: string; - quantity: number | string; - availableQuantity: number | string; - currency: string; - costPrice: number | string; - market: string; - initQuantity: number | string; -} -⋮---- -export interface StockPlusPositionChannelV3 { - accountChannel: string; - positions: StockPlusPositionItemV3[]; -} -⋮---- -export interface StockPlusStockPositionV3 { - channels: StockPlusPositionChannelV3[]; +export interface StockPlusStockPositionV3 { + channels: StockPlusPositionChannelV3[]; } ⋮---- export interface StockPlusTransferResponseV3 { @@ -9178,7 +8934,7 @@ constructor( options?: WSClientConfigurableOptions & Partial, logger?: DefaultLogger, -) + ) ⋮---- public getWSClient(): WebsocketClientV3 ⋮---- @@ -9201,7 +8957,7 @@ public setTimeOffsetMs(newOffset: number): void submitNewOrder( category: BitgetInstTypeV3, params: WSAPIPlaceOrderRequestV3, -): Promise> + ): Promise> ⋮---- /** * Submit a batch of orders @@ -9216,7 +8972,7 @@ submitNewOrder( placeBatchOrders( category: BitgetInstTypeV3, params: WSAPIPlaceOrderRequestV3[], -): Promise> + ): Promise> ⋮---- /* * Bitget WebSocket API Methods @@ -9233,7 +8989,7 @@ placeBatchOrders( cancelOrder( category: BitgetInstTypeV3, params: CancelOrderRequestV3, -): Promise> + ): Promise> ⋮---- /** * Batch Cancel Order @@ -9245,17 +9001,17 @@ cancelOrder( cancelBatchOrders( category: BitgetInstTypeV3, params: CancelOrderRequestV3[], -): Promise> + ): Promise> ⋮---- updateOrder( category: BitgetInstTypeV3, params: ModifyOrderRequestV3, -): Promise> + ): Promise> ⋮---- batchUpdateOrders( category: BitgetInstTypeV3, params: ModifyOrderRequestV3[], -): Promise> + ): Promise> ⋮---- /** * @@ -9744,349 +9500,1084 @@ export interface GetSubAffiliateInfoRequestV2 { } ================ -File: src/websocket-client-v3.ts +File: src/types/request/v3/broker.ts ================ -import { - WsAPIOperationResponseMap, - WSAPIRequestBitgetV3, - WSAPIRequestFlags, - WsAPITopicRequestParamMap, - WsAPIWsKeyTopicMap, - WSOperation, - WSOperationLoginParams, - WsRequestOperationBitget, -} from './types/websockets/ws-api.js'; -import { MessageEventLike } from './types/websockets/ws-events.js'; -import { - BitgetInstTypeV3, - WsKey, - WsTopicV3, -} from './types/websockets/ws-general.js'; -import { - BaseWebsocketClient, - EmittableEvent, - MidflightWsRequestEvent, -} from './util/BaseWSClient.js'; -import { CHANNEL_API_CODE, isWsPong } from './util/requestUtils.js'; -import { isWSAPIResponse } from './util/type-guards.js'; -import { SignAlgorithm, signMessage } from './util/webCryptoAPI.js'; -import { - getMaxTopicsPerSubscribeEvent, - getNormalisedTopicRequests, - getPromiseRefForWSAPIRequest, - getWsUrl, - WS_AUTH_ON_CONNECT_KEYS, - WS_KEY_MAP, - WS_LOGGER_CATEGORY, - WsTopicRequest, -} from './util/websocket-util.js'; -import { WSConnectedResult } from './util/WsStore.types.js'; -⋮---- -/** - * WebSocket client dedicated to the unified account (V3) WebSockets. - * - * Your Bitget account needs to be upgraded to unified account mode, to use the account-level WebSocket topics. - */ -export class WebsocketClientV3 extends BaseWebsocketClient< +export interface CreateBrokerSubAccountRequestV3 { + subaccountName: string; + label: string; +} ⋮---- -WsRequestOperationBitget // subscribe requests have an "args" parameter with an object within -⋮---- -/** - * Request connection of all dependent (public & private) websockets, instead of waiting for automatic connection by library - */ -public connectAll(): Promise[] +export interface GetBrokerSubAccountListRequestV3 { + limit?: string; + cursor?: string; + status?: 'normal' | 'freeze'; +} ⋮---- -/** - * Ensures the WS API connection is active and ready. - * - * You do not need to call this, but if you call this before making any WS API requests, - * it can accelerate the first request (by preparing the connection in advance). - */ -public connectWSAPI(): Promise +export interface ModifyBrokerSubAccountRequestV3 { + subUid: string; + status?: 'normal' | 'freeze'; + permList?: string[]; +} ⋮---- -/** This call automatically ensures the connection is active AND authenticated before resolving */ +export interface BrokerSubWithdrawalRequestV3 { + subUid: string; + coin: string; + dest: 'on_chain' | 'internal_transfer'; + address: string; + amount: string; + chain?: string; + tag?: string; + clientOid?: string; +} ⋮---- -/** - * Request subscription to one or more topics. Pass topics as either an array of strings, - * or array of objects (if the topic has parameters). - * - * Objects should be formatted as {topic: string, params: object, category: CategoryV5}. - * - * - Subscriptions are automatically routed to the correct websocket connection. - * - Authentication/connection is automatic. - * - Resubscribe after network issues is automatic. - * - * Call `unsubscribe(topics)` to remove topics - */ -public subscribe( - requests: - | (WsTopicRequest | WsTopicV3) - | (WsTopicRequest | WsTopicV3)[], - wsKey: WsKey, -): Promise +export interface GetBrokerSubDepositAddressRequestV3 { + subUid: string; + coin: string; + chain?: string; +} ⋮---- -/** - * Unsubscribe from one or more topics. Similar to subscribe() but in reverse. - * - * - Requests are automatically routed to the correct websocket connection. - * - These topics will be removed from the topic cache, so they won't be subscribed to again. - */ -public unsubscribe( - requests: - | (WsTopicRequest | WsTopicV3) - | (WsTopicRequest | WsTopicV3)[], - wsKey: WsKey, -) +export interface GetBrokerAllSubDepositWithdrawalRequestV3 { + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; + status?: 'pending' | 'fail' | 'success'; +} ⋮---- -/** - * - * - * Internal methods required to integrate with the BaseWSClient - * - * - */ +export interface GetBrokerCommissionRequestV3 { + startTime?: string; + endTime?: string; + pageSize?: string; + pageNo?: string; + bizType?: 'spot' | 'futures'; + subBizType?: + | 'spot_trade' + | 'spot_margin' + | 'usdt_futures' + | 'usdc_futures' + | 'coin_futures'; +} ⋮---- -protected sendPingEvent(wsKey: WsKey): void +export interface CreateBrokerSubApiKeyRequestV3 { + subUid: string; + passphrase: string; + label: string; + ipList?: string[]; + permType: 'read_write' | 'read_only'; + permList: string[]; +} ⋮---- -protected sendPongEvent(wsKey: WsKey): void +export interface ModifyBrokerSubApiKeyRequestV3 { + subUid: string; + passphrase: string; + apiKey: string; + label?: string; + ipList?: string[]; + permType?: 'read_write' | 'read_only'; + permList?: string[]; +} ⋮---- -protected isWsPing(data: any): boolean +export interface DeleteBrokerSubApiKeyRequestV3 { + subUid: string; + apiKey: string; +} ⋮---- -protected isWsPong(data: any): boolean +export interface GetBrokerSubApiKeyRequestV3 { + subUid: string; +} ⋮---- -protected isPrivateTopicRequest( - _request: WsTopicRequest, - wsKey: WsKey, -): boolean +/** + * + * + * Broker | Email and Commissions + * + * + */ ⋮---- -protected getPrivateWSKeys(): WsKey[] +export interface ModifySubaccountEmailRequestV3 { + subUid: string; + subaccountEmail: string; +} ⋮---- -protected isAuthOnConnectWsKey(wsKey: WsKey): boolean +export interface GetSubaccountEmailRequestV3 { + subUid: string; +} ⋮---- -protected async getWsUrl(wsKey: WsKey): Promise +export interface GetBrokerTradeVolumeRequestV3 { + startTime?: string; + endTime?: string; + pageSize?: string; + pageNo?: string; +} ⋮---- -protected getMaxTopicsPerSubscribeEvent(wsKey: WsKey): number | null +export interface GetBrokerTotalCommissionRequestV3 { + startTime?: string; + endTime?: string; +} ⋮---- -/** - * @returns one or more correctly structured request events for performing a operations over WS. This can vary per exchange spec. - */ -protected async getWsRequestEvents( - operation: WSOperation, - requests: WsTopicRequest[], -): Promise>[]> +export interface GetBrokerOrderCommissionRequestV3 { + startTime?: string; + endTime?: string; + limit?: string; + uid?: string; + orderid?: string; + /** Pass endId from the previous response. Omit on the first page. */ + idLessThan?: string; +} ⋮---- -// Previously used to track topics in a request. Keeping this for subscribe/unsubscribe requests, no need for incremental values +/** Pass endId from the previous response. Omit on the first page. */ ⋮---- +export interface GetBrokerRebateInfoRequestV3 { + uid: string; +} + +================ +File: src/types/request/v3/earn.ts +================ /** - { - "op":"subscribe", - "args":[ - { - "instType":"spot", - "topic":"ticker", - "symbol":"BTCUSDT" - }, - { - "instType":"spot", - "topic":"candle5m", - "symbol":"BTCUSDT" - } - ] - } - */ + * + * + * Earn | On-Chain Elite (UTA) + * + * + */ ⋮---- -// const request = { -// topic: 'ticker', -// payload: { instType: 'spot', symbol: 'BTCUSDT' }, -// }; -// becomes: -// const request = { -// topic: 'ticker', -// instType: 'spot', -// symbol: 'BTCUSDT', -// }; +export interface GetEarnEliteRecordsRequestV3 { + type: 'subscribe' | 'redeem' | 'interest'; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; +} ⋮---- -private async getWsAuthSignature( - wsKey: WsKey, -): Promise< +export interface GetEarnEliteSubscribeInfoRequestV3 { + productId: string; +} ⋮---- -private async signMessage( - paramsStr: string, - secret: string, - method: 'hex' | 'base64', - algorithm: SignAlgorithm, -): Promise +export interface EarnEliteSubscribeRequestV3 { + productSubId: string; + amount: string; + coin?: string; + paymentAccount?: 'spot' | 'unified'; +} ⋮---- -protected async getWsAuthRequestEvent( - wsKey: WsKey, -): Promise> +export interface GetEarnEliteSubscribeResultRequestV3 { + orderId: string; +} ⋮---- -/** - * Abstraction called to sort ws events into emittable event types (response to a request, data update, etc) - */ -protected resolveEmittableEvents( - wsKey: WsKey, - event: MessageEventLike, -): EmittableEvent[] +export interface GetEarnEliteRedeemInfoRequestV3 { + productId: string; +} +⋮---- +export interface RedeemEarnEliteRequestV3 { + productId: string; + productSubId: string; + redeemType: 'fast' | 'standard'; + amount: string; + receiveAccount: 'spot' | 'unified'; + advancedSettle?: 'yes' | 'no'; + coin?: string; +} ⋮---- /** - * WS API response handling - */ + * + * + * Earn | Cash+ (UTA) + * Master and sub-accounts can call these. + * + * + */ ⋮---- -// const eg1 = { -// event: 'error', -// id: '1', -// code: '43012', -// msg: 'Insufficient balance', -// }; +export type EarnCashPlusRecordTypeV3 = + | 'subscribe' + | 'redeem' + | 'compound_interest' + | 'liquidation_redeem'; ⋮---- -// WS API Success +export interface EarnCashPlusSubscribeRequestV3 { + /** From subscribe-info */ + productSubId: string; + /** Subscription amount, in the subscription coin */ + amount: string; + /** + * Debit account. funding (default), uta, or otc. + * Comma-separated when more than one, e.g. funding,uta. + */ + accountType?: string; + /** Prevents a duplicate submit of the same subscription */ + idempotentNo?: string; +} +⋮---- +/** From subscribe-info */ +⋮---- +/** Subscription amount, in the subscription coin */ ⋮---- /** - * V3 event handling for consumers - behaves the same as V2 - */ + * Debit account. funding (default), uta, or otc. + * Comma-separated when more than one, e.g. funding,uta. + */ ⋮---- -// v2 authentication event +/** Prevents a duplicate submit of the same subscription */ ⋮---- -// messageType: typeof msg, -// messageString: JSON.stringify(msg), +export interface GetEarnCashPlusSubscribeResultRequestV3 { + orderId: string; +} ⋮---- -// Service upgrade (30033): Bitget sends this ~60s before disconnect. Log and let automatic reconnect handle when connection drops. +export interface EarnCashPlusRedeemRequestV3 { + productSubId: string; + /** Amount of Cash+ to redeem */ + amount: string; + /** Credit account. funding (default) or uta */ + accountType?: 'funding' | 'uta'; +} ⋮---- -// messageType: typeof msg, -// messageString: JSON.stringify(msg), +/** Amount of Cash+ to redeem */ ⋮---- -// fallback emit anyway +/** Credit account. funding (default) or uta */ +⋮---- +export interface GetEarnCashPlusRedeemResultRequestV3 { + orderId: string; +} +⋮---- +export interface GetEarnCashPlusHistoryOrdersRequestV3 { + startTime?: string; + endTime?: string; + recordType?: EarnCashPlusRecordTypeV3; + /** Default 20, max 100 */ + limit?: string; + /** Pass nextCursor from the previous page. Omit on the first page */ + cursor?: string; +} +⋮---- +/** Default 20, max 100 */ +⋮---- +/** Pass nextCursor from the previous page. Omit on the first page */ ⋮---- /** - * V3/UTA supports order placement via WebSockets. This is the WS API: - * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel - * - * @returns a promise that resolves/rejects when a matching response arrives - */ -async sendWSAPIRequest< - TWSKey extends keyof WsAPIWsKeyTopicMap, - TWSOperation extends WsAPIWsKeyTopicMap[TWSKey], - TWSParams extends WsAPITopicRequestParamMap[TWSOperation], - TWSAPIResponse extends - WsAPIOperationResponseMap[TWSOperation] = WsAPIOperationResponseMap[TWSOperation], - >( - wsKey: WsKey, - operation: TWSOperation, - category: BitgetInstTypeV3, - params: TWSParams & { signRequest?: boolean }, - requestFlags?: WSAPIRequestFlags, -): Promise + * + * + * Earn | Savings (UTA) + * + * + */ ⋮---- -// this.logger.trace('sendWSAPIRequest(): assertIsAuthenticated(${wsKey})...'); +export interface GetEarnSavingsProductsRequestV3 { + coin?: string; + filter?: 'available' | 'held' | 'available_and_held' | 'all'; +} ⋮---- -// this.logger.trace('sendWSAPIRequest(): assertIsAuthenticated(${wsKey}) ok'); +export interface GetEarnSavingsAssetsRequestV3 { + periodType: 'flexible' | 'fixed'; + startTime?: string; + endTime?: string; + limit?: string; + /** Pass endId from the previous response. Omit on the first page. */ + cursor?: string; +} ⋮---- -// apiCode is a top-level field on the trade envelope, not an arg. -// A caller value replaces the SDK broker code. One code per request. +/** Pass endId from the previous response. Omit on the first page. */ ⋮---- -// Ensure "args" is always wrapped as array +export interface GetEarnSavingsRecordsRequestV3 { + coin?: string; + periodType: 'flexible' | 'fixed'; + orderType?: 'subscribe' | 'redeem' | 'pay_interest' | 'deduction'; + startTime?: string; + endTime?: string; + limit?: string; + /** Pass endId from the previous response. Omit on the first page. */ + cursor?: string; +} ⋮---- -// Store deferred promise, resolved within the "resolveEmittableEvents" method while parsing incoming events +/** Pass endId from the previous response. Omit on the first page. */ ⋮---- -// eslint-disable-next-line @typescript-eslint/no-explicit-any +export interface GetEarnSavingsSubscriptionRequestV3 { + productId: string; + periodType: 'flexible' | 'fixed'; +} ⋮---- -// Enrich returned promise with request context for easier debugging +export interface SubscribeSavingsRequestV3 { + productId: string; + periodType: 'flexible' | 'fixed'; + amount: string; +} ⋮---- -// throw e; +export interface GetEarnSavingsSubscriptionResultRequestV3 { + orderId: string; + periodType: 'flexible' | 'fixed'; +} ⋮---- -// Send event +export interface RedeemSavingsRequestV3 { + productId: string; + /** Assets order ID returned by getEarnSavingsAssets */ + orderId?: string; + periodType: 'flexible' | 'fixed'; + amount: string; +} ⋮---- -// Return deferred promise, so caller can await this call +/** Assets order ID returned by getEarnSavingsAssets */ +⋮---- +export interface GetEarnSavingsRedemptionResultRequestV3 { + orderId: string; + periodType: 'flexible' | 'fixed'; +} +⋮---- +/** + * + * + * Earn | SharkFin (UTA) + * + * + */ +⋮---- +export interface GetSharkfinProductsRequestV3 { + coin: string; + limit?: string; + /** Pass endId from the previous response. Omit on the first page. */ + cursor?: string; +} +⋮---- +/** Pass endId from the previous response. Omit on the first page. */ +⋮---- +export interface GetSharkfinAssetsRequestV3 { + status: 'subscribed' | 'settled'; + startTime?: string; + endTime?: string; + limit?: string; + /** Pass endId from the previous response. Omit on the first page. */ + cursor?: string; +} +⋮---- +/** Pass endId from the previous response. Omit on the first page. */ +⋮---- +export interface GetSharkfinRecordsRequestV3 { + coin?: string; + type: 'subscription' | 'redemption' | 'interest'; + startTime?: string; + endTime?: string; + limit?: string; + /** Pass endId from the previous response. Omit on the first page. */ + cursor?: string; +} +⋮---- +/** Pass endId from the previous response. Omit on the first page. */ +⋮---- +export interface GetSharkfinSubscriptionRequestV3 { + productId: string; +} +⋮---- +export interface SubscribeSharkfinRequestV3 { + productId: string; + amount: string; +} +⋮---- +export interface GetSharkfinSubscriptionResultRequestV3 { + orderId: string; +} ================ -File: docs/BITGET_SDK_QUICKSTART_GUIDE.md +File: src/types/response/v3/broker.ts ================ - ================ -File: src/types/request/v3/account.ts +File: src/types/request/v3/trade.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; - /** - * Error 25159 means a low-liquidity period capped leverage at 5x. - * There is no pre-check API for that cap. - */ - 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; +export interface BatchModifyOrderRequestV3 { + orderId?: string; + clientOid?: string; + qty?: string; + price?: string; + /** Custom request ID. Numbers within 18 digits. */ + requestId?: number; + autoCancel?: 'yes' | 'no'; + /** Required since 30 Sep 2026 */ + symbol: string; + /** Required since 30 Sep 2026 */ + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ + pxAmendType?: 'yes' | 'no'; } ⋮---- -/** - * Error 25159 means a low-liquidity period capped leverage at 5x. - * There is no pre-check API for that cap. - */ +/** Custom request ID. Numbers within 18 digits. */ ⋮---- -/** Futures only. Defaults to crossed */ +/** Required since 30 Sep 2026 */ ⋮---- -/** Isolated two-way mode: long leverage. Takes priority over leverage when both set */ +/** Required since 30 Sep 2026 */ ⋮---- -/** Isolated two-way mode: short leverage. Takes priority over leverage when both set */ +/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ ⋮---- -export interface GetAllFeeRatesRequestV3 { +export interface CancelAllOrdersRequestV3 { category: | 'SPOT' | 'MARGIN' @@ -17219,323 +17826,246 @@ export interface GetAllFeeRatesRequestV3 { symbol?: string; } ⋮---- -export interface GetConvertRecordsRequestV3 { - fromCoin?: string; - toCoin?: string; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; -} -⋮---- -/** - * UTA account financial-record type. - * https://www.bitget.com/docs/uta/enum - * MARIN_BUY_DEAL and MARIN_SELL_DEAL keep Bitget's spelling. - */ -export type FinancialRecordTypeV3 = - | 'TRANSFER_IN' - | 'TRANSFER_OUT' - | 'CONVERSION_UPON_DELISTING' - | 'ORDER_DEALT_FROZEN_OUT' - | 'ORDER_DEALT_IN' - | 'ORDER_PLF_FEE_OUT' - | 'EXCHANGE_SOURCE_TOKEN_USER_OUT' - | 'EXCHANGE_TARGET_TOKEN_USER_IN' - | 'OPEN_LONG' - | 'OPEN_SHORT' - | 'BUY_DEAL' - | 'SELL_DEAL' - | 'CLOSE_LONG' - | 'CLOSE_SHORT' - | 'FORCE_CLOSE_LONG' - | 'FORCE_CLOSE_SHORT' - | 'BURST_CLOSE_LONG' - | 'BURST_CLOSE_SHORT' - | 'OFFSET_REDUCE_CLOSE_LONG' - | 'OFFSET_REDUCE_CLOSE_SHORT' - | 'FORCE_BUY_SSM' - | 'FORCE_SELL_SSM' - | 'BURST_BUY_SSM' - | 'BURST_SELL_SSM' - | 'RISK_LIQ_USER_IN' - | 'INTEREST_SETTLEMENT_OUT' - | 'CONTRACT_MAIN_SETTLE_FEE_USER_IN' - | 'CONTRACT_MAIN_SETTLE_FEE_USER_OUT' - | 'RISK_LIQ_USER_OUT' - | 'BORROW' - | 'RESERVE_TRANSFER_IN' - | 'RESERVE_TRANSFER_OUT' - | 'REPAYMENT' - | 'INTEREST_REPAYMENT' - | 'LIQ_FUND_OUT' - | 'LIQ_CONVERT_USER_OUT' - | 'LIQ_CONVERT_SYS_IN' - | 'LIQ_CONVERT_SYS_OUT' - | 'LIQ_CONVERT_USER_IN' - | 'LIQ_TRANSFER_IN' - | 'LIQ_TRANSFER_OUT' - | 'LIQ_FUND_IN' - | 'LIQ_FEE' - | 'LIQ_REPAYMENT' - | 'DELIST_MARGIN_TOKEN_SOURCE_USER_OUT' - | 'DELIST_MARGIN_TOKEN_SOURCE_SYS_IN' - | 'DELIST_MARGIN_TOKEN_TARGET_SYS_OUT' - | 'DELIST_MARGIN_TOKEN_TARGET_USER_IN' - | 'CONFISCATE_TOKEN_USER_OUT' - | 'CONFISCATE_TOKEN_SYS_IN' - | 'DELIST_SMALL_BALANCE_USER_OUT' - | 'DELIST_SMALL_BALANCE_SYS_IN' - | 'DELIST_SMALL_LIABILITY_SYS_OUT' - | 'DELIST_SMALL_LIABILITY_USER_IN' - | 'SMALL_ASSET_SOURCE_TOKEN_USER_OUT' - | 'SMALL_ASSET_SOURCE_TOKEN_SYS_IN' - | 'SMALL_ASSET_TARGET_TOKEN_SYS_OUT' - | 'SMALL_ASSET_TARGET_TOKEN_USER_IN' - | 'SMALL_ASSET_FEE_SYS_IN' - | 'TRACE_SHARE_BENEFIT_USER_OUT' - | 'TRACE_SHARE_BENEFIT_SYSTEM_IN' - | 'TRACE_SHARE_BENEFIT_SYSTEM_OUT' - | 'TRACE_SHARE_BENEFIT_USER_IN' - | 'MARGIN_OPEN_LONG' - | 'MARGIN_OPEN_SHORT' - | 'MARIN_BUY_DEAL' - | 'MARIN_SELL_DEAL' - | 'MARGIN_BACK' - | 'INCREASE_MARGIN' - | 'REDUCE_MARGIN' - | 'MARGIN_SETTLE_FEE_USER_IN' - | 'MARGIN_SETTLE_FEE_USER_OUT' - | 'MARGIN_LEVER_ORDER_REFROZEN' - | 'MARGIN_LEVER_ORDER_FROZEN' - | 'MARGIN_LEVER_POS_IN' - | 'MARGIN_OFFSET_IN_SSM_LONG' - | 'MARGIN_OFFSET_IN_SSM_SHORT' - | 'FIXED_OFFSET_IN_SSM_LONG' - | 'FIXED_OFFSET_IN_SSM_SHORT' - | 'FIXED_CLOSE_LONG' - | 'FIXED_CLOSE_SHORT' - | 'FIXED_FORCE_CLOSE_LONG' - | 'FIXED_FORCE_CLOSE_SHORT' - | 'FIXED_BURST_CLOSE_LONG' - | 'FIXED_BURST_CLOSE_SHORT' - | 'FIXED_ADL_CLOSE_LONG' - | 'FIXED_ADL_CLOSE_SHORT' - | 'FIXED_RISK_LIQ_USER_IN' - | 'FIXED_RISK_LIQ_USER_OUT' - | 'FIXED_FORCE_BUY_SSM' - | 'FIXED_FORCE_SELL_SSM' - | 'FIXED_BURST_BUY_SSM' - | 'FIXED_BURST_SELL_SSM' - | 'ON_CHAIN_TRANSFER_REFUND' - | 'ON_CHAIN_TRANSFER_OUT' - | 'MT5_TRANSFER_IN' - | 'MT5_REFUND_IN' - | 'MT5_TRANSFER_OUT' - | 'TRACE_LOCK_USER_OUT' - | 'TRACE_LOCK_USER_IN' - | 'TRACE_TRANSFER_USER_OUT' - | 'TRACE_TRANSFER_USER_IN' - | 'TRACE_TRANSFER_REFUND_IN' - | 'FINANCIAL_TRANSFER_OUT' - | 'FINANCIAL_TRANSFER_IN' - | 'CONVERT_TRANSFER_IN' - | 'CONVERT_TRANSFER_OUT' - | 'BGPAY_TRANSFER_OUT' - | 'BGPAY_REFUND_IN' - | 'RWA_FIXED_SETTLE_FEE_USER_IN' - | 'RWA_FIXED_SETTLE_FEE_USER_OUT' - | 'RWA_CONTRACT_MAIN_SETTLE_FEE_SYSTEM_IN' - | 'RWA_CONTRACT_MAIN_SETTLE_FEE_SYSTEM_OUT' - | 'RWA_CONTRACT_MAIN_SETTLE_FEE_SYSTEM_KEEP_IN' - | 'RWA_CONTRACT_MAIN_SETTLE_FEE_SYSTEM_KEEP_OUT' - | 'RWA_CONTRACT_MAIN_SETTLE_FEE_USER_IN' - | 'RWA_CONTRACT_MAIN_SETTLE_FEE_USER_OUT' - | 'RWA_CONTRACT_REBASE_USER_OPEN_LONG' - | 'RWA_CONTRACT_REBASE_USER_OPEN_SHORT' - | 'RWA_CONTRACT_REBASE_USER_CLOSE_LONG' - | 'RWA_CONTRACT_REBASE_USER_CLOSE_SHORT' - | 'RWA_CONTRACT_REBASE_USER_BUY_IN_SSM' - | 'RWA_CONTRACT_REBASE_USER_SELL_IN_SSM' - | 'RISK_LIQ_DEFAULT_USER_IN' - | 'FIXED_RISK_LIQ_DEFAULT_USER_IN' - | 'BONUS_GRANT_USER_IN' - | 'BONUS_EXPIRE_USER_OUT' - | 'BONUS_TRANSFER_USER_OUT' - | 'WITHDRAW_TRANSFER_OUT' - | 'WITHDRAW_TRANSFER_IN' - | 'DELIVERY_LONG' - | 'DELIVERY_SHORT' - | 'FIXED_DELIVERY_LONG' - | 'FIXED_DELIVERY_SHORT' - | 'REBASE_COIN_SPLIT_OUT' - | 'REBASE_COIN_SPLIT_IN' - | 'REBASE_COIN_MERGE_OUT' - | 'REBASE_COIN_MERGE_IN'; +export interface CancelBatchOrdersRequestV3 { + orderId?: string; + clientOid?: string; + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol: string; +} ⋮---- -export interface GetFinancialRecordsRequestV3 { - category: +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'; - coin?: string; - type?: FinancialRecordTypeV3; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; } ⋮---- -export interface RepayRequestV3 { - repayableCoinList: string[]; - paymentCoinList: string[]; +export type FuturesMarginModeV3 = 'crossed' | 'isolated'; +⋮---- +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'; + /** + * crossed (default) or isolated. + * Under isolated margin, available excludes futures trial funds. + */ + marginMode?: FuturesMarginModeV3; } ⋮---- -// Sub-account Management Request Types +/** Spot only. Default: no */ ⋮---- -export interface CreateSubAccountApiKeyRequestV3 { - subUid: string; - note: string; - type: 'read_write' | 'read_only'; - passphrase: string; - permissions: string[]; - ips: string[]; +/** + * crossed (default) or isolated. + * Under isolated margin, available excludes futures trial funds. + */ +⋮---- +export interface GetOrderInfoRequestV3 { + orderId?: string; + clientOid?: string; } ⋮---- -export interface DeleteSubAccountApiKeyRequestV3 { - apiKey: 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 GetSubAccountApiKeysRequestV3 { - subUid: 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 UpdateSubAccountApiKeyRequestV3 { - apiKey: string; - passphrase: string; - type?: 'read_write' | 'read_only'; - permissions?: string[]; - ips?: 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 CreateSubAccountRequestV3 { - username: string; - accountMode?: 'classic' | 'unified'; - note?: string; +export interface GetPositionHistoryRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; } ⋮---- -export interface FreezeSubAccountRequestV3 { - subUid: string; - operation: 'freeze' | 'unfreeze'; +export interface GetCurrentPositionRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; + posSide?: 'long' | 'short'; } ⋮---- -export interface GetSubAccountListRequestV3 { - limit?: string; - cursor?: string; +export interface ModifyOrderRequestV3 { + orderId?: string; + clientOid?: string; + qty?: string; + price?: string; + /** Custom request ID. Numbers within 18 digits. */ + requestId?: number; + autoCancel?: 'yes' | 'no'; + /** Required since 30 Sep 2026 */ + symbol: string; + /** Required since 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; + /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ + pxAmendType?: 'yes' | 'no'; } ⋮---- -// Transfer Request Types +/** Custom request ID. Numbers within 18 digits. */ ⋮---- -export interface TransferRequestV3 { +/** Required since 30 Sep 2026 */ +⋮---- +/** Required since 30 Sep 2026 */ +⋮---- +/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ +⋮---- +export interface PlaceRealityOrderRequestV3 { + category?: 'SPOT' | 'MARGIN'; + symbol: string; + side: 'buy' | 'sell'; + orderType: 'limit' | 'market'; + qty: string; + price?: string; 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'; + /** + * rToken routing. Accepted: internal_market | lit_market. Omit for default. + * internal_market = on-exchange only (not submitted to the U.S. stock broker). + * lit_market = broker only (not matched on-exchange). + * Omit / default = internal first at best price, then unfilled to broker. + * Live since 5 Nov 2026 (internalization renamed; old lit_market meaning is now default). + */ + venue?: 'internal_market' | 'lit_market'; + /** + * rToken time in force. gtd (default) = current session. + * gtc = 90 days. Same changelog note as venue. + */ + rTokenTimeInForce?: 'gtd' | 'gtc'; } ⋮---- -/** Enable automatic margin borrowing when balance insufficient. yes | no */ +/** + * rToken routing. Accepted: internal_market | lit_market. Omit for default. + * internal_market = on-exchange only (not submitted to the U.S. stock broker). + * lit_market = broker only (not matched on-exchange). + * Omit / default = internal first at best price, then unfilled to broker. + * Live since 5 Nov 2026 (internalization renamed; old lit_market meaning is now default). + */ ⋮---- -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'; +/** + * rToken time in force. gtd (default) = current session. + * gtc = 90 days. Same changelog note as venue. + */ +⋮---- +export interface CancelRealityOrderRequestV3 { + category?: 'SPOT' | 'MARGIN'; + symbol: string; + orderId?: string; + clientOid?: string; } ⋮---- -export interface GetSubTransferRecordsRequestV3 { - subUid?: string; - role?: 'initiator' | 'receiver'; - coin?: string; - startTime?: string; - endTime?: 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; - limit?: string; - cursor?: string; + reduceOnly?: 'yes' | 'no'; + /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ + pxAmendType?: 'yes' | 'no'; + /** + * Unix ms. Used with receiveWindow. + * If omitted, receiveWindow has no effect. + * An order that reaches the matching engine after requestTime + receiveWindow is canceled. + */ + requestTime?: string; + /** Validity window in ms. Range [10, 60000]. Requires requestTime. */ + receiveWindow?: 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'; -} +/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ ⋮---- -/** Enable automatic margin borrowing when balance insufficient. yes | no */ +/** + * Unix ms. Used with receiveWindow. + * If omitted, receiveWindow has no effect. + * An order that reaches the matching engine after requestTime + receiveWindow is canceled. + */ ⋮---- -export interface GetSubUnifiedAssetsRequestV3 { - subUid?: string; - cursor?: string; - limit?: string; -} +/** Validity window in ms. Range [10, 60000]. Requires requestTime. */ ⋮---- -export interface GetFeeRateRequestV3 { +export interface PlaceOrderRequestV3 { category: | 'SPOT' | 'MARGIN' @@ -17543,1931 +18073,2027 @@ export interface GetFeeRateRequestV3 { | 'COIN-FUTURES' | 'USDC-FUTURES'; symbol: string; - /** RPI fee rate flag for market maker users. Default: no */ - rpiFlag?: 'yes' | 'no'; + /** + * Futures qty must be a multiple of quantityMultiplier + * and have at most quantityPrecision decimal places. + * Both come from /api/v3/market/instruments. Futures only. + */ + qty: string; + price?: string; + side: 'buy' | 'sell'; + /** + * Market orders always run as IOC. + * Staff-confirmed: t.me/bitgetOpenapi/153169. + * timeInForce does not change that. + */ + 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'; + /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ + pxAmendType?: 'yes' | 'no'; + /** Limit orders only. queue1, queue5, counterparty1, or counterparty5 */ + bboLevel?: 'queue1' | 'queue5' | 'counterparty1' | 'counterparty5'; + /** Market orders only. Decimal, default 0.02, range 0.01-0.05 */ + slippageTolerance?: string; + /** + * rToken routing. Accepted: internal_market | lit_market. Omit for default. + * internal_market = on-exchange only (not submitted to the U.S. stock broker). + * lit_market = broker only (not matched on-exchange). + * Omit / default = internal first at best price, then unfilled to broker. + * Ignored for non-rToken symbols. timeInForce is also ignored for rToken. + * Live since 5 Nov 2026 (internalization renamed; old lit_market meaning is now default). + */ + venue?: 'internal_market' | 'lit_market'; + /** + * rToken time in force. gtd (default) lasts the current session. + * gtc lasts 90 days. Ignored for non-rToken symbols. + */ + rTokenTimeInForce?: 'gtd' | 'gtc'; + /** + * Unix ms. Used with receiveWindow. + * If omitted, receiveWindow has no effect. + * An order that reaches the matching engine after requestTime + receiveWindow is canceled. + */ + requestTime?: string; + /** Validity window in ms. Range [10, 60000]. Requires requestTime. */ + receiveWindow?: string; } ⋮---- -/** RPI fee rate flag for market maker users. Default: no */ +/** + * Futures qty must be a multiple of quantityMultiplier + * and have at most quantityPrecision decimal places. + * Both come from /api/v3/market/instruments. Futures only. + */ ⋮---- -export interface GetFundingAssetsRequestV3 { - coin?: string; -} +/** + * Market orders always run as IOC. + * Staff-confirmed: t.me/bitgetOpenapi/153169. + * timeInForce does not change that. + */ ⋮---- -export interface SwitchDeductRequestV3 { - deduct: 'on' | 'off'; -} +/** Futures only. Defaults to crossed */ ⋮---- -// Deposit Request Types +/** Spot only. Default: no */ ⋮---- -export interface GetDepositAddressRequestV3 { - coin: string; - chain?: string; - size?: string; -} +/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ ⋮---- -export interface GetSubDepositAddressRequestV3 { - subUid: string; - coin: string; - chain?: string; - size?: string; +/** Limit orders only. queue1, queue5, counterparty1, or counterparty5 */ +⋮---- +/** Market orders only. Decimal, default 0.02, range 0.01-0.05 */ +⋮---- +/** + * rToken routing. Accepted: internal_market | lit_market. Omit for default. + * internal_market = on-exchange only (not submitted to the U.S. stock broker). + * lit_market = broker only (not matched on-exchange). + * Omit / default = internal first at best price, then unfilled to broker. + * Ignored for non-rToken symbols. timeInForce is also ignored for rToken. + * Live since 5 Nov 2026 (internalization renamed; old lit_market meaning is now default). + */ +⋮---- +/** + * rToken time in force. gtd (default) lasts the current session. + * gtc lasts 90 days. Ignored for non-rToken symbols. + */ +⋮---- +/** + * Unix ms. Used with receiveWindow. + * If omitted, receiveWindow has no effect. + * An order that reaches the matching engine after requestTime + receiveWindow is canceled. + */ +⋮---- +/** Validity window in ms. Range [10, 60000]. Requires requestTime. */ +⋮---- +export interface CountdownCancelAllRequestV3 { + countdown: string; // seconds until auto-cancel (5-60, or 0 to disable) } ⋮---- -export interface GetDepositRecordsRequestV3 { - coin?: string; - orderId?: string; - startTime: string; - endTime: string; - limit?: string; - cursor?: string; +countdown: string; // seconds until auto-cancel (5-60, or 0 to disable) + +================ +File: src/types/response/v3/account.ts +================ +// Account Management Response Types +import type { + CollateralTypeV3, + FinancialRecordTypeV3, +} from '../../request/v3/account.js'; +⋮---- +export interface AccountSymbolConfigV3 { + category: string; + symbol: string; + marginMode: string; + leverage: string; } ⋮---- -export interface GetSubDepositRecordsRequestV3 { - coin?: string; - subUid: string; - startTime: string; - endTime: string; - limit?: string; - cursor?: string; +export interface AccountCoinConfigV3 { + coin: string; + leverage: string; } ⋮---- -// Withdraw Request Types +export type AccountPermissionV3 = + | 'uta_mgt' + | 'uta_trade' + | 'withdraw' + | 'copy_futures_position' + | 'copy_futures_order'; ⋮---- -export interface WithdrawRequestV3 { - coin: string; - chain?: string; - /** Deduct from funding, uta, and/or otc accounts (comma-separated). Order: funding -> otc -> uta */ - accountType?: string; - transferType: 'on_chain' | 'internal_transfer'; - address: string; - innerToType?: 'uid' | 'email' | 'mobile'; - areaCode?: string; - tag?: string; - size: string; - remark?: string; - clientOid?: string; - memberCode?: 'bithumb' | 'korbit' | 'coinone'; - identityType?: 'company' | 'user'; - companyName?: string; - firstName?: string; - lastName?: string; +export interface AccountInfoV3 { + userId: string; + inviterId: string; + /** + * Only set when the calling account is a sub-account. + * Confirmed by Bitget devs but not yet in their docs: the API returns + * parentId as an integer, not only the string shown in the docs. + */ + parentId: string | number; + channelCode: string; + channel: string; + ips: string; + /** + * Confirmed by Bitget devs but not yet in their docs: permType uses + * underscores (read_and_write). readonly is also possible on demo keys. + */ + permType: + | 'read-only' + | 'read-and-write' + | 'read_only' + | 'read_and_write' + | 'readonly'; + permissions: AccountPermissionV3[]; + regisTime: string; + traderType?: 'trader' | 'not_trader'; } ⋮---- -/** 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; -} +/** + * Only set when the calling account is a sub-account. + * Confirmed by Bitget devs but not yet in their docs: the API returns + * parentId as an integer, not only the string shown in the docs. + */ ⋮---- -export interface GetWithdrawAddressBookRequestV3 { - coin?: string; - type?: 'EVM' | 'regular' | 'universal' | 'internal'; - limit?: string; - cursor?: string; -} +/** + * Confirmed by Bitget devs but not yet in their docs: permType uses + * underscores (read_and_write). readonly is also possible on demo keys. + */ ⋮---- -export interface CancelWithdrawalRequestV3 { - orderId?: string; - clientOid?: string; -} +export type AccountLevelV3 = 'basic' | 'advanced' | 'isolated' | 'delta'; ⋮---- -export interface SetDepositAccountRequestV3 { - coin: string; - accountType: 'funding' | 'unified' | 'otc'; +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'; + repayMode?: 'auto' | 'manual'; + symbolConfigList: AccountSymbolConfigV3[]; + coinConfigList: AccountCoinConfigV3[]; } ⋮---- -export interface GetMaxTransferableRequestV3 { +export interface AccountDeltaCoinPositionV3 { coin: string; + positionRatio: string; } ⋮---- -export interface GetOpenInterestLimitRequestV3 { - symbol: string; - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; +/** 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[]; } ⋮---- -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; -} +/** Deprecated, no longer used as a hedge-eligibility criterion */ ⋮---- -export type CollateralTypeV3 = 'mainstream' | 'all' | 'custom'; +/** Deprecated, no longer used as a hedge-eligibility criterion */ ⋮---- -export interface SetCollateralTypeRequestV3 { - collateralType: CollateralTypeV3; - /** Required when collateralType=custom. Comma-separated coin names */ - collateralCoins?: string; - /** Enable Cash+ as collateral. Official field name is allowCashPlus */ - allowCashPlus?: 'yes' | 'no'; +export interface AccountAssetV3 { + coin: string; + equity: string; + usdValue: string; + balance: string; + /** Coin balance before borrowing-related amounts are deducted */ + balanceOriginal?: string; + available: string; + debt: string; + locked: string; + /** Position value in USD */ + positionValue?: string; + /** Account leverage (non-negative) */ + leverage?: string; + /** USDT bonus amount */ + bonus?: string; + /** Interest calculation base */ + interestBase?: string; } ⋮---- -/** Required when collateralType=custom. Comma-separated coin names */ -⋮---- -/** Enable Cash+ as collateral. Official field name is allowCashPlus */ +/** Coin balance before borrowing-related amounts are deducted */ ⋮---- -export interface BorrowRequestV3 { - coin: string; - amount: string; - clientOid?: string; -} +/** Position value in USD */ ⋮---- -export interface GetMaxBorrowableRequestV3 { - coin: string; -} +/** Account leverage (non-negative) */ ⋮---- -export interface SetRepayModeRequestV3 { - /** Account-level. Master and each sub-account keep their own setting */ - repayMode: 'auto' | 'manual'; -} +/** USDT bonus amount */ ⋮---- -/** Account-level. Master and each sub-account keep their own setting */ +/** Interest calculation base */ ⋮---- -export interface DeleteSubAccountRequestV3 { - subUid: string; +export interface BorrowResponseV3 { + orderId: string; + clientOid?: string; } ⋮---- -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 MaxBorrowableV3 { + maxBorrowable: string; } ⋮---- -export interface SetMarginRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol: string; - posSide: 'long' | 'short'; - operation: 'add' | 'remove'; - amount: string; +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 GetMaxWithdrawalRequestV3 { - coin: string; +export interface ConvertRecordV3 { + fromCoin: string; + fromCoinSize: string; + toCoin: string; + toCoinSize: string; + price: string; + ts: string; } ⋮---- -export interface GetRealityOrderBookRequestV3 { +export interface FinancialRecordV3 { + category: string; + id: string; symbol: string; + coin: string; + type: FinancialRecordTypeV3; + amount: string; + fee: string; + balance: string; + ts: string; + /** crossed | isolated */ + positionType?: string; + positionAmount?: string; + positionBalance?: string; } ⋮---- -export interface GetRealityOrderBookSegmentedRequestV3 { - symbol: string; -} +/** crossed | isolated */ ⋮---- -export interface GetRealityFillsRequestV3 { - symbol: string; - limit?: string; +export interface PaymentCoinV3 { + coin: string; + size: string; + amount: string; } ⋮---- -export interface SubMasterTransferRequestV3 { - fromType: 'spot' | 'uta'; - toType: 'spot' | 'p2p' | 'uta'; - amount: string; +export interface RepayableCoinV3 { coin: string; - clientOid?: string; + size: string; + amount: string; } ⋮---- -export interface CreateAgentSubAccountRequestV3 { - username: string; - passphrase: string; - note?: string; +export interface RepayResponseV3 { + result: string; + repayAmount: string; } ⋮---- -export interface MovePositionItemRequestV3 { - symbol: string; - side: 'buy' | 'sell'; - qty: string; -} +// Sub-account Management Response Types ⋮---- -export interface MovePositionsRequestV3 { - fromUid: string; - toUid: string; - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - positionList: MovePositionItemRequestV3[]; +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 GetMovePositionHistoryRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - startTime?: string; - endTime?: string; - cursor?: string; - limit?: string; +export interface UpdateSubAccountApiKeyResponseV3 { + note: string; + apiKey: string; + type: string; + permissions: string[]; + ips: string[]; } ⋮---- -export interface GetEligibleSymbolsRequestV3 { - symbol?: string; +export interface CreateSubAccountResponseV3 { + username: string; + subUid: string; + status: string; + note: string; + createdTime: string; + updatedTime: string; } ⋮---- -export interface GetEligibleMarginTierRequestV3 { - coin?: string; +export interface CreateAgentSubAccountResponseV3 { + username: string; + subUid: string; + apiKey: string; + secret: string; + note: string; + createdTime: string; } ⋮---- -export interface GetEligibleLoanInfoRequestV3 { - coin?: 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 GetEligibleDiscountRateRequestV3 { - coin?: 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 GetFundingFinancialRecordsRequestV3 { - coin?: string; - type?: string; - startTime?: string; - endTime?: string; - limit?: string; +export interface WithdrawAddressBookV3 { + addressList: WithdrawAddressBookEntryV3[]; cursor?: string; } ⋮---- -export interface GetSmallAssetsRequestV3 { - coin?: string; -} +// Transfer Response Types ⋮---- -export interface TradeSmallAssetsRequestV3 { - fromCoinList: string[]; - toCoin?: string; +export interface AllSymbolFeeRateV3 { + symbol: string; + makerFeeRate: string; + takerFeeRate: string; } ⋮---- -export interface GetSmallAssetsHistoryRequestV3 { - orderId?: string; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; +export interface TransferResponseV3 { + transferId: string; + clientOid?: string; } ⋮---- -export interface GetRateLimitQuotaRequestV3 { - category: 'spot' | 'futures'; - /** - * Omit to list sub-accounts under the master. - * Ignored when a sub-account calls this for itself. - */ - uid?: string; - cursor?: string; - limit?: 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; } ⋮---- -/** - * Omit to list sub-accounts under the master. - * Ignored when a sub-account calls this for itself. - */ -⋮---- -export interface SetRateLimitQuotaRequestV3 { - category: 'spot' | 'futures'; - /** - * Required when the master account sets quotas. - * Not required, and ignored, when a sub-account sets its own quota. - */ - uids?: string[]; - quota: string; +export interface SubUnifiedAssetV3 { + coin: string; + equity: string; + usdValue: string; + balance: string; + available: string; + debt: string; + locked: string; } ⋮---- -/** - * Required when the master account sets quotas. - * Not required, and ignored, when a sub-account sets its own quota. - */ -⋮---- -export interface CreateStpGroupRequestV3 { - /** Max 32 characters. Must be unique. */ - groupName: string; +export interface SubUnifiedAssetV3 { + subUid: string; + cursor: string; + assets: SubUnifiedAssetV3[]; } ⋮---- -/** Max 32 characters. Must be unique. */ -⋮---- -export interface StpGroupMembersRequestV3 { - /** Comma-separated sub-account UIDs. Max 50. */ - uids: string; - groupId: string; +export interface GetFeeRateResponseV3 { + makerFeeRate: string; + takerFeeRate: string; } ⋮---- -/** Comma-separated sub-account UIDs. Max 50. */ - -================ -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 since 30 Sep 2026 */ - symbol: string; - /** Required since 30 Sep 2026 */ - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ - pxAmendType?: 'yes' | 'no'; +export interface FundingAssetV3 { + coin: string; + available: string; + frozen: string; + balance: string; } ⋮---- -/** Custom request ID. Numbers within 18 digits. */ -⋮---- -/** Required since 30 Sep 2026 */ -⋮---- -/** Required since 30 Sep 2026 */ -⋮---- -/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ +// Deposit Response Types ⋮---- -export interface CancelAllOrdersRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol?: string; +export interface DepositAddressV3 { + address: string; + chain: string; + coin: string; + tag: string; + url: string; } ⋮---- -export interface CancelBatchOrdersRequestV3 { - orderId?: string; - clientOid?: string; - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol: 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; } ⋮---- -export interface CloseAllPositionsRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - posSide?: 'long' | 'short'; -} +// Withdraw Response Types ⋮---- -export interface CancelOrderRequestV3 { - orderId?: string; - clientOid?: string; - category?: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; +export interface WithdrawResponseV3 { + orderId: string; + clientOid: string; } ⋮---- -export type FuturesMarginModeV3 = 'crossed' | 'isolated'; -⋮---- -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'; - /** - * crossed (default) or isolated. - * Under isolated margin, available excludes futures trial funds. - */ - marginMode?: FuturesMarginModeV3; +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; } ⋮---- -/** Spot only. Default: no */ -⋮---- -/** - * crossed (default) or isolated. - * Under isolated margin, available excludes futures trial funds. - */ -⋮---- -export interface GetOrderInfoRequestV3 { - orderId?: string; - clientOid?: string; +export interface MaxTransferableV3 { + coin: string; + maxTransfer: string; + borrowMaxTransfer: 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 OpenInterestLimitV3 { + symbol: string; + singleUserLimit: string; + masterSubLimit: string; + marketMakerLimit: 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 TaxRecordV3 { + id: string; + coin: string; + type: string; + amount: string; + fee: string; + balance: string; + ts: 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 CollateralTypeConfigV3 { + collateralType: CollateralTypeV3; + /** Returned when collateralType=custom */ + collateralCoins?: string; } ⋮---- -export interface GetPositionHistoryRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; -} +/** Returned when collateralType=custom */ ⋮---- -export interface GetCurrentPositionRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - posSide?: 'long' | 'short'; +export interface CustomCollateralCoinV3 { + collateralCoin: string; } ⋮---- -export interface ModifyOrderRequestV3 { - orderId?: string; - clientOid?: string; - qty?: string; - price?: string; - /** Custom request ID. Numbers within 18 digits. */ - requestId?: number; - autoCancel?: 'yes' | 'no'; - /** Required since 30 Sep 2026 */ - symbol: string; - /** Required since 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; - /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ - pxAmendType?: 'yes' | 'no'; +export interface PreSetLeverageV3 { + estMaxOpen?: string; + estMaxBorrowable?: string; + requiredMargin: string; + marginChange: string; } ⋮---- -/** Custom request ID. Numbers within 18 digits. */ -⋮---- -/** Required since 30 Sep 2026 */ +export interface MaxWithdrawalV3 { + coin: string; + otcMaxWithdrawal: string; + spotMaxWithdrawal: string; + utaMaxWithdrawal: string; + totalMaxWithdrawal: string; +} ⋮---- -/** Required since 30 Sep 2026 */ +export interface MovePositionOrderResultV3 { + orderId: string; + clientOid: string; + code: string; + msg: string; +} ⋮---- -/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ +export interface MovePositionsResponseV3 { + closePosition: MovePositionOrderResultV3[]; + openPosition: MovePositionOrderResultV3[]; +} ⋮---- -export interface PlaceRealityOrderRequestV3 { - category?: 'SPOT' | 'MARGIN'; +export interface MovePositionHistoryV3 { + category: string; + fromUid: string; + toUid: string; + orderId: string; + openExecId: string; + closeExecId: string; symbol: string; - side: 'buy' | 'sell'; - orderType: 'limit' | 'market'; + posSide: 'long' | 'short'; qty: string; - price?: string; - clientOid?: string; - /** - * rToken routing. Accepted: internal_market | lit_market. Omit for default. - * internal_market = on-exchange only (not submitted to the U.S. stock broker). - * lit_market = broker only (not matched on-exchange). - * Omit / default = internal first at best price, then unfilled to broker. - * Live since 5 Nov 2026 (internalization renamed; old lit_market meaning is now default). - */ - venue?: 'internal_market' | 'lit_market'; - /** - * rToken time in force. gtd (default) = current session. - * gtc = 90 days. Same changelog note as venue. - */ - rTokenTimeInForce?: 'gtd' | 'gtc'; + price: string; + status: 'processing' | 'completed' | 'failed'; + createdTime: string; + updatedTime: string; } ⋮---- -/** - * rToken routing. Accepted: internal_market | lit_market. Omit for default. - * internal_market = on-exchange only (not submitted to the U.S. stock broker). - * lit_market = broker only (not matched on-exchange). - * Omit / default = internal first at best price, then unfilled to broker. - * Live since 5 Nov 2026 (internalization renamed; old lit_market meaning is now default). - */ -⋮---- -/** - * rToken time in force. gtd (default) = current session. - * gtc = 90 days. Same changelog note as venue. - */ -⋮---- -export interface CancelRealityOrderRequestV3 { - category?: 'SPOT' | 'MARGIN'; +export interface EligibleSymbolV3 { symbol: string; - orderId?: string; - clientOid?: 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 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'; - /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ - pxAmendType?: 'yes' | 'no'; - /** - * Unix ms. Used with receiveWindow. - * If omitted, receiveWindow has no effect. - * An order that reaches the matching engine after requestTime + receiveWindow is canceled. - */ - requestTime?: string; - /** Validity window in ms. Range [10, 60000]. Requires requestTime. */ - receiveWindow?: string; +export interface EligibleMarginTierItemV3 { + tier: string; + minTierValue: string; + maxTierValue: string; + leverage: string; + mmr: string; } ⋮---- -/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ +export interface EligibleMarginTierV3 { + coin: string; + tiers: EligibleMarginTierItemV3[]; +} ⋮---- -/** - * Unix ms. Used with receiveWindow. - * If omitted, receiveWindow has no effect. - * An order that reaches the matching engine after requestTime + receiveWindow is canceled. - */ +export interface EligibleLoanInfoV3 { + limit: string; + masterSubLimit: string; + /** Bitget spelling */ + platformRemaingQuota: string; +} ⋮---- -/** Validity window in ms. Range [10, 60000]. Requires requestTime. */ +/** Bitget spelling */ ⋮---- -export interface PlaceOrderRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol: string; - /** - * Futures qty must be a multiple of quantityMultiplier - * and have at most quantityPrecision decimal places. - * Both come from /api/v3/market/instruments. Futures only. - */ - qty: string; - price?: string; - side: 'buy' | 'sell'; - /** - * Market orders always run as IOC. - * Staff-confirmed: t.me/bitgetOpenapi/153169. - * timeInForce does not change that. - */ - 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'; - /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ - pxAmendType?: 'yes' | 'no'; - /** Limit orders only. queue1, queue5, counterparty1, or counterparty5 */ - bboLevel?: 'queue1' | 'queue5' | 'counterparty1' | 'counterparty5'; - /** Market orders only. Decimal, default 0.02, range 0.01-0.05 */ - slippageTolerance?: string; - /** - * rToken routing. Accepted: internal_market | lit_market. Omit for default. - * internal_market = on-exchange only (not submitted to the U.S. stock broker). - * lit_market = broker only (not matched on-exchange). - * Omit / default = internal first at best price, then unfilled to broker. - * Ignored for non-rToken symbols. timeInForce is also ignored for rToken. - * Live since 5 Nov 2026 (internalization renamed; old lit_market meaning is now default). - */ - venue?: 'internal_market' | 'lit_market'; - /** - * rToken time in force. gtd (default) lasts the current session. - * gtc lasts 90 days. Ignored for non-rToken symbols. - */ - rTokenTimeInForce?: 'gtd' | 'gtc'; - /** - * Unix ms. Used with receiveWindow. - * If omitted, receiveWindow has no effect. - * An order that reaches the matching engine after requestTime + receiveWindow is canceled. - */ - requestTime?: string; - /** Validity window in ms. Range [10, 60000]. Requires requestTime. */ - receiveWindow?: string; +export interface EligibleDiscountRateTierV3 { + tierStartValue: string; + discountRate: string; } ⋮---- -/** - * Futures qty must be a multiple of quantityMultiplier - * and have at most quantityPrecision decimal places. - * Both come from /api/v3/market/instruments. Futures only. - */ +export interface EligibleDiscountRateV3 { + coin: string; + list: EligibleDiscountRateTierV3[]; +} ⋮---- -/** - * Market orders always run as IOC. - * Staff-confirmed: t.me/bitgetOpenapi/153169. - * timeInForce does not change that. - */ +export interface FundingFinancialRecordV3 { + id: string; + coin: string; + groupType: string; + type: string; + amount: string; + balance: string; + ts: string; +} ⋮---- -/** Futures only. Defaults to crossed */ +export interface SmallAssetFeeDetailV3 { + feeRate?: string; + fee?: string; + feeCoin?: string; +} ⋮---- -/** Spot only. Default: no */ +export interface SmallAssetV3 { + coin: string; + available?: string; + estimatedCoin?: string; + estimatedAmount?: string; + feeDetail?: SmallAssetFeeDetailV3; + cTime?: string; + size?: string; + usdtValue?: string; +} ⋮---- -/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ +export interface SmallAssetsTradeResponseV3 { + fromCoin?: string; + toCoin?: string; + orderId?: string; + result?: string; +} ⋮---- -/** Limit orders only. queue1, queue5, counterparty1, or counterparty5 */ +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; +} ⋮---- -/** Market orders only. Decimal, default 0.02, range 0.01-0.05 */ +export interface RateLimitQuotaItemV3 { + uid: string; + quota: string; +} ⋮---- -/** - * rToken routing. Accepted: internal_market | lit_market. Omit for default. - * internal_market = on-exchange only (not submitted to the U.S. stock broker). - * lit_market = broker only (not matched on-exchange). - * Omit / default = internal first at best price, then unfilled to broker. - * Ignored for non-rToken symbols. timeInForce is also ignored for rToken. - * Live since 5 Nov 2026 (internalization renamed; old lit_market meaning is now default). - */ +export interface RateLimitQuotaV3 { + category: 'spot' | 'futures' | string; + quotaList: RateLimitQuotaItemV3[]; + masterSubQuota: string; + masterSubCap: string; + cursor: string; +} ⋮---- -/** - * rToken time in force. gtd (default) lasts the current session. - * gtc lasts 90 days. Ignored for non-rToken symbols. - */ +export interface StpGroupMemberV3 { + uid: string; + joinedTime: string; +} ⋮---- -/** - * Unix ms. Used with receiveWindow. - * If omitted, receiveWindow has no effect. - * An order that reaches the matching engine after requestTime + receiveWindow is canceled. - */ +export interface StpGroupV3 { + groupId: string; + groupName: string; + createdTime: string; + members?: StpGroupMemberV3[]; +} ⋮---- -/** Validity window in ms. Range [10, 60000]. Requires requestTime. */ +export interface StpGroupListV3 { + groups: StpGroupV3[]; +} ⋮---- -export interface CountdownCancelAllRequestV3 { - countdown: string; // seconds until auto-cancel (5-60, or 0 to disable) +export interface CreateStpGroupResponseV3 { + groupId: string; + groupName: string; + createdTime: string; } ⋮---- -countdown: string; // seconds until auto-cancel (5-60, or 0 to disable) +export interface StpGroupUidResultV3 { + uid: string; +} +⋮---- +export interface StpGroupMembersResponseV3 { + createdTime: string; + successUids: StpGroupUidResultV3[]; + failedUids: StpGroupUidResultV3[]; +} ================ -File: src/types/response/v3/account.ts +File: src/types/response/v3/public.ts ================ -// Account Management Response Types -import type { - CollateralTypeV3, - FinancialRecordTypeV3, -} from '../../request/v3/account.js'; -⋮---- -export interface AccountSymbolConfigV3 { - category: string; - symbol: string; - marginMode: string; - leverage: string; +export interface PublicFillV3 { + execId: string; + execLinkId?: string; + price: string; + size: string; + side: 'sell' | 'buy'; + ts: string; + isRPI?: 'yes' | 'no' | string; } ⋮---- -export interface AccountCoinConfigV3 { - coin: string; - leverage: string; +export interface CandlestickV3 extends Array { + 0: string; // timestamp + 1: string; // open price + 2: string; // high price + 3: string; // low price + 4: string; // close price + 5: string; // volume + 6: string; // turnover } ⋮---- -export type AccountPermissionV3 = - | 'uta_mgt' - | 'uta_trade' - | 'withdraw' - | 'copy_futures_position' - | 'copy_futures_order'; +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 AccountInfoV3 { - userId: string; - inviterId: string; - /** - * Only set when the calling account is a sub-account. - * Confirmed by Bitget devs but not yet in their docs: the API returns - * parentId as an integer, not only the string shown in the docs. - */ - parentId: string | number; - channelCode: string; - channel: string; - ips: string; +export interface ContractOiV3 { + symbol: string; + notionalValue: string; + totalNotionalValue: string; + /** Single UID position ratio. Decimal, 0.1 means 10% */ + singlePositionRatio?: string; + /** Master and sub-account position ratio. Decimal, 0.1 means 10% */ + totalPositionRatio?: string; +} +⋮---- +/** Single UID position ratio. Decimal, 0.1 means 10% */ +⋮---- +/** Master and sub-account position ratio. Decimal, 0.1 means 10% */ +⋮---- +export interface CurrentFundingRateV3 { + symbol: string; + fundingRate: string; + fundingRateInterval: string; + nextUpdate: string; + minFundingRate: string; + maxFundingRate: string; + /** Previous settlement, decimal */ + lastFundingRate?: string; + /** Upcoming settlement, decimal */ + nextFundingRate?: string; + /** Decimal. 0.0001 means 0.01%. Docs name. Live rows still use baselnterestRate. */ + baseInterestRate?: string; /** - * Confirmed by Bitget devs but not yet in their docs: permType uses - * underscores (read_and_write). readonly is also possible on demo keys. + * Live spelling of baseInterestRate (lowercase L, not i). + * Decimal. 0.0001 means 0.01%. */ - permType: - | 'read-only' - | 'read-and-write' - | 'read_only' - | 'read_and_write' - | 'readonly'; - permissions: AccountPermissionV3[]; - regisTime: string; - traderType?: 'trader' | 'not_trader'; + baselnterestRate?: string; + /** Quote-coin notional used for the impact price */ + impactMarginNotional?: string; + cashDividend?: string; + cashDividendNextUpdate?: string; } ⋮---- -/** - * Only set when the calling account is a sub-account. - * Confirmed by Bitget devs but not yet in their docs: the API returns - * parentId as an integer, not only the string shown in the docs. - */ +/** Previous settlement, decimal */ +⋮---- +/** Upcoming settlement, decimal */ +⋮---- +/** Decimal. 0.0001 means 0.01%. Docs name. Live rows still use baselnterestRate. */ ⋮---- /** - * Confirmed by Bitget devs but not yet in their docs: permType uses - * underscores (read_and_write). readonly is also possible on demo keys. + * Live spelling of baseInterestRate (lowercase L, not i). + * Decimal. 0.0001 means 0.01%. */ ⋮---- -export type AccountLevelV3 = 'basic' | 'advanced' | 'isolated' | 'delta'; +/** Quote-coin notional used for the impact price */ ⋮---- -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'; - repayMode?: 'auto' | 'manual'; - symbolConfigList: AccountSymbolConfigV3[]; - coinConfigList: AccountCoinConfigV3[]; +export interface DiscountRateTierV3 { + tierStartValue: string; + discountRate: string; } ⋮---- -export interface AccountDeltaCoinPositionV3 { +export interface DiscountRateV3 { coin: string; - positionRatio: string; + list: DiscountRateTierV3[]; } ⋮---- -/** 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[]; +export interface HistoryFundingRateV3 { + symbol: string; + fundingRate: string; + fundingRateTimestamp: string; } ⋮---- -/** Deprecated, no longer used as a hedge-eligibility criterion */ +export interface MarginLoanV3 { + dailyInterest: string; + annualInterest: string; + limit: string; + masterSubLimit?: string; + /** Bitget spelling */ + platformRemaingQuota?: string; +} ⋮---- -/** Deprecated, no longer used as a hedge-eligibility criterion */ +/** Bitget spelling */ ⋮---- -export interface AccountAssetV3 { +export interface MarginLoanAllV3 extends MarginLoanV3 { coin: string; - equity: string; - usdValue: string; - balance: string; - /** Coin balance before borrowing-related amounts are deducted */ - balanceOriginal?: string; - available: string; - debt: string; - locked: string; - /** Position value in USD */ - positionValue?: string; - /** Account leverage (non-negative) */ - leverage?: string; - /** USDT bonus amount */ - bonus?: string; - /** Interest calculation base */ - interestBase?: string; } ⋮---- -/** Coin balance before borrowing-related amounts are deducted */ -⋮---- -/** Position value in USD */ -⋮---- -/** Account leverage (non-negative) */ -⋮---- -/** USDT bonus amount */ -⋮---- -/** Interest calculation base */ -⋮---- -export interface BorrowResponseV3 { - orderId: string; - clientOid?: string; +export interface OpenInterestItemV3 { + symbol: string; + openInterest: string; } ⋮---- -export interface MaxBorrowableV3 { - maxBorrowable: string; +export interface OpenInterestV3 { + list: OpenInterestItemV3[]; + ts: string; } ⋮---- -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 OpenInterestHistoryItemV3 { + symbol: string; + openInterest: string; + oneSideOpenInterest: string; + openInterestValue: string; + oneSideOpenInterestValue: string; + timestamp: string; } ⋮---- -export interface ConvertRecordV3 { - fromCoin: string; - fromCoinSize: string; - toCoin: string; - toCoinSize: string; - price: string; - ts: string; +export interface OpenInterestHistoryV3 { + list: OpenInterestHistoryItemV3[]; } ⋮---- -export interface FinancialRecordV3 { - category: string; - id: string; - symbol: string; +export interface InterestRateHistoryItemV3 { coin: string; - type: FinancialRecordTypeV3; - amount: string; - fee: string; - balance: string; + dailyInterestRate: string; + annualInterestRate: string; ts: string; - /** crossed | isolated */ - positionType?: string; - positionAmount?: string; - positionBalance?: string; } ⋮---- -/** crossed | isolated */ -⋮---- -export interface PaymentCoinV3 { - coin: string; - size: string; - amount: string; +export interface InterestRateHistoryV3 { + list: InterestRateHistoryItemV3[]; + cursor?: string; } ⋮---- -export interface RepayableCoinV3 { - coin: string; - size: string; - amount: string; +export interface AnnouncementV3 { + annId: string; + annTitle: string; + language: string; + annUrl: string; + annType: string; + annSubType?: string; + /** Documented release time. The live payload uses cTime instead. */ + createdTime?: string; + /** Observed live. Unix ms. Docs call this createdTime. */ + cTime?: string; + /** Observed live. Not in the docs example. */ + annDesc?: string; } ⋮---- -export interface RepayResponseV3 { - result: string; - repayAmount: string; -} +/** Documented release time. The live payload uses cTime instead. */ ⋮---- -// Sub-account Management Response Types +/** Observed live. Unix ms. Docs call this createdTime. */ ⋮---- -export interface CreateSubAccountApiKeyResponseV3 { - note: string; - apiKey: string; - secret: string; - type: string; - permissions: string[]; - ips: string[]; +/** Observed live. Not in the docs example. */ +⋮---- +export interface MarketCoinChainV3 { + chain: string; + needTag: string; + withdrawable: string; + rechargeable: string; + withdrawFee: string; + extraWithdrawFee: string; + depositConfirm: string; + withdrawConfirm: string; + minDepositAmount: string; + minWithdrawAmount: string; + browserUrl: string; + contractAddress: string | null; + withdrawStep: string; + /** + * Live field. The docs example names this withdrawPrecision. + */ + withdrawMinScale: string; + congestion: string; } -export interface SubAccountApiKeyV3 { - apiKey: string; - note: string; - type: string; - permissions: string[]; - ips: string[]; - ts?: string; +⋮---- +/** + * Live field. The docs example names this withdrawPrecision. + */ +⋮---- +export interface MarketCoinV3 { + coinId?: string; + coin: string; + /** "true" / "false" */ + transfer: string; + areaCoin?: string; + chains: MarketCoinChainV3[]; } ⋮---- -export interface UpdateSubAccountApiKeyResponseV3 { - note: string; - apiKey: string; - type: string; - permissions: string[]; - ips: string[]; +/** "true" / "false" */ +⋮---- +export interface PositionTierV3 { + tier: string; + minTierValue: string; + maxTierValue: string; + leverage: string; + mmr: string; } ⋮---- -export interface CreateSubAccountResponseV3 { - username: string; - subUid: string; - status: string; - note: string; - createdTime: string; - updatedTime: string; +export interface RiskReserveRecordV3 { + balance: string; + amount: string; + ts: string; + type?: string; } ⋮---- -export interface CreateAgentSubAccountResponseV3 { - username: string; - subUid: string; - apiKey: string; - secret: string; - note: string; - createdTime: string; +export interface RiskReserveV3 { + totalBalance?: string; + coin: string; + riskReserveRecords: RiskReserveRecordV3[]; } ⋮---- -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 RiskReserveHourRecordV3 { + amount: string; + balance: string; + ts: string; } ⋮---- -export interface WithdrawAddressBookEntryV3 { +export interface RiskReserveHourV3 { coin: string; - chain: string; - address: string; - countryCode: string; - label: string; - memo: string; - type: 'regular' | 'EVM' | 'universal' | 'internal'; - internalType: '' | 'uid' | 'mobile' | 'email'; - createdTime: string; + riskReserveRecords: RiskReserveHourRecordV3[]; } ⋮---- -export interface WithdrawAddressBookV3 { - addressList: WithdrawAddressBookEntryV3[]; - cursor?: string; +export interface RiskReserveAllItemV3 { + symbols: string[]; + coin: string; + balance: string; } ⋮---- -// Transfer Response Types +export interface RiskReserveAllV3 { + list: RiskReserveAllItemV3[]; +} ⋮---- -export interface AllSymbolFeeRateV3 { +export interface InstrumentV3 { symbol: string; - makerFeeRate: string; - takerFeeRate: 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; + /** + * Max decimal places for qty. + * Futures qty must stay within this and be a multiple of quantityMultiplier. + * Spot qty is not bound by quantityMultiplier. + */ + quantityPrecision: string; + quotePrecision: string; + minOrderAmount: string; + maxSymbolOrderNum: string; + maxProductOrderNum: string; + status: + | 'listed' + | 'online' + | 'limit_open' + | 'limit_close' + | 'offline' + | 'restrictedAPI'; + offTime: string; + limitOpenTime: string; + maintainTime: string; + areaSymbol?: string; + + isRwa?: 'YES' | 'NO'; + /** yes = Reality stock token, no = non-Reality stock token */ + isReality?: 'yes' | 'no'; + + // Futures specific fields + makerFeeRate?: string; + takerFeeRate?: string; + openCostUpRatio?: string; + priceMultiplier?: string; + /** + * Futures only. Order qty must be a multiple of this, + * with at most quantityPrecision decimal places. + */ + quantityMultiplier?: string; + type?: 'perpetual' | 'delivery'; + symbolType?: 'crypto' | 'metal' | 'stock' | 'commodity'; + /** Display name. Returned alongside symbolType. */ + fullName?: string; + /** + * metal / energy / stock / etf / crypto. + * Independent of symbolType, which is still returned. + */ + instrumentType?: 'metal' | 'energy' | 'stock' | 'etf' | 'crypto'; + /** Set for traditional-finance pairs. Null for crypto. */ + marketRegion?: string | null; + /** ISIN for traditional-finance pairs. Null for crypto. */ + isin?: string | null; + maxPositionNum?: string; + deliveryTime?: string; + deliveryStartTime?: string; + deliveryPeriod?: string; + /** Launch time - Unix millisecond timestamp. Null for some margin pairs. */ + launchTime?: string | null; + fundInterval?: string; + minLeverage?: string; + maxLeverage?: string; + + // Margin specific fields + isIsolatedBaseBorrowable?: 'YES' | 'NO'; + isIsolatedQuotedBorrowable?: 'YES' | 'NO'; + warningRiskRatio?: string; + liquidationRiskRatio?: string; + maxCrossedLeverage?: string; + maxIsolatedLeverage?: string; + userMinBorrow?: string; } ⋮---- -export interface TransferResponseV3 { - transferId: string; - clientOid?: string; -} +/** Spot only. Max amount for a single market order. */ ⋮---- -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; -} +/** + * Max decimal places for qty. + * Futures qty must stay within this and be a multiple of quantityMultiplier. + * Spot qty is not bound by quantityMultiplier. + */ ⋮---- -export interface SubUnifiedAssetV3 { - coin: string; - equity: string; - usdValue: string; - balance: string; - available: string; - debt: string; - locked: string; -} +/** yes = Reality stock token, no = non-Reality stock token */ ⋮---- -export interface SubUnifiedAssetV3 { - subUid: string; - cursor: string; - assets: SubUnifiedAssetV3[]; +// Futures specific fields +⋮---- +/** + * Futures only. Order qty must be a multiple of this, + * with at most quantityPrecision decimal places. + */ +⋮---- +/** Display name. Returned alongside symbolType. */ +⋮---- +/** + * metal / energy / stock / etf / crypto. + * Independent of symbolType, which is still returned. + */ +⋮---- +/** Set for traditional-finance pairs. Null for crypto. */ +⋮---- +/** ISIN for traditional-finance pairs. Null for crypto. */ +⋮---- +/** Launch time - Unix millisecond timestamp. Null for some margin pairs. */ +⋮---- +// Margin specific fields +⋮---- +export interface MarketFeeGroupLabelV3 { + weight: string; + label: string; + symbols: string[]; } ⋮---- -export interface GetFeeRateResponseV3 { +export interface MarketFeeGroupTierV3 { + level: string; makerFeeRate: string; - takerFeeRate: 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 FundingAssetV3 { - coin: string; - available: string; - frozen: string; - balance: string; -} +/** PRO1~PRO6 only. Taker fee rate in decimal form */ ⋮---- -// Deposit Response Types +/** Market maker RPI maker fee rate in decimal form */ ⋮---- -export interface DepositAddressV3 { - address: string; - chain: string; - coin: string; - tag: string; - url: string; +export interface MarketFeeGroupV3 { + category: string; + group: string; + labelList: MarketFeeGroupLabelV3[]; + tierList: MarketFeeGroupTierV3[]; } ⋮---- -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; +export interface MarketScoreWeightV3 { + category: string; + label: string; + symbol: string; + requiredSpread: string; + minMakerVolume: string; + weight: string; } ⋮---- -// Withdraw Response Types +export interface LiquidationV3 { + symbol: string; + side: 'buy' | 'sell'; + price: string; + amount: string; + ts: string; +} ⋮---- -export interface WithdrawResponseV3 { - orderId: string; - clientOid: string; +export interface LiquidationsV3 { + list: LiquidationV3[]; + cursor?: 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 OrderBookV3 { + a: string[][]; // asks - [price, size] + b: string[][]; // bids - [price, size] + ts: string; } ⋮---- -export interface MaxTransferableV3 { - coin: string; - maxTransfer: string; - borrowMaxTransfer: string; +a: string[][]; // asks - [price, size] +b: string[][]; // bids - [price, size] +⋮---- +export interface RealityOrderBookV3 { + symbol: string; + a: string[][]; + b: string[][]; + ts: string; } ⋮---- -export interface OpenInterestLimitV3 { +/** [price, onshoreQty, offshoreQty] */ +export type RealitySegmentedLevelV3 = [string, string, string]; +⋮---- +export interface RealityOrderBookSegmentedV3 { symbol: string; - singleUserLimit: string; - masterSubLimit: string; - marketMakerLimit: string; + a: RealitySegmentedLevelV3[]; + b: RealitySegmentedLevelV3[]; + ts: string; } ⋮---- -export interface TaxRecordV3 { - id: string; - coin: string; - type: string; - amount: string; - fee: string; - balance: string; +export interface RealityFillV3 { + execId: string; + price: string; + size: string; + side: 'buy' | 'sell'; ts: string; } ⋮---- -export interface CollateralTypeConfigV3 { - collateralType: CollateralTypeV3; - /** Returned when collateralType=custom */ - collateralCoins?: 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; } ⋮---- -/** Returned when collateralType=custom */ +/** 24h platform turnover; only available for rtoken */ ⋮---- -export interface CustomCollateralCoinV3 { - collateralCoin: string; +// Futures specific fields +⋮---- +export interface ProofOfReservesV3 { + merkleRootHash: string; + totalReserveRatio: string; + list: { + coin: string; + userAssets: string; + platformAssets: string; + reserveRatio: string; + }[]; } ⋮---- -export interface PreSetLeverageV3 { - estMaxOpen?: string; - estMaxBorrowable?: string; - requiredMargin: string; - marginChange: string; +export interface IndexComponentV3 { + exchange: string; + spotPair: string; + equivalentPrice: string; + weight: string; } ⋮---- -export interface MaxWithdrawalV3 { - coin: string; - otcMaxWithdrawal: string; - spotMaxWithdrawal: string; - utaMaxWithdrawal: string; - totalMaxWithdrawal: string; +export interface IndexPriceComponentsV3 { + symbol: string; + componentList: IndexComponentV3[]; } ⋮---- -export interface MovePositionOrderResultV3 { - orderId: string; - clientOid: string; - code: string; - msg: string; +export interface RpiSymbolV3 { + category: 'spot' | 'usdt-futures' | 'coin-futures' | 'usdc-futures'; + symbol: string; } ⋮---- -export interface MovePositionsResponseV3 { - closePosition: MovePositionOrderResultV3[]; - openPosition: MovePositionOrderResultV3[]; +/** RPI order book depth: [price, nonRpiQty, rpiQty] */ +export interface RpiOrderBookV3 { + a: [string, string, string][]; + b: [string, string, string][]; + ts: string; } ⋮---- -export interface MovePositionHistoryV3 { - category: string; - fromUid: string; - toUid: string; - orderId: string; - openExecId: string; - closeExecId: string; +export interface CashDividendRecordV3 { symbol: string; - posSide: 'long' | 'short'; - qty: string; - price: string; - status: 'processing' | 'completed' | 'failed'; - createdTime: string; - updatedTime: string; + exDividendDate: string; + cashDividendPerShare: string; + cashDividendTimestamp: string; } ⋮---- -export interface EligibleSymbolV3 { +export interface SplitRecordV3 { 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; + type: 'split' | 'reverse_split' | string; + status: 'pending' | 'ongoing' | 'completed' | string; + adjustmentRatio: string; + exDividendDate: string; + exDividendDateTimezone: string; + tradingHaltStartTime: string; + tradingHaltEndTime: string; } ⋮---- -export interface EligibleMarginTierItemV3 { - tier: string; - minTierValue: string; - maxTierValue: string; - leverage: string; - mmr: string; +export interface SpotWhaleFlowV3 { + volume: string; + date: string; } ⋮---- -export interface EligibleMarginTierV3 { - coin: string; - tiers: EligibleMarginTierItemV3[]; +export interface SpotNetFlowV3 { + netFlow: string; + ts: string; } ⋮---- -export interface EligibleLoanInfoV3 { - limit: string; - masterSubLimit: string; - /** Bitget spelling */ - platformRemaingQuota: 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; } ⋮---- -/** Bitget spelling */ -⋮---- -export interface EligibleDiscountRateTierV3 { - tierStartValue: string; - discountRate: string; +export interface MarginLongShortV3 { + longShortRatio: string; + ts: string; } ⋮---- -export interface EligibleDiscountRateV3 { - coin: string; - list: EligibleDiscountRateTierV3[]; +export interface MarginLoanGrowthV3 { + growthRate: string; + ts: string; } ⋮---- -export interface FundingFinancialRecordV3 { - id: string; - coin: string; - groupType: string; - type: string; - amount: string; - balance: string; +export interface MarginIsolatedBorrowV3 { + borrowRate: string; ts: string; } ⋮---- -export interface SmallAssetFeeDetailV3 { - feeRate?: string; - fee?: string; - feeCoin?: string; +export interface FuturesActiveBuySellV3 { + buyVolume: string; + sellVolume: string; + ts: string; } ⋮---- -export interface SmallAssetV3 { - coin: string; - available?: string; - estimatedCoin?: string; - estimatedAmount?: string; - feeDetail?: SmallAssetFeeDetailV3; - cTime?: string; - size?: string; - usdtValue?: string; +export interface FuturesLongShortV3 { + longRatio: string; + shortRatio: string; + longShortRatio: string; + ts: string; } ⋮---- -export interface SmallAssetsTradeResponseV3 { - fromCoin?: string; - toCoin?: string; - orderId?: string; - result?: string; +export interface FuturesPositionLongShortV3 { + longPositionRatio: string; + shortPositionRatio: string; + longShortPositionRatio: string; + ts: 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 FuturesAccountLongShortV3 { + longAccountRatio: string; + shortAccountRatio: string; + longShortAccountRatio: string; + ts: string; } + +================ +File: src/types/request/v3/account.ts +================ +// Account Management Request Types ⋮---- -export interface RateLimitQuotaItemV3 { - uid: string; - quota: string; -} +export type AccountAdjustModeV3 = 'basic' | 'advanced' | 'delta' | 'isolated'; ⋮---- -export interface RateLimitQuotaV3 { - category: 'spot' | 'futures' | string; - quotaList: RateLimitQuotaItemV3[]; - masterSubQuota: string; - masterSubCap: string; - cursor: string; +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; } ⋮---- -export interface StpGroupMemberV3 { - uid: string; - joinedTime: 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; + /** + * Error 25159 means a low-liquidity period capped leverage at 5x. + * There is no pre-check API for that cap. + */ + 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; } ⋮---- -export interface StpGroupV3 { - groupId: string; - groupName: string; - createdTime: string; - members?: StpGroupMemberV3[]; +/** + * Error 25159 means a low-liquidity period capped leverage at 5x. + * There is no pre-check API for that cap. + */ +⋮---- +/** 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 StpGroupListV3 { - groups: StpGroupV3[]; +export interface GetConvertRecordsRequestV3 { + fromCoin?: string; + toCoin?: string; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; } ⋮---- -export interface CreateStpGroupResponseV3 { - groupId: string; - groupName: string; - createdTime: string; +/** + * UTA account financial-record type. + * https://www.bitget.com/docs/uta/enum + * MARIN_BUY_DEAL and MARIN_SELL_DEAL keep Bitget's spelling. + */ +export type FinancialRecordTypeV3 = + | 'TRANSFER_IN' + | 'TRANSFER_OUT' + | 'CONVERSION_UPON_DELISTING' + | 'ORDER_DEALT_FROZEN_OUT' + | 'ORDER_DEALT_IN' + | 'ORDER_PLF_FEE_OUT' + | 'EXCHANGE_SOURCE_TOKEN_USER_OUT' + | 'EXCHANGE_TARGET_TOKEN_USER_IN' + | 'OPEN_LONG' + | 'OPEN_SHORT' + | 'BUY_DEAL' + | 'SELL_DEAL' + | 'CLOSE_LONG' + | 'CLOSE_SHORT' + | 'FORCE_CLOSE_LONG' + | 'FORCE_CLOSE_SHORT' + | 'BURST_CLOSE_LONG' + | 'BURST_CLOSE_SHORT' + | 'OFFSET_REDUCE_CLOSE_LONG' + | 'OFFSET_REDUCE_CLOSE_SHORT' + | 'FORCE_BUY_SSM' + | 'FORCE_SELL_SSM' + | 'BURST_BUY_SSM' + | 'BURST_SELL_SSM' + | 'RISK_LIQ_USER_IN' + | 'INTEREST_SETTLEMENT_OUT' + | 'CONTRACT_MAIN_SETTLE_FEE_USER_IN' + | 'CONTRACT_MAIN_SETTLE_FEE_USER_OUT' + | 'RISK_LIQ_USER_OUT' + | 'BORROW' + | 'RESERVE_TRANSFER_IN' + | 'RESERVE_TRANSFER_OUT' + | 'REPAYMENT' + | 'INTEREST_REPAYMENT' + | 'LIQ_FUND_OUT' + | 'LIQ_CONVERT_USER_OUT' + | 'LIQ_CONVERT_SYS_IN' + | 'LIQ_CONVERT_SYS_OUT' + | 'LIQ_CONVERT_USER_IN' + | 'LIQ_TRANSFER_IN' + | 'LIQ_TRANSFER_OUT' + | 'LIQ_FUND_IN' + | 'LIQ_FEE' + | 'LIQ_REPAYMENT' + | 'DELIST_MARGIN_TOKEN_SOURCE_USER_OUT' + | 'DELIST_MARGIN_TOKEN_SOURCE_SYS_IN' + | 'DELIST_MARGIN_TOKEN_TARGET_SYS_OUT' + | 'DELIST_MARGIN_TOKEN_TARGET_USER_IN' + | 'CONFISCATE_TOKEN_USER_OUT' + | 'CONFISCATE_TOKEN_SYS_IN' + | 'DELIST_SMALL_BALANCE_USER_OUT' + | 'DELIST_SMALL_BALANCE_SYS_IN' + | 'DELIST_SMALL_LIABILITY_SYS_OUT' + | 'DELIST_SMALL_LIABILITY_USER_IN' + | 'SMALL_ASSET_SOURCE_TOKEN_USER_OUT' + | 'SMALL_ASSET_SOURCE_TOKEN_SYS_IN' + | 'SMALL_ASSET_TARGET_TOKEN_SYS_OUT' + | 'SMALL_ASSET_TARGET_TOKEN_USER_IN' + | 'SMALL_ASSET_FEE_SYS_IN' + | 'TRACE_SHARE_BENEFIT_USER_OUT' + | 'TRACE_SHARE_BENEFIT_SYSTEM_IN' + | 'TRACE_SHARE_BENEFIT_SYSTEM_OUT' + | 'TRACE_SHARE_BENEFIT_USER_IN' + | 'MARGIN_OPEN_LONG' + | 'MARGIN_OPEN_SHORT' + | 'MARIN_BUY_DEAL' + | 'MARIN_SELL_DEAL' + | 'MARGIN_BACK' + | 'INCREASE_MARGIN' + | 'REDUCE_MARGIN' + | 'MARGIN_SETTLE_FEE_USER_IN' + | 'MARGIN_SETTLE_FEE_USER_OUT' + | 'MARGIN_LEVER_ORDER_REFROZEN' + | 'MARGIN_LEVER_ORDER_FROZEN' + | 'MARGIN_LEVER_POS_IN' + | 'MARGIN_OFFSET_IN_SSM_LONG' + | 'MARGIN_OFFSET_IN_SSM_SHORT' + | 'FIXED_OFFSET_IN_SSM_LONG' + | 'FIXED_OFFSET_IN_SSM_SHORT' + | 'FIXED_CLOSE_LONG' + | 'FIXED_CLOSE_SHORT' + | 'FIXED_FORCE_CLOSE_LONG' + | 'FIXED_FORCE_CLOSE_SHORT' + | 'FIXED_BURST_CLOSE_LONG' + | 'FIXED_BURST_CLOSE_SHORT' + | 'FIXED_ADL_CLOSE_LONG' + | 'FIXED_ADL_CLOSE_SHORT' + | 'FIXED_RISK_LIQ_USER_IN' + | 'FIXED_RISK_LIQ_USER_OUT' + | 'FIXED_FORCE_BUY_SSM' + | 'FIXED_FORCE_SELL_SSM' + | 'FIXED_BURST_BUY_SSM' + | 'FIXED_BURST_SELL_SSM' + | 'ON_CHAIN_TRANSFER_REFUND' + | 'ON_CHAIN_TRANSFER_OUT' + | 'MT5_TRANSFER_IN' + | 'MT5_REFUND_IN' + | 'MT5_TRANSFER_OUT' + | 'TRACE_LOCK_USER_OUT' + | 'TRACE_LOCK_USER_IN' + | 'TRACE_TRANSFER_USER_OUT' + | 'TRACE_TRANSFER_USER_IN' + | 'TRACE_TRANSFER_REFUND_IN' + | 'FINANCIAL_TRANSFER_OUT' + | 'FINANCIAL_TRANSFER_IN' + | 'CONVERT_TRANSFER_IN' + | 'CONVERT_TRANSFER_OUT' + | 'BGPAY_TRANSFER_OUT' + | 'BGPAY_REFUND_IN' + | 'RWA_FIXED_SETTLE_FEE_USER_IN' + | 'RWA_FIXED_SETTLE_FEE_USER_OUT' + | 'RWA_CONTRACT_MAIN_SETTLE_FEE_SYSTEM_IN' + | 'RWA_CONTRACT_MAIN_SETTLE_FEE_SYSTEM_OUT' + | 'RWA_CONTRACT_MAIN_SETTLE_FEE_SYSTEM_KEEP_IN' + | 'RWA_CONTRACT_MAIN_SETTLE_FEE_SYSTEM_KEEP_OUT' + | 'RWA_CONTRACT_MAIN_SETTLE_FEE_USER_IN' + | 'RWA_CONTRACT_MAIN_SETTLE_FEE_USER_OUT' + | 'RWA_CONTRACT_REBASE_USER_OPEN_LONG' + | 'RWA_CONTRACT_REBASE_USER_OPEN_SHORT' + | 'RWA_CONTRACT_REBASE_USER_CLOSE_LONG' + | 'RWA_CONTRACT_REBASE_USER_CLOSE_SHORT' + | 'RWA_CONTRACT_REBASE_USER_BUY_IN_SSM' + | 'RWA_CONTRACT_REBASE_USER_SELL_IN_SSM' + | 'RISK_LIQ_DEFAULT_USER_IN' + | 'FIXED_RISK_LIQ_DEFAULT_USER_IN' + | 'BONUS_GRANT_USER_IN' + | 'BONUS_EXPIRE_USER_OUT' + | 'BONUS_TRANSFER_USER_OUT' + | 'WITHDRAW_TRANSFER_OUT' + | 'WITHDRAW_TRANSFER_IN' + | 'DELIVERY_LONG' + | 'DELIVERY_SHORT' + | 'FIXED_DELIVERY_LONG' + | 'FIXED_DELIVERY_SHORT' + | 'REBASE_COIN_SPLIT_OUT' + | 'REBASE_COIN_SPLIT_IN' + | 'REBASE_COIN_MERGE_OUT' + | 'REBASE_COIN_MERGE_IN'; +⋮---- +export interface GetFinancialRecordsRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + coin?: string; + type?: FinancialRecordTypeV3; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; } ⋮---- -export interface StpGroupUidResultV3 { - uid: string; +export interface RepayRequestV3 { + repayableCoinList: string[]; + paymentCoinList: string[]; } ⋮---- -export interface StpGroupMembersResponseV3 { - createdTime: string; - successUids: StpGroupUidResultV3[]; - failedUids: StpGroupUidResultV3[]; -} - -================ -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; -} +// Sub-account Management Request Types ⋮---- -export interface CandlestickV3 extends Array { - 0: string; // timestamp - 1: string; // open price - 2: string; // high price - 3: string; // low price - 4: string; // close price - 5: string; // volume - 6: string; // turnover +export interface CreateSubAccountApiKeyRequestV3 { + subUid: string; + note: string; + type: 'read_write' | 'read_only'; + passphrase: string; + permissions: string[]; + ips: string[]; } ⋮---- -0: string; // timestamp -1: string; // open price -2: string; // high price -3: string; // low price -4: string; // close price -5: string; // volume -6: string; // turnover -⋮---- -export interface ContractOiV3 { - symbol: string; - notionalValue: string; - totalNotionalValue: string; - /** Single UID position ratio. Decimal, 0.1 means 10% */ - singlePositionRatio?: string; - /** Master and sub-account position ratio. Decimal, 0.1 means 10% */ - totalPositionRatio?: string; +export interface DeleteSubAccountApiKeyRequestV3 { + apiKey: string; } ⋮---- -/** Single UID position ratio. Decimal, 0.1 means 10% */ -⋮---- -/** Master and sub-account position ratio. Decimal, 0.1 means 10% */ -⋮---- -export interface CurrentFundingRateV3 { - symbol: string; - fundingRate: string; - fundingRateInterval: string; - nextUpdate: string; - minFundingRate: string; - maxFundingRate: string; - /** Previous settlement, decimal */ - lastFundingRate?: string; - /** Upcoming settlement, decimal */ - nextFundingRate?: string; - /** Decimal. 0.0001 means 0.01%. Docs name. Live rows still use baselnterestRate. */ - baseInterestRate?: string; - /** - * Live spelling of baseInterestRate (lowercase L, not i). - * Decimal. 0.0001 means 0.01%. - */ - baselnterestRate?: string; - /** Quote-coin notional used for the impact price */ - impactMarginNotional?: string; - cashDividend?: string; - cashDividendNextUpdate?: string; +export interface GetSubAccountApiKeysRequestV3 { + subUid: string; + limit?: string; + cursor?: string; } ⋮---- -/** Previous settlement, decimal */ -⋮---- -/** Upcoming settlement, decimal */ -⋮---- -/** Decimal. 0.0001 means 0.01%. Docs name. Live rows still use baselnterestRate. */ -⋮---- -/** - * Live spelling of baseInterestRate (lowercase L, not i). - * Decimal. 0.0001 means 0.01%. - */ -⋮---- -/** Quote-coin notional used for the impact price */ -⋮---- -export interface DiscountRateTierV3 { - tierStartValue: string; - discountRate: string; +export interface UpdateSubAccountApiKeyRequestV3 { + apiKey: string; + passphrase: string; + type?: 'read_write' | 'read_only'; + permissions?: string[]; + ips?: string[]; } ⋮---- -export interface DiscountRateV3 { - coin: string; - list: DiscountRateTierV3[]; +export interface CreateSubAccountRequestV3 { + username: string; + accountMode?: 'classic' | 'unified'; + note?: string; } ⋮---- -export interface HistoryFundingRateV3 { - symbol: string; - fundingRate: string; - fundingRateTimestamp: string; +export interface FreezeSubAccountRequestV3 { + subUid: string; + operation: 'freeze' | 'unfreeze'; } ⋮---- -export interface MarginLoanV3 { - dailyInterest: string; - annualInterest: string; - limit: string; - masterSubLimit?: string; - /** Bitget spelling */ - platformRemaingQuota?: string; +export interface GetSubAccountListRequestV3 { + limit?: string; + cursor?: string; } ⋮---- -/** Bitget spelling */ +// Transfer Request Types ⋮---- -export interface MarginLoanAllV3 extends MarginLoanV3 { +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'; } ⋮---- -export interface OpenInterestItemV3 { - symbol: string; - openInterest: string; -} -⋮---- -export interface OpenInterestV3 { - list: OpenInterestItemV3[]; - ts: string; -} -⋮---- -export interface OpenInterestHistoryItemV3 { - symbol: string; - openInterest: string; - oneSideOpenInterest: string; - openInterestValue: string; - oneSideOpenInterestValue: string; - timestamp: string; -} -⋮---- -export interface OpenInterestHistoryV3 { - list: OpenInterestHistoryItemV3[]; -} +/** Enable automatic margin borrowing when balance insufficient. yes | no */ ⋮---- -export interface InterestRateHistoryItemV3 { - coin: string; - dailyInterestRate: string; - annualInterestRate: string; - ts: string; +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 InterestRateHistoryV3 { - list: InterestRateHistoryItemV3[]; +export interface GetSubTransferRecordsRequestV3 { + subUid?: string; + role?: 'initiator' | 'receiver'; + coin?: string; + startTime?: string; + endTime?: string; + clientOid?: string; + limit?: string; cursor?: string; } ⋮---- -export interface AnnouncementV3 { - annId: string; - annTitle: string; - language: string; - annUrl: string; - annType: string; - annSubType?: string; - /** Documented release time. The live payload uses cTime instead. */ - createdTime?: string; - /** Observed live. Unix ms. Docs call this createdTime. */ - cTime?: string; - /** Observed live. Not in the docs example. */ - annDesc?: 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; + /** Custom order ID, max 50 characters */ + clientOid: string; + /** Enable automatic margin borrowing when balance insufficient. yes | no */ + allowBorrow?: 'yes' | 'no'; } ⋮---- -/** Documented release time. The live payload uses cTime instead. */ -⋮---- -/** Observed live. Unix ms. Docs call this createdTime. */ +/** Custom order ID, max 50 characters */ ⋮---- -/** Observed live. Not in the docs example. */ +/** Enable automatic margin borrowing when balance insufficient. yes | no */ ⋮---- -export interface MarketCoinChainV3 { - chain: string; - needTag: string; - withdrawable: string; - rechargeable: string; - withdrawFee: string; - extraWithdrawFee: string; - depositConfirm: string; - withdrawConfirm: string; - minDepositAmount: string; - minWithdrawAmount: string; - browserUrl: string; - contractAddress: string | null; - withdrawStep: string; - /** - * Live field. The docs example names this withdrawPrecision. - */ - withdrawMinScale: string; - congestion: string; +export interface GetSubUnifiedAssetsRequestV3 { + subUid?: string; + cursor?: string; + limit?: string; } ⋮---- -/** - * Live field. The docs example names this withdrawPrecision. - */ -⋮---- -export interface MarketCoinV3 { - coinId?: string; - coin: string; - /** "true" / "false" */ - transfer: string; - areaCoin?: string; - chains: MarketCoinChainV3[]; +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'; } ⋮---- -/** "true" / "false" */ +/** RPI fee rate flag for market maker users. Default: no */ ⋮---- -export interface PositionTierV3 { - tier: string; - minTierValue: string; - maxTierValue: string; - leverage: string; - mmr: string; +export interface GetFundingAssetsRequestV3 { + coin?: string; } ⋮---- -export interface RiskReserveRecordV3 { - balance: string; - amount: string; - ts: string; - type?: string; +export interface SwitchDeductRequestV3 { + deduct: 'on' | 'off'; } ⋮---- -export interface RiskReserveV3 { - totalBalance?: string; - coin: string; - riskReserveRecords: RiskReserveRecordV3[]; -} +// Deposit Request Types ⋮---- -export interface RiskReserveHourRecordV3 { - amount: string; - balance: string; - ts: string; +export interface GetDepositAddressRequestV3 { + coin: string; + chain?: string; + size?: string; } ⋮---- -export interface RiskReserveHourV3 { +export interface GetSubDepositAddressRequestV3 { + subUid: string; coin: string; - riskReserveRecords: RiskReserveHourRecordV3[]; + chain?: string; + size?: string; } ⋮---- -export interface RiskReserveAllItemV3 { - symbols: string[]; - coin: string; - balance: string; +export interface GetDepositRecordsRequestV3 { + coin?: string; + orderId?: string; + startTime: string; + endTime: string; + limit?: string; + cursor?: string; } ⋮---- -export interface RiskReserveAllV3 { - list: RiskReserveAllItemV3[]; +export interface GetSubDepositRecordsRequestV3 { + coin?: string; + subUid: string; + startTime: string; + endTime: string; + limit?: string; + cursor?: string; } ⋮---- -export interface InstrumentV3 { - symbol: string; - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - baseCoin: string; - quoteCoin: string; - buyLimitPriceRatio: string; - sellLimitPriceRatio: string; - feeRateUpRatio: string; - minOrderQty: string; - maxOrderQty: string; - maxMarketOrderQty: string; - /** Spot only. Max amount for a single market order. */ - maxMarketOrderAmount?: string; - pricePrecision: string; - /** - * Max decimal places for qty. - * Futures qty must stay within this and be a multiple of quantityMultiplier. - * Spot qty is not bound by quantityMultiplier. - */ - quantityPrecision: string; - quotePrecision: string; - minOrderAmount: string; - maxSymbolOrderNum: string; - maxProductOrderNum: string; - status: - | 'listed' - | 'online' - | 'limit_open' - | 'limit_close' - | 'offline' - | 'restrictedAPI'; - offTime: string; - limitOpenTime: string; - maintainTime: string; - areaSymbol?: string; - - isRwa?: 'YES' | 'NO'; - /** yes = Reality stock token, no = non-Reality stock token */ - isReality?: 'yes' | 'no'; - - // Futures specific fields - makerFeeRate?: string; - takerFeeRate?: string; - openCostUpRatio?: string; - priceMultiplier?: string; - /** - * Futures only. Order qty must be a multiple of this, - * with at most quantityPrecision decimal places. - */ - quantityMultiplier?: string; - type?: 'perpetual' | 'delivery'; - symbolType?: 'crypto' | 'metal' | 'stock' | 'commodity'; - /** Display name. Returned alongside symbolType. */ - fullName?: string; - /** - * metal / energy / stock / etf / crypto. - * Independent of symbolType, which is still returned. - */ - instrumentType?: 'metal' | 'energy' | 'stock' | 'etf' | 'crypto'; - /** Set for traditional-finance pairs. Null for crypto. */ - marketRegion?: string | null; - /** ISIN for traditional-finance pairs. Null for crypto. */ - isin?: string | null; - maxPositionNum?: string; - deliveryTime?: string; - deliveryStartTime?: string; - deliveryPeriod?: string; - /** Launch time - Unix millisecond timestamp. Null for some margin pairs. */ - launchTime?: string | null; - fundInterval?: string; - minLeverage?: string; - maxLeverage?: string; - - // Margin specific fields - isIsolatedBaseBorrowable?: 'YES' | 'NO'; - isIsolatedQuotedBorrowable?: 'YES' | 'NO'; - warningRiskRatio?: string; - liquidationRiskRatio?: string; - maxCrossedLeverage?: string; - maxIsolatedLeverage?: string; - userMinBorrow?: string; +// 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; } ⋮---- -/** Spot only. Max amount for a single market order. */ +/** Deduct from funding, uta, and/or otc accounts (comma-separated). Order: funding -> otc -> uta */ ⋮---- -/** - * Max decimal places for qty. - * Futures qty must stay within this and be a multiple of quantityMultiplier. - * Spot qty is not bound by quantityMultiplier. - */ +export interface GetWithdrawRecordsRequestV3 { + coin?: string; + orderId?: string; + clientOid?: string; + startTime: string; + endTime: string; + limit?: string; + cursor?: string; +} ⋮---- -/** yes = Reality stock token, no = non-Reality stock token */ +export interface GetWithdrawAddressBookRequestV3 { + coin?: string; + type?: 'EVM' | 'regular' | 'universal' | 'internal'; + limit?: string; + cursor?: string; +} ⋮---- -// Futures specific fields +export interface CancelWithdrawalRequestV3 { + orderId?: string; + clientOid?: string; +} ⋮---- -/** - * Futures only. Order qty must be a multiple of this, - * with at most quantityPrecision decimal places. - */ +export interface SetDepositAccountRequestV3 { + coin: string; + accountType: 'funding' | 'unified' | 'otc'; +} ⋮---- -/** Display name. Returned alongside symbolType. */ +export interface GetMaxTransferableRequestV3 { + coin: string; +} ⋮---- -/** - * metal / energy / stock / etf / crypto. - * Independent of symbolType, which is still returned. - */ +export interface GetOpenInterestLimitRequestV3 { + symbol: string; + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; +} ⋮---- -/** Set for traditional-finance pairs. Null for crypto. */ +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; +} ⋮---- -/** ISIN for traditional-finance pairs. Null for crypto. */ +export type CollateralTypeV3 = 'mainstream' | 'all' | 'custom'; ⋮---- -/** Launch time - Unix millisecond timestamp. Null for some margin pairs. */ +export interface SetCollateralTypeRequestV3 { + collateralType: CollateralTypeV3; + /** Required when collateralType=custom. Comma-separated coin names */ + collateralCoins?: string; + /** Enable Cash+ as collateral. Official field name is allowCashPlus */ + allowCashPlus?: 'yes' | 'no'; +} ⋮---- -// Margin specific fields +/** Required when collateralType=custom. Comma-separated coin names */ ⋮---- -export interface MarketFeeGroupLabelV3 { - weight: string; - label: string; - symbols: string[]; +/** Enable Cash+ as collateral. Official field name is allowCashPlus */ +⋮---- +export interface BorrowRequestV3 { + coin: string; + amount: string; + clientOid?: 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; +export interface GetMaxBorrowableRequestV3 { + coin: string; } ⋮---- -/** PRO1~PRO6 only. Taker fee rate in decimal form */ +export interface SetRepayModeRequestV3 { + /** Account-level. Master and each sub-account keep their own setting */ + repayMode: 'auto' | 'manual'; +} ⋮---- -/** Market maker RPI maker fee rate in decimal form */ +/** Account-level. Master and each sub-account keep their own setting */ ⋮---- -export interface MarketFeeGroupV3 { - category: string; - group: string; - labelList: MarketFeeGroupLabelV3[]; - tierList: MarketFeeGroupTierV3[]; +export interface DeleteSubAccountRequestV3 { + subUid: string; } ⋮---- -export interface MarketScoreWeightV3 { - category: string; - label: string; - symbol: string; - requiredSpread: string; - minMakerVolume: string; - weight: string; +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 LiquidationV3 { +export interface SetMarginRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; symbol: string; - side: 'buy' | 'sell'; - price: string; + posSide: 'long' | 'short'; + operation: 'add' | 'remove'; 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; +export interface GetMaxWithdrawalRequestV3 { + coin: string; } ⋮---- -a: string[][]; // asks - [price, size] -b: string[][]; // bids - [price, size] -⋮---- -export interface RealityOrderBookV3 { +export interface GetRealityOrderBookRequestV3 { symbol: string; - a: string[][]; - b: string[][]; - ts: string; } ⋮---- -/** [price, onshoreQty, offshoreQty] */ -export type RealitySegmentedLevelV3 = [string, string, string]; -⋮---- -export interface RealityOrderBookSegmentedV3 { +export interface GetRealityOrderBookSegmentedRequestV3 { symbol: string; - a: RealitySegmentedLevelV3[]; - b: RealitySegmentedLevelV3[]; - 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'; +export interface GetRealityFillsRequestV3 { 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; + limit?: 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 SubMasterTransferRequestV3 { + fromType: 'spot' | 'uta'; + toType: 'spot' | 'p2p' | 'uta'; + amount: string; + coin: string; + clientOid?: string; } ⋮---- -export interface IndexComponentV3 { - exchange: string; - spotPair: string; - equivalentPrice: string; - weight: string; +export interface CreateAgentSubAccountRequestV3 { + username: string; + passphrase: string; + note?: string; } ⋮---- -export interface IndexPriceComponentsV3 { +export interface MovePositionItemRequestV3 { symbol: string; - componentList: IndexComponentV3[]; + side: 'buy' | 'sell'; + qty: string; } ⋮---- -export interface RpiSymbolV3 { - category: 'spot' | 'usdt-futures' | 'coin-futures' | 'usdc-futures'; - symbol: string; +export interface MovePositionsRequestV3 { + fromUid: string; + toUid: string; + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + positionList: MovePositionItemRequestV3[]; } ⋮---- -/** RPI order book depth: [price, nonRpiQty, rpiQty] */ -export interface RpiOrderBookV3 { - a: [string, string, string][]; - b: [string, string, string][]; - ts: string; +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 CashDividendRecordV3 { - symbol: string; - exDividendDate: string; - cashDividendPerShare: string; - cashDividendTimestamp: string; +export interface GetEligibleMarginTierRequestV3 { + coin?: 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 GetEligibleLoanInfoRequestV3 { + coin?: string; } ⋮---- -export interface SpotWhaleFlowV3 { - volume: string; - date: string; +export interface GetEligibleDiscountRateRequestV3 { + coin?: string; } ⋮---- -export interface SpotNetFlowV3 { - netFlow: string; - ts: string; +export interface GetFundingFinancialRecordsRequestV3 { + coin?: string; + type?: string; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: 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 GetSmallAssetsRequestV3 { + coin?: string; } ⋮---- -export interface MarginLongShortV3 { - longShortRatio: string; - ts: string; +export interface TradeSmallAssetsRequestV3 { + fromCoinList: string[]; + toCoin?: string; } ⋮---- -export interface MarginLoanGrowthV3 { - growthRate: string; - ts: string; +export interface GetSmallAssetsHistoryRequestV3 { + orderId?: string; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; } ⋮---- -export interface MarginIsolatedBorrowV3 { - borrowRate: string; - ts: string; +export interface GetRateLimitQuotaRequestV3 { + category: 'spot' | 'futures'; + /** + * Omit to list sub-accounts under the master. + * Ignored when a sub-account calls this for itself. + */ + uid?: string; + cursor?: string; + limit?: string; } ⋮---- -export interface FuturesActiveBuySellV3 { - buyVolume: string; - sellVolume: string; - ts: string; -} +/** + * Omit to list sub-accounts under the master. + * Ignored when a sub-account calls this for itself. + */ ⋮---- -export interface FuturesLongShortV3 { - longRatio: string; - shortRatio: string; - longShortRatio: string; - ts: string; +export interface SetRateLimitQuotaRequestV3 { + category: 'spot' | 'futures'; + /** + * Required when the master account sets quotas. + * Not required, and ignored, when a sub-account sets its own quota. + */ + uids?: string[]; + quota: string; } ⋮---- -export interface FuturesPositionLongShortV3 { - longPositionRatio: string; - shortPositionRatio: string; - longShortPositionRatio: string; - ts: string; +/** + * Required when the master account sets quotas. + * Not required, and ignored, when a sub-account sets its own quota. + */ +⋮---- +export interface CreateStpGroupRequestV3 { + /** Max 32 characters. Must be unique. */ + groupName: string; } ⋮---- -export interface FuturesAccountLongShortV3 { - longAccountRatio: string; - shortAccountRatio: string; - longShortAccountRatio: string; - ts: string; +/** Max 32 characters. Must be unique. */ +⋮---- +export interface StpGroupMembersRequestV3 { + /** Comma-separated sub-account UIDs. Max 50. */ + uids: string; + groupId: string; } +⋮---- +/** Comma-separated sub-account UIDs. Max 50. */ ================ File: src/rest-client-v3.ts @@ -19534,6 +20160,17 @@ import { UpdateSubAccountApiKeyRequestV3, WithdrawRequestV3, } from './types/request/v3/account.js'; +import { + AgentCustomerAssetRequestV3, + AgentCustomerDepositRequestV3, + AgentCustomerListRequestV3, + AgentCustomerTradeVolumeRequestV3, + GetAgentCustomerCommissionsRequestV3, + GetAgentCustomerKycResultRequestV3, + GetAgentSubCustomerListRequestV3, + GetSubAffiliateCommissionRequestV3, + GetSubAffiliateInfoRequestV3, +} from './types/request/v3/affiliate.js'; import { BrokerSubWithdrawalRequestV3, CreateBrokerSubAccountRequestV3, @@ -19541,11 +20178,17 @@ import { DeleteBrokerSubApiKeyRequestV3, GetBrokerAllSubDepositWithdrawalRequestV3, GetBrokerCommissionRequestV3, + GetBrokerOrderCommissionRequestV3, + GetBrokerRebateInfoRequestV3, GetBrokerSubAccountListRequestV3, GetBrokerSubApiKeyRequestV3, GetBrokerSubDepositAddressRequestV3, + GetBrokerTotalCommissionRequestV3, + GetBrokerTradeVolumeRequestV3, + GetSubaccountEmailRequestV3, ModifyBrokerSubAccountRequestV3, ModifyBrokerSubApiKeyRequestV3, + ModifySubaccountEmailRequestV3, } from './types/request/v3/broker.js'; import { CancelAllCfdOrdersRequestV3, @@ -19600,7 +20243,21 @@ import { GetEarnEliteRedeemInfoRequestV3, GetEarnEliteSubscribeInfoRequestV3, GetEarnEliteSubscribeResultRequestV3, + GetEarnSavingsAssetsRequestV3, + GetEarnSavingsProductsRequestV3, + GetEarnSavingsRecordsRequestV3, + GetEarnSavingsRedemptionResultRequestV3, + GetEarnSavingsSubscriptionRequestV3, + GetEarnSavingsSubscriptionResultRequestV3, + GetSharkfinAssetsRequestV3, + GetSharkfinProductsRequestV3, + GetSharkfinRecordsRequestV3, + GetSharkfinSubscriptionRequestV3, + GetSharkfinSubscriptionResultRequestV3, RedeemEarnEliteRequestV3, + RedeemSavingsRequestV3, + SubscribeSavingsRequestV3, + SubscribeSharkfinRequestV3, } from './types/request/v3/earn.js'; import { AddGridInvestmentRequestV3, @@ -19806,10 +20463,25 @@ import { WithdrawRecordV3, WithdrawResponseV3, } from './types/response/v3/account.js'; +import { + AgentCustomerAssetItemV3, + AgentCustomerCommissionsV3, + AgentCustomerDepositItemV3, + AgentCustomerKycResultV3, + AgentCustomerListItemV3, + AgentCustomerTradeVolumeItemV3, + AgentSubCustomerListV3, + SubAffiliateCommissionV3, + SubAffiliateInfoV3, +} from './types/response/v3/affiliate.js'; import { BrokerCommissionRecordV3, + BrokerOrderCommissionV3, + BrokerRebateInfoV3, BrokerSubDepositAddressV3, BrokerSubWithdrawalResponseV3, + BrokerTotalCommissionV3, + BrokerTradeVolumeV3, CreateBrokerSubAccountResponseV3, CreateBrokerSubApiKeyResponseV3, GetBrokerAllSubDepositWithdrawalResponseV3, @@ -19817,6 +20489,8 @@ import { GetBrokerSubApiKeyResponseV3, ModifyBrokerSubAccountResponseV3, ModifyBrokerSubApiKeyResponseV3, + ModifySubaccountEmailResponseV3, + SubaccountEmailV3, } from './types/response/v3/broker.js'; import { CfdCandlestickV3, @@ -19869,7 +20543,23 @@ import { EarnEliteSubscribeInfoV3, EarnEliteSubscribeResultV3, EarnEliteSubscribeStatusV3, + EarnSavingsAccountV3, + EarnSavingsAssetsV3, + EarnSavingsProductV3, + EarnSavingsRecordsV3, + EarnSavingsRedemptionResultV3, + EarnSavingsSubscriptionDetailV3, + EarnSavingsSubscriptionResultV3, + EarnSharkfinAccountV3, + EarnSharkfinAssetsV3, + EarnSharkfinProductsV3, + EarnSharkfinRecordsV3, + EarnSharkfinSubscriptionDetailV3, + EarnSharkfinSubscriptionResultV3, RedeemEarnEliteResultV3, + RedeemSavingsResponseV3, + SubscribeSavingsResponseV3, + SubscribeSharkfinResponseV3, } from './types/response/v3/earn.js'; import { GridBotDetailV3, @@ -20075,8 +20765,7 @@ getServerTime(): Promise< serverTime: string; serverTimeMicros: string; }> - > { - return this.get('/api/v3/market/time'); + > ⋮---- /** * Get Announcements @@ -20085,7 +20774,7 @@ getServerTime(): Promise< */ getAnnouncements( params: GetAnnouncementsRequestV3, -): Promise> + ): Promise> ⋮---- /** * @@ -20102,21 +20791,21 @@ getAnnouncements( */ getInstruments( params: GetInstrumentsRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Market Maker Fee Group - Query fee rate tiers and grouping */ getMarketFeeGroup( params: GetMarketFeeGroupRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Liquidations History - Query historical liquidation order data (last 3 days) */ getLiquidations( params: GetLiquidationsRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get RPI Symbols - Trading pairs supporting Retail Price Improvement @@ -20128,95 +20817,95 @@ getRpiSymbols(): Promise> */ getRpiOrderBook( params: GetRpiOrderBookRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Cash Dividend Records - RWA stock futures cash dividend records */ getCashDividendRecords( params: GetCashDividendRecordsRequestV3, -): Promise> + ): Promise> ⋮---- getSplitRecords( params?: GetSplitRecordsRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Spot Whale Net Flow Data */ getSpotWhaleFlow( params: GetSpotWhaleFlowRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Spot Fund Flow Data */ getSpotFundFlow( params: GetSpotFundFlowRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Spot 24H Net Capital Inflow Data */ getSpotNetFlow( params: GetSpotNetFlowRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Margin Long Short Ratio Data */ getMarginLongShort( params: GetMarginLongShortRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Margin Loan Growth Rate Data */ getMarginLoanGrowth( params: GetMarginLoanGrowthRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Isolated Margin Borrowing Ratio Data */ getMarginIsolatedBorrow( params: GetMarginIsolatedBorrowRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Futures Active Buy Sell Volume Data */ getFuturesActiveBuySell( params: GetFuturesTradingDataRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Futures Long Short Ratio Data */ getFuturesLongShort( params: GetFuturesTradingDataRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Futures Active Long Short Position Data */ getFuturesPositionLongShort( params: GetFuturesTradingDataRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Futures Active Long Short Account Data */ getFuturesAccountLongShort( params: GetFuturesTradingDataRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Market Maker Score Weight - Query score weights per symbol */ getMarketScoreWeights( params?: GetMarketScoreWeightsRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Tickers @@ -20231,14 +20920,14 @@ getTickers(params: GetTickersRequestV3): Promise> */ getOrderBook( params: GetOrderBookRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Recent Public Fills */ getFills( params: GetPublicFillsRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Proof Of Reserves @@ -20250,7 +20939,7 @@ getProofOfReserves(): Promise> */ getOpenInterest( params: GetOpenInterestRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Open Interest History @@ -20258,7 +20947,7 @@ getOpenInterest( */ getOpenInterestHistory( params: GetOpenInterestHistoryRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Coins @@ -20273,49 +20962,49 @@ getCoins(params?: GetCoinsRequestV3): Promise> */ getCandles( params: GetCandlesRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Kline/Candlestick History */ getHistoryCandles( params: GetHistoryCandlesRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Current Funding Rate */ getCurrentFundingRate( params: GetCurrentFundingRateRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Funding Rate History */ getHistoryFundingRate( params: GetHistoryFundingRateRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Risk Reserve */ getRiskReserve( params: GetRiskReserveRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Risk Reserve (Hourly) */ getRiskReserveHour( params: GetRiskReserveRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Risk Reserve All — current insurance funds */ getRiskReserveAll( params: GetRiskReserveAllRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Discount Rate @@ -20329,14 +21018,14 @@ getDiscountRate(): Promise> */ getInterestRateHistory( params: GetInterestRateHistoryRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Margin Loan */ getMarginLoans( params: GetMarginLoansRequestV3, -): Promise> + ): Promise> ⋮---- /** * Margin loan info for every coin, or one coin when coin is set. @@ -20344,28 +21033,28 @@ getMarginLoans( */ getMarginLoansAll( params?: GetMarginLoansAllRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Position Tier */ getPositionTier( params: GetPositionTierRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Open Interest Limit */ getContractsOi( params: GetContractsOiRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Index Price Components */ getIndexComponents( params: GetIndexComponentsRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Reality OrderBook @@ -20374,7 +21063,7 @@ getIndexComponents( */ getRealityOrderBook( params: GetRealityOrderBookRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Reality OrderBook Segmented @@ -20385,57 +21074,56 @@ getRealityOrderBook( */ getRealityOrderBookSegmented( params: GetRealityOrderBookSegmentedRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Reality Fills */ getRealityFills( params: GetRealityFillsRequestV3, -): Promise> + ): Promise> ⋮---- getRealityCompanyOverview( params: GetRealityCompanyOverviewRequestV3, -): Promise> + ): Promise> ⋮---- getRealityValuationIndicators( params: GetRealityValuationIndicatorsRequestV3, -): Promise> + ): Promise> ⋮---- getRealityEarningsForecast( params: GetRealityEarningsForecastRequestV3, -): Promise> + ): Promise> ⋮---- getRealitySuspensionResumptionInfo( params: GetRealitySuspensionResumptionInfoRequestV3, -): Promise> + ): Promise> ⋮---- getRealityDividends( params: GetRealityDividendsRequestV3, -): Promise>> + ): Promise>> ⋮---- getRealityShareCapitalChange( params: GetRealityShareCapitalChangeRequestV3, -): Promise> + ): Promise> ⋮---- getRealityInnerTrades( params: GetRealityInnerTradesRequestV3, -): Promise>> + ): Promise>> ⋮---- getRealityExecutiveShareholdings( params: GetRealityExecutiveShareholdingsRequestV3, ): Promise< APIResponse> - > { - return this.get('/api/v3/reality/market/executive-shareholdings', params); + > ⋮---- getRealityShareholdDetail( params: GetRealityShareholdDetailRequestV3, -): Promise>> + ): Promise>> ⋮---- getRealityStockInfo( params?: GetRealityStockInfoRequestV3, -): Promise> + ): Promise> ⋮---- getRealityMarketStates(): Promise> ⋮---- @@ -20454,8 +21142,7 @@ getRealityMarketCalendar(): Promise> */ getCopyFuturesTradingPairs(): Promise< APIResponse - > { - return this.getPrivate('/api/v3/copy/futures/trading-pairs'); + > ⋮---- /** * Get copy-trading position summary @@ -20464,8 +21151,7 @@ getCopyFuturesTradingPairs(): Promise< */ getCopyFuturesPositionSummary(): Promise< APIResponse - > { - return this.getPrivate('/api/v3/copy/futures/position-summary'); + > ⋮---- /** * Get max transferable amount and available balance for the copy-trading lead account. @@ -20473,7 +21159,7 @@ getCopyFuturesPositionSummary(): Promise< */ getCopyFuturesMaxTransferable( params: GetCopyFuturesMaxTransferableRequestV3, -): Promise> + ): Promise> ⋮---- /** * Max transferable amount of a follower copy account for one coin. @@ -20482,7 +21168,7 @@ getCopyFuturesMaxTransferable( */ getCopyFuturesCopyMaxTransferable( params: GetCopyFuturesCopyMaxTransferableRequestV3, -): Promise> + ): Promise> ⋮---- /** * Transfer funds between spot/funding and the copy-trading lead account. @@ -20490,7 +21176,7 @@ getCopyFuturesCopyMaxTransferable( */ copyFuturesTransfer( params: CopyFuturesTransferRequestV3, -): Promise> + ): Promise> ⋮---- /** * Query copy-trading lead account transfer history. @@ -20498,92 +21184,91 @@ copyFuturesTransfer( */ getCopyFuturesTransferRecords( params?: GetCopyFuturesTransferRecordRequestV3, -): Promise> + ): Promise> ⋮---- getCopyFuturesCurrentFollowers( params?: GetCopyFuturesFollowersRequestV3, -): Promise> + ): Promise> ⋮---- getCopyFuturesHistoryFollowers( params?: GetCopyFuturesFollowersRequestV3, -): Promise> + ): Promise> ⋮---- getCopyFuturesProfitSummary(): Promise< APIResponse - > { - return this.getPrivate('/api/v3/copy/futures/profit-summary'); + > ⋮---- getCopyFuturesProfitDetails( params?: GetCopyFuturesProfitDetailsRequestV3, -): Promise> + ): Promise> ⋮---- getCopyFuturesPortfolioOverview( params: GetCopyFuturesPortfolioOverviewRequestV3, -): Promise> + ): Promise> ⋮---- createCopyFutures( params: CreateCopyFuturesRequestV3, -): Promise> + ): Promise> ⋮---- modifyCopyFuturesFollowerSettings( params: ModifyCopyFuturesFollowerSettingsRequestV3, -): Promise> + ): Promise> ⋮---- unfollowCopyFutures( params: UnfollowCopyFuturesRequestV3, -): Promise> + ): Promise> ⋮---- getCopyFuturesCopySettings( params: GetCopyFuturesCopySettingsRequestV3, -): Promise> + ): Promise> ⋮---- copyFuturesFollowerTransfer( params: CopyFuturesFollowerTransferRequestV3, -): Promise> + ): Promise> ⋮---- getCopyFuturesFollowerTransferRecords( params: GetCopyFuturesFollowerTransferRecordRequestV3, -): Promise> + ): Promise> ⋮---- getCopyFuturesCurrentCopy( params: GetCopyFuturesCurrentCopyRequestV3, -): Promise> + ): Promise> ⋮---- getCopyFuturesCopyProfitDetails( params: GetCopyFuturesCopyProfitDetailsRequestV3, -): Promise> + ): Promise> ⋮---- closeCopyFuturesPositions( params: CloseCopyFuturesPositionsRequestV3, -): Promise> + ): Promise> ⋮---- closeAllCopyFuturesPositions( params: CloseAllCopyFuturesRequestV3, -): Promise> + ): Promise> ⋮---- getCopyFuturesCurrentPositions( params: GetCopyFuturesCurrentPositionsRequestV3, -): Promise> + ): Promise> ⋮---- placeCopyFuturesTpSl( params: PlaceCopyFuturesTpSlRequestV3, -): Promise> + ): Promise> ⋮---- modifyCopyFuturesTpSl( params: ModifyCopyFuturesTpSlRequestV3, -): Promise> + ): Promise> ⋮---- cancelCopyFuturesTpSl( params: CancelCopyFuturesTpSlRequestV3, -): Promise> + ): Promise> ⋮---- getCopyFuturesCurrentTpSlOrders( params: GetCopyFuturesCurrentTpSlOrdersRequestV3, -): Promise> + ): Promise> ⋮---- getCopyFuturesTpSlOrderHistory( params: GetCopyFuturesTpSlOrderHistoryRequestV3, -): Promise> + ): Promise> ⋮---- /** * @@ -20593,103 +21278,103 @@ getCopyFuturesTpSlOrderHistory( ⋮---- getStockPlusOptionQuote( params: GetStockPlusOptionQuoteRequestV3, -): Promise> + ): Promise> ⋮---- getStockPlusOptionChainInfo( params: GetStockPlusOptionChainInfoRequestV3, -): Promise> + ): Promise> ⋮---- getStockPlusOptionExpiryDate( params: GetStockPlusOptionExpiryDateRequestV3, -): Promise> + ): Promise> ⋮---- getStockPlusOptionVolume( params: GetStockPlusOptionVolumeRequestV3, -): Promise> + ): Promise> ⋮---- getStockPlusStaticInfo( params: GetStockPlusStaticInfoRequestV3, -): Promise> + ): Promise> ⋮---- getStockPlusQuote( params: GetStockPlusQuoteRequestV3, -): Promise> + ): Promise> ⋮---- getStockPlusTradeDetail( params: GetStockPlusTradeDetailRequestV3, -): Promise> + ): Promise> ⋮---- getStockPlusIntraday( params: GetStockPlusIntradayRequestV3, -): Promise> + ): Promise> ⋮---- getStockPlusHistoryCandlestick( params: GetStockPlusHistoryCandlestickRequestV3, -): Promise> + ): Promise> ⋮---- getStockPlusCandlestick( params: GetStockPlusCandlestickRequestV3, -): Promise> + ): Promise> ⋮---- getStockPlusDepth( params: GetStockPlusDepthRequestV3, -): Promise> + ): Promise> ⋮---- placeStockPlusOrder( params: PlaceStockPlusOrderRequestV3, -): Promise> + ): Promise> ⋮---- cancelStockPlusOrder( params: CancelStockPlusOrderRequestV3, -): Promise> + ): Promise> ⋮---- modifyStockPlusOrder( params: ModifyStockPlusOrderRequestV3, -): Promise> + ): Promise> ⋮---- getStockPlusTodayOrders( params?: GetStockPlusTodayOrdersRequestV3, -): Promise> + ): Promise> ⋮---- getStockPlusHistoryOrders( params?: GetStockPlusHistoryOrdersRequestV3, -): Promise> + ): Promise> ⋮---- getStockPlusOrderDetail( params: GetStockPlusOrderDetailRequestV3, -): Promise> + ): Promise> ⋮---- getStockPlusMaxPurchase( params: GetStockPlusMaxPurchaseRequestV3, -): Promise> + ): Promise> ⋮---- getStockPlusTodayExecutions( params?: GetStockPlusTodayExecutionsRequestV3, -): Promise> + ): Promise> ⋮---- getStockPlusHistoryExecutions( params?: GetStockPlusHistoryExecutionsRequestV3, -): Promise> + ): Promise> ⋮---- getStockPlusAccount( params?: GetStockPlusAccountRequestV3, -): Promise> + ): Promise> ⋮---- getStockPlusCashFlow( params: GetStockPlusCashFlowRequestV3, -): Promise> + ): Promise> ⋮---- getStockPlusStockPosition( params?: GetStockPlusStockPositionRequestV3, -): Promise> + ): Promise> ⋮---- stockPlusTransfer( params: StockPlusTransferRequestV3, -): Promise> + ): Promise> ⋮---- getStockPlusTransferRecords( params?: GetStockPlusTransferRecordsRequestV3, -): Promise> + ): Promise> ⋮---- /** * @@ -20699,37 +21384,37 @@ getStockPlusTransferRecords( ⋮---- getCfdTickers( params?: GetCfdTickersRequestV3, -): Promise> + ): Promise> ⋮---- getCfdHistoryCandlestick( params: GetCfdHistoryCandlestickRequestV3, -): Promise> + ): Promise> ⋮---- placeCfdOrder( params: PlaceCfdOrderRequestV3, -): Promise> + ): Promise> ⋮---- modifyCfdOrder( params: ModifyCfdOrderRequestV3, -): Promise> + ): Promise> ⋮---- cancelCfdOrder(params: CancelCfdOrderRequestV3): Promise> ⋮---- cancelAllCfdOrders( params?: CancelAllCfdOrdersRequestV3, -): Promise> + ): Promise> ⋮---- closeCfdPositions( params: CloseCfdPositionsRequestV3, -): Promise> + ): Promise> ⋮---- closeAllCfdPositions( params?: CloseAllCfdPositionsRequestV3, -): Promise> + ): Promise> ⋮---- getCfdUnfilledOrders( params?: GetCfdUnfilledOrdersRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get CFD Order History @@ -20738,29 +21423,29 @@ getCfdUnfilledOrders( */ getCfdOrderHistory( params: GetCfdOrderHistoryRequestV3, -): Promise> + ): Promise> ⋮---- getCfdCurrentPositions( params?: GetCfdCurrentPositionsRequestV3, -): Promise> + ): Promise> ⋮---- getCfdFundDetail(): Promise> ⋮---- cfdTransfer( params: CfdTransferRequestV3, -): Promise> + ): Promise> ⋮---- getCfdTransferRecords( params?: GetCfdTransferRecordsRequestV3, -): Promise> + ): Promise> ⋮---- getCfdFinancialRecords( params?: GetCfdFinancialRecordsRequestV3, -): Promise> + ): Promise> ⋮---- getCfdInstruments( params?: GetCfdInstrumentsRequestV3, -): Promise> + ): Promise> ⋮---- /** * @@ -20778,7 +21463,7 @@ getBalances(): Promise> */ getFundingAssets( params?: GetFundingAssetsRequestV3, -): Promise> + ): Promise> ⋮---- /** * Query account metadata (UID, inviter, parent account, channel, IP whitelist, permissions). @@ -20797,7 +21482,7 @@ getAccountSettings(): Promise> */ adjustAccountMode( params: AdjustAccountModeRequestV3, -): Promise> + ): Promise> ⋮---- /** * Delta-neutral metrics (equity ratio, thresholds, per-coin position ratios). @@ -20817,7 +21502,7 @@ setLeverage(params: SetLeverageRequestV3): Promise> */ setHoldMode(params: { holdMode: 'one_way_mode' | 'hedge_mode'; -}): Promise> + }): Promise> ⋮---- /** * Get Collateral Type - Query unified account collateral configuration @@ -20829,7 +21514,7 @@ getCollateralType(): Promise> */ setCollateralType( params: SetCollateralTypeRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Custom Collateral Coins - Platform-supported custom collateral coins @@ -20841,7 +21526,7 @@ getCustomCollateralCoins(): Promise> */ preSetLeverage( params: PreSetLeverageRequestV3, -): Promise> + ): Promise> ⋮---- /** * Set Margin - Adjust isolated margin position margin amount @@ -20853,7 +21538,7 @@ setMargin(params: SetMarginRequestV3): Promise> */ getMaxWithdrawal( params: GetMaxWithdrawalRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Financial Records @@ -20868,8 +21553,7 @@ getFinancialRecords(params: GetFinancialRecordsRequestV3): Promise< /** Undocumented but staff-confirmed: null when pagination is exhausted. */ cursor: string | null; }> - > { - return this.getPrivate('/api/v3/account/financial-records', params); + > ⋮---- /** * Undocumented but staff-confirmed: null when there are no records. @@ -20885,8 +21569,7 @@ getFundingFinancialRecords( list: FundingFinancialRecordV3[]; cursor: string; }> - > { - return this.getPrivate('/api/v3/account/funding-financial-records', params); + > ⋮---- /** * Get Repayable Coins @@ -20896,8 +21579,7 @@ getRepayableCoins(): Promise< repayableCoinList: RepayableCoinV3[]; maxSelection: string; }> - > { - return this.getPrivate('/api/v3/account/repayable-coins'); + > ⋮---- /** * Get Payment Coins @@ -20907,8 +21589,7 @@ getPaymentCoins(): Promise< paymentCoinList: PaymentCoinV3[]; maxSelection: string; }> - > { - return this.getPrivate('/api/v3/account/payment-coins'); + > ⋮---- /** * Repay @@ -20919,11 +21600,11 @@ borrow(params: BorrowRequestV3): Promise> ⋮---- getMaxBorrowable( params: GetMaxBorrowableRequestV3, -): Promise> + ): Promise> ⋮---- setRepayMode( params: SetRepayModeRequestV3, -): Promise>> + ): Promise>> ⋮---- /** * Get Convert Records @@ -20933,24 +21614,22 @@ getConvertRecords(params: GetConvertRecordsRequestV3): Promise< list: ConvertRecordV3[]; cursor: string; }> - > { - return this.getPrivate('/api/v3/account/convert-records', params); + > ⋮---- getSmallAssets( params?: GetSmallAssetsRequestV3, -): Promise> + ): Promise> ⋮---- tradeSmallAssets( params: TradeSmallAssetsRequestV3, -): Promise> + ): 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 @@ -20960,7 +21639,7 @@ getSmallAssetsHistory(params?: GetSmallAssetsHistoryRequestV3): Promise< */ setDepositAccount( params: SetDepositAccountRequestV3, -): Promise> + ): Promise> ⋮---- /** * Switch Deduct - Set BGB deduction @@ -20974,8 +21653,7 @@ getDeductInfo(): Promise< APIResponse<{ deduct: 'on' | 'off'; }> - > { - return this.getPrivate('/api/v3/account/deduct-info'); + > ⋮---- /** * Get Trading Fee Rate @@ -20985,15 +21663,14 @@ getFeeRate(params: GetFeeRateRequestV3): Promise< makerFeeRate: string; takerFeeRate: string; }> - > { - return this.getPrivate('/api/v3/account/fee-rate', params); + > ⋮---- /** * Get All Symbol Fee Rates - Query fee rates for all trading pairs under a product type */ getAllFeeRates( params: GetAllFeeRatesRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Max Transferable @@ -21004,7 +21681,7 @@ getAllFeeRates( */ getMaxTransferable( params: GetMaxTransferableRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Open Interest Limit @@ -21014,23 +21691,23 @@ getMaxTransferable( */ getOpenInterestLimit( params: GetOpenInterestLimitRequestV3, -): Promise> + ): Promise> ⋮---- getEligibleSymbols( params?: GetEligibleSymbolsRequestV3, -): Promise> + ): Promise> ⋮---- getEligibleMarginTier( params?: GetEligibleMarginTierRequestV3, -): Promise> + ): Promise> ⋮---- getEligibleLoanInfo( params?: GetEligibleLoanInfoRequestV3, -): Promise> + ): Promise> ⋮---- getEligibleDiscountRate( params?: GetEligibleDiscountRateRequestV3, -): Promise> + ): Promise> ⋮---- /** * Switch Account - Switch to classic account mode @@ -21051,8 +21728,7 @@ getUnifiedAccountSwitchStatus(): Promise< APIResponse<{ status: 'processProcessing' | 'successSuccess' | 'failFailed'; }> - > { - return this.getPrivate('/api/v3/account/switch-status'); + > ⋮---- /** * Get Tax Records @@ -21064,7 +21740,7 @@ getUnifiedAccountSwitchStatus(): Promise< */ getTaxRecords( params: GetTaxRecordsRequestV3, -): Promise> + ): Promise> ⋮---- /** * @@ -21077,32 +21753,32 @@ getTaxRecords( */ createSubAccount( params: CreateSubAccountRequestV3, -): Promise> + ): Promise> ⋮---- /** * Create Agent Sub-account */ createAgentSubAccount( params: CreateAgentSubAccountRequestV3, -): Promise> + ): Promise> ⋮---- /** * Freeze/Unfreeze Sub-account */ freezeSubAccount( params: FreezeSubAccountRequestV3, -): Promise> + ): Promise> ⋮---- deleteSubAccount( params: DeleteSubAccountRequestV3, -): Promise>> + ): Promise>> ⋮---- /** * Get Sub-account Unified Account Assets */ getSubUnifiedAssets( params?: GetSubUnifiedAssetsRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Sub-account List @@ -21113,29 +21789,28 @@ getSubAccountList(params?: GetSubAccountListRequestV3): Promise< hasNext: boolean; cursor: string; }> - > { - return this.getPrivate('/api/v3/user/sub-list', params); + > ⋮---- /** * Create Sub-account API Key */ createSubAccountApiKey( params: CreateSubAccountApiKeyRequestV3, -): Promise> + ): Promise> ⋮---- /** * Modify Sub-account API Key */ updateSubAccountApiKey( params: UpdateSubAccountApiKeyRequestV3, -): Promise> + ): Promise> ⋮---- /** * Delete Sub-account API Key */ deleteSubAccountApiKey( params: DeleteSubAccountApiKeyRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Sub-account API Keys @@ -21146,8 +21821,7 @@ getSubAccountApiKeys(params: GetSubAccountApiKeysRequestV3): Promise< hasNext: boolean; cursor: string; }> - > { - return this.getPrivate('/api/v3/user/sub-api-list', params); + > ⋮---- /** * Get RateLimit Quota @@ -21155,7 +21829,7 @@ getSubAccountApiKeys(params: GetSubAccountApiKeysRequestV3): Promise< */ getRateLimitQuota( params: GetRateLimitQuotaRequestV3, -): Promise> + ): Promise> ⋮---- /** * Set RateLimit Quota @@ -21164,7 +21838,7 @@ getRateLimitQuota( */ setRateLimitQuota( params: SetRateLimitQuotaRequestV3, -): Promise>> + ): Promise>> ⋮---- /** * Create STP Group @@ -21172,7 +21846,7 @@ setRateLimitQuota( */ createStpGroup( params: CreateStpGroupRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get STP Groups @@ -21188,7 +21862,7 @@ getStpGroups(): Promise> */ addStpGroupMembers( params: StpGroupMembersRequestV3, -): Promise> + ): Promise> ⋮---- /** * Remove STP Group Members @@ -21198,7 +21872,7 @@ addStpGroupMembers( */ removeStpGroupMembers( params: StpGroupMembersRequestV3, -): Promise> + ): Promise> ⋮---- /** * @@ -21211,14 +21885,14 @@ removeStpGroupMembers( */ getTransferableCoins( params: GetTransferableCoinsRequestV3, -): Promise> + ): Promise> ⋮---- /** * Transfer */ submitTransfer( params: TransferRequestV3, -): Promise> + ): Promise> ⋮---- /** * Main-Sub Account Transfer @@ -21228,8 +21902,7 @@ subAccountTransfer(params: SubAccountTransferRequestV3): Promise< transferId: string; clientOid: string; }> - > { - return this.postPrivate('/api/v3/account/sub-transfer', params); + > ⋮---- /** * Get Main-Sub Transfer Records @@ -21239,8 +21912,7 @@ getSubTransferRecords(params?: GetSubTransferRecordsRequestV3): Promise< items: SubTransferRecordV3[]; cursor: string; }> - > { - return this.getPrivate('/api/v3/account/sub-transfer-record', params); + > ⋮---- /** * Sub-Main Account Transfer @@ -21250,8 +21922,7 @@ subMasterTransfer(params: SubMasterTransferRequestV3): Promise< transferId: string; clientOid: string; }> - > { - return this.postPrivate('/api/v3/account/sub-master-transfer', params); + > ⋮---- /** * @@ -21264,28 +21935,28 @@ subMasterTransfer(params: SubMasterTransferRequestV3): Promise< */ getDepositAddress( params: GetDepositAddressRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Sub Deposit Address */ getSubDepositAddress( params: GetSubDepositAddressRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Deposit Records */ getDepositRecords( params: GetDepositRecordsRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Sub Deposit Records */ getSubDepositRecords( params: GetSubDepositRecordsRequestV3, -): Promise> + ): Promise> ⋮---- /** * @@ -21298,28 +21969,28 @@ getSubDepositRecords( */ submitWithdraw( params: WithdrawRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Withdraw Records */ getWithdrawRecords( params: GetWithdrawRecordsRequestV3, -): Promise> + ): Promise> ⋮---- /** * Query the withdrawal address book. Rate limit: 1/sec/UID. */ getWithdrawAddressBook( params?: GetWithdrawAddressBookRequestV3, -): Promise> + ): Promise> ⋮---- /** * Cancel a withdrawal still in the cooling-off period. Rate limit: 1/sec/UID. */ cancelWithdrawal( params: CancelWithdrawalRequestV3, -): Promise> + ): Promise> ⋮---- /** * @@ -21335,28 +22006,28 @@ cancelWithdrawal( */ submitNewOrder( params: PlaceOrderRequestV3, -): Promise> + ): Promise> ⋮---- /** * Modify Order */ modifyOrder( params: ModifyOrderRequestV3, -): Promise> + ): Promise> ⋮---- /** * Place Reality Order - Limit or market order for Reality stock trading pairs */ placeRealityOrder( params: PlaceRealityOrderRequestV3, -): Promise> + ): Promise> ⋮---- /** * Cancel Reality Order - Cancel an unfilled or partially filled Reality stock order */ cancelRealityOrder( params: CancelRealityOrderRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Loan Data - Query current loan data for the unified trading account @@ -21368,49 +22039,49 @@ getLoanData(): Promise> */ cancelOrder( params: CancelOrderRequestV3, -): Promise> + ): Promise> ⋮---- /** * Batch Order */ placeBatchOrders( params: PlaceBatchOrdersRequestV3[], -): Promise> + ): Promise> ⋮---- /** * Batch Modify Orders */ batchModifyOrders( params: BatchModifyOrderRequestV3[], -): Promise> + ): Promise> ⋮---- /** * Batch Cancel */ cancelBatchOrders( params: CancelBatchOrdersRequestV3[], -): Promise> + ): Promise> ⋮---- /** * Cancel All Orders */ cancelAllOrders( params: CancelAllOrdersRequestV3, -): Promise> + ): Promise> ⋮---- /** * Close All Positions */ closeAllPositions( params: CloseAllPositionsRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Order Details */ getOrderInfo( params: GetOrderInfoRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Open Orders @@ -21420,8 +22091,7 @@ getUnfilledOrders(params?: GetUnfilledOrdersRequestV3): Promise< list: UnfilledOrderV3[]; cursor: string; }> - > { - return this.getPrivate('/api/v3/trade/unfilled-orders', params); + > ⋮---- /** * Get Order History @@ -21431,15 +22101,14 @@ getHistoryOrders(params: GetHistoryOrdersRequestV3): Promise< list: HistoryOrderV3[]; cursor: string; }> - > { - return this.getPrivate('/api/v3/trade/history-orders', params); + > ⋮---- /** * Move Positions - Transfer positions between master and sub-accounts */ movePositions( params: MovePositionsRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Move Position History @@ -21449,8 +22118,7 @@ getMovePositionHistory(params: GetMovePositionHistoryRequestV3): Promise< list: MovePositionHistoryV3[]; cursor: string; }> - > { - return this.getPrivate('/api/v3/account/move-position-history', params); + > ⋮---- /** * Get Fill History @@ -21460,8 +22128,7 @@ getTradeFills(params?: GetFillsRequestV3): Promise< list: FillV3[]; cursor: string; }> - > { - return this.getPrivate('/api/v3/trade/fills', params); + > ⋮---- /** * Get Position Info @@ -21474,8 +22141,7 @@ getCurrentPosition(params: GetCurrentPositionRequestV3): Promise< */ list: CurrentPositionV3[] | null; }> - > { - return this.getPrivate('/api/v3/position/current-position', params); + > ⋮---- /** * Undocumented but staff-confirmed: null when there are no matching positions. @@ -21490,8 +22156,7 @@ getPositionHistory(params: GetPositionHistoryRequestV3): Promise< list: PositionHistoryV3[]; cursor: string; }> - > { - return this.getPrivate('/api/v3/position/history-position', params); + > ⋮---- /** * Get Max Open Available @@ -21500,7 +22165,7 @@ getPositionHistory(params: GetPositionHistoryRequestV3): Promise< */ getMaxOpenAvailable( params: GetMaxOpenAvailableRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Position ADL Rank - Get position auto-deleveraging ranking @@ -21512,7 +22177,7 @@ getPositionAdlRank(): Promise> */ countdownCancelAll( params: CountdownCancelAllRequestV3, -): Promise> + ): Promise> ⋮---- /** * @@ -21525,14 +22190,14 @@ countdownCancelAll( */ getLoanTransfered( params: GetTransferedRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Trade Symbols */ getLoanSymbols( params: GetSymbolsRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Risk Unit @@ -21541,36 +22206,35 @@ getLoanRiskUnit(): Promise< APIResponse<{ riskUnitId: string[]; }> - > { - return this.getPrivate('/api/v3/ins-loan/risk-unit'); + > ⋮---- /** * Get Repayment Orders */ getLoanRepaidHistory( params?: GetRepaidHistoryRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Product Info */ getLoanProductInfo( params: GetProductInfosRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Loan Orders */ getLoanOrder( params?: GetLoanOrderRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get LTV */ getLoanLTVConvert( params?: GetLTVConvertRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Margin Coin Info @@ -21580,15 +22244,14 @@ getLoanMarginCoinInfo(params: GetEnsureCoinsRequestV3): Promise< productId: string; coinInfo: CoinInfoV3[]; }> - > { - return this.getPrivate('/api/v3/ins-loan/ensure-coins-convert', params); + > ⋮---- /** * Bind/Unbind UID to Risk Unit */ bindLoanUid( params: BindUidRequestV3, -): Promise> + ): Promise> ⋮---- /** * @@ -21601,63 +22264,63 @@ bindLoanUid( */ getLoanCoins( params?: GetLoanCoinsRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Loan Interest - Query estimated interest and borrowable amount */ getLoanInterest( params: GetLoanInterestRequestV3, -): Promise> + ): Promise> ⋮---- /** * Borrow - Borrow coins */ loanBorrow( params: LoanBorrowRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Borrow Ongoing - Query current borrowings */ getLoanBorrowOngoing( params?: GetLoanBorrowOngoingRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Borrow History - Query borrowing history */ getLoanBorrowHistory( params: GetLoanBorrowHistoryRequestV3, -): Promise> + ): Promise> ⋮---- /** * Repay - Repay coins */ loanRepay( params: LoanRepayRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Repay History - Query repayment history */ getLoanRepayHistory( params: GetLoanRepayHistoryRequestV3, -): Promise> + ): Promise> ⋮---- /** * Revise Pledge - Adjust collateral ratio */ loanRevisePledge( params: LoanRevisePledgeRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Pledge Rate History - Query collateral ratio history */ getLoanPledgeRateHistory( params: GetLoanPledgeRateHistoryRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Loan Debts - Query assets and liabilities @@ -21669,7 +22332,7 @@ getLoanDebts(): Promise> */ getLoanReduces( params: GetLoanReducesRequestV3, -): Promise> + ): Promise> ⋮---- /** * @@ -21682,28 +22345,28 @@ getLoanReduces( */ submitStrategyOrder( params: PlaceStrategyOrderRequestV3, -): Promise> + ): Promise> ⋮---- /** * Modify Strategy Order */ modifyStrategyOrder( params: ModifyStrategyOrderRequestV3, -): Promise> + ): Promise> ⋮---- /** * Cancel Strategy Order */ cancelStrategyOrder( params: CancelStrategyOrderRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Unfilled Strategy Orders */ getUnfilledStrategyOrders( params: GetUnfilledStrategyOrdersRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Strategy Order History @@ -21714,8 +22377,7 @@ getHistoryStrategyOrders(params: GetHistoryStrategyOrdersRequestV3): Promise< /** Observed as a number though the docs say string. */ cursor?: string | number; }> - > { - return this.getPrivate('/api/v3/trade/history-strategy-orders', params); + > ⋮---- /** Observed as a number though the docs say string. */ ⋮---- @@ -21724,8 +22386,7 @@ getStrategySubOrders(params: GetStrategySubOrdersRequestV3): Promise< list: StrategySubOrderV3[]; cursor?: string; }> - > { - return this.getPrivate('/api/v3/trade/strategy-sub-orders', params); + > ⋮---- /** * @@ -21735,59 +22396,59 @@ getStrategySubOrders(params: GetStrategySubOrdersRequestV3): Promise< ⋮---- validateGridBot( params: ValidateGridBotRequestV3, -): Promise> + ): Promise> ⋮---- createGridBot( params: CreateGridBotRequestV3, -): Promise> + ): Promise> ⋮---- modifyGridBot( params: ModifyGridBotRequestV3, -): Promise> + ): Promise> ⋮---- modifyGridInterval( params: ModifyGridIntervalRequestV3, -): Promise> + ): Promise> ⋮---- addGridInvestment( params: AddGridInvestmentRequestV3, -): Promise> + ): Promise> ⋮---- closeGridBot( params: CloseGridBotRequestV3, -): Promise> + ): Promise> ⋮---- getGridBotDetail( params: GetGridBotDetailRequestV3, -): Promise> + ): Promise> ⋮---- getGridBotOrderDetails( params: GetGridBotOrderDetailsRequestV3, -): Promise> + ): Promise> ⋮---- validateNeutralGridBot( params: ValidateNeutralGridBotRequestV3, -): Promise> + ): Promise> ⋮---- createNeutralGridBot( params: CreateNeutralGridBotRequestV3, -): Promise> + ): Promise> ⋮---- modifyNeutralGridBot( params: ModifyNeutralGridBotRequestV3, -): Promise> + ): Promise> ⋮---- modifyNeutralGridInterval( params: ModifyNeutralGridIntervalRequestV3, -): Promise> + ): Promise> ⋮---- getNeutralGridBotDetail( params: GetNeutralGridBotDetailRequestV3, -): Promise> + ): Promise> ⋮---- getNeutralGridBotOrderDetails( params: GetNeutralGridBotOrderDetailsRequestV3, -): Promise> + ): Promise> ⋮---- /** * @@ -21803,7 +22464,7 @@ getNeutralGridBotOrderDetails( */ createBrokerSubAccount( params: CreateBrokerSubAccountRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Broker Sub-Account List @@ -21813,7 +22474,7 @@ createBrokerSubAccount( */ getBrokerSubAccountList( params?: GetBrokerSubAccountListRequestV3, -): Promise> + ): Promise> ⋮---- /** * Modify Broker Sub-Account @@ -21823,7 +22484,7 @@ getBrokerSubAccountList( */ modifyBrokerSubAccount( params: ModifyBrokerSubAccountRequestV3, -): Promise> + ): Promise> ⋮---- /** * Broker Subaccount Withdrawal @@ -21836,7 +22497,7 @@ modifyBrokerSubAccount( */ brokerSubWithdrawal( params: BrokerSubWithdrawalRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Broker Subaccount Deposit Address @@ -21846,7 +22507,7 @@ brokerSubWithdrawal( */ getBrokerSubDepositAddress( params: GetBrokerSubDepositAddressRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get All Broker Subaccount Deposit Withdrawal @@ -21856,7 +22517,7 @@ getBrokerSubDepositAddress( */ getBrokerAllSubDepositWithdrawal( params?: GetBrokerAllSubDepositWithdrawalRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Broker Commission @@ -21866,7 +22527,7 @@ getBrokerAllSubDepositWithdrawal( */ getBrokerCommission( params?: GetBrokerCommissionRequestV3, -): Promise> + ): Promise> ⋮---- /** * Create Broker Sub-Account API Key @@ -21876,7 +22537,7 @@ getBrokerCommission( */ createBrokerSubApiKey( params: CreateBrokerSubApiKeyRequestV3, -): Promise> + ): Promise> ⋮---- /** * Modify Broker Sub-Account API Key @@ -21886,7 +22547,7 @@ createBrokerSubApiKey( */ modifyBrokerSubApiKey( params: ModifyBrokerSubApiKeyRequestV3, -): Promise> + ): Promise> ⋮---- /** * Delete Broker Subaccount Apikey @@ -21900,7 +22561,7 @@ modifyBrokerSubApiKey( */ deleteBrokerSubApiKey( params: DeleteBrokerSubApiKeyRequestV3, -): Promise> + ): Promise> ⋮---- /** * Get Broker Sub-Account API Key @@ -21910,7 +22571,127 @@ deleteBrokerSubApiKey( */ getBrokerSubApiKey( params: GetBrokerSubApiKeyRequestV3, -): Promise> + ): Promise> +⋮---- +/** + * + * =====Affiliate===== + * + */ +⋮---- +/** + * Get Agent Customer List. Rate limit: 10/sec/UID. + * Without startTime/endTime, returns all registered customers (no time restriction). + */ +getAgentCustomerList( + params?: AgentCustomerListRequestV3, + ): Promise> +⋮---- +/** + * Get Agent Customer Asset. Rate limit: 10/sec/UID. + */ +getAgentCustomerAssets( + params?: AgentCustomerAssetRequestV3, + ): Promise> +⋮---- +/** + * Get Agent Customer Trade Volume. Rate limit: 10/sec/UID. + */ +getAgentCustomerTradeVolume( + params?: AgentCustomerTradeVolumeRequestV3, + ): Promise> +⋮---- +/** + * Get Agent Customer Deposit. Rate limit: 10/sec/UID. + */ +getAgentCustomerDeposits( + params?: AgentCustomerDepositRequestV3, + ): Promise> +⋮---- +/** + * Get Agent Customer Kyc Result. Rate limit: 10/sec/UID. + */ +getAgentCustomerKycResult( + params?: GetAgentCustomerKycResultRequestV3, + ): Promise> +⋮---- +/** + * Get Agent Customer Commission. Rate limit: 10/sec/UID. + */ +getAgentCustomerCommissions( + params?: GetAgentCustomerCommissionsRequestV3, + ): Promise> +⋮---- +/** + * Get Agent Sub Customer List. Rate limit: 10/sec/UID. + * Without startTime/endTime, returns all registered customers (no time restriction). + */ +getAgentSubCustomerList( + params?: GetAgentSubCustomerListRequestV3, + ): Promise> +⋮---- +/** + * Get Sub Affiliate Info. Rate limit: 10/sec/UID. + */ +getSubAffiliateInfo( + params?: GetSubAffiliateInfoRequestV3, + ): Promise> +⋮---- +/** + * Get Sub Affiliate Commission. Rate limit: 10/sec/UID. + */ +getSubAffiliateCommission( + params?: GetSubAffiliateCommissionRequestV3, + ): Promise> +⋮---- +/** + * + * =====Broker | Email and Commissions===== + * + */ +⋮---- +/** + * Modify Subaccount Email. Rate limit: 10/sec/UID. + */ +modifySubaccountEmail( + params: ModifySubaccountEmailRequestV3, + ): Promise> +⋮---- +/** + * Get Subaccount Email. Rate limit: 10/sec/UID. + */ +getSubaccountEmail( + params: GetSubaccountEmailRequestV3, + ): Promise> +⋮---- +/** + * Get Broker Trade Volume. Rate limit: 5/sec/UID. + * Contact your BD or RM to apply for access permissions. + */ +getBrokerTradeVolume( + params?: GetBrokerTradeVolumeRequestV3, + ): Promise> +⋮---- +/** + * Get Total Commission. Rate limit: 20/sec/UID. + */ +getBrokerTotalCommission( + params?: GetBrokerTotalCommissionRequestV3, + ): Promise> +⋮---- +/** + * Get Order Commission. Rate limit: 20/sec/UID. + */ +getBrokerOrderCommission( + params?: GetBrokerOrderCommissionRequestV3, + ): Promise> +⋮---- +/** + * Get Rebate Info. Rate limit: 20/sec/UID. + */ +getBrokerRebateInfo( + params: GetBrokerRebateInfoRequestV3, + ): Promise> ⋮---- /** * @@ -21920,23 +22701,23 @@ getBrokerSubApiKey( ⋮---- getP2pAdList( params: GetP2pAdListRequestV3, -): Promise> + ): Promise> ⋮---- getP2pExchangeRate( params: GetP2pExchangeRateRequestV3, -): Promise> + ): Promise> ⋮---- simulateP2pFee( params: P2pFeeSimulateRequestV3, -): Promise> + ): Promise> ⋮---- getP2pAdLimit( params: GetP2pAdLimitRequestV3, -): Promise> + ): Promise> ⋮---- createP2pAd( params: CreateP2pAdRequestV3, -): Promise> + ): Promise> ⋮---- updateP2pAd(params: UpdateP2pAdRequestV3): Promise> ⋮---- @@ -21944,31 +22725,31 @@ operateP2pAd(params: OperateP2pAdRequestV3): Promise> ⋮---- getP2pAdInfo( params: GetP2pAdInfoRequestV3, -): Promise> + ): Promise> ⋮---- getP2pMyAds( params?: GetP2pMyAdsRequestV3, -): Promise>> + ): Promise>> ⋮---- getP2pPendingOrders( params?: GetP2pPendingOrdersRequestV3, -): Promise>> + ): Promise>> ⋮---- getP2pAllOrders( params?: GetP2pAllOrdersRequestV3, -): Promise>> + ): Promise>> ⋮---- getP2pOrderInfo( params: GetP2pOrderInfoRequestV3, -): Promise> + ): Promise> ⋮---- confirmP2pOrderPayment( params: P2pOrderActionRequestV3, -): Promise> + ): Promise> ⋮---- releaseP2pOrderAsset( params: P2pOrderActionRequestV3, -): Promise> + ): Promise> ⋮---- getP2pUserInfo(): Promise> ⋮---- @@ -21978,7 +22759,127 @@ getP2pPayMethods(): Promise> ⋮---- getP2pBalance( params: GetP2pBalanceRequestV3, -): Promise> + ): Promise> +⋮---- +/** + * + * =====Earn | Savings (UTA)===== + * + */ +⋮---- +/** + * Get Savings Product List. Rate limit: 10/sec/UID. + */ +getEarnSavingsProducts( + params?: GetEarnSavingsProductsRequestV3, + ): Promise> +⋮---- +/** + * Savings Account. Rate limit: 10/sec/UID. + */ +getEarnSavingsAccount(): Promise> +⋮---- +/** + * Savings Assets. Rate limit: 10/sec/UID. + */ +getEarnSavingsAssets( + params: GetEarnSavingsAssetsRequestV3, + ): Promise> +⋮---- +/** + * Savings Records. Rate limit: 10/sec/UID. + */ +getEarnSavingsRecords( + params: GetEarnSavingsRecordsRequestV3, + ): Promise> +⋮---- +/** + * Savings Subscription Detail. Rate limit: 10/sec/UID. + */ +getEarnSavingsSubscription( + params: GetEarnSavingsSubscriptionRequestV3, + ): Promise> +⋮---- +/** + * Subscribe Savings. Rate limit: 10/sec/UID. + */ +earnSubscribeSavings( + params: SubscribeSavingsRequestV3, + ): Promise> +⋮---- +/** + * Savings Subscription Result. Rate limit: 10/sec/UID. + */ +getEarnSavingsSubscriptionResult( + params: GetEarnSavingsSubscriptionResultRequestV3, + ): Promise> +⋮---- +/** + * Redeem Savings. Rate limit: 10/sec/UID. + */ +earnRedeemSavings( + params: RedeemSavingsRequestV3, + ): Promise> +⋮---- +/** + * Savings Redemption Results. Rate limit: 10/sec/UID. + */ +getEarnSavingsRedemptionResult( + params: GetEarnSavingsRedemptionResultRequestV3, + ): Promise> +⋮---- +/** + * + * =====Earn | SharkFin (UTA)===== + * + */ +⋮---- +/** + * Get Sharkfin Products. Rate limit: 10/sec/UID. + */ +getSharkfinProducts( + params: GetSharkfinProductsRequestV3, + ): Promise> +⋮---- +/** + * SharkFin Account. Rate limit: 10/sec/UID. + */ +getSharkfinAccount(): Promise> +⋮---- +/** + * SharkFin Assets. Rate limit: 10/sec/UID. + */ +getSharkfinAssets( + params: GetSharkfinAssetsRequestV3, + ): Promise> +⋮---- +/** + * SharkFin Records. Rate limit: 10/sec/UID. + */ +getSharkfinRecords( + params: GetSharkfinRecordsRequestV3, + ): Promise> +⋮---- +/** + * SharkFin Subscription Detail. Rate limit: 10/sec/UID. + */ +getSharkfinSubscription( + params: GetSharkfinSubscriptionRequestV3, + ): Promise> +⋮---- +/** + * Subscribe SharkFin. Rate limit: 10/sec/UID. + */ +subscribeSharkfin( + params: SubscribeSharkfinRequestV3, + ): Promise> +⋮---- +/** + * SharkFin Subscription Result. Rate limit: 5/sec/UID. + */ +getSharkfinSubscriptionResult( + params: GetSharkfinSubscriptionResultRequestV3, + ): Promise> ⋮---- /** * @@ -21992,27 +22893,27 @@ getEarnEliteAssets(): Promise> ⋮---- getEarnEliteRecords( params: GetEarnEliteRecordsRequestV3, -): Promise> + ): Promise> ⋮---- getEarnEliteSubscribeInfo( params: GetEarnEliteSubscribeInfoRequestV3, -): Promise> + ): Promise> ⋮---- subscribeEarnElite( params: EarnEliteSubscribeRequestV3, -): Promise> + ): Promise> ⋮---- getEarnEliteSubscribeResult( params: GetEarnEliteSubscribeResultRequestV3, -): Promise> + ): Promise> ⋮---- getEarnEliteRedeemInfo( params: GetEarnEliteRedeemInfoRequestV3, -): Promise> + ): Promise> ⋮---- redeemEarnElite( params: RedeemEarnEliteRequestV3, -): Promise> + ): Promise> ⋮---- /** * @@ -22027,22 +22928,21 @@ redeemEarnElite( */ getEarnCashPlusSubscribeInfo(): Promise< APIResponse - > { - return this.getPrivate('/api/v3/earn/cashplus/subscribe-info'); + > ⋮---- /** * Subscribe to Cash+. Rate limit: 1/sec/UID. */ subscribeEarnCashPlus( params: EarnCashPlusSubscribeRequestV3, -): Promise> + ): Promise> ⋮---- /** * Result of a Cash+ subscription order. Rate limit: 10/sec/UID. */ getEarnCashPlusSubscribeResult( params: GetEarnCashPlusSubscribeResultRequestV3, -): Promise> + ): Promise> ⋮---- /** * Cash+ redemption prerequisites: credited coins and the redeemable position. @@ -22055,14 +22955,14 @@ getEarnCashPlusRedeemInfo(): Promise> */ redeemEarnCashPlus( params: EarnCashPlusRedeemRequestV3, -): Promise> + ): Promise> ⋮---- /** * Result of a Cash+ redemption order. Rate limit: 10/sec/UID. */ getEarnCashPlusRedeemResult( params: GetEarnCashPlusRedeemResultRequestV3, -): Promise> + ): Promise> ⋮---- /** * Cash+ holding, cumulative profit, and APR. Rate limit: 10/sec/UID. @@ -22074,7 +22974,7 @@ getEarnCashPlusPositions(): Promise> */ getEarnCashPlusHistoryOrders( params?: GetEarnCashPlusHistoryOrdersRequestV3, -): Promise> + ): Promise> ================ File: package.json From 56f7c062d4f16a3bb48fe263e927238f22846bc1 Mon Sep 17 00:00:00 2001 From: JJ-Cro sync bot Date: Mon, 9 Nov 2026 12:05:32 +0100 Subject: [PATCH 9/9] chore: regenerate endpoint docs and examples --- docs/endpointFunctionList.md | 10 +- llms.txt | 22970 ++++++++++++++++----------------- 2 files changed, 11478 insertions(+), 11502 deletions(-) diff --git a/docs/endpointFunctionList.md b/docs/endpointFunctionList.md index 65391a99..3b958a5d 100644 --- a/docs/endpointFunctionList.md +++ b/docs/endpointFunctionList.md @@ -703,8 +703,8 @@ 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#L85) | | WS | `place-order` | -| [placeBatchOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/websocket-api-client.ts#L106) | | WS | `batch-place` | -| [cancelOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/websocket-api-client.ts#L130) | | WS | `cancel-order` | -| [cancelBatchOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/websocket-api-client.ts#L149) | | WS | `batch-cancel` | -| [updateOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/websocket-api-client.ts#L161) | | WS | `modify-order` | -| [batchUpdateOrders()](https://github.com/sieblyio/bitget-api/blob/master/src/websocket-api-client.ts#L173) | | WS | `batch-modify` | \ No newline at end of file +| [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` | +| [updateOrder()](https://github.com/sieblyio/bitget-api/blob/master/src/websocket-api-client.ts#L159) | | WS | `modify-order` | +| [batchUpdateOrders()](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/llms.txt b/llms.txt index 4709b47c..e024904e 100644 --- a/llms.txt +++ b/llms.txt @@ -171,6 +171,75 @@ tsconfig.linting.json Files ================================================================ +================ +File: examples/auth/fasterHmacSign.ts +================ +import { createHmac } from 'crypto'; +⋮---- +import { + DefaultLogger, + RestClientV3, + WebsocketClientV3, +} from '../../src/index.js'; +⋮---- +// or +// import { createHmac } from 'crypto'; +// import { DefaultLogger, RestClientV3, WebsocketClientV3 } from 'bitget-api'; +⋮---- +/** + * Injecting a custom signMessage function. + * + * As of version 3.0.0 of the bitget-api Node.js/TypeScript/JavaScript + * SDK for Bitget, the SDK uses the Web Crypto API for signing requests. + * While it is compatible with Node and Browser environments, it is + * slightly slower than using Node's native crypto module (only + * available in backend Node environments). + * + * For latency sensitive users, you can inject the previous node crypto sign + * method (or your own even faster implementation), if this change affects you. + * + * This example demonstrates how to inject a custom sign function, to achieve + * the same peformance as seen before the Web Crypto API was introduced. + * + * For context on standard usage, the "signMessage" function is used: + * - During every single API call + * - After opening a new private WebSocket connection + */ +⋮---- +/** + * Set this to true to enable demo trading: + */ +⋮---- +/** + * Overkill in almost every case, but if you need any optimisation available, + * you can inject a faster sign mechanism such as node's native createHmac: + */ +⋮---- +// Optional, uncomment the "trace" override to log a lot more info about what the WS client is doing +⋮---- +// trace: (...params) => console.log('trace', ...params), +⋮---- +/** + * Set this to true to enable demo trading for the private account data WS + * Topics: order,execution,position,wallet,greeks + */ +⋮---- +/** + * Overkill in almost every case, but if you need any optimisation available, + * you can inject a faster sign mechanism such as node's native createHmac: + */ +⋮---- +function setWsClientEventListeners( + websocketClient: WebsocketClientV3, + accountRef: string, +): Promise +⋮---- +// console.log('raw message received ', JSON.stringify(data, null, 2)); +⋮---- +// Simple promise to ensure we're subscribed before trying anything else +⋮---- +// Start trading + ================ File: examples/auth/rest-private-rsa.md ================ @@ -284,6 +353,131 @@ const clientV3 = new RestClientV3({ For a complete example, refer to the [rest-private-rsa.ts](./rest-private-rsa.ts) file on GitHub. +================ +File: examples/auth/rest-private-rsa.ts +================ +import { RestClientV2, RestClientV3 } from '../../src/index.js'; +⋮---- +// Import frmo NPM: +// import { RestClientV2, RestClientV3 } from 'bitget-api'; +// or if you prefer require: +// const { RestClientV2, RestClientV3 } = require('bitget-api'); +⋮---- +// Received after creating a new API key with a self-generated RSA public key on Bitget +⋮---- +// The self-generated RSA private key, this is never directly given to Bitget, but used to generate a signature +// Note: this MUST include the "BEGIN PRIVATE KEY" header so that the SDK understands this is RSA auth +⋮---- +// This is set by you when registering your RSA API key in Bitget's website. +⋮---- +// const wsClient = new WebsocketClientV2({ +// apiKey: API_KEY, +// apiSecret: rsaPrivateKey, +// apiPass: API_PASS, +// }); + +================ +File: examples/V2 - Classic/Rest/rest-private-futures.ts +================ +import { RestClientV2 } from '../../../src/index.js'; +⋮---- +// or +// import { RestClientV2 } from 'bitget-api'; +⋮---- +// read from environmental variables +⋮---- +// If running from CLI in unix, you can pass env vars as such: +// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/rest-private-futures.ts +⋮---- +// note the single quotes, preventing special characters such as $ from being incorrectly passed +⋮---- +// apiKey: 'apiKeyHere', +// apiSecret: 'apiSecretHere', +// apiPass: 'apiPassHere', +⋮---- +/** This is a simple script wrapped in a immediately invoked function expression, designed to check for any available BTC balance and immediately sell the full amount for USDT */ +⋮---- +startTime: fromTime.getTime() + '', // should be sent as a string +endTime: now.getTime() + '', // should be sent as a string + +================ +File: examples/V2 - Classic/Rest/rest-private-spot.ts +================ +import { RestClientV2 } from '../../../src/index.js'; +⋮---- +// or +// import { RestClientV2 } from 'bitget-api'; +⋮---- +// read from environmental variables +⋮---- +// If running from CLI in unix, you can pass env vars as such: +// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/rest-private-spot.ts +⋮---- +// note the single quotes, preventing special characters such as $ from being incorrectly passed +⋮---- +// apiKey: 'apiKeyHere', +// apiSecret: 'apiSecretHere', +// apiPass: 'apiPassHere', +⋮---- +/** This is a simple script wrapped in a immediately invoked function expression, designed to check for any available BTC balance and immediately sell the full amount for USDT */ + +================ +File: examples/V2 - Classic/Rest/rest-public-futures.ts +================ +import { RestClientV2 } from '../../../src/index.js'; +⋮---- +// or +// import { RestClientV2 } from 'bitget-api'; +⋮---- +// Fetch the last 1000 1min candles for a symbol +⋮---- +const msPerCandle = 60 * 1000; // 60 seconds x 1000 + +================ +File: examples/V2 - Classic/Rest/rest-public-spot.ts +================ +import { RestClientV2 } from '../../../src/index.js'; +⋮---- +// or +// import { RestClientV2 } from 'bitget-api'; + +================ +File: examples/V3 - UTA/Rest/rest-private.ts +================ +import { RestClientV3 } from '../../../src/index.js'; +⋮---- +// or +// import { RestClientV3 } from 'bitget-api'; +⋮---- +// read from environmental variables +⋮---- +// If running from CLI in unix, you can pass env vars as such: +// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/V3/rest-private-futures.ts +⋮---- +// note the single quotes, preventing special characters such as $ from being incorrectly passed +⋮---- +// apiKey: 'apiKeyHere', +// apiSecret: 'apiSecretHere', +// apiPass: 'apiPassHere', +⋮---- +/** This is a simple script wrapped in a immediately invoked function expression, designed to check account assets for futures trading */ + +================ +File: examples/V3 - UTA/Rest/rest-public-UTA-futures.ts +================ +import { RestClientV3 } from '../../../src/index.js'; +⋮---- +// or +// import { RestClientV3 } from 'bitget-api'; + +================ +File: examples/V3 - UTA/Rest/rest-public-UTA-spot.ts +================ +import { RestClientV3 } from '../../../src/index.js'; +⋮---- +// or +// import { RestClientV3 } from 'bitget-api'; + ================ File: examples/README.md ================ @@ -2173,40 +2367,21 @@ File: tsconfig.linting.json } ================ -File: examples/auth/rest-private-rsa.ts -================ -import { RestClientV2, RestClientV3 } from '../../src/index.js'; -⋮---- -// Import frmo NPM: -// import { RestClientV2, RestClientV3 } from 'bitget-api'; -// or if you prefer require: -// const { RestClientV2, RestClientV3 } = require('bitget-api'); -⋮---- -// Received after creating a new API key with a self-generated RSA public key on Bitget -⋮---- -// The self-generated RSA private key, this is never directly given to Bitget, but used to generate a signature -// Note: this MUST include the "BEGIN PRIVATE KEY" header so that the SDK understands this is RSA auth -⋮---- -// This is set by you when registering your RSA API key in Bitget's website. -⋮---- -// const wsClient = new WebsocketClientV2({ -// apiKey: API_KEY, -// apiSecret: rsaPrivateKey, -// apiPass: API_PASS, -// }); - -================ -File: examples/V2 - Classic/Rest/rest-private-futures.ts +File: examples/V2 - Classic/Rest/rest-trade-futures.ts ================ -import { RestClientV2 } from '../../../src/index.js'; +import { + FuturesPlaceOrderRequestV2, + RestClientV2, + WebsocketClientV2, +} from '../../../src/index.js'; ⋮---- // or -// import { RestClientV2 } from 'bitget-api'; +// import { FuturesPlaceOrderRequestV2, RestClientV2, WebsocketClientV2 } from '../src'; ⋮---- // read from environmental variables ⋮---- // If running from CLI in unix, you can pass env vars as such: -// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/rest-private-futures.ts +// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/rest-trade-futures.ts ⋮---- // note the single quotes, preventing special characters such as $ from being incorrectly passed ⋮---- @@ -2214,64 +2389,54 @@ import { RestClientV2 } from '../../../src/index.js'; // apiSecret: 'apiSecretHere', // apiPass: 'apiPassHere', ⋮---- -/** This is a simple script wrapped in a immediately invoked function expression, designed to check for any available BTC balance and immediately sell the full amount for USDT */ +function logWSEvent(type: string, data: any) ⋮---- -startTime: fromTime.getTime() + '', // should be sent as a string -endTime: now.getTime() + '', // should be sent as a string - -================ -File: examples/V2 - Classic/Rest/rest-private-spot.ts -================ -import { RestClientV2 } from '../../../src/index.js'; +// simple sleep function +function promiseSleep(milliseconds: number) ⋮---- -// or -// import { RestClientV2 } from 'bitget-api'; +/** + * This is a simple script wrapped in a immediately invoked function expression (to execute the below workflow immediately). + * + * It is designed to: + * - open a private websocket channel to log account events + * - check for any available USDT balance in the futures account + * - immediately open a minimum sized long position on BTCUSDT + * - check active positions + * - immediately send closing orders for any active futures positions + * - check positions again + * + */ ⋮---- -// read from environmental variables +// Add event listeners to log websocket events on account ⋮---- -// If running from CLI in unix, you can pass env vars as such: -// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/rest-private-spot.ts -⋮---- -// note the single quotes, preventing special characters such as $ from being incorrectly passed -⋮---- -// apiKey: 'apiKeyHere', -// apiSecret: 'apiSecretHere', -// apiPass: 'apiPassHere', +// futures private +// : account updates ⋮---- -/** This is a simple script wrapped in a immediately invoked function expression, designed to check for any available BTC balance and immediately sell the full amount for USDT */ - -================ -File: examples/V2 - Classic/Rest/rest-public-futures.ts -================ -import { RestClientV2 } from '../../../src/index.js'; +// : position updates ⋮---- -// or -// import { RestClientV2 } from 'bitget-api'; +// : order updates ⋮---- -// Fetch the last 1000 1min candles for a symbol +// wait briefly for ws to be ready (could also use the response or authenticated events, to make sure topics are subscribed to before starting) ⋮---- -const msPerCandle = 60 * 1000; // 60 seconds x 1000 - -================ -File: examples/V2 - Classic/Rest/rest-public-spot.ts -================ -import { RestClientV2 } from '../../../src/index.js'; +// const balances = allBalances.filter((bal) => Number(bal.available) != 0); ⋮---- -// or -// import { RestClientV2 } from 'bitget-api'; +// Loop through any active positions and send a closing market order on each position ================ -File: examples/V3 - UTA/Rest/rest-private.ts +File: examples/V2 - Classic/Rest/rest-trade-spot.ts ================ -import { RestClientV3 } from '../../../src/index.js'; +import { + RestClientV2, + SpotOrderRequestV2, + WebsocketClientV2, +} from '../../../src/index.js'; ⋮---- -// or -// import { RestClientV3 } from 'bitget-api'; +// import { RestClientV2, WebsocketClient } from '../src/index'; ⋮---- // read from environmental variables ⋮---- // If running from CLI in unix, you can pass env vars as such: -// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/V3/rest-private-futures.ts +// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/rest-trade-spot.ts ⋮---- // note the single quotes, preventing special characters such as $ from being incorrectly passed ⋮---- @@ -2279,3683 +2444,3686 @@ import { RestClientV3 } from '../../../src/index.js'; // apiSecret: 'apiSecretHere', // apiPass: 'apiPassHere', ⋮---- -/** This is a simple script wrapped in a immediately invoked function expression, designed to check account assets for futures trading */ +function logWSEvent(type: string, data: any) +⋮---- +// simple sleep function +function promiseSleep(milliseconds: number) +⋮---- +/** This is a simple script wrapped in a immediately invoked function expression, designed to check for any available BTC balance and immediately sell the full amount for USDT */ +⋮---- +// Add event listeners to log websocket events on account +⋮---- +// Subscribe to private account topics +// spot private +// : account updates +⋮---- +// : order updates (note: symbol is required) +⋮---- +// wait briefly for ws to be ready (could also use the response or authenticated events, to make sure topics are subscribed to before starting) +⋮---- +// console.log('balance: ', JSON.stringify(balances, null, 2)); ================ -File: examples/V3 - UTA/Rest/rest-public-UTA-futures.ts +File: examples/V2 - Classic/Websocket/ws-demo-trading.ts ================ -import { RestClientV3 } from '../../../src/index.js'; +import { DefaultLogger, WebsocketClientV2 } from '../../../src/index.js'; ⋮---- // or -// import { RestClientV3 } from 'bitget-api'; +// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; +⋮---- +// If running from CLI in unix, you can pass env vars as such: +// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/ws-private.ts +⋮---- +// restOptions: { +// optionally provide rest options, e.g. to pass through a proxy +// }, +⋮---- +// Set demoTrading to true, to route all connections to the demo trading wss URLs: +⋮---- +// If using private topics, make sure to include API keys +⋮---- +// console.log('WS raw message received ', JSON.stringify(data, null, 2)); +⋮---- +/** + * Public events + */ ================ -File: examples/V3 - UTA/Rest/rest-public-UTA-spot.ts +File: examples/V2 - Classic/Websocket/ws-private.ts ================ -import { RestClientV3 } from '../../../src/index.js'; +import { DefaultLogger, WebsocketClientV2 } from '../../../src/index.js'; ⋮---- // or -// import { RestClientV3 } from 'bitget-api'; - -================ -File: src/constants/enum.ts -================ -/** Parameter verification exception margin mode == FIXED */ - -================ -File: src/types/request/v2/earn.ts -================ -/** - * - * - * Earn | Savings - * - * - */ +// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; ⋮---- -export interface GetEarnSavingsAssetsRequestV2 { - periodType: string; - startTime?: string; - endTime?: string; - limit?: string; - idLessThan?: 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 GetEarnSavingsRecordsRequestV2 { - coin?: string; - periodType: string; - orderType?: string; - startTime?: string; - endTime?: string; - limit?: string; - idLessThan?: string; -} +// note the single quotes, preventing special characters such as $ from being incorrectly passed ⋮---- -export interface RedeemSavingsRequestV2 { - productId: string; - orderId?: string; - periodType: string; - amount: string; -} +// restOptions: { +// optionally provide rest options, e.g. to pass through a proxy +// }, ⋮---- -/** - * - * - * Earn | Shark Fin - * - * - */ +// console.log('WS raw message received ', JSON.stringify(data, null, 2)); ⋮---- -export interface GetSharkfinAssetsRequestV2 { - status: string; - startTime?: string; - endTime?: string; - limit?: string; - idLessThan?: string; -} +// auth happens async after the ws connection opens ⋮---- -export interface GetSharkfinRecordsRequestV2 { - coin?: string; - type: string; - startTime?: string; - endTime?: string; - limit?: string; - idLessThan?: string; -} +// wsClient.subscribePublicSpotTickers(['BTCUSDT', 'LTCUSDT']); ⋮---- /** - * - * - * Earn | Loan - * - * - */ + * Private account updates + */ ⋮---- -export interface GetLoanEstInterestAndBorrowableRequestV2 { - loanCoin: string; - pledgeCoin: string; - daily: 'SEVEN' | 'THIRTY'; - pledgeAmount?: string; -} +// spot private +// : account updates ⋮---- -export interface BorrowLoanRequestV2 { - loanCoin: string; - pledgeCoin: string; - daily: 'SEVEN' | 'THIRTY'; - pledgeAmount?: string; - loanAmount?: string; -} +// : order updates (note: symbol is required) +// wsClient.subscribeTopic('SPOT', 'orders', 'BTCUSDT'); ⋮---- -export interface RepayLoanRequestV2 { - orderId: string; - amount?: string; - repayUnlock?: string; - repayAll: string; -} +// futures private +// : account updates ⋮---- -export interface GetLoanRepayHistoryRequestV2 { - orderId?: string; - loanCoin?: string; - pledgeCoin?: string; - startTime: string; - endTime: string; - pageNo?: string; - pageSize?: string; -} +// : position updates +// wsClient.subscribeTopic('USDT-FUTURES', 'positions'); ⋮---- -export interface ModifyLoanPledgeRateRequestV2 { - orderId: string; - amount: string; - pledgeCoin: string; - reviseType: string; -} +// : order updates +// wsClient.subscribeTopic('USDT-FUTURES', 'orders'); ⋮---- -export interface GetLoanPledgeRateHistoryRequestV2 { - orderId?: string; - reviseSide?: string; - pledgeCoin?: string; - startTime: string; - endTime: string; - pageNo?: string; - pageSize?: string; -} +// : plan order updates +// wsClient.subscribeTopic('USDT-FUTURES', 'orders-algo'); ⋮---- -export interface GetLoanHistoryRequestV2 { - orderId?: string; - loanCoin?: string; - pledgeCoin?: string; - status?: string; - startTime: string; - endTime: string; - pageNo?: string; - pageSize?: string; -} +// wsClient +// .getWsStore() +// .getKeys() +// .forEach((wsKey) => { +// const state = wsClient.getWsStore().get(wsKey); +// console.log(`${wsKey} state: `, state.subscribedTopics.values()); +// }); ⋮---- -export interface GetLiquidationRecordsRequestV2 { - orderId?: string; - loanCoin?: string; - pledgeCoin?: string; - status?: string; - startTime: string; - endTime: string; - pageNo?: string; - pageSize?: string; -} +// setTimeout(() => { +// wsClient.unsubscribeTopic('USDT-FUTURES', 'account'); +// }, 1000 * 2); ⋮---- -/** - * - * - * Earn | On-Chain Elite - * - * - */ +// setTimeout(() => { +// wsClient +// .getWsStore() +// .getKeys() +// .forEach((wsKey) => { +// const state = wsClient.getWsStore().get(wsKey); +// console.log(`${wsKey} state: `, state.subscribedTopics.values()); +// }); +// }, 1000 * 5); + +================ +File: examples/V2 - Classic/Websocket/ws-public.ts +================ +import { + DefaultLogger, + WebsocketClientV2, + WS_KEY_MAP, +} from '../../../src/index.js'; ⋮---- -export interface GetEarnEliteRecordsRequestV2 { - type: 'subscribe' | 'redeem' | 'interest'; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; -} +// or +// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; ⋮---- -export interface GetEarnEliteSubscribeInfoRequestV2 { - productId: string; -} +// restOptions: { +// optionally provide rest options, e.g. to pass through a proxy +// }, ⋮---- -export interface EarnEliteSubscribeRequestV2 { - productSubId: string; - amount: string; - coin?: string; - paymentAccount?: 'spot' | 'unified'; -} +// console.log('WS raw message received ', JSON.stringify(data, null, 2)); ⋮---- -export interface GetEarnEliteSubscribeResultRequestV2 { - orderId: string; -} +/** + * Public events + */ ⋮---- -export interface GetEarnEliteRedeemInfoRequestV2 { - productId: string; -} +// Spot public ⋮---- -export interface RedeemEarnEliteRequestV2 { - productId: string; - productSubId: string; - redeemType: 'fast' | 'standard'; - amount: string; - receiveAccount: 'spot' | 'unified'; - advancedSettle?: 'yes' | 'no'; - coin?: string; -} - -================ -File: src/types/request/v2/instloan.ts -================ -export interface GetInstLoanProductInfoRequestV2 { - productId: string; -} +// tickers ⋮---- -export interface GetInstLoanSymbolsRequestV2 { - productId: string; -} +// candles +// wsClient.subscribeTopic('SPOT', 'candle1m', symbol); ⋮---- -export interface GetInstLoanRepaidHistoryRequestV2 { - startTime?: string; - endTime?: string; - limit?: string; -} +// orderbook updates +// wsClient.subscribeTopic('SPOT', 'books', symbol); ⋮---- -export interface GetInstLoanOrderRequestV2 { - orderId?: string; - startTime?: string; - endTime?: string; -} +// trades +// wsClient.subscribeTopic('SPOT', 'trade', symbol); ⋮---- -export interface GetInstLoanLTVConvertRequestV2 { - riskUnitId?: string; -} +// Futures public ⋮---- -export interface GetInstLoanMarginCoinInfoRequestV2 { - productId: string; -} +// tickers +// wsClient.subscribeTopic('USDT-FUTURES', 'ticker', symbol); +⋮---- +// candles +// wsClient.subscribeTopic('USDT-FUTURES', 'candle1m', symbol); +⋮---- +// orderbook updates +// wsClient.subscribeTopic('USDT-FUTURES', 'books', symbol); +⋮---- +// trades +// wsClient.subscribeTopic('USDT-FUTURES', 'trade', symbol); +⋮---- +// Topics are tracked per websocket type +// Get a list of subscribed topics (e.g. all public topics) (after a 5 second delay) ================ -File: src/types/request/v2/spot.ts +File: examples/V3 - UTA/Rest/rest-trade-UTA-futures.ts ================ -type SpotKlineIntervalV2 = - | '1min' - | '5min' - | '15min' - | '30min' - | '1h' - | '4h' - | '6h' - | '12h' - | '1day' - | '3day' - | '1week' - | '1M' - | '6Hutc' - | '12Hutc' - | '1Dutc' - | '3Dutc' - | '1Wutc' - | '1Mutc'; +/* eslint-disable @typescript-eslint/no-unused-vars */ +import { + PlaceOrderRequestV3, + RestClientV3, + WebsocketClientV3, +} from '../../../src/index.js'; ⋮---- -export interface SpotCandlesRequestV2 { - symbol: string; - granularity: SpotKlineIntervalV2; - startTime?: string; - endTime?: string; - limit?: string; -} +// or +// import { PlaceOrderRequestV3, RestClientV3, WebsocketClientV3 } from '../src'; ⋮---- -export interface SpotHistoricCandlesRequestV2 { - symbol: string; - granularity: SpotKlineIntervalV2; - endTime?: string; - limit?: string; -} +// read from environmental variables ⋮---- -export interface SpotHistoricTradesRequestV2 { - symbol: string; - limit?: string; - idLessThan?: string; - startTime?: string; - endTime?: string; -} +// If running from CLI in unix, you can pass env vars as such: +// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/V3/rest-trade-futures.ts ⋮---- -export interface SpotCallAuctionRequestV2 { - symbol: string; -} +// note the single quotes, preventing special characters such as $ from being incorrectly passed +⋮---- +// apiKey: 'apiKeyHere', +// apiSecret: 'apiSecretHere', +// apiPass: 'apiPassHere', +⋮---- +function logWSEvent(type: string, data: any) +⋮---- +// simple sleep function +function promiseSleep(milliseconds: number) ⋮---- /** + * This is a simple script wrapped in a immediately invoked function expression (to execute the below workflow immediately). * - * * Spot | Trade + * It is designed to: + * - open a private websocket channel to log account events + * - check for any available USDT balance in the account + * - immediately open a minimum sized long position on BTCUSDT + * - check active positions + * - immediately send closing orders for any active futures positions + * - check positions again * */ ⋮---- -export type SpotOrderSideV2 = 'buy' | 'sell'; +// Add event listeners to log websocket events on account ⋮---- -export type SpotOrderTypeV2 = 'limit' | 'market'; +// Subscribe to private topics for UTA account ⋮---- -export type SpotOrderForceV2 = 'gtc' | 'post_only' | 'fok' | 'ioc'; +// Subscribe to position updates ⋮---- -export type SpotTPSLTypeV2 = 'normal' | 'tpsl'; +// Subscribe to order updates ⋮---- -export type SpotSTPModeV2 = - | 'none' - | 'cancel_taker' - | 'cancel_maker' - | 'cancel_both'; +// wait briefly for ws to be ready (could also use the response or authenticated events, to make sure topics are subscribed to before starting) ⋮---- -export type SpotBatchModeV2 = 'single' | 'multiple'; +// Loop through any active positions and send a closing market order on each position + +================ +File: examples/V3 - UTA/Rest/rest-trade-UTA-spot.ts +================ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import { + PlaceOrderRequestV3, + RestClientV3, + WebsocketClientV3, +} from '../../../src/index.js'; ⋮---- -export interface SpotOrderRequestV2 { - symbol: string; - side: SpotOrderSideV2; - orderType: SpotOrderTypeV2; - force: SpotOrderForceV2; - price?: string; - size: string; - clientOid?: string; - triggerPrice?: string; - tpslType?: SpotTPSLTypeV2; - requestTime?: string; - receiveWindow?: string; - stpMode?: SpotSTPModeV2; - presetTakeProfitPrice?: string; - executeTakeProfitPrice?: string; - presetStopLossPrice?: string; - executeStopLossPrice?: string; -} +// import { RestClientV3, WebsocketClientV3 } from '../src/index'; ⋮---- -export interface SpotCancelandSubmitOrderRequestV2 { - symbol: string; - price: string; - size: string; - orderId?: string; - clientOid?: string; - newClientOid?: string; - presetTakeProfitPrice?: string; - executeTakeProfitPrice?: string; - presetStopLossPrice?: string; - executeStopLossPrice?: string; -} +// read from environmental variables ⋮---- -export interface SpotCancelOrderRequestV2 { - symbol: string; - tpslType?: SpotTPSLTypeV2; - orderId?: string; - clientOid?: string; -} +// If running from CLI in unix, you can pass env vars as such: +// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/V3/rest-trade-spot.ts ⋮---- -export interface SpotBatchOrderRequestItemV2 { - symbol?: string; - side: SpotOrderSideV2; - orderType: SpotOrderTypeV2; - force: SpotOrderForceV2; - price?: string; - size: string; - clientOid?: string; - stpMode?: SpotSTPModeV2; - presetTakeProfitPrice?: string; - executeTakeProfitPrice?: string; - presetStopLossPrice?: string; - executeStopLossPrice?: string; -} -⋮---- -export interface SpotBatchOrderRequestV2 { - symbol?: string; - batchMode?: SpotBatchModeV2; - orderList: SpotBatchOrderRequestItemV2[]; -} +// note the single quotes, preventing special characters such as $ from being incorrectly passed ⋮---- -export interface SpotBatchCancelOrderRequestV2 { - symbol?: string; - batchMode?: SpotBatchModeV2; - orderList: { - symbol?: string; - orderId?: string; - clientOid?: string; - }[]; -} +// apiKey: 'apiKeyHere', +// apiSecret: 'apiSecretHere', +// apiPass: 'apiPassHere', ⋮---- -export interface GetSpotOrderInfoRequestV2 { - orderId?: string; - clientOid?: string; - requestTime?: string; - receiveWindow?: string; -} +function logWSEvent(type: string, data: any) ⋮---- -export interface GetSpotOpenOrdersRequestV2 { - symbol?: string; - startTime?: string; - endTime?: string; - idLessThan?: string; - limit?: string; - orderId?: string; - tpslType?: SpotTPSLTypeV2; - requestTime?: string; - receiveWindow?: string; -} +// simple sleep function +function promiseSleep(milliseconds: number) ⋮---- -export interface GetSpotHistoryOrdersRequestV2 { - symbol?: string; - startTime?: string; - endTime?: string; - idLessThan?: string; - limit?: string; - orderId?: string; - tpslType?: SpotTPSLTypeV2; - requestTime?: string; - receiveWindow?: string; -} +/** This is a simple script wrapped in a immediately invoked function expression, designed to check for any available BTC balance and immediately sell the full amount for USDT */ ⋮---- -export interface GetSpotFillsRequestV2 { - symbol: string; - orderId?: string; - startTime?: string; - endTime?: string; - limit?: string; - idLessThan?: string; -} +// Add event listeners to log websocket events on account ⋮---- -/** - * - * * Spot | Trigger Orders - * - */ +// Subscribe to private account topics +// Account updates for UTA (unified trading account) ⋮---- -export type SpotPlanTypeV2 = 'amount' | 'total'; +// Order updates for spot ⋮---- -export type SpotTriggerTypeV2 = 'fill_price' | 'mark_price'; +// wait briefly for ws to be ready (could also use the response or authenticated events, to make sure topics are subscribed to before starting) + +================ +File: examples/V3 - UTA/Websocket/ws-private.ts +================ +import { + DefaultLogger, + WebsocketClientV3, + WS_KEY_MAP, +} from '../../../src/index.js'; ⋮---- -export interface SpotPlanOrderRequestV2 { - symbol: string; - side: SpotOrderSideV2; - triggerPrice: string; - orderType: SpotOrderTypeV2; - executePrice?: string; - planType?: SpotPlanTypeV2; - size: string; - triggerType: SpotTriggerTypeV2; - clientOid?: string; - force?: SpotOrderForceV2; - stpMode?: SpotSTPModeV2; -} +// or +// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; ⋮---- -export interface SpotModifyPlanOrderRequestV2 { - orderId?: string; - clientOid?: string; - triggerPrice: string; - orderType: SpotOrderTypeV2; - executePrice?: 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 GetSpotCurrentPlanOrdersRequestV2 { - symbol: string; - limit?: string; - idLessThan?: string; - startTime?: string; - endTime?: string; -} +// console.log('WS raw message received ', JSON.stringify(data, null, 2)); ⋮---- -export interface GetSpotHistoryPlanOrdersRequestV2 { - symbol: string; - startTime: string; - endTime: string; - limit?: string; -} +// You can subscribe to one topic at a time ⋮---- -/** - * - * * Spot | Account - * - */ +instType: 'UTA', // Note: all account events go on the UTA instType ⋮---- -export type SpotBillGroupTypeV2 = - | 'deposit' - | 'withdraw' - | 'transaction' - | 'transfer' - | 'other'; +WS_KEY_MAP.v3Private, // This parameter points to private or public ⋮---- -export type SpotBusinessTypeV2 = - | 'deposit' - | 'withdraw' - | 'buy' - | 'sell' - | 'deduction of handling fee' - | 'transfer-in' - | 'transfer-out' - | 'rebate rewards' - | 'airdrop rewards' - | 'USDT contract rewards' - | 'mix contract rewards' - | 'system lock' - | 'user lock'; +// Note: all account events go on the UTA instType ⋮---- -export type SpotAccountTypeV2 = - | 'spot' - | 'p2p' - | 'coin_futures' - | 'usdt_futures' - | 'usdc_futures' - | 'crossed_margin' - | 'isolated_margin'; +// Or multiple at once: ⋮---- -export interface GetSpotAccountBillsRequestV2 { - coin?: string; - groupType?: SpotBillGroupTypeV2; - businessType?: SpotBusinessTypeV2; - startTime?: string; - endTime?: string; - limit?: string; - idLessThan?: string; -} +// Topics are tracked per websocket type +// The below example will pull a list of subscribed topics on that connection (e.g. all private topics), after a 5 second delay: + +================ +File: examples/V3 - UTA/Websocket/ws-public.ts +================ +import { + DefaultLogger, + WebsocketClientV3, + WS_KEY_MAP, +} from '../../../src/index.js'; ⋮---- -export interface SpotTransferRequestV2 { - fromType: SpotAccountTypeV2; - toType: SpotAccountTypeV2; - amount: string; - coin: string; - symbol: string; - clientOid?: string; -} +// or +// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; ⋮---- -export interface SpotSubAccountTransferRequestV2 { - fromType: SpotAccountTypeV2; - toType: SpotAccountTypeV2; - amount: string; - coin: string; - symbol?: string; - clientOid?: string; - fromUserId: string; - toUserId: string; -} +// console.log('WS raw message received ', JSON.stringify(data, null, 2)); ⋮---- -export interface SpotWithdrawalRequestV2 { - coin: string; - transferType: 'on_chain' | 'internal_transfer'; - address: string; - chain?: string; - innerToType?: 'email' | 'mobile' | 'uid'; - areaCode?: string; - tag?: string; - size: string; - remark?: string; - clientOid?: string; -} +/** + * Public events + */ ⋮---- -export interface SpotMainSubTransferRecordRequestV2 { - coin?: string; - role?: 'initiator' | 'receiver'; - subUid?: string; - startTime?: string; - endTime?: string; - clientOid?: string; - limit?: string; - idLessThan?: string; -} +// You can subscribe to one topic at a time ⋮---- -export interface GetSpotTransferRecordRequestV2 { - coin: string; - fromType: SpotAccountTypeV2; - startTime?: string; - endTime?: string; - clientOid?: string; - limit?: string; - idLessThan?: string; -} +WS_KEY_MAP.v3Public, // This parameter points to private or public ⋮---- -export interface GetSpotSubAccountDepositRecordRequestV2 { - subUid: string; - coin?: string; - startTime?: string; - endTime?: string; - idLessThan?: string; - limit?: string; -} +// Or multiple at once: ⋮---- -export interface GetSpotWithdrawalRecordRequestV2 { - coin?: string; - clientOid?: string; - startTime: string; - endTime: string; - idLessThan?: string; - orderId?: string; - limit?: string; -} -⋮---- -export interface GetSpotDepositRecordRequestV2 { - coin?: string; - orderId?: string; - startTime: string; - endTime: string; - idLessThan?: string; - limit?: string; -} +// Topics are tracked per websocket type +// The below example will pull a list of subscribed topics on that connection (e.g. all public topics), after a 5 second delay: ================ -File: src/types/request/v3/affiliate.ts +File: examples/V3 - UTA/WS-API/ws-api-client-trade.ts ================ -/** - * - * - * Affiliate - * - * - */ -⋮---- -export interface AgentCustomerListRequestV3 { - startTime?: string; - endTime?: string; - pageNo?: string; - pageSize?: string; - uid?: string; - referralCode?: string; -} -⋮---- -export interface AgentCustomerAssetRequestV3 { - pageNo?: string; - pageSize?: string; - uid?: string; - showSub?: 'yes' | 'no'; -} -⋮---- -export interface AgentCustomerTradeVolumeRequestV3 { - startTime?: string; - endTime?: string; - pageNo?: string; - pageSize?: string; - uid?: string; - showSub?: 'yes' | 'no'; -} -⋮---- -export interface AgentCustomerDepositRequestV3 { - startTime?: string; - endTime?: string; - pageNo?: string; - pageSize?: string; - uid?: string; - showSub?: 'yes' | 'no'; -} -⋮---- -export interface GetAgentCustomerKycResultRequestV3 { - startTime?: string; - endTime?: string; - /** Pass endId from the previous response. Omit on the first page. */ - cursor?: string; - limit?: string; - uid?: string; - showSub?: 'yes' | 'no'; -} -⋮---- -/** Pass endId from the previous response. Omit on the first page. */ +import { DefaultLogger, WebsocketAPIClient } from '../../../src/index.js'; ⋮---- -export interface GetAgentCustomerCommissionsRequestV3 { - startTime?: string; - endTime?: string; - /** Pass endId from the previous response. Omit on the first page. */ - cursor?: string; - limit?: string; - uid?: string; - coin?: string; - symbol?: string; - showSub?: 'yes' | 'no'; -} +// or +// import { DefaultLogger, WS_KEY_MAP, WebsocketAPIClient } from 'bitget-api'; ⋮---- -/** Pass endId from the previous response. Omit on the first page. */ +// 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 GetAgentSubCustomerListRequestV3 { - startTime?: string; - endTime?: string; - /** Pass minId from the previous response. Omit on the first page. */ - cursor?: string; - limit?: string; - uid?: string; - showSub?: 'yes' | 'no'; -} +// 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 ⋮---- -/** Pass minId from the previous response. Omit on the first page. */ +// Whether to use the demo trading wss connection +// demoTrading: true, ⋮---- -export interface GetSubAffiliateInfoRequestV3 { - uid?: string; - startTime?: string; - endTime?: string; - /** Pass endId from the previous response. Omit on the first page. */ - idLessThan?: string; - limit?: string; - includeDownLine?: 'yes' | 'no'; -} +// 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 ⋮---- -/** Pass endId from the previous response. Omit on the first page. */ +logger, // Optional: inject a custom logger ⋮---- -export interface GetSubAffiliateCommissionRequestV3 { - startTime?: string; - endTime?: string; - limit?: string; - /** Pass endId from the previous response. Omit on the first page. */ - cursor?: string; -} +// Optional, see above "attachEventListeners". Attach basic event handlers, so nothing is left unhandled +// attachEventHandlers(wsClient.getWSClient()); ⋮---- -/** Pass endId from the previous response. Omit on the first page. */ - -================ -File: src/types/request/v3/grid.ts -================ -export type GridCategoryV3 = 'SPOT' | 'USDT-FUTURES' | 'USDC-FUTURES'; +// 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 type NeutralGridCategoryV3 = 'USDT-FUTURES' | 'USDC-FUTURES'; +/** + * Bitget's WebSocket API be used like a REST API, through this SDK's WebsocketAPIClient. The WebsocketAPIClient is a utility class wrapped around WebsocketClientV3's sendWSAPIRequest() capabilities. + * + * Each request sent via the WebsocketAPIClient will automatically: + * - route via the active WS API connection + * - return a Promise, which automatically resolves/rejects when a matching response is received + * + * Note: this requires V3/UTA API keys! + */ ⋮---- -export type GridFundsSourceV3 = 'funding' | 'uta' | 'otc'; +/** + * Place Order + * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters + */ ⋮---- -export type GridYesNoV3 = 'yes' | 'no'; +/** + 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 type GridOrderModeV3 = 'arithmetic' | 'geometric'; +/** + * Batch Place Order Channel + * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel + */ ⋮---- -export type GridTypeV3 = 'long' | 'short' | 'neutral' | 'netural'; +/** + * 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 type GridTriggerConditionV3 = 'instant' | 'price' | 'rsi' | 'boll'; +/** + 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 type GridTerminationConditionV3 = 'rsi' | 'boll'; +/** + * Cancel Order + * https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel + */ ⋮---- -export type GridAdjustTypeV3 = 'increase' | 'decrease'; +/** + const res = { + "event": "trade", + "id": "1750034870205", + "topic": "cancel-order", + "args": [ + { + "orderId": "xxxxxxxx", + "clientOid": "xxxxxxxx" + } + ], + "code": "0", + "msg": "Success", + "ts": "1750034870597" + } + */ ⋮---- -export interface GridInvestmentAmountV3 { - coin: string; - amount: string; -} +/** + * Batch Cancel Order + * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Cancel-Order-Channel + */ ⋮---- -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; -} +/** + 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: examples/V3 - UTA/WS-API/ws-api-trade-raw.ts +================ +import { + DefaultLogger, + WebsocketClientV3, + WS_KEY_MAP, +} from '../../../src/index.js'; ⋮---- -export interface CloseGridBotRequestV3 { - botId: string; -} +// or +// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV3 } from 'bitget-api'; ⋮---- -export interface AddGridInvestmentRequestV3 { - category: GridCategoryV3; - botId: string; - coin?: string; - size?: string; - fundsSource: GridFundsSourceV3[]; - adjustType?: GridAdjustTypeV3; - reinvestProfit?: GridYesNoV3; -} +// 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 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; -} +// console.log('WS raw message received ', JSON.stringify(data, null, 2)); ⋮---- -export type ValidateGridBotRequestV3 = CreateGridBotRequestV3; +/** + * Bitget's WebSocket API can be used via the sendWSAPIRequest() method. + * + * Use the `WS_KEY_MAP.v3Private` connection key for any requests. + * + * Note: this requires V3/UTA API keys! + * Note: for a better user experience, it is recommended to use the WebsocketAPIClient. + */ ⋮---- -export interface ModifyGridBotRequestV3 { - botId: string; - category: GridCategoryV3; - takeProfit?: string; - stopLoss?: string; - terminationCondition?: GridTerminationConditionV3; - terminationParams?: GridIndicatorParamsV3[]; - hodlMode?: GridYesNoV3; - autoTransferProfits?: GridYesNoV3; -} +// Use the V3 private wss connection URL ⋮---- -export interface ModifyGridIntervalRequestV3 { - category: GridCategoryV3; - botId: string; - maxPrice: string; - minPrice: string; - gridNum: string; -} +/** + * Place Order + * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters + */ ⋮---- -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; -} +/** + 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 type ValidateNeutralGridBotRequestV3 = CreateNeutralGridBotRequestV3; +/** + * Batch Place Order Channel + * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel + */ ⋮---- -export interface ModifyNeutralGridBotRequestV3 { - botId: string; - category: NeutralGridCategoryV3; - takeProfit?: string; - stopLoss?: string; - autoTransferProfits?: GridYesNoV3; -} +/** + * 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 ModifyNeutralGridIntervalRequestV3 { - category: NeutralGridCategoryV3; - botId: string; - maxPrice: string; - minPrice: string; - gridNum: string; -} +/** + const res = { + "event": "trade", + "id": "1750035029506", + "category": "spot", + "topic": "batch-place", + "args": [ + { + "code": "0", + "msg": "Success", + "symbol": "BTCUSDT", + "orderId": "xxxxxxxx", + "clientOid": "xxxxxxxx" + }, + { + "code": "0", + "msg": "Success", + "symbol": "BTCUSDT", + "orderId": "xxxxxxxx", + "clientOid": "xxxxxxxx" + } + ], + "code": "0", + "msg": "Success", + "ts": "1750035029925" + } + */ ⋮---- -export interface GetNeutralGridBotDetailRequestV3 { - botId: string; -} +/** + * Cancel Order + * https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel + */ ⋮---- -export interface GetNeutralGridBotOrderDetailsRequestV3 { - category: NeutralGridCategoryV3 | GridCategoryV3; - botId: string; -} - -================ -File: src/types/request/v3/loan.ts -================ -export interface GetTransferedRequestV3 { - userId?: string; - coin: string; -} +/** + const res = { + "event": "trade", + "id": "1750034870205", + "topic": "cancel-order", + "args": [ + { + "orderId": "xxxxxxxx", + "clientOid": "xxxxxxxx" + } + ], + "code": "0", + "msg": "Success", + "ts": "1750034870597" + } + */ ⋮---- -export interface GetSymbolsRequestV3 { - productId: string; -} +/** + * Batch Cancel Order + * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Cancel-Order-Channel + */ ⋮---- -export interface GetRepaidHistoryRequestV3 { - startTime?: string; - endTime?: string; - limit?: string; -} +/** + const res = { + "event": "trade", + "id": "bb553cc0-c1fa-454e-956d-c96c8d715760", + "topic": "batch-cancel", + "args": [ + { + "code": "0", + "msg": "Success", + "orderId": "xxxxxxxxxxxxx" + }, + { + "code": "25204", + "msg": "Order does not exist", + "orderId": "xxxxxxxxxxxxx" + } + ], + "code": "0", + "msg": "Success", + "ts": "1751980011084" + } + */ + +================ +File: src/constants/enum.ts +================ +/** Parameter verification exception margin mode == FIXED */ + +================ +File: src/types/request/v2/earn.ts +================ +/** + * + * + * Earn | Savings + * + * + */ ⋮---- -export interface GetProductInfosRequestV3 { - productId: string; +export interface GetEarnSavingsAssetsRequestV2 { + periodType: string; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; } ⋮---- -export interface GetLoanOrderRequestV3 { - orderId?: string; +export interface GetEarnSavingsRecordsRequestV2 { + coin?: string; + periodType: string; + orderType?: string; startTime?: string; endTime?: string; + limit?: string; + idLessThan?: string; } ⋮---- -export interface GetEnsureCoinsRequestV3 { +export interface RedeemSavingsRequestV2 { productId: string; + orderId?: string; + periodType: string; + amount: string; } ⋮---- -export interface BindUidRequestV3 { - riskUnitId?: string; - uid: string; - operate: 'bind' | 'unbind'; -} +/** + * + * + * Earn | Shark Fin + * + * + */ ⋮---- -export interface GetLTVConvertRequestV3 { - riskUnitId?: string; +export interface GetSharkfinAssetsRequestV2 { + status: string; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; } ⋮---- -/* Unified Account Staking & Lending (Crypto Loans) - /api/v3/loan/* */ -⋮---- -export interface GetLoanCoinsRequestV3 { +export interface GetSharkfinRecordsRequestV2 { coin?: string; + type: string; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; } ⋮---- -export interface GetLoanInterestRequestV3 { +/** + * + * + * Earn | Loan + * + * + */ +⋮---- +export interface GetLoanEstInterestAndBorrowableRequestV2 { loanCoin: string; pledgeCoin: string; - daily: 'SEVEN' | 'THIRTY' | 'FLEXIBLE'; - pledgeAmount: string; + daily: 'SEVEN' | 'THIRTY'; + pledgeAmount?: string; } ⋮---- -export interface LoanBorrowRequestV3 { +export interface BorrowLoanRequestV2 { loanCoin: string; pledgeCoin: string; - daily: 'SEVEN' | 'THIRTY' | 'FLEXIBLE'; + daily: 'SEVEN' | 'THIRTY'; pledgeAmount?: string; loanAmount?: string; } ⋮---- -export interface GetLoanBorrowOngoingRequestV3 { - orderId?: string; - loanCoin?: string; - pledgeCoin?: string; +export interface RepayLoanRequestV2 { + orderId: string; + amount?: string; + repayUnlock?: string; + repayAll: string; } ⋮---- -export interface GetLoanBorrowHistoryRequestV3 { +export interface GetLoanRepayHistoryRequestV2 { orderId?: string; loanCoin?: string; pledgeCoin?: string; - status?: 'ROLLBACK' | 'FORCE' | 'REPAY'; startTime: string; endTime: string; - pageNum?: string; + pageNo?: string; pageSize?: string; } ⋮---- -export interface LoanRepayRequestV3 { +export interface ModifyLoanPledgeRateRequestV2 { orderId: string; - method: 'borrowed_coin' | 'collateral'; - repayAll: 'yes' | 'no'; - amount?: string; - repayUnlock?: 'yes' | 'no'; + amount: string; + pledgeCoin: string; + reviseType: string; } ⋮---- -export interface GetLoanRepayHistoryRequestV3 { +export interface GetLoanPledgeRateHistoryRequestV2 { orderId?: string; - loanCoin?: string; + reviseSide?: string; pledgeCoin?: string; startTime: string; endTime: string; - pageNum?: string; + pageNo?: string; pageSize?: string; } ⋮---- -export interface LoanRevisePledgeRequestV3 { - orderId: string; - amount: string; - pledgeCoin: string; - reviseType?: 'OUT' | 'IN'; -} -⋮---- -export interface GetLoanPledgeRateHistoryRequestV3 { +export interface GetLoanHistoryRequestV2 { orderId?: string; - reviseSide?: 'down' | 'up'; + loanCoin?: string; pledgeCoin?: string; + status?: string; startTime: string; endTime: string; - pageNum?: string; + pageNo?: string; pageSize?: string; } ⋮---- -export interface GetLoanReducesRequestV3 { +export interface GetLiquidationRecordsRequestV2 { orderId?: string; loanCoin?: string; pledgeCoin?: string; - status?: 'COMPLETE' | 'WAIT'; + status?: string; startTime: string; endTime: string; - pageNum?: string; + pageNo?: string; pageSize?: string; } - -================ -File: src/types/request/v3/p2p.ts -================ -export type P2pSideV3 = 'buy' | 'sell'; ⋮---- -export type P2pPriceTypeV3 = 'fixed' | 'floating'; -⋮---- -export type P2pMarketTypeV3 = 'public' | 'private'; -⋮---- -export type P2pAdStatusV3 = 'publish' | 'delist' | 'remove'; +/** + * + * + * Earn | On-Chain Elite + * + * + */ ⋮---- -export type P2pAdOperationV3 = 'publish' | 'delist' | 'remove'; +export interface GetEarnEliteRecordsRequestV2 { + type: 'subscribe' | 'redeem' | 'interest'; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; +} ⋮---- -export type P2pOrderStatusV3 = - | 'pending_payment' - | 'pending_release' - | 'completed' - | 'cancelled' - | 'in_appeal'; +export interface GetEarnEliteSubscribeInfoRequestV2 { + productId: string; +} ⋮---- -export interface P2pPayMethodIdRefV3 { - payMethodId: string; - userPayMethodId?: string; +export interface EarnEliteSubscribeRequestV2 { + productSubId: string; + amount: string; + coin?: string; + paymentAccount?: 'spot' | 'unified'; } ⋮---- -export interface GetP2pAdListRequestV3 { - token: string; - fiat: string; - side: P2pSideV3; - amount?: string; - pageNum: string; - limit: string; +export interface GetEarnEliteSubscribeResultRequestV2 { + orderId: string; } ⋮---- -export interface GetP2pExchangeRateRequestV3 { - token: string; - fiat: string; +export interface GetEarnEliteRedeemInfoRequestV2 { + productId: string; } ⋮---- -export interface P2pFeeSimulateRequestV3 { - token: string; - fiat: string; - side: P2pSideV3; - marketType: P2pMarketTypeV3; +export interface RedeemEarnEliteRequestV2 { + productId: string; + productSubId: string; + redeemType: 'fast' | 'standard'; amount: string; + receiveAccount: 'spot' | 'unified'; + advancedSettle?: 'yes' | 'no'; + coin?: string; +} + +================ +File: src/types/request/v2/instloan.ts +================ +export interface GetInstLoanProductInfoRequestV2 { + productId: string; } ⋮---- -export interface GetP2pAdLimitRequestV3 { - token: string; - fiat: string; - side: P2pSideV3; +export interface GetInstLoanSymbolsRequestV2 { + productId: string; } ⋮---- -export interface CreateP2pAdRequestV3 { - token: string; - fiat: string; - side: P2pSideV3; - priceType: P2pPriceTypeV3; - price?: string; - premium?: string; - minAmount: string; - maxAmount: string; - quantity: string; - payMethodIds: P2pPayMethodIdRefV3[]; - remark?: string; - tradeTerms?: string; - payTimeLimit: string; +export interface GetInstLoanRepaidHistoryRequestV2 { + startTime?: string; + endTime?: string; + limit?: string; } ⋮---- -export interface UpdateP2pAdRequestV3 { - advId: string; - priceType?: P2pPriceTypeV3; - price?: string; - premium?: string; - minAmount?: string; - maxAmount?: string; - quantity?: string; - payMethodIds?: P2pPayMethodIdRefV3[]; - payTimeLimit?: string; - remark?: string; - tradeTerms?: string; +export interface GetInstLoanOrderRequestV2 { + orderId?: string; + startTime?: string; + endTime?: string; } ⋮---- -export interface OperateP2pAdRequestV3 { - advId: string; - operation: P2pAdOperationV3; +export interface GetInstLoanLTVConvertRequestV2 { + riskUnitId?: string; } ⋮---- -export interface GetP2pAdInfoRequestV3 { - advId: string; +export interface GetInstLoanMarginCoinInfoRequestV2 { + productId: string; } + +================ +File: src/types/request/v2/spot.ts +================ +type SpotKlineIntervalV2 = + | '1min' + | '5min' + | '15min' + | '30min' + | '1h' + | '4h' + | '6h' + | '12h' + | '1day' + | '3day' + | '1week' + | '1M' + | '6Hutc' + | '12Hutc' + | '1Dutc' + | '3Dutc' + | '1Wutc' + | '1Mutc'; ⋮---- -export interface GetP2pMyAdsRequestV3 { +export interface SpotCandlesRequestV2 { + symbol: string; + granularity: SpotKlineIntervalV2; startTime?: string; endTime?: string; limit?: string; - cursor?: string; - advId?: string; - token?: string; - fiat?: string; - status?: P2pAdStatusV3; } ⋮---- -export interface GetP2pPendingOrdersRequestV3 { - orderId?: string; - side?: P2pSideV3; - startTime?: string; +export interface SpotHistoricCandlesRequestV2 { + symbol: string; + granularity: SpotKlineIntervalV2; endTime?: string; - cursor?: string; limit?: string; } ⋮---- -export interface GetP2pAllOrdersRequestV3 { +export interface SpotHistoricTradesRequestV2 { + symbol: string; + limit?: string; + idLessThan?: string; startTime?: string; endTime?: string; - limit?: string; - cursor?: string; - orderId?: string; - side?: P2pSideV3; - status?: P2pOrderStatusV3; } ⋮---- -export interface GetP2pOrderInfoRequestV3 { - orderId: string; +export interface SpotCallAuctionRequestV2 { + symbol: string; } ⋮---- -export interface P2pOrderActionRequestV3 { - orderId: string; -} +/** + * + * * Spot | Trade + * + */ ⋮---- -export interface GetP2pBalanceRequestV3 { - token: string; -} - -================ -File: src/types/request/v3/reality.ts -================ -export interface GetRealityCompanyOverviewRequestV3 { - code: string; -} +export type SpotOrderSideV2 = 'buy' | 'sell'; ⋮---- -export interface GetRealityValuationIndicatorsRequestV3 { - code: string; +export type SpotOrderTypeV2 = 'limit' | 'market'; +⋮---- +export type SpotOrderForceV2 = 'gtc' | 'post_only' | 'fok' | 'ioc'; +⋮---- +export type SpotTPSLTypeV2 = 'normal' | 'tpsl'; +⋮---- +export type SpotSTPModeV2 = + | 'none' + | 'cancel_taker' + | 'cancel_maker' + | 'cancel_both'; +⋮---- +export type SpotBatchModeV2 = 'single' | 'multiple'; +⋮---- +export interface SpotOrderRequestV2 { + symbol: string; + side: SpotOrderSideV2; + orderType: SpotOrderTypeV2; + force: SpotOrderForceV2; + price?: string; + size: string; + clientOid?: string; + triggerPrice?: string; + tpslType?: SpotTPSLTypeV2; + requestTime?: string; + receiveWindow?: string; + stpMode?: SpotSTPModeV2; + presetTakeProfitPrice?: string; + executeTakeProfitPrice?: string; + presetStopLossPrice?: string; + executeStopLossPrice?: string; } ⋮---- -export interface GetRealityEarningsForecastRequestV3 { - code: string; +export interface SpotCancelandSubmitOrderRequestV2 { + symbol: string; + price: string; + size: string; + orderId?: string; + clientOid?: string; + newClientOid?: string; + presetTakeProfitPrice?: string; + executeTakeProfitPrice?: string; + presetStopLossPrice?: string; + executeStopLossPrice?: string; } ⋮---- -export interface GetRealitySuspensionResumptionInfoRequestV3 { - code: string; +export interface SpotCancelOrderRequestV2 { + symbol: string; + tpslType?: SpotTPSLTypeV2; + orderId?: string; + clientOid?: string; } ⋮---- -export interface GetRealityDividendsRequestV3 { - code: string; - limit?: string; - cursor?: string; +export interface SpotBatchOrderRequestItemV2 { + symbol?: string; + side: SpotOrderSideV2; + orderType: SpotOrderTypeV2; + force: SpotOrderForceV2; + price?: string; + size: string; + clientOid?: string; + stpMode?: SpotSTPModeV2; + presetTakeProfitPrice?: string; + executeTakeProfitPrice?: string; + presetStopLossPrice?: string; + executeStopLossPrice?: string; } ⋮---- -export interface GetRealityShareCapitalChangeRequestV3 { - code: string; +export interface SpotBatchOrderRequestV2 { + symbol?: string; + batchMode?: SpotBatchModeV2; + orderList: SpotBatchOrderRequestItemV2[]; } ⋮---- -export interface GetRealityInnerTradesRequestV3 { - code: string; - limit?: string; - cursor?: string; +export interface SpotBatchCancelOrderRequestV2 { + symbol?: string; + batchMode?: SpotBatchModeV2; + orderList: { + symbol?: string; + orderId?: string; + clientOid?: string; + }[]; } ⋮---- -export interface GetRealityExecutiveShareholdingsRequestV3 { - code: string; - limit?: string; - cursor?: string; +export interface GetSpotOrderInfoRequestV2 { + orderId?: string; + clientOid?: string; + requestTime?: string; + receiveWindow?: string; } ⋮---- -export interface GetRealityShareholdDetailRequestV3 { - code: string; +export interface GetSpotOpenOrdersRequestV2 { + symbol?: string; + startTime?: string; + endTime?: string; + idLessThan?: string; limit?: string; - cursor?: string; + orderId?: string; + tpslType?: SpotTPSLTypeV2; + requestTime?: string; + receiveWindow?: string; } ⋮---- -export interface GetRealityStockInfoRequestV3 { +export interface GetSpotHistoryOrdersRequestV2 { symbol?: string; + startTime?: string; + endTime?: string; + idLessThan?: string; + limit?: string; + orderId?: string; + tpslType?: SpotTPSLTypeV2; + requestTime?: string; + receiveWindow?: string; } - -================ -File: src/types/response/v2/common.ts -================ -/** - * - * * Common | Notice - * - */ ⋮---- -export interface AnnouncementV2 { - annId: string; - annTitle: string; - annDesc: string; - cTime: string; - language: string; - annUrl: string; +export interface GetSpotFillsRequestV2 { + symbol: string; + orderId?: string; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; } ⋮---- /** * - * * Common | Public + * * Spot | Trigger Orders * */ ⋮---- -/** - * - * * Common | Tax - * - */ +export type SpotPlanTypeV2 = 'amount' | 'total'; ⋮---- -export interface SpotTransactionRecordV2 { - id: string; - coin: string; - spotTaxType: string; - amount: string; - fee: string; - balance: string; - ts: string; -} +export type SpotTriggerTypeV2 = 'fill_price' | 'mark_price'; ⋮---- -export interface FuturesTransactionRecordV2 { - id: string; +export interface SpotPlanOrderRequestV2 { symbol: string; - marginCoin: string; - futureTaxType: string; - amount: string; - fee: string; - ts: string; + side: SpotOrderSideV2; + triggerPrice: string; + orderType: SpotOrderTypeV2; + executePrice?: string; + planType?: SpotPlanTypeV2; + size: string; + triggerType: SpotTriggerTypeV2; + clientOid?: string; + force?: SpotOrderForceV2; + stpMode?: SpotSTPModeV2; } ⋮---- -export interface MarginTransactionRecordV2 { - id: string; - coin: string; - marginTaxType: string; - amount: string; - fee: string; - total: string; +export interface SpotModifyPlanOrderRequestV2 { + orderId?: string; + clientOid?: string; + triggerPrice: string; + orderType: SpotOrderTypeV2; + executePrice?: string; + size: string; +} +⋮---- +export interface GetSpotCurrentPlanOrdersRequestV2 { symbol: string; - ts: string; + limit?: string; + idLessThan?: string; + startTime?: string; + endTime?: string; } ⋮---- -export interface P2PMerchantOrdersV2 { - id: string; - coin: string; - p2pTaxType: string; - total: string; - ts: string; +export interface GetSpotHistoryPlanOrdersRequestV2 { + symbol: string; + startTime: string; + endTime: string; + limit?: string; } ⋮---- /** * - * * Common | P2P + * * Spot | Account * */ ⋮---- -export interface P2PMerchantV2 { - registerTime: string; - nickName: string; - isOnline: string; - avgPaymentTime: string; - avgReleaseTime: string; - totalTrades: string; - totalBuy: string; - totalSell: string; - totalCompletionRate: string; - trades30d: string; - sell30d: string; - buy30d: string; - completionRate30d: string; -} +export type SpotBillGroupTypeV2 = + | 'deposit' + | 'withdraw' + | 'transaction' + | 'transfer' + | 'other'; ⋮---- -export interface P2PMerchantInfoV2 { - registerTime: string; - nickName: string; - merchantId: string; - avgPaymentTime: string; - avgReleaseTime: string; - totalTrades: string; - totalBuy: string; - totalSell: string; - totalCompletionRate: string; - trades30d: string; - sell30d: string; - buy30d: string; - completionRate30d: string; - kycStatus: boolean; - emailBindStatus: boolean; - mobileBindStatus: boolean; - email: string; - mobile: string; +export type SpotBusinessTypeV2 = + | 'deposit' + | 'withdraw' + | 'buy' + | 'sell' + | 'deduction of handling fee' + | 'transfer-in' + | 'transfer-out' + | 'rebate rewards' + | 'airdrop rewards' + | 'USDT contract rewards' + | 'mix contract rewards' + | 'system lock' + | 'user lock'; +⋮---- +export type SpotAccountTypeV2 = + | 'spot' + | 'p2p' + | 'coin_futures' + | 'usdt_futures' + | 'usdc_futures' + | 'crossed_margin' + | 'isolated_margin'; +⋮---- +export interface GetSpotAccountBillsRequestV2 { + coin?: string; + groupType?: SpotBillGroupTypeV2; + businessType?: SpotBusinessTypeV2; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; } ⋮---- -export interface P2PMerchantOrderV2 { - orderId: string; - orderNo: string; - advNo: string; - side: string; - count: string; - coin: string; - price: string; - fiat: string; - withdrawTime: string; - representTime: string; - releaseTime: string; - paymentTime: string; +export interface SpotTransferRequestV2 { + fromType: SpotAccountTypeV2; + toType: SpotAccountTypeV2; amount: string; - status: string; - buyerRealName: string; - sellerRealName: string; - ctime: string; - utime: string; - paymentInfo: { - paymethodName: string; - paymethodId: string; - paymethodInfo: { - name: string; - required: string; - type: string; - value: string; - }[]; - }; + coin: string; + symbol: string; + clientOid?: string; } ⋮---- -export interface P2PMerchantAdvertismentV2 { - advId: string; - advNo: string; - side: string; - advSize: string; - size: string; +export interface SpotSubAccountTransferRequestV2 { + fromType: SpotAccountTypeV2; + toType: SpotAccountTypeV2; + amount: string; coin: string; - price: string; - coinPrecision: string; - fiat: string; - fiatPrecision: string; - fiatSymbol: string; - status: string; - hide: string; - maxTradeAmount: string; - minTradeAmount: string; - payDuration: string; - turnoverNum: string; - turnoverRate: string; - label: string | null; - userLimitList: { - minCompleteNum: string; - maxCompleteNum: string; - placeOrderNum: string; - allowMerchantPlace: string; - completeRate30d: string; - country: string; - }; - paymentMethodList: { - paymentMethod: string; - paymentId: string; - paymentInfo: { - name: string; - required: boolean; - type: string; - }[]; - }[]; - merchantCertifiedList: { - imageUrl: string; - desc: string; - }[]; - utime: string; - ctime: string; + symbol?: string; + clientOid?: string; + fromUserId: string; + toUserId: string; } ⋮---- -/** - * - * * Common | Trading insights - * - */ -⋮---- -export interface SpotWhaleNetFlowV2 { - volume: string; - date: string; +export interface SpotWithdrawalRequestV2 { + coin: string; + transferType: 'on_chain' | 'internal_transfer'; + address: string; + chain?: string; + innerToType?: 'email' | 'mobile' | 'uid'; + areaCode?: string; + tag?: string; + size: string; + remark?: string; + clientOid?: string; } ⋮---- -export interface FuturesActiveBuySellVolumeV2 { - buyVolume: string; - sellVolume: string; - ts: string; +export interface SpotMainSubTransferRecordRequestV2 { + coin?: string; + role?: 'initiator' | 'receiver'; + subUid?: string; + startTime?: string; + endTime?: string; + clientOid?: string; + limit?: string; + idLessThan?: string; } ⋮---- -export interface FuturesActiveLongShortPositionV2 { - longPositionRatio: string; - shortPositionRatio: string; - longShortPositionRatio: string; - ts: string; +export interface GetSpotTransferRecordRequestV2 { + coin: string; + fromType: SpotAccountTypeV2; + startTime?: string; + endTime?: string; + clientOid?: string; + limit?: string; + idLessThan?: string; } ⋮---- -export interface LeveragedLongShortRatioV2 { - ts: string; - longShortRatio: string; -} -⋮---- -export interface MarginLoanGrowthRateV2 { - ts: string; - growthRate: string; -} -⋮---- -export interface IsolatedMarginBorrowingRatioV2 { - ts: string; - borrowRate: string; -} -⋮---- -export interface FuturesLongShortRatioV2 { - longRatio: string; - shortRatio: string; - longShortRatio: string; - ts: string; +export interface GetSpotSubAccountDepositRecordRequestV2 { + subUid: string; + coin?: string; + startTime?: string; + endTime?: string; + idLessThan?: string; + limit?: string; } ⋮---- -export interface SpotFundFlowV2 { - whaleBuyVolume: string; - dolphinBuyVolume: string; - fishBuyVolume: string; - whaleSellVolume: string; - dolphinSellVolume: string; - fishSellVolume: string; - whaleBuyRatio: string; - dolphinBuyRatio: string; - fishBuyRatio: string; - whaleSellRatio: string; - dolphinSellRatio: string; - fishSellRatio: string; +export interface GetSpotWithdrawalRecordRequestV2 { + coin?: string; + clientOid?: string; + startTime: string; + endTime: string; + idLessThan?: string; + orderId?: string; + limit?: string; } ⋮---- -export interface FuturesActiveLongShortAccountV2 { - longAccountRatio: string; - shortAccountRatio: string; - longShortAccountRatio: string; - ts: string; +export interface GetSpotDepositRecordRequestV2 { + coin?: string; + orderId?: string; + startTime: string; + endTime: string; + idLessThan?: string; + limit?: string; } -⋮---- + +================ +File: src/types/request/v3/affiliate.ts +================ /** * - * * Common | Virtual Subaccount + * + * Affiliate + * * */ ⋮---- -export interface CreateVirtualSubAccountV2 { - failureList: { - subaAccountName: string; - }[]; - successList: { - subaAccountUid: string; - subaAccountName: string; - status: string; - label: string; - permList: string[]; - cTime: string; - uTime: string; - }[]; +export interface AgentCustomerListRequestV3 { + startTime?: string; + endTime?: string; + pageNo?: string; + pageSize?: string; + uid?: string; + referralCode?: string; } ⋮---- -export interface CreateVirtualSubAccountAndApiKeyV2 { - subAccountUid: string; - subAccountName: string; - label: string; - subAccountApiKey: string; - secretKey: string; - permList: string[]; - ipList: string[]; +export interface AgentCustomerAssetRequestV3 { + pageNo?: string; + pageSize?: string; + uid?: string; + showSub?: 'yes' | 'no'; } ⋮---- -export interface VirtualSubAccountV2 { - subAccountUid: string; - subAccountName: string; - status: string; - permList: string[]; - label: string; - accountType: string; - bindingTime: string; - cTime: string; - uTime: string; +export interface AgentCustomerTradeVolumeRequestV3 { + startTime?: string; + endTime?: string; + pageNo?: string; + pageSize?: string; + uid?: string; + showSub?: 'yes' | 'no'; } ⋮---- -export interface CreateVirtualSubAccountApiKeyV2 { - subAccountUid: string; - label: string; - subAccountApiKey: string; - secretKey: string; - permList: string[]; - ipList: string[]; +export interface AgentCustomerDepositRequestV3 { + startTime?: string; + endTime?: string; + pageNo?: string; + pageSize?: string; + uid?: string; + showSub?: 'yes' | 'no'; } ⋮---- -export interface ModifyVirtualSubAccountApiKeyV2 { - subAccountUid: string; - label: string; - subAccountApiKey: string; - secretKey: string; - permList: string[]; - ipList: string[]; +export interface GetAgentCustomerKycResultRequestV3 { + startTime?: string; + endTime?: string; + /** Pass endId from the previous response. Omit on the first page. */ + cursor?: string; + limit?: string; + uid?: string; + showSub?: 'yes' | 'no'; } ⋮---- -export interface CreateAgentSubaccountV2 { - username: string; - subUid: string; - apiKey: string; - secret: string; - note: string; - createdTime: string; -} +/** Pass endId from the previous response. Omit on the first page. */ ⋮---- -export interface SubAccountApiKeyItemV2 { - subAccountUid: string; - label: string; - subAccountApiKey: string; - permList: string[]; - ipList: string[]; +export interface GetAgentCustomerCommissionsRequestV3 { + startTime?: string; + endTime?: string; + /** Pass endId from the previous response. Omit on the first page. */ + cursor?: string; + limit?: string; + uid?: string; + coin?: string; + symbol?: string; + showSub?: 'yes' | 'no'; } ⋮---- -/** - * - * * Common | Assets - * - */ -⋮---- -export interface FundingAssetV2 { - coin: string; - available: string; - frozen: string; - usdtValue: string; -} +/** Pass endId from the previous response. Omit on the first page. */ ⋮---- -export interface BotAssetV2 { - coin: string; - available: string; - equity: string; - bonus: string; - frozen: string; - usdtValue: string; +export interface GetAgentSubCustomerListRequestV3 { + startTime?: string; + endTime?: string; + /** Pass minId from the previous response. Omit on the first page. */ + cursor?: string; + limit?: string; + uid?: string; + showSub?: 'yes' | 'no'; } ⋮---- -/** - * - * * Common | Convert - * - */ +/** Pass minId from the previous response. Omit on the first page. */ ⋮---- -export interface ConvertCurrencyV2 { - coin: string; - available: string; - maxAmount: string; - minAmount: string; +export interface GetSubAffiliateInfoRequestV3 { + uid?: string; + startTime?: string; + endTime?: string; + /** Pass endId from the previous response. Omit on the first page. */ + idLessThan?: string; + limit?: string; + includeDownLine?: 'yes' | 'no'; } ⋮---- -export interface ConvertQuotedPriceV2 { - fee: string; - fromCoinSize: string; - fromCoin: string; - cnvtPrice: string; - toCoinSize: string; - toCoin: string; - traceId: string; -} +/** Pass endId from the previous response. Omit on the first page. */ ⋮---- -export interface ConvertTradeResponseV2 { - ts: string; - cnvtPrice: string; - toCoinSize: string; - toCoin: string; +export interface GetSubAffiliateCommissionRequestV3 { + startTime?: string; + endTime?: string; + limit?: string; + /** Pass endId from the previous response. Omit on the first page. */ + cursor?: string; } ⋮---- -export interface ConvertRecordV2 { - id: string; - ts: string; - cnvtPrice: string; - fee: string; - fromCoinSize: string; - fromCoin: string; - toCoinSize: string; - toCoin: string; -} +/** Pass endId from the previous response. Omit on the first page. */ + +================ +File: src/types/request/v3/grid.ts +================ +export type GridCategoryV3 = 'SPOT' | 'USDT-FUTURES' | 'USDC-FUTURES'; ⋮---- -/** - * - * * Common | BGB Convert - * - */ +export type NeutralGridCategoryV3 = 'USDT-FUTURES' | 'USDC-FUTURES'; ⋮---- -export interface BGBConvertCoinV2 { - coin: string; - available: string; - bgbEstAmount: string; - precision: string; - feeDetail: { - feeRate: string; - fee: string; - }[]; - cTime: string; -} +export type GridFundsSourceV3 = 'funding' | 'uta' | 'otc'; ⋮---- -export interface ConvertBGBResponseV2 { - orderList: { - coin: string; - orderId: string; - }[]; -} +export type GridYesNoV3 = 'yes' | 'no'; ⋮---- -export interface BGBConvertHistoryV2 { - orderId: string; - fromCoin: string; - fromAmount: string; - fromCoinPrice: string; - toCoin: string; - toAmount: string; - toCoinPrice: string; - feeDetail: { - feeCoin: string; - fee: string; - }[]; - status: string; - ctime: string; -} - -================ -File: src/types/response/v2/earn.ts -================ -/** - * - * - * Earn | Savings - * - * - */ +export type GridOrderModeV3 = 'arithmetic' | 'geometric'; ⋮---- -export interface EarnSavingsProductsV2 { - productId: string; - coin: string; - periodType: string; - period: string; - apyType: string; - advanceRedeem: string; - settleMethod: string; - apyList: { - rateLevel: string; - minStepVal: string; - maxStepVal: string; - currentApy: string; - }[]; - status: string; - productLevel: string; -} +export type GridTypeV3 = 'long' | 'short' | 'neutral' | 'netural'; ⋮---- -export interface EarnSavingsAccountV2 { - btcAmount: string; - usdtAmount: string; - btc24hEarning: string; - usdt24hEarning: string; - btcTotalEarning: string; - usdtTotalEarning: string; -} +export type GridTriggerConditionV3 = 'instant' | 'price' | 'rsi' | 'boll'; ⋮---- -export interface EarnSavingsAssetV2 { - productId: string; - orderId: string; - productCoin: string; - interestCoin: string; - periodType: string; - period: string; - holdAmount: string; - lastProfit: string; - totalProfit: string; - holdDays: string; - status: string; - allowRedemption: string; - productLevel: string; - apy: { - rateLevel: string; - minApy: string; - maxApy: string; - currentApy: string; - }[]; -} +export type GridTerminationConditionV3 = 'rsi' | 'boll'; ⋮---- -export interface EarnSavingsAssetsV2 { - resultList: EarnSavingsAssetV2[]; - endId: string; -} +export type GridAdjustTypeV3 = 'increase' | 'decrease'; ⋮---- -export interface EarnSavingsRecordV2 { - orderId: string; - coinName: string; - settleCoinName: string; - productType: string; - period: string; - productLevel: string; +export interface GridInvestmentAmountV3 { + coin: string; amount: string; - ts: string; - orderType: string; } ⋮---- -export interface EarnSavingsRecordsV2 { - resultList: EarnSavingsRecordV2[]; - endId: string; +export interface GridIndicatorParamsV3 { + indicatorLength?: string; + threshold?: string; + multiplier?: string; + interval?: string; } ⋮---- -export interface EarnSavingsSubscriptionDetailV2 { - singleMinAmount: string; - singleMaxAmount: string; - remainingAmount: string; - subscribePrecision: string; - profitPrecision: string; - subscribeTime: string; - interestTime: string; - settleTime: string; - expireTime: string; - redeemTime: string; - settleMethod: string; - apyList: { - rateLevel: string; - minStepVal: string; - maxStepVal: string; - currentApy: string; - }[]; - redeemDelay: string; +export interface GridBotIdRequestV3 { + botId: string; } ⋮---- -/** - * - * - * Earn | Earn Account - * - * - */ -⋮---- -/** - * - * - * Earn | Shark Fin - * - * - */ -⋮---- -export interface EarnSharkfinProductV2 { - productId: string; - productName: string; - productCoin: string; - subscribeCoin: string; - farmingStartTime: string; - farmingEndTime: string; - lowerRate: string; - defaultRate: string; - upperRate: string; - period: string; - interestStartTime: string; - status: string; - minAmount: string; - limitAmount: string; - soldAmount: string; - endTime: string; - startTime: string; +export interface GetGridBotDetailRequestV3 { + botId: string; } ⋮---- -export interface EarnSharkfinProductsV2 { - resultList: EarnSharkfinProductV2[]; - endId: string; +export interface GetGridBotOrderDetailsRequestV3 { + category: GridCategoryV3; + botId: string; } ⋮---- -export interface EarnSharkfinAccountV2 { - btcSubscribeAmount: string; - usdtSubscribeAmount: string; - btcHistoricalAmount: string; - usdtHistoricalAmount: string; - btcTotalEarning: string; - usdtTotalEarning: string; +export interface CloseGridBotRequestV3 { + botId: string; } ⋮---- -export interface EarnSharkfinAssetV2 { - productId: string; - interestStartTime: string; - interestEndTime: string; - productCoin: string; - subscribeCoin: string; - trend: string; - settleTime: string; - interestAmount: string; - productStatus: string; +export interface AddGridInvestmentRequestV3 { + category: GridCategoryV3; + botId: string; + coin?: string; + size?: string; + fundsSource: GridFundsSourceV3[]; + adjustType?: GridAdjustTypeV3; + reinvestProfit?: GridYesNoV3; } ⋮---- -export interface EarnSharkfinAssetsV2 { - resultList: EarnSharkfinAssetV2[]; - endId: string; +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 interface EarnSharkfinRecordV2 { - orderId: string; - product: string; - period: string; - amount: string; - ts: string; - type: string; -} -export interface EarnSharkfinRecordsV2 { - resultList: EarnSharkfinRecordV2[]; - endId: string; +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 EarnSharkfinSubscriptionDetailV2 { - productCoin: string; - subscribeCoin: string; - interestTime: string; - expirationTime: string; +export interface ModifyGridIntervalRequestV3 { + category: GridCategoryV3; + botId: string; + maxPrice: string; minPrice: string; - currentPrice: string; + gridNum: string; +} +⋮---- +export interface CreateNeutralGridBotRequestV3 { + category: NeutralGridCategoryV3; + symbol: string; maxPrice: string; - minRate: string; - defaultRate: string; - maxRate: string; - period: string; - productMinAmount: string; - availableBalance: string; - userAmount: string; - remainingAmount: string; - profitPrecision: string; - subscribePrecision: string; + minPrice: string; + gridNum: string; + gridOrderMode: GridOrderModeV3; + fundsSource?: GridFundsSourceV3[]; + leverage?: string; + investmentAmount: GridInvestmentAmountV3[]; + triggerPrice?: string; + stopLoss?: string; + takeProfit?: string; + autoTransferProfits?: GridYesNoV3; } ⋮---- -/** - * - * - * Earn | Loan - * - * - */ +export type ValidateNeutralGridBotRequestV3 = CreateNeutralGridBotRequestV3; ⋮---- -export interface EarnLoanCurrencyLoanInfoV2 { - coin: string; - hourRate7D: string; - rate7D: string; - hourRate30D: string; - rate30D: string; - minUsdt: string; - maxUsdt: string; - min: string; - max: string; +export interface ModifyNeutralGridBotRequestV3 { + botId: string; + category: NeutralGridCategoryV3; + takeProfit?: string; + stopLoss?: string; + autoTransferProfits?: GridYesNoV3; } -export interface EarnLoanCurrencyPledgeInfoV2 { - coin: string; - initRate: string; - supRate: string; - forceRate: string; - minUsdt: string; - maxUsdt: string; +⋮---- +export interface ModifyNeutralGridIntervalRequestV3 { + category: NeutralGridCategoryV3; + botId: string; + maxPrice: string; + minPrice: string; + gridNum: string; } ⋮---- -export interface EarnLoanCurrenciesV2 { - loanInfos: EarnLoanCurrencyLoanInfoV2[]; - pledgeInfos: EarnLoanCurrencyPledgeInfoV2[]; +export interface GetNeutralGridBotDetailRequestV3 { + botId: string; } ⋮---- -export interface EarnLoanOrdersV2 { - orderId: string; - loanCoin: string; - loanAmount: string; - interestAmount: string; - hourInterestRate: string; - pledgeCoin: string; - pledgeAmount: string; - pledgeRate: string; - supRate: string; - forceRate: string; - borrowTime: string; - expireTime: string; +export interface GetNeutralGridBotOrderDetailsRequestV3 { + category: NeutralGridCategoryV3 | GridCategoryV3; + botId: string; +} + +================ +File: src/types/request/v3/loan.ts +================ +export interface GetTransferedRequestV3 { + userId?: string; + coin: string; } ⋮---- -export interface EarnLoanRepayResponseV2 { - loanCoin: string; - pledgeCoin: string; - repayAmount: string; - payInterest: string; - repayLoanAmount: string; - repayUnlockAmount: string; +export interface GetSymbolsRequestV3 { + productId: string; } ⋮---- -export interface EarnLoanRepayHistoryV2 { - orderId: string; - loanCoin: string; - pledgeCoin: string; - repayAmount: string; - payInterest: string; - repayLoanAmount: string; - repayUnlockAmount: string; - repayTime: string; +export interface GetRepaidHistoryRequestV3 { + startTime?: string; + endTime?: string; + limit?: string; } ⋮---- -export interface EarnLoanPledgeRateHistoryV2 { - loanCoin: string; - pledgeCoin: string; - orderId: string; - reviseTime: string; - reviseSide: string; - reviseAmount: string; - afterPledgeRate: string; - beforePledgeRate: string; +export interface GetProductInfosRequestV3 { + productId: string; } ⋮---- -export interface EarnLoanHistoryV2 { - orderId: string; - loanCoin: string; - pledgeCoin: string; - initPledgeAmount: string; - initLoanAmount: string; - hourRate: string; - daily: string; - borrowTime: string; - status: string; +export interface GetLoanOrderRequestV3 { + orderId?: string; + startTime?: string; + endTime?: string; } ⋮---- -export interface EarnLoanDebtPledgeInfoV2 { - coin: string; - amount: string; - amountUsdt: string; +export interface GetEnsureCoinsRequestV3 { + productId: string; } ⋮---- -export interface EarnLoanDebtLoanInfoV2 { - coin: string; - amount: string; - amountUsdt: string; +export interface BindUidRequestV3 { + riskUnitId?: string; + uid: string; + operate: 'bind' | 'unbind'; } ⋮---- -export interface EarnLoanDebtsV2 { - pledgeInfos: EarnLoanDebtPledgeInfoV2[]; - loanInfos: EarnLoanDebtLoanInfoV2[]; +export interface GetLTVConvertRequestV3 { + riskUnitId?: string; } ⋮---- -export interface EarnLoanLiquidationRecordsV2 { - orderId: string; +/* Unified Account Staking & Lending (Crypto Loans) - /api/v3/loan/* */ +⋮---- +export interface GetLoanCoinsRequestV3 { + coin?: string; +} +⋮---- +export interface GetLoanInterestRequestV3 { loanCoin: string; pledgeCoin: string; - reduceTime: string; - pledgeRate: string; - pledgePrice: string; - status: string; + daily: 'SEVEN' | 'THIRTY' | 'FLEXIBLE'; pledgeAmount: string; - reduceFee: string; - residueAmount: string; - runlockAmount: string; - repayLoanAmount: string; } ⋮---- -/** - * - * - * Earn | On-Chain Elite - * - * - */ +export interface LoanBorrowRequestV3 { + loanCoin: string; + pledgeCoin: string; + daily: 'SEVEN' | 'THIRTY' | 'FLEXIBLE'; + pledgeAmount?: string; + loanAmount?: string; +} ⋮---- -export interface EarnEliteSubscriptionCoinV2 { - subscriptionCoin: string; - precision: string; - feeRate: string; - exchangeRate: string; - remainQuota?: string; - minAmount?: string; +export interface GetLoanBorrowOngoingRequestV3 { + orderId?: string; + loanCoin?: string; + pledgeCoin?: string; } ⋮---- -export interface EarnEliteProductV2 { - productId: string; - coin: string; - minApr: string; - maxApr: string; - subscriptionCoinList: EarnEliteSubscriptionCoinV2[]; - sellOut: 'YES' | 'NO' | string; +export interface GetLoanBorrowHistoryRequestV3 { + orderId?: string; + loanCoin?: string; + pledgeCoin?: string; + status?: 'ROLLBACK' | 'FORCE' | 'REPAY'; + startTime: string; + endTime: string; + pageNum?: string; + pageSize?: string; } ⋮---- -export interface EarnEliteAssetProjectV2 { - projectName: string; +export interface LoanRepayRequestV3 { + orderId: string; + method: 'borrowed_coin' | 'collateral'; + repayAll: 'yes' | 'no'; + amount?: string; + repayUnlock?: 'yes' | 'no'; } ⋮---- -export interface EarnEliteAssetV2 { - productId: string; - productCoin: string; - holdingAmount: string; - usdtHoldingAmount: string; - exchangeRate: string; - apr: string; - minApy?: string; - maxApy?: string; - subscriptionCoin: string; - exchangeAmount: string; - projectList?: EarnEliteAssetProjectV2[]; - unsettledBGPoints: string; - interestCoin: string; - totalProfit: string; +export interface GetLoanRepayHistoryRequestV3 { + orderId?: string; + loanCoin?: string; + pledgeCoin?: string; + startTime: string; + endTime: string; + pageNum?: string; + pageSize?: string; } ⋮---- -export interface EarnEliteAssetsV2 { - resultList: EarnEliteAssetV2[]; +export interface LoanRevisePledgeRequestV3 { + orderId: string; + amount: string; + pledgeCoin: string; + reviseType?: 'OUT' | 'IN'; } ⋮---- -export interface EarnEliteRecordV2 { - recordId: string; - productId: string; - coin: string; - status: string; - exchangeRate: string; - receivedCoin: string; - receivedAmount: string; - investAmount: string; - feeRate: string; - redeemType?: string | string[]; - receivingAccount: string; - actualReceivingAccount: string; - paymentAccount?: string[]; - settlePoints: string; - fee: string; +export interface GetLoanPledgeRateHistoryRequestV3 { + orderId?: string; + reviseSide?: 'down' | 'up'; + pledgeCoin?: string; + startTime: string; + endTime: string; + pageNum?: string; + pageSize?: string; } ⋮---- -export interface EarnEliteRecordsV2 { - recordList: EarnEliteRecordV2[]; - endId: string; +export interface GetLoanReducesRequestV3 { + orderId?: string; + loanCoin?: string; + pledgeCoin?: string; + status?: 'COMPLETE' | 'WAIT'; + startTime: string; + endTime: string; + pageNum?: string; + pageSize?: string; } + +================ +File: src/types/request/v3/p2p.ts +================ +export type P2pSideV3 = 'buy' | 'sell'; ⋮---- -export interface EarnEliteSubscribeInfoV2 { - productSubId: string; - minAmount: string; - remainQuota: string; - exchangeRate: string; - productCoin: string; - interestTime: string; - settleTime: string; - precision: string; - feeRate: string; - /** Present for BGUSD per API docs. */ - subscriptionCoinList?: EarnEliteSubscriptionCoinV2[]; +export type P2pPriceTypeV3 = 'fixed' | 'floating'; +⋮---- +export type P2pMarketTypeV3 = 'public' | 'private'; +⋮---- +export type P2pAdStatusV3 = 'publish' | 'delist' | 'remove'; +⋮---- +export type P2pAdOperationV3 = 'publish' | 'delist' | 'remove'; +⋮---- +export type P2pOrderStatusV3 = + | 'pending_payment' + | 'pending_release' + | 'completed' + | 'cancelled' + | 'in_appeal'; +⋮---- +export interface P2pPayMethodIdRefV3 { + payMethodId: string; + userPayMethodId?: string; } ⋮---- -/** Present for BGUSD per API docs. */ +export interface GetP2pAdListRequestV3 { + token: string; + fiat: string; + side: P2pSideV3; + amount?: string; + pageNum: string; + limit: string; +} ⋮---- -export interface EarnEliteSubscribeResultV2 { - orderId: string; +export interface GetP2pExchangeRateRequestV3 { + token: string; + fiat: string; } ⋮---- -export interface EarnEliteSubscribeStatusV2 { - result: 'settled' | 'pending' | 'rejected' | string; +export interface P2pFeeSimulateRequestV3 { + token: string; + fiat: string; + side: P2pSideV3; + marketType: P2pMarketTypeV3; + amount: string; } ⋮---- -export interface EarnEliteRedeemInfoBgusdReceiveCoinV2 { - bgusdReceiveCoin: string; - bgusdExchangeRate: string; +export interface GetP2pAdLimitRequestV3 { + token: string; + fiat: string; + side: P2pSideV3; } ⋮---- -export interface EarnEliteRedeemModeV2 { - redeemFeeRate: string; - remainQuota: string; - redeemType: 'fast' | 'standard' | string; - redeemScale: string; - redeemDelayDate: string; - minRedeemAmount: string; - redeemTime: string; +export interface CreateP2pAdRequestV3 { + token: string; + fiat: string; + side: P2pSideV3; + priceType: P2pPriceTypeV3; + price?: string; + premium?: string; + minAmount: string; + maxAmount: string; + quantity: string; + payMethodIds: P2pPayMethodIdRefV3[]; + remark?: string; + tradeTerms?: string; + payTimeLimit: string; } ⋮---- -export interface EarnEliteRedeemInfoV2 { - productId: string; - productSubId: string; - productCoin: string; - subscriptionCoin: string; - profitCoin: string; - exchangeRate: string; - totalUnPayInterestAmount: string; - preSettleApr: string; - receivedCoin: string; - unsettledPoints: string; - bgusdReceiveCoinList: EarnEliteRedeemInfoBgusdReceiveCoinV2[]; - redeemModeList: EarnEliteRedeemModeV2[]; +export interface UpdateP2pAdRequestV3 { + advId: string; + priceType?: P2pPriceTypeV3; + price?: string; + premium?: string; + minAmount?: string; + maxAmount?: string; + quantity?: string; + payMethodIds?: P2pPayMethodIdRefV3[]; + payTimeLimit?: string; + remark?: string; + tradeTerms?: string; } ⋮---- -export interface RedeemEarnEliteResultV2 { - orderId: string; +export interface OperateP2pAdRequestV3 { + advId: string; + operation: P2pAdOperationV3; } - -================ -File: src/types/response/v2/instloan.ts -================ -export interface InstLoanProductInfoV2 { - productId: string; - leverage: string; - transferLine: string; - spotBuyLine: string; - liquidationLine: string; - stopLiquidationLine: string; +⋮---- +export interface GetP2pAdInfoRequestV3 { + advId: string; } ⋮---- -export interface InstLoanSymbolsV2 { - productId: string; - spotSymbols: string[]; +export interface GetP2pMyAdsRequestV3 { + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; + advId?: string; + token?: string; + fiat?: string; + status?: P2pAdStatusV3; } ⋮---- -export interface InstLoanRepaidHistoryItemV2 { - repayOrderId: string; - businessType: string; - repayType: string; - repaidTime: string; - coin: string; - repaidAmount: string; - repaidInterest: string; +export interface GetP2pPendingOrdersRequestV3 { + orderId?: string; + side?: P2pSideV3; + startTime?: string; + endTime?: string; + cursor?: string; + limit?: string; } ⋮---- -export interface InstLoanOrderV2 { +export interface GetP2pAllOrdersRequestV3 { + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; + orderId?: string; + side?: P2pSideV3; + status?: P2pOrderStatusV3; +} +⋮---- +export interface GetP2pOrderInfoRequestV3 { orderId: string; - orderProductId: string; - uid: string; - loanTime: string; - loanCoin: string; - loanAmount: string; - unpaidAmount: string; - unpaidInterest: string; - repaidAmount: string; - repaidInterest: string; - status: string; } ⋮---- -export interface InstLoanCoinInfoV2 { - coin: string; - convertRatio: string; - maxConvertValue: string; +export interface P2pOrderActionRequestV3 { + orderId: string; } ⋮---- -export interface InstLoanLTVConvertV2 { - ltv: string; - subAccountUids: string[]; - unpaidUsdtAmount: string; - usdtBalance: string; - unpaidInfo: { - coin: string; - unpaidQty: string; - unpaidInterest: string; - }[]; - balanceInfo: { - coin: string; - price: string; - amount: string; - convertedUsdtAmount: string; - }[]; +export interface GetP2pBalanceRequestV3 { + token: string; } ================ -File: src/types/response/v3/affiliate.ts +File: src/types/request/v3/reality.ts ================ -/** - * - * - * Affiliate - * https://www.bitget.com/docs/catalog/affiliate/affiliate - * - * - */ -⋮---- -export interface AgentCustomerListItemV3 { - uid: string; - registerTime: string; +export interface GetRealityCompanyOverviewRequestV3 { + code: string; } ⋮---- -export interface AgentCustomerAssetItemV3 { - uid: string; - balance: string; - uTime: string; - remark: string; +export interface GetRealityValuationIndicatorsRequestV3 { + code: string; } ⋮---- -export interface AgentCustomerTradeVolumeItemV3 { - uid: string; - /** API field name (Bitget spelling). */ - volumn: string; - spotVolume: string; - futuresVolume: string; - time: string; +export interface GetRealityEarningsForecastRequestV3 { + code: string; } ⋮---- -/** API field name (Bitget spelling). */ -⋮---- -export interface AgentCustomerDepositItemV3 { - uid: string; - orderId: string; - depositTime: string; - depositCoin: string; - depositAmount: string; +export interface GetRealitySuspensionResumptionInfoRequestV3 { + code: string; } ⋮---- -export interface AgentCustomerKycResultItemV3 { - uid: string; - kycResult: 'passed' | 'not_passed'; +export interface GetRealityDividendsRequestV3 { + code: string; + limit?: string; + cursor?: string; } ⋮---- -/** Pagination wrapper follows the documented response example. */ -export interface AgentCustomerKycResultV3 { - userList: AgentCustomerKycResultItemV3[]; - endId: string; +export interface GetRealityShareCapitalChangeRequestV3 { + code: string; } ⋮---- -export interface AgentCustomerCommissionV3 { - uid: string; - date: string; - coin: string; - symbol: string; - productType: string; - dealAmount: string; - fee: string; - feeDeduction: string; - activityBonusDeduct: string; - spotCouponDeduct: string; - futuresCouponDeduct: string; - spotFeeDiscountDeduct: string; - negativeMakerFeeDeduct: string; - feePaid: string; - rebateAmount: string; - userTotalRebateAmount: string; - dayTotalRebateAmount: string; - totalRebateAmount: string; +export interface GetRealityInnerTradesRequestV3 { + code: string; + limit?: string; + cursor?: string; } ⋮---- -export interface AgentCustomerCommissionsV3 { - commissionList: AgentCustomerCommissionV3[]; - endId: string; +export interface GetRealityExecutiveShareholdingsRequestV3 { + code: string; + limit?: string; + cursor?: string; } ⋮---- -/** Pagination wrapper follows the documented response example. */ -export interface AgentSubCustomerListV3 { - list: AgentCustomerListItemV3[]; - minId: string; +export interface GetRealityShareholdDetailRequestV3 { + code: string; + limit?: string; + cursor?: string; } ⋮---- -export interface SubAffiliateRebateRateV3 { - rebateType: string; - rebateRate: string; +export interface GetRealityStockInfoRequestV3 { + symbol?: string; } + +================ +File: src/types/response/v2/common.ts +================ +/** + * + * * Common | Notice + * + */ ⋮---- -export interface SubAffiliateInfoItemV3 { - uid: string; - uplineName: string; - rebateRateList: SubAffiliateRebateRateV3[]; - verificationStatus: string; - directReferrals: string; - subAffiliates: string; - subAffiliateDirectReferrals: string; - volume: string; - deposit: string; - transactionFee: string; - rebate: string; +export interface AnnouncementV2 { + annId: string; + annTitle: string; + annDesc: string; + cTime: string; + language: string; + annUrl: string; } ⋮---- -export interface SubAffiliateInfoV3 { - list: SubAffiliateInfoItemV3[]; - endId: string; -} +/** + * + * * Common | Public + * + */ ⋮---- -export interface SubAffiliateCommissionItemV3 { - uid: string; - bizType: string; - subBizType: string; - symbol: string; +/** + * + * * Common | Tax + * + */ +⋮---- +export interface SpotTransactionRecordV2 { + id: string; coin: string; + spotTaxType: string; + amount: string; fee: string; - volume: string; - activityBonusDeduct: string; - spotCouponDeduct: string; - futuresCouponDeduct: string; - spotFeeDiscountDeduct: string; - negativeMakerFeeDeduct: string; - feePaid: string; - directCommission: string; - subCommission: string; - partnerCommission: string; - partnerActualCommission: string; - traderType: string; - apiType: string; - status: string; - startCalculationTime: string; - endCalculationTime: string; + balance: string; + ts: string; } ⋮---- -export interface SubAffiliateCommissionV3 { - commissionList: SubAffiliateCommissionItemV3[]; - endId: string; +export interface FuturesTransactionRecordV2 { + id: string; + symbol: string; + marginCoin: string; + futureTaxType: string; + amount: string; + fee: string; + ts: string; } - -================ -File: src/types/response/v3/grid.ts -================ -import type { GridIndicatorParamsV3 } from '../../request/v3/grid.js'; ⋮---- -export interface GridBotIdResponseV3 { - botId: string; +export interface MarginTransactionRecordV2 { + id: string; + coin: string; + marginTaxType: string; + amount: string; + fee: string; + total: string; + symbol: string; + ts: string; } ⋮---- -export interface GridValidateResponseV3 { - valid: string; - reason?: string; - minInvestment?: string; +export interface P2PMerchantOrdersV2 { + id: string; + coin: string; + p2pTaxType: string; + total: string; + ts: string; } ⋮---- -export interface GridBotOrderItemV3 { - orderId: string; - delegateCount: string; - delegatePrice: string; - changeRequired: number | string; -} +/** + * + * * Common | P2P + * + */ ⋮---- -export interface GridBotOrderDetailsV3 { - botId: string; - symbol: string; - buyOrderList: GridBotOrderItemV3[]; - sellOrderList: GridBotOrderItemV3[]; +export interface P2PMerchantV2 { + registerTime: string; + nickName: string; + isOnline: string; + avgPaymentTime: string; + avgReleaseTime: string; + totalTrades: string; + totalBuy: string; + totalSell: string; + totalCompletionRate: string; + trades30d: string; + sell30d: string; + buy30d: string; + completionRate30d: string; } ⋮---- -export interface 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 P2PMerchantInfoV2 { + registerTime: string; + nickName: string; + merchantId: string; + avgPaymentTime: string; + avgReleaseTime: string; + totalTrades: string; + totalBuy: string; + totalSell: string; + totalCompletionRate: string; + trades30d: string; + sell30d: string; + buy30d: string; + completionRate30d: string; + kycStatus: boolean; + emailBindStatus: boolean; + mobileBindStatus: boolean; + email: string; + mobile: string; } ⋮---- -export interface 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/loan.ts -================ -export interface LoanTransfersV3 { +export interface P2PMerchantOrderV2 { + orderId: string; + orderNo: string; + advNo: string; + side: string; + count: string; coin: string; - transfered: string; - userId: string; + price: string; + fiat: string; + withdrawTime: string; + representTime: string; + releaseTime: string; + paymentTime: string; + amount: string; + status: string; + buyerRealName: string; + sellerRealName: string; + ctime: string; + utime: string; + paymentInfo: { + paymethodName: string; + paymethodId: string; + paymethodInfo: { + name: string; + required: string; + type: string; + value: string; + }[]; + }; } ⋮---- -export interface LoanSymbolSettingV3 { - symbol: string; - leverage: string; +export interface P2PMerchantAdvertismentV2 { + advId: string; + advNo: string; + side: string; + advSize: string; + size: string; + coin: string; + price: string; + coinPrecision: string; + fiat: string; + fiatPrecision: string; + fiatSymbol: string; + status: string; + hide: string; + maxTradeAmount: string; + minTradeAmount: string; + payDuration: string; + turnoverNum: string; + turnoverRate: string; + label: string | null; + userLimitList: { + minCompleteNum: string; + maxCompleteNum: string; + placeOrderNum: string; + allowMerchantPlace: string; + completeRate30d: string; + country: string; + }; + paymentMethodList: { + paymentMethod: string; + paymentId: string; + paymentInfo: { + name: string; + required: boolean; + type: string; + }[]; + }[]; + merchantCertifiedList: { + imageUrl: string; + desc: string; + }[]; + utime: string; + ctime: string; } ⋮---- -export interface LoanSymbolsV3 { - productId: string; - spotSymbols: string[]; - marginLeverage: string; - usdtContractLeverage: string; - coinContractLeverage: string; - usdcContractLeverage: string; - usdtContractSymbols: LoanSymbolSettingV3[]; - coinContractSymbols: LoanSymbolSettingV3[]; - usdcContractSymbols: LoanSymbolSettingV3[]; -} +/** + * + * * Common | Trading insights + * + */ ⋮---- -export interface RepaidHistoryItemV3 { - repayOrderId: string; - businessType: 'normal' | 'liquidation'; - repayType: 'all' | 'part'; - repaidTime: string; - coin: string; - repayAmount: string; - repayInterest: string; +export interface SpotWhaleNetFlowV2 { + volume: string; + date: 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 FuturesActiveBuySellVolumeV2 { + buyVolume: string; + sellVolume: string; + ts: 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 FuturesActiveLongShortPositionV2 { + longPositionRatio: string; + shortPositionRatio: string; + longShortPositionRatio: string; + ts: string; } ⋮---- -/** Tiered conversion rate item (when Tiered Discount Rate Model is enabled) */ -export interface ConvertRatioListItemV3 { - ladder: string; - convertRatio: string; +export interface LeveragedLongShortRatioV2 { + ts: string; + longShortRatio: 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 MarginLoanGrowthRateV2 { + ts: string; + growthRate: string; } ⋮---- -/** Tiered conversion rate (when margin mode is Tiered Discount Rate Model) */ -⋮---- -export interface BindUidResponseV3 { - riskUnitId: string; - uid: string; - operate: 'bind' | 'unbind'; +export interface IsolatedMarginBorrowingRatioV2 { + ts: string; + borrowRate: string; } ⋮---- -export interface UnpaidInfoV3 { - coin: string; - unpaidQty: string; - unpaidInterest: string; +export interface FuturesLongShortRatioV2 { + longRatio: string; + shortRatio: string; + longShortRatio: string; + ts: string; } ⋮---- -export interface BalanceInfoV3 { - coin: string; - price: string; - amount: string; - convertedUsdtAmount: string; +export interface SpotFundFlowV2 { + whaleBuyVolume: string; + dolphinBuyVolume: string; + fishBuyVolume: string; + whaleSellVolume: string; + dolphinSellVolume: string; + fishSellVolume: string; + whaleBuyRatio: string; + dolphinBuyRatio: string; + fishBuyRatio: string; + whaleSellRatio: string; + dolphinSellRatio: string; + fishSellRatio: string; } ⋮---- -export interface LTVConvertResponseV3 { - ltv: string; - subAccountUids: string[]; - unpaidUsdtAmount: string; - usdtBalance: string; - unpaidInfo: UnpaidInfoV3[]; - balanceInfo: BalanceInfoV3[]; +export interface FuturesActiveLongShortAccountV2 { + longAccountRatio: string; + shortAccountRatio: string; + longShortAccountRatio: string; + ts: string; } ⋮---- -/* Unified Account Staking & Lending (Crypto Loans) - /api/v3/loan/* */ +/** + * + * * Common | Virtual Subaccount + * + */ ⋮---- -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 CreateVirtualSubAccountV2 { + failureList: { + subaAccountName: string; + }[]; + successList: { + subaAccountUid: string; + subaAccountName: string; + status: string; + label: string; + permList: string[]; + cTime: string; + uTime: string; + }[]; } ⋮---- -export interface LoanPledgeInfoV3 { - coin: string; - initRate: string; - supRate: string; - forceRate: string; - minPledgeAmount: string; - maxPledgeAmount: string; +export interface CreateVirtualSubAccountAndApiKeyV2 { + subAccountUid: string; + subAccountName: string; + label: string; + subAccountApiKey: string; + secretKey: string; + permList: string[]; + ipList: string[]; } ⋮---- -export interface GetLoanCoinsResponseV3 { - loanInfos: LoanCoinInfoV3[]; - pledgeInfos: LoanPledgeInfoV3[]; +export interface VirtualSubAccountV2 { + subAccountUid: string; + subAccountName: string; + status: string; + permList: string[]; + label: string; + accountType: string; + bindingTime: string; + cTime: string; + uTime: string; } ⋮---- -export interface GetLoanInterestResponseV3 { - hourInterest: string; - loanAmount: string; +export interface CreateVirtualSubAccountApiKeyV2 { + subAccountUid: string; + label: string; + subAccountApiKey: string; + secretKey: string; + permList: string[]; + ipList: string[]; } ⋮---- -export interface LoanBorrowResponseV3 { - orderId: string; +export interface ModifyVirtualSubAccountApiKeyV2 { + subAccountUid: string; + label: string; + subAccountApiKey: string; + secretKey: string; + permList: string[]; + ipList: 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 CreateAgentSubaccountV2 { + username: string; + subUid: string; + apiKey: string; + secret: string; + note: string; + createdTime: string; } ⋮---- -export interface LoanBorrowHistoryItemV3 { - orderId: string; - loanCoin: string; - pledgeCoin: string; - initPledgeAmount: string; - initLoanAmount: string; - hourRate: string; - daily: string; - borrowTime: string; - status: string; +export interface SubAccountApiKeyItemV2 { + subAccountUid: string; + label: string; + subAccountApiKey: string; + permList: string[]; + ipList: string[]; } ⋮---- -export interface LoanRepayResponseV3 { - loanCoin: string; - pledgeCoin: string; - repayAmount: string; - payInterest: string; - repayLoanAmount: string; - repayUnlockAmount: string; -} +/** + * + * * Common | Assets + * + */ ⋮---- -export interface LoanRepayHistoryItemV3 { - orderId: string; - loanCoin: string; - pledgeCoin: string; - repayAmount: string; - payInterest: string; - repayLoanAmount: string; - repayUnlockAmount: string; - repayTime: string; +export interface FundingAssetV2 { + coin: string; + available: string; + frozen: string; + usdtValue: string; } ⋮---- -export interface LoanRevisePledgeResponseV3 { - loanCoin: string; - pledgeCoin: string; - afterPledgeRate: string; +export interface BotAssetV2 { + coin: string; + available: string; + equity: string; + bonus: string; + frozen: string; + usdtValue: string; } ⋮---- -export interface LoanPledgeRateHistoryItemV3 { - loanCoin: string; - pledgeCoin: string; - orderId: string; - reviseTime: string; - reviseSide: string; - reviseAmount: string; - afterPledgeRate: string; - beforePledgeRate: string; -} +/** + * + * * Common | Convert + * + */ ⋮---- -export interface LoanDebtInfoV3 { +export interface ConvertCurrencyV2 { coin: string; - amount: string; - amountUsdt: string; + available: string; + maxAmount: string; + minAmount: string; } ⋮---- -export interface GetLoanDebtsResponseV3 { - pledgeInfos: LoanDebtInfoV3[]; - loanInfos: LoanDebtInfoV3[]; +export interface ConvertQuotedPriceV2 { + fee: string; + fromCoinSize: string; + fromCoin: string; + cnvtPrice: string; + toCoinSize: string; + toCoin: string; + traceId: string; } ⋮---- -export interface LoanReduceItemV3 { - orderId: string; - loanCoin: string; - pledgeCoin: string; - reduceTime: string; - pledgeRate: string; - pledgePrice: string; - status: string; - pledgeAmount: string; - reduceFee: string; - residueAmount: string; - runlockAmount: string; - repayLoanAmount: string; +export interface ConvertTradeResponseV2 { + ts: string; + cnvtPrice: string; + toCoinSize: string; + toCoin: 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 ConvertRecordV2 { + id: string; + ts: string; + cnvtPrice: string; + fee: string; + fromCoinSize: string; + fromCoin: string; + toCoinSize: string; + toCoin: string; } ⋮---- -export interface P2pPayMethodV3 { - payMethodId: string; - payMethodName: string; - payMethodUserName: string; - userPayMethodId: string; - payMethodInfo: P2pPayMethodInfoFieldV3[]; -} +/** + * + * * Common | BGB Convert + * + */ ⋮---- -export interface P2pTokenDetailV3 { - token: string; +export interface BGBConvertCoinV2 { + coin: string; + available: string; + bgbEstAmount: string; precision: string; + feeDetail: { + feeRate: string; + fee: string; + }[]; + cTime: string; } ⋮---- -export interface P2pFiatPayMethodV3 { - payMethodName: string; - iconUrl: string; - payMethodId: string; -} -⋮---- -export interface P2pWithdrawalLimitV3 { - withdrawLimitKey: string; - withdrawLimitValue: string; +export interface ConvertBGBResponseV2 { + orderList: { + coin: string; + orderId: string; + }[]; } ⋮---- -export interface P2pFiatDetailV3 { - fiat: string; - precision: string; - floatRateMin: string; - floatRateMax: string; - fixedRateMin: string; - fixedRateMax: string; - adMinLimit: string; - adMaxLimit: string; - payMethods: P2pFiatPayMethodV3; - withdrawalLimit: P2pWithdrawalLimitV3; - payTimeLimit: number[]; +export interface BGBConvertHistoryV2 { + orderId: string; + fromCoin: string; + fromAmount: string; + fromCoinPrice: string; + toCoin: string; + toAmount: string; + toCoinPrice: string; + feeDetail: { + feeCoin: string; + fee: string; + }[]; + status: string; + ctime: string; } + +================ +File: src/types/response/v2/earn.ts +================ +/** + * + * + * Earn | Savings + * + * + */ ⋮---- -export interface P2pCurrenciesV3 { - tokenDetailList: P2pTokenDetailV3[]; - fiatDetailList: P2pFiatDetailV3[]; +export interface EarnSavingsProductsV2 { + productId: string; + coin: string; + periodType: string; + period: string; + apyType: string; + advanceRedeem: string; + settleMethod: string; + apyList: { + rateLevel: string; + minStepVal: string; + maxStepVal: string; + currentApy: string; + }[]; + status: string; + productLevel: string; } ⋮---- -export interface P2pUserEquityDetailV3 { - maxAdvSellNum: string; - maxAdvSellLimit: string; - maxAdvBuyNum: string; - maxAdvBuyLimit: string; - totalMaxPendingOrder: string; - advMaxPendingOrder: string; +export interface EarnSavingsAccountV2 { + btcAmount: string; + usdtAmount: string; + btc24hEarning: string; + usdt24hEarning: string; + btcTotalEarning: string; + usdtTotalEarning: string; } ⋮---- -export interface P2pUserInfoV3 { - uid: string; - nickName: string; - accountLevel: 'starter' | 'advanced' | 'master'; - completedOrderNum: string; - positiveRate: string; - completedOrderNum30D: string; - completedRate30D: string; - avgPayTime30D: string; - avgReleaseTime30D: string; - equityDetail: P2pUserEquityDetailV3; - registerTime: string; +export interface EarnSavingsAssetV2 { + productId: string; + orderId: string; + productCoin: string; + interestCoin: string; + periodType: string; + period: string; + holdAmount: string; + lastProfit: string; + totalProfit: string; + holdDays: string; + status: string; + allowRedemption: string; + productLevel: string; + apy: { + rateLevel: string; + minApy: string; + maxApy: string; + currentApy: string; + }[]; } ⋮---- -export interface P2pBalanceV3 { - token: string; - totalBalance: string; - frozenBalance: string; - availableBalance: string; +export interface EarnSavingsAssetsV2 { + resultList: EarnSavingsAssetV2[]; + endId: string; } ⋮---- -export interface P2pExchangeRateV3 { - rate: string; +export interface EarnSavingsRecordV2 { + orderId: string; + coinName: string; + settleCoinName: string; + productType: string; + period: string; + productLevel: string; + amount: string; + ts: string; + orderType: string; } ⋮---- -export interface P2pFeeSimulateV3 { - feeToken: string; - feeAmount: string; - taxToken: string; - taxAmount: string; +export interface EarnSavingsRecordsV2 { + resultList: EarnSavingsRecordV2[]; + endId: string; } ⋮---- -export interface P2pAdLimitV3 { - buyMinTokenAmount: string; - buyMaxTokenAmount: string; - sellMinTokenAmount: string; - sellMaxTokenAmount: string; +export interface EarnSavingsSubscriptionDetailV2 { + singleMinAmount: string; + singleMaxAmount: string; + remainingAmount: string; + subscribePrecision: string; + profitPrecision: string; + subscribeTime: string; + interestTime: string; + settleTime: string; + expireTime: string; + redeemTime: string; + settleMethod: string; + apyList: { + rateLevel: string; + minStepVal: string; + maxStepVal: string; + currentApy: string; + }[]; + redeemDelay: string; } ⋮---- -export interface P2pCreateAdResponseV3 { - advId: string; -} +/** + * + * + * Earn | Earn Account + * + * + */ ⋮---- -export interface P2pAdPayMethodRefV3 { - payMethodId: string; - userPayMethodId?: string; -} +/** + * + * + * Earn | Shark Fin + * + * + */ ⋮---- -export interface P2pAdInfoV3 { - advId: string; - side: P2pSideV3; - priceType: P2pPriceTypeV3; - token: string; - fiat: string; - price: string; - amount: string; +export interface EarnSharkfinProductV2 { + productId: string; + productName: string; + productCoin: string; + subscribeCoin: string; + farmingStartTime: string; + farmingEndTime: string; + lowerRate: string; + defaultRate: string; + upperRate: string; + period: string; + interestStartTime: string; + status: string; minAmount: string; - maxAmount: string; - payDuration: string; + limitAmount: string; soldAmount: string; - lastAmount: string; - premium: string; - turnover: string; - remark: string; - tradeTerm: string; - payMethodIds: P2pAdPayMethodRefV3[]; - tokenPrecision: string; - fiatPrecision: string; - market: P2pMarketTypeV3; - avgTime: string; - createdTime: string; - updatedTime: string; + endTime: string; + startTime: string; } ⋮---- -export interface P2pPublicAdListItemV3 { - advId: string; - merchantId: string; - merchantName: string; - token: string; - fiat: string; - side: P2pSideV3; - price: string; - minAmount: string; - maxAmount: string; - quantity: string; - payMethods: { - payMethodId: string; - payMethodName: string; - }[]; - completedOrderNum: string; - completedRate: string; - avgReleaseTime: string; - createdTime: string; +export interface EarnSharkfinProductsV2 { + resultList: EarnSharkfinProductV2[]; + endId: string; } ⋮---- -export interface P2pMyAdListItemV3 { - advId: string; - side: P2pSideV3; - priceType: P2pPriceTypeV3; - token: string; - fiat: string; - price: string; - soldAmount: string; - lastAmount: string; - payMethods: { payMethodId: string }[]; - status: P2pAdStatusV3; - createdTime: string; - updatedTime: string; +export interface EarnSharkfinAccountV2 { + btcSubscribeAmount: string; + usdtSubscribeAmount: string; + btcHistoricalAmount: string; + usdtHistoricalAmount: string; + btcTotalEarning: string; + usdtTotalEarning: string; } ⋮---- -export interface P2pCursorListV3 { - items: T[]; - nextId?: string; +export interface EarnSharkfinAssetV2 { + productId: string; + interestStartTime: string; + interestEndTime: string; + productCoin: string; + subscribeCoin: string; + trend: string; + settleTime: string; + interestAmount: string; + productStatus: string; } ⋮---- -export interface P2pOrderListItemV3 { +export interface EarnSharkfinAssetsV2 { + resultList: EarnSharkfinAssetV2[]; + endId: string; +} +⋮---- +export interface EarnSharkfinRecordV2 { orderId: string; - side: P2pSideV3; - token: string; - fiat: string; - price: string; + product: string; + period: string; amount: string; - quantity: string; - fee: string; - counterparty: string; - status: P2pOrderStatusV3; - createdTime: string; - updatedTime: string; + ts: string; + type: string; } -⋮---- -export interface P2pOrderPayMethodDetailV3 { - payMethodId: string; - payMethodName: string; - payMethodUserName: string; - postscript: string; - payMethodInfo: P2pPayMethodInfoFieldV3[]; +export interface EarnSharkfinRecordsV2 { + resultList: EarnSharkfinRecordV2[]; + endId: string; } ⋮---- -export interface P2pOrderUserInfoV3 { - nickName: string; - realName: string; +export interface EarnSharkfinSubscriptionDetailV2 { + productCoin: string; + subscribeCoin: string; + interestTime: string; + expirationTime: string; + minPrice: string; + currentPrice: string; + maxPrice: string; + minRate: string; + defaultRate: string; + maxRate: string; + period: string; + productMinAmount: string; + availableBalance: string; + userAmount: string; + remainingAmount: string; + profitPrecision: string; + subscribePrecision: string; } ⋮---- -export interface P2pOrderInfoV3 { - orderId: string; - side: P2pSideV3; - token: string; - fiat: string; - price: string; - quantity: string; - amount: string; - status: P2pOrderStatusV3; - advId: string; - remark: string; - orderCancelCountdown: string; - fee: string; - verifyCapital: 'yes' | 'no'; - payMethodDetail?: P2pOrderPayMethodDetailV3; - sellUserInfo: P2pOrderUserInfoV3; - buyUserInfo: P2pOrderUserInfoV3; - createdTime: string; - updatedTime: string; +/** + * + * + * Earn | Loan + * + * + */ +⋮---- +export interface EarnLoanCurrencyLoanInfoV2 { + coin: string; + hourRate7D: string; + rate7D: string; + hourRate30D: string; + rate30D: string; + minUsdt: string; + maxUsdt: string; + min: string; + max: 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 EarnLoanCurrencyPledgeInfoV2 { + coin: string; + initRate: string; + supRate: string; + forceRate: string; + minUsdt: string; + maxUsdt: 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 EarnLoanCurrenciesV2 { + loanInfos: EarnLoanCurrencyLoanInfoV2[]; + pledgeInfos: EarnLoanCurrencyPledgeInfoV2[]; } ⋮---- -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 EarnLoanOrdersV2 { + orderId: string; + loanCoin: string; + loanAmount: string; + interestAmount: string; + hourInterestRate: string; + pledgeCoin: string; + pledgeAmount: string; + pledgeRate: string; + supRate: string; + forceRate: string; + borrowTime: string; + expireTime: string; } ⋮---- -export interface RealitySuspensionResumptionInfoV3 { - code: string; - name: string; - suspensionDate: string; - suspensionTime: string; - suspensionReason: string; - suspensionPrice: string; - resumptionDate: string; - resumptionQuoteTime: string; - resumptionTradingTime: string; +export interface EarnLoanRepayResponseV2 { + loanCoin: string; + pledgeCoin: string; + repayAmount: string; + payInterest: string; + repayLoanAmount: string; + repayUnlockAmount: 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 EarnLoanRepayHistoryV2 { + orderId: string; + loanCoin: string; + pledgeCoin: string; + repayAmount: string; + payInterest: string; + repayLoanAmount: string; + repayUnlockAmount: string; + repayTime: string; } ⋮---- -export interface RealityShareCapitalChangeV3 { - announcementDate: string; - changeDate: string; - totalShares: string; - commonShares: string; - preferredShares: string; - otherShares: string; - specialExplain: string; - changeReason: string; +export interface EarnLoanPledgeRateHistoryV2 { + loanCoin: string; + pledgeCoin: string; + orderId: string; + reviseTime: string; + reviseSide: string; + reviseAmount: string; + afterPledgeRate: string; + beforePledgeRate: 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 EarnLoanHistoryV2 { + orderId: string; + loanCoin: string; + pledgeCoin: string; + initPledgeAmount: string; + initLoanAmount: string; + hourRate: string; + daily: string; + borrowTime: string; + status: string; } ⋮---- -export interface RealityExecutiveShareholdingItemV3 { - name: string; - holdingNum: string; - holdingRatio: string; - voteRatio: string; - period: string; - announcementDate: string; +export interface EarnLoanDebtPledgeInfoV2 { + coin: string; + amount: string; + amountUsdt: string; } ⋮---- -export interface RealityShareholdDetailItemV3 { - name: string; - holdingNum: string; - holdingRatio: string; +export interface EarnLoanDebtLoanInfoV2 { + coin: string; + amount: string; + amountUsdt: string; } ⋮---- -export interface RealityCursorListV3 { - list: T[]; - cursor?: string; +export interface EarnLoanDebtsV2 { + pledgeInfos: EarnLoanDebtPledgeInfoV2[]; + loanInfos: EarnLoanDebtLoanInfoV2[]; } ⋮---- -export interface RealityStockInfoV3 { - symbol: string; - code: string; - name: string; - tradingPeriod: string[]; - weekendTradable: 'yes' | 'no' | string; +export interface EarnLoanLiquidationRecordsV2 { + orderId: string; + loanCoin: string; + pledgeCoin: string; + reduceTime: string; + pledgeRate: string; + pledgePrice: string; + status: string; + pledgeAmount: string; + reduceFee: string; + residueAmount: string; + runlockAmount: string; + repayLoanAmount: string; } ⋮---- -export interface RealityMarketSessionStateV3 { - state: string; - timeZone: string; - startTime: string; - endTime: string; -} +/** + * + * + * Earn | On-Chain Elite + * + * + */ ⋮---- -export interface RealityMarketStateV3 { - market: string; - daylightType: string; - stateList: RealityMarketSessionStateV3[]; +export interface EarnEliteSubscriptionCoinV2 { + subscriptionCoin: string; + precision: string; + feeRate: string; + exchangeRate: string; + remainQuota?: string; + minAmount?: string; } ⋮---- -export interface RealityMarketSpecificConfigV3 { - remark: string; - startTime: string; - endTime: string; +export interface EarnEliteProductV2 { + productId: string; + coin: string; + minApr: string; + maxApr: string; + subscriptionCoinList: EarnEliteSubscriptionCoinV2[]; + sellOut: 'YES' | 'NO' | string; } ⋮---- -export interface RealityMarketCalendarV3 { - timeZone: string; - specificConfig: RealityMarketSpecificConfigV3[]; - regularConfig: string[]; +export interface EarnEliteAssetProjectV2 { + projectName: string; } - -================ -File: webpack/webpack.config.cjs -================ -function generateConfig(name) ⋮---- -// Add '.ts' and '.tsx' as resolvable extensions. -⋮---- -// Node.js core modules not available in browsers -// The REST client's https.Agent (for keepAlive) is Node.js-only and won't work in browsers +export interface EarnEliteAssetV2 { + productId: string; + productCoin: string; + holdingAmount: string; + usdtHoldingAmount: string; + exchangeRate: string; + apr: string; + minApy?: string; + maxApy?: string; + subscriptionCoin: string; + exchangeAmount: string; + projectList?: EarnEliteAssetProjectV2[]; + unsettledBGPoints: string; + interestCoin: string; + totalProfit: string; +} ⋮---- -// Code is already transpiled from TypeScript, no additional loaders needed - -================ -File: .npmrc -================ -min-release-age=30 -save-exact=true - -================ -File: .nvmrc -================ -v24.18.0 - -================ -File: examples/auth/fasterHmacSign.ts -================ -import { createHmac } from 'crypto'; +export interface EarnEliteAssetsV2 { + resultList: EarnEliteAssetV2[]; +} ⋮---- -import { - DefaultLogger, - RestClientV3, - WebsocketClientV3, -} from '../../src/index.js'; +export interface EarnEliteRecordV2 { + recordId: string; + productId: string; + coin: string; + status: string; + exchangeRate: string; + receivedCoin: string; + receivedAmount: string; + investAmount: string; + feeRate: string; + redeemType?: string | string[]; + receivingAccount: string; + actualReceivingAccount: string; + paymentAccount?: string[]; + settlePoints: string; + fee: string; +} ⋮---- -// or -// import { createHmac } from 'crypto'; -// import { DefaultLogger, RestClientV3, WebsocketClientV3 } from 'bitget-api'; +export interface EarnEliteRecordsV2 { + recordList: EarnEliteRecordV2[]; + endId: string; +} ⋮---- -/** - * Injecting a custom signMessage function. - * - * As of version 3.0.0 of the bitget-api Node.js/TypeScript/JavaScript - * SDK for Bitget, the SDK uses the Web Crypto API for signing requests. - * While it is compatible with Node and Browser environments, it is - * slightly slower than using Node's native crypto module (only - * available in backend Node environments). - * - * For latency sensitive users, you can inject the previous node crypto sign - * method (or your own even faster implementation), if this change affects you. - * - * This example demonstrates how to inject a custom sign function, to achieve - * the same peformance as seen before the Web Crypto API was introduced. - * - * For context on standard usage, the "signMessage" function is used: - * - During every single API call - * - After opening a new private WebSocket connection - */ +export interface EarnEliteSubscribeInfoV2 { + productSubId: string; + minAmount: string; + remainQuota: string; + exchangeRate: string; + productCoin: string; + interestTime: string; + settleTime: string; + precision: string; + feeRate: string; + /** Present for BGUSD per API docs. */ + subscriptionCoinList?: EarnEliteSubscriptionCoinV2[]; +} ⋮---- -/** - * Set this to true to enable demo trading: - */ +/** Present for BGUSD per API docs. */ ⋮---- -/** - * Overkill in almost every case, but if you need any optimisation available, - * you can inject a faster sign mechanism such as node's native createHmac: - */ +export interface EarnEliteSubscribeResultV2 { + orderId: string; +} ⋮---- -// Optional, uncomment the "trace" override to log a lot more info about what the WS client is doing +export interface EarnEliteSubscribeStatusV2 { + result: 'settled' | 'pending' | 'rejected' | string; +} ⋮---- -// trace: (...params) => console.log('trace', ...params), +export interface EarnEliteRedeemInfoBgusdReceiveCoinV2 { + bgusdReceiveCoin: string; + bgusdExchangeRate: string; +} ⋮---- -/** - * Set this to true to enable demo trading for the private account data WS - * Topics: order,execution,position,wallet,greeks - */ -⋮---- -/** - * Overkill in almost every case, but if you need any optimisation available, - * you can inject a faster sign mechanism such as node's native createHmac: - */ -⋮---- -function setWsClientEventListeners( - websocketClient: WebsocketClientV3, - accountRef: string, -): Promise -⋮---- -// console.log('raw message received ', JSON.stringify(data, null, 2)); +export interface EarnEliteRedeemModeV2 { + redeemFeeRate: string; + remainQuota: string; + redeemType: 'fast' | 'standard' | string; + redeemScale: string; + redeemDelayDate: string; + minRedeemAmount: string; + redeemTime: string; +} ⋮---- -// Simple promise to ensure we're subscribed before trying anything else +export interface EarnEliteRedeemInfoV2 { + productId: string; + productSubId: string; + productCoin: string; + subscriptionCoin: string; + profitCoin: string; + exchangeRate: string; + totalUnPayInterestAmount: string; + preSettleApr: string; + receivedCoin: string; + unsettledPoints: string; + bgusdReceiveCoinList: EarnEliteRedeemInfoBgusdReceiveCoinV2[]; + redeemModeList: EarnEliteRedeemModeV2[]; +} ⋮---- -// Start trading +export interface RedeemEarnEliteResultV2 { + orderId: string; +} ================ -File: examples/V2 - Classic/Rest/rest-trade-futures.ts +File: src/types/response/v2/instloan.ts ================ -import { - FuturesPlaceOrderRequestV2, - RestClientV2, - WebsocketClientV2, -} from '../../../src/index.js'; -⋮---- -// or -// import { FuturesPlaceOrderRequestV2, RestClientV2, WebsocketClientV2 } from '../src'; -⋮---- -// read from environmental variables -⋮---- -// If running from CLI in unix, you can pass env vars as such: -// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/rest-trade-futures.ts +export interface InstLoanProductInfoV2 { + productId: string; + leverage: string; + transferLine: string; + spotBuyLine: string; + liquidationLine: string; + stopLiquidationLine: string; +} ⋮---- -// note the single quotes, preventing special characters such as $ from being incorrectly passed +export interface InstLoanSymbolsV2 { + productId: string; + spotSymbols: string[]; +} ⋮---- -// apiKey: 'apiKeyHere', -// apiSecret: 'apiSecretHere', -// apiPass: 'apiPassHere', +export interface InstLoanRepaidHistoryItemV2 { + repayOrderId: string; + businessType: string; + repayType: string; + repaidTime: string; + coin: string; + repaidAmount: string; + repaidInterest: string; +} ⋮---- -function logWSEvent(type: string, data: any) +export interface InstLoanOrderV2 { + orderId: string; + orderProductId: string; + uid: string; + loanTime: string; + loanCoin: string; + loanAmount: string; + unpaidAmount: string; + unpaidInterest: string; + repaidAmount: string; + repaidInterest: string; + status: string; +} ⋮---- -// simple sleep function -function promiseSleep(milliseconds: number) +export interface InstLoanCoinInfoV2 { + coin: string; + convertRatio: string; + maxConvertValue: string; +} ⋮---- +export interface InstLoanLTVConvertV2 { + ltv: string; + subAccountUids: string[]; + unpaidUsdtAmount: string; + usdtBalance: string; + unpaidInfo: { + coin: string; + unpaidQty: string; + unpaidInterest: string; + }[]; + balanceInfo: { + coin: string; + price: string; + amount: string; + convertedUsdtAmount: string; + }[]; +} + +================ +File: src/types/response/v3/affiliate.ts +================ /** - * This is a simple script wrapped in a immediately invoked function expression (to execute the below workflow immediately). * - * It is designed to: - * - open a private websocket channel to log account events - * - check for any available USDT balance in the futures account - * - immediately open a minimum sized long position on BTCUSDT - * - check active positions - * - immediately send closing orders for any active futures positions - * - check positions again + * + * Affiliate + * https://www.bitget.com/docs/catalog/affiliate/affiliate + * * */ ⋮---- -// Add event listeners to log websocket events on account -⋮---- -// futures private -// : account updates -⋮---- -// : position updates -⋮---- -// : order updates +export interface AgentCustomerListItemV3 { + uid: string; + registerTime: string; +} ⋮---- -// wait briefly for ws to be ready (could also use the response or authenticated events, to make sure topics are subscribed to before starting) +export interface AgentCustomerAssetItemV3 { + uid: string; + balance: string; + uTime: string; + remark: string; +} ⋮---- -// const balances = allBalances.filter((bal) => Number(bal.available) != 0); +export interface AgentCustomerTradeVolumeItemV3 { + uid: string; + /** API field name (Bitget spelling). */ + volumn: string; + spotVolume: string; + futuresVolume: string; + time: string; +} ⋮---- -// Loop through any active positions and send a closing market order on each position - -================ -File: examples/V2 - Classic/Rest/rest-trade-spot.ts -================ -import { - RestClientV2, - SpotOrderRequestV2, - WebsocketClientV2, -} from '../../../src/index.js'; +/** API field name (Bitget spelling). */ ⋮---- -// import { RestClientV2, WebsocketClient } from '../src/index'; +export interface AgentCustomerDepositItemV3 { + uid: string; + orderId: string; + depositTime: string; + depositCoin: string; + depositAmount: string; +} ⋮---- -// read from environmental variables +export interface AgentCustomerKycResultItemV3 { + uid: string; + kycResult: 'passed' | 'not_passed'; +} ⋮---- -// If running from CLI in unix, you can pass env vars as such: -// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/rest-trade-spot.ts +/** Pagination wrapper follows the documented response example. */ +export interface AgentCustomerKycResultV3 { + userList: AgentCustomerKycResultItemV3[]; + endId: string; +} ⋮---- -// note the single quotes, preventing special characters such as $ from being incorrectly passed +export interface AgentCustomerCommissionV3 { + uid: string; + date: string; + coin: string; + symbol: string; + productType: string; + dealAmount: string; + fee: string; + feeDeduction: string; + activityBonusDeduct: string; + spotCouponDeduct: string; + futuresCouponDeduct: string; + spotFeeDiscountDeduct: string; + negativeMakerFeeDeduct: string; + feePaid: string; + rebateAmount: string; + userTotalRebateAmount: string; + dayTotalRebateAmount: string; + totalRebateAmount: string; +} ⋮---- -// apiKey: 'apiKeyHere', -// apiSecret: 'apiSecretHere', -// apiPass: 'apiPassHere', +export interface AgentCustomerCommissionsV3 { + commissionList: AgentCustomerCommissionV3[]; + endId: string; +} ⋮---- -function logWSEvent(type: string, data: any) +/** Pagination wrapper follows the documented response example. */ +export interface AgentSubCustomerListV3 { + list: AgentCustomerListItemV3[]; + minId: string; +} ⋮---- -// simple sleep function -function promiseSleep(milliseconds: number) +export interface SubAffiliateRebateRateV3 { + rebateType: string; + rebateRate: string; +} ⋮---- -/** This is a simple script wrapped in a immediately invoked function expression, designed to check for any available BTC balance and immediately sell the full amount for USDT */ +export interface SubAffiliateInfoItemV3 { + uid: string; + uplineName: string; + rebateRateList: SubAffiliateRebateRateV3[]; + verificationStatus: string; + directReferrals: string; + subAffiliates: string; + subAffiliateDirectReferrals: string; + volume: string; + deposit: string; + transactionFee: string; + rebate: string; +} ⋮---- -// Add event listeners to log websocket events on account +export interface SubAffiliateInfoV3 { + list: SubAffiliateInfoItemV3[]; + endId: string; +} ⋮---- -// Subscribe to private account topics -// spot private -// : account updates -⋮---- -// : order updates (note: symbol is required) -⋮---- -// wait briefly for ws to be ready (could also use the response or authenticated events, to make sure topics are subscribed to before starting) +export interface SubAffiliateCommissionItemV3 { + uid: string; + bizType: string; + subBizType: string; + symbol: string; + coin: string; + fee: string; + volume: string; + activityBonusDeduct: string; + spotCouponDeduct: string; + futuresCouponDeduct: string; + spotFeeDiscountDeduct: string; + negativeMakerFeeDeduct: string; + feePaid: string; + directCommission: string; + subCommission: string; + partnerCommission: string; + partnerActualCommission: string; + traderType: string; + apiType: string; + status: string; + startCalculationTime: string; + endCalculationTime: string; +} ⋮---- -// console.log('balance: ', JSON.stringify(balances, null, 2)); +export interface SubAffiliateCommissionV3 { + commissionList: SubAffiliateCommissionItemV3[]; + endId: string; +} ================ -File: examples/V2 - Classic/Websocket/ws-demo-trading.ts +File: src/types/response/v3/grid.ts ================ -import { DefaultLogger, WebsocketClientV2 } from '../../../src/index.js'; -⋮---- -// or -// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; +import type { GridIndicatorParamsV3 } from '../../request/v3/grid.js'; ⋮---- -// 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 GridBotIdResponseV3 { + botId: string; +} ⋮---- -// restOptions: { -// optionally provide rest options, e.g. to pass through a proxy -// }, +export interface GridValidateResponseV3 { + valid: string; + reason?: string; + minInvestment?: string; +} ⋮---- -// Set demoTrading to true, to route all connections to the demo trading wss URLs: +export interface GridBotOrderItemV3 { + orderId: string; + delegateCount: string; + delegatePrice: string; + changeRequired: number | string; +} ⋮---- -// If using private topics, make sure to include API keys +export interface GridBotOrderDetailsV3 { + botId: string; + symbol: string; + buyOrderList: GridBotOrderItemV3[]; + sellOrderList: GridBotOrderItemV3[]; +} ⋮---- -// console.log('WS raw message received ', JSON.stringify(data, null, 2)); +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; +} ⋮---- -/** - * Public events - */ +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: examples/V2 - Classic/Websocket/ws-private.ts +File: src/types/response/v3/loan.ts ================ -import { DefaultLogger, WebsocketClientV2 } from '../../../src/index.js'; +export interface LoanTransfersV3 { + coin: string; + transfered: string; + userId: string; +} ⋮---- -// or -// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; +export interface LoanSymbolSettingV3 { + symbol: string; + leverage: 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 LoanSymbolsV3 { + productId: string; + spotSymbols: string[]; + marginLeverage: string; + usdtContractLeverage: string; + coinContractLeverage: string; + usdcContractLeverage: string; + usdtContractSymbols: LoanSymbolSettingV3[]; + coinContractSymbols: LoanSymbolSettingV3[]; + usdcContractSymbols: LoanSymbolSettingV3[]; +} ⋮---- -// note the single quotes, preventing special characters such as $ from being incorrectly passed +export interface RepaidHistoryItemV3 { + repayOrderId: string; + businessType: 'normal' | 'liquidation'; + repayType: 'all' | 'part'; + repaidTime: string; + coin: string; + repayAmount: string; + repayInterest: string; +} ⋮---- -// restOptions: { -// optionally provide rest options, e.g. to pass through a proxy -// }, +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; +} ⋮---- -// console.log('WS raw message received ', JSON.stringify(data, null, 2)); +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'; +} ⋮---- -// auth happens async after the ws connection opens +/** Tiered conversion rate item (when Tiered Discount Rate Model is enabled) */ +export interface ConvertRatioListItemV3 { + ladder: string; + convertRatio: string; +} ⋮---- -// wsClient.subscribePublicSpotTickers(['BTCUSDT', 'LTCUSDT']); +export interface CoinInfoV3 { + coin: string; + convertRatio: string; + maxConvertValue: string; + /** Tiered conversion rate (when margin mode is Tiered Discount Rate Model) */ + convertRatioList?: ConvertRatioListItemV3[]; +} ⋮---- -/** - * Private account updates - */ +/** Tiered conversion rate (when margin mode is Tiered Discount Rate Model) */ ⋮---- -// spot private -// : account updates +export interface BindUidResponseV3 { + riskUnitId: string; + uid: string; + operate: 'bind' | 'unbind'; +} ⋮---- -// : order updates (note: symbol is required) -// wsClient.subscribeTopic('SPOT', 'orders', 'BTCUSDT'); +export interface UnpaidInfoV3 { + coin: string; + unpaidQty: string; + unpaidInterest: string; +} ⋮---- -// futures private -// : account updates +export interface BalanceInfoV3 { + coin: string; + price: string; + amount: string; + convertedUsdtAmount: string; +} ⋮---- -// : position updates -// wsClient.subscribeTopic('USDT-FUTURES', 'positions'); -⋮---- -// : order updates -// wsClient.subscribeTopic('USDT-FUTURES', 'orders'); -⋮---- -// : plan order updates -// wsClient.subscribeTopic('USDT-FUTURES', 'orders-algo'); -⋮---- -// wsClient -// .getWsStore() -// .getKeys() -// .forEach((wsKey) => { -// const state = wsClient.getWsStore().get(wsKey); -// console.log(`${wsKey} state: `, state.subscribedTopics.values()); -// }); -⋮---- -// setTimeout(() => { -// wsClient.unsubscribeTopic('USDT-FUTURES', 'account'); -// }, 1000 * 2); -⋮---- -// setTimeout(() => { -// wsClient -// .getWsStore() -// .getKeys() -// .forEach((wsKey) => { -// const state = wsClient.getWsStore().get(wsKey); -// console.log(`${wsKey} state: `, state.subscribedTopics.values()); -// }); -// }, 1000 * 5); - -================ -File: examples/V2 - Classic/Websocket/ws-public.ts -================ -import { - DefaultLogger, - WebsocketClientV2, - WS_KEY_MAP, -} from '../../../src/index.js'; +export interface LTVConvertResponseV3 { + ltv: string; + subAccountUids: string[]; + unpaidUsdtAmount: string; + usdtBalance: string; + unpaidInfo: UnpaidInfoV3[]; + balanceInfo: BalanceInfoV3[]; +} ⋮---- -// or -// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; +/* Unified Account Staking & Lending (Crypto Loans) - /api/v3/loan/* */ ⋮---- -// restOptions: { -// optionally provide rest options, e.g. to pass through a proxy -// }, +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; +} ⋮---- -// console.log('WS raw message received ', JSON.stringify(data, null, 2)); +export interface LoanPledgeInfoV3 { + coin: string; + initRate: string; + supRate: string; + forceRate: string; + minPledgeAmount: string; + maxPledgeAmount: string; +} ⋮---- -/** - * Public events - */ +export interface GetLoanCoinsResponseV3 { + loanInfos: LoanCoinInfoV3[]; + pledgeInfos: LoanPledgeInfoV3[]; +} ⋮---- -// Spot public +export interface GetLoanInterestResponseV3 { + hourInterest: string; + loanAmount: string; +} ⋮---- -// tickers +export interface LoanBorrowResponseV3 { + orderId: string; +} ⋮---- -// candles -// wsClient.subscribeTopic('SPOT', 'candle1m', symbol); +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; +} ⋮---- -// orderbook updates -// wsClient.subscribeTopic('SPOT', 'books', symbol); +export interface LoanBorrowHistoryItemV3 { + orderId: string; + loanCoin: string; + pledgeCoin: string; + initPledgeAmount: string; + initLoanAmount: string; + hourRate: string; + daily: string; + borrowTime: string; + status: string; +} ⋮---- -// trades -// wsClient.subscribeTopic('SPOT', 'trade', symbol); +export interface LoanRepayResponseV3 { + loanCoin: string; + pledgeCoin: string; + repayAmount: string; + payInterest: string; + repayLoanAmount: string; + repayUnlockAmount: string; +} ⋮---- -// Futures public +export interface LoanRepayHistoryItemV3 { + orderId: string; + loanCoin: string; + pledgeCoin: string; + repayAmount: string; + payInterest: string; + repayLoanAmount: string; + repayUnlockAmount: string; + repayTime: string; +} ⋮---- -// tickers -// wsClient.subscribeTopic('USDT-FUTURES', 'ticker', symbol); +export interface LoanRevisePledgeResponseV3 { + loanCoin: string; + pledgeCoin: string; + afterPledgeRate: string; +} ⋮---- -// candles -// wsClient.subscribeTopic('USDT-FUTURES', 'candle1m', symbol); +export interface LoanPledgeRateHistoryItemV3 { + loanCoin: string; + pledgeCoin: string; + orderId: string; + reviseTime: string; + reviseSide: string; + reviseAmount: string; + afterPledgeRate: string; + beforePledgeRate: string; +} ⋮---- -// orderbook updates -// wsClient.subscribeTopic('USDT-FUTURES', 'books', symbol); +export interface LoanDebtInfoV3 { + coin: string; + amount: string; + amountUsdt: string; +} ⋮---- -// trades -// wsClient.subscribeTopic('USDT-FUTURES', 'trade', symbol); +export interface GetLoanDebtsResponseV3 { + pledgeInfos: LoanDebtInfoV3[]; + loanInfos: LoanDebtInfoV3[]; +} ⋮---- -// Topics are tracked per websocket type -// Get a list of subscribed topics (e.g. all public topics) (after a 5 second delay) +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: examples/V3 - UTA/Rest/rest-trade-UTA-futures.ts +File: src/types/response/v3/p2p.ts ================ -/* eslint-disable @typescript-eslint/no-unused-vars */ -import { - PlaceOrderRequestV3, - RestClientV3, - WebsocketClientV3, -} from '../../../src/index.js'; +import type { + P2pAdStatusV3, + P2pMarketTypeV3, + P2pOrderStatusV3, + P2pPriceTypeV3, + P2pSideV3, +} from '../../request/v3/p2p.js'; ⋮---- -// or -// import { PlaceOrderRequestV3, RestClientV3, WebsocketClientV3 } from '../src'; +export interface P2pPayMethodInfoFieldV3 { + name: string; + type: 'file' | 'number' | 'txt'; + value: string; +} ⋮---- -// read from environmental variables +export interface P2pPayMethodV3 { + payMethodId: string; + payMethodName: string; + payMethodUserName: string; + userPayMethodId: string; + payMethodInfo: P2pPayMethodInfoFieldV3[]; +} ⋮---- -// If running from CLI in unix, you can pass env vars as such: -// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/V3/rest-trade-futures.ts +export interface P2pTokenDetailV3 { + token: string; + precision: string; +} ⋮---- -// note the single quotes, preventing special characters such as $ from being incorrectly passed +export interface P2pFiatPayMethodV3 { + payMethodName: string; + iconUrl: string; + payMethodId: string; +} ⋮---- -// apiKey: 'apiKeyHere', -// apiSecret: 'apiSecretHere', -// apiPass: 'apiPassHere', +export interface P2pWithdrawalLimitV3 { + withdrawLimitKey: string; + withdrawLimitValue: string; +} ⋮---- -function logWSEvent(type: string, data: any) +export interface P2pFiatDetailV3 { + fiat: string; + precision: string; + floatRateMin: string; + floatRateMax: string; + fixedRateMin: string; + fixedRateMax: string; + adMinLimit: string; + adMaxLimit: string; + payMethods: P2pFiatPayMethodV3; + withdrawalLimit: P2pWithdrawalLimitV3; + payTimeLimit: number[]; +} ⋮---- -// simple sleep function -function promiseSleep(milliseconds: number) +export interface P2pCurrenciesV3 { + tokenDetailList: P2pTokenDetailV3[]; + fiatDetailList: P2pFiatDetailV3[]; +} ⋮---- -/** - * This is a simple script wrapped in a immediately invoked function expression (to execute the below workflow immediately). - * - * It is designed to: - * - open a private websocket channel to log account events - * - check for any available USDT balance in the account - * - immediately open a minimum sized long position on BTCUSDT - * - check active positions - * - immediately send closing orders for any active futures positions - * - check positions again - * - */ -⋮---- -// Add event listeners to log websocket events on account -⋮---- -// Subscribe to private topics for UTA account -⋮---- -// Subscribe to position updates +export interface P2pUserEquityDetailV3 { + maxAdvSellNum: string; + maxAdvSellLimit: string; + maxAdvBuyNum: string; + maxAdvBuyLimit: string; + totalMaxPendingOrder: string; + advMaxPendingOrder: string; +} ⋮---- -// Subscribe to order updates +export interface P2pUserInfoV3 { + uid: string; + nickName: string; + accountLevel: 'starter' | 'advanced' | 'master'; + completedOrderNum: string; + positiveRate: string; + completedOrderNum30D: string; + completedRate30D: string; + avgPayTime30D: string; + avgReleaseTime30D: string; + equityDetail: P2pUserEquityDetailV3; + registerTime: string; +} ⋮---- -// wait briefly for ws to be ready (could also use the response or authenticated events, to make sure topics are subscribed to before starting) +export interface P2pBalanceV3 { + token: string; + totalBalance: string; + frozenBalance: string; + availableBalance: string; +} ⋮---- -// Loop through any active positions and send a closing market order on each position - -================ -File: examples/V3 - UTA/Rest/rest-trade-UTA-spot.ts -================ -/* eslint-disable @typescript-eslint/no-unused-vars */ -import { - PlaceOrderRequestV3, - RestClientV3, - WebsocketClientV3, -} from '../../../src/index.js'; +export interface P2pExchangeRateV3 { + rate: string; +} ⋮---- -// import { RestClientV3, WebsocketClientV3 } from '../src/index'; +export interface P2pFeeSimulateV3 { + feeToken: string; + feeAmount: string; + taxToken: string; + taxAmount: string; +} ⋮---- -// read from environmental variables +export interface P2pAdLimitV3 { + buyMinTokenAmount: string; + buyMaxTokenAmount: string; + sellMinTokenAmount: string; + sellMaxTokenAmount: string; +} ⋮---- -// If running from CLI in unix, you can pass env vars as such: -// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/V3/rest-trade-spot.ts +export interface P2pCreateAdResponseV3 { + advId: string; +} ⋮---- -// note the single quotes, preventing special characters such as $ from being incorrectly passed +export interface P2pAdPayMethodRefV3 { + payMethodId: string; + userPayMethodId?: string; +} ⋮---- -// apiKey: 'apiKeyHere', -// apiSecret: 'apiSecretHere', -// apiPass: 'apiPassHere', +export interface P2pAdInfoV3 { + advId: string; + side: P2pSideV3; + priceType: P2pPriceTypeV3; + token: string; + fiat: string; + price: string; + amount: string; + minAmount: string; + maxAmount: string; + payDuration: string; + soldAmount: string; + lastAmount: string; + premium: string; + turnover: string; + remark: string; + tradeTerm: string; + payMethodIds: P2pAdPayMethodRefV3[]; + tokenPrecision: string; + fiatPrecision: string; + market: P2pMarketTypeV3; + avgTime: string; + createdTime: string; + updatedTime: string; +} ⋮---- -function logWSEvent(type: string, data: any) +export interface P2pPublicAdListItemV3 { + advId: string; + merchantId: string; + merchantName: string; + token: string; + fiat: string; + side: P2pSideV3; + price: string; + minAmount: string; + maxAmount: string; + quantity: string; + payMethods: { + payMethodId: string; + payMethodName: string; + }[]; + completedOrderNum: string; + completedRate: string; + avgReleaseTime: string; + createdTime: string; +} ⋮---- -// simple sleep function -function promiseSleep(milliseconds: number) +export interface P2pMyAdListItemV3 { + advId: string; + side: P2pSideV3; + priceType: P2pPriceTypeV3; + token: string; + fiat: string; + price: string; + soldAmount: string; + lastAmount: string; + payMethods: { payMethodId: string }[]; + status: P2pAdStatusV3; + createdTime: string; + updatedTime: string; +} ⋮---- -/** This is a simple script wrapped in a immediately invoked function expression, designed to check for any available BTC balance and immediately sell the full amount for USDT */ +export interface P2pCursorListV3 { + items: T[]; + nextId?: string; +} ⋮---- -// Add event listeners to log websocket events on account +export interface P2pOrderListItemV3 { + orderId: string; + side: P2pSideV3; + token: string; + fiat: string; + price: string; + amount: string; + quantity: string; + fee: string; + counterparty: string; + status: P2pOrderStatusV3; + createdTime: string; + updatedTime: string; +} ⋮---- -// Subscribe to private account topics -// Account updates for UTA (unified trading account) +export interface P2pOrderPayMethodDetailV3 { + payMethodId: string; + payMethodName: string; + payMethodUserName: string; + postscript: string; + payMethodInfo: P2pPayMethodInfoFieldV3[]; +} ⋮---- -// Order updates for spot +export interface P2pOrderUserInfoV3 { + nickName: string; + realName: string; +} ⋮---- -// wait briefly for ws to be ready (could also use the response or authenticated events, to make sure topics are subscribed to before starting) +export interface P2pOrderInfoV3 { + orderId: string; + side: P2pSideV3; + token: string; + fiat: string; + price: string; + quantity: string; + amount: string; + status: P2pOrderStatusV3; + advId: string; + remark: string; + orderCancelCountdown: string; + fee: string; + verifyCapital: 'yes' | 'no'; + payMethodDetail?: P2pOrderPayMethodDetailV3; + sellUserInfo: P2pOrderUserInfoV3; + buyUserInfo: P2pOrderUserInfoV3; + createdTime: string; + updatedTime: string; +} ================ -File: examples/V3 - UTA/Websocket/ws-private.ts +File: src/types/response/v3/reality.ts ================ -import { - DefaultLogger, - WebsocketClientV3, - WS_KEY_MAP, -} from '../../../src/index.js'; +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; +} ⋮---- -// or -// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; +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; +} ⋮---- -// If running from CLI in unix, you can pass env vars as such: -// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/ws-private.ts -⋮---- -// console.log('WS raw message received ', JSON.stringify(data, null, 2)); -⋮---- -// You can subscribe to one topic at a time +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; +} ⋮---- -instType: 'UTA', // Note: all account events go on the UTA instType +export interface RealitySuspensionResumptionInfoV3 { + code: string; + name: string; + suspensionDate: string; + suspensionTime: string; + suspensionReason: string; + suspensionPrice: string; + resumptionDate: string; + resumptionQuoteTime: string; + resumptionTradingTime: string; +} ⋮---- -WS_KEY_MAP.v3Private, // This parameter points to private or public +export interface RealityDividendItemV3 { + type: string; + announcementDate: string; + recordDate: string; + exrightDate: string; + dividendDate: string; + dividendPerShare: string; + stockDividendPerShare: string; + splitValidDate: string; + splitNumerator: string; + splitDenominator: string; +} ⋮---- -// Note: all account events go on the UTA instType +export interface RealityShareCapitalChangeV3 { + announcementDate: string; + changeDate: string; + totalShares: string; + commonShares: string; + preferredShares: string; + otherShares: string; + specialExplain: string; + changeReason: string; +} ⋮---- -// Or multiple at once: +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; +} ⋮---- -// Topics are tracked per websocket type -// The below example will pull a list of subscribed topics on that connection (e.g. all private topics), after a 5 second delay: - -================ -File: examples/V3 - UTA/Websocket/ws-public.ts -================ -import { - DefaultLogger, - WebsocketClientV3, - WS_KEY_MAP, -} from '../../../src/index.js'; +export interface RealityExecutiveShareholdingItemV3 { + name: string; + holdingNum: string; + holdingRatio: string; + voteRatio: string; + period: string; + announcementDate: string; +} ⋮---- -// or -// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV2 } from 'bitget-api'; +export interface RealityShareholdDetailItemV3 { + name: string; + holdingNum: string; + holdingRatio: string; +} ⋮---- -// console.log('WS raw message received ', JSON.stringify(data, null, 2)); +export interface RealityCursorListV3 { + list: T[]; + cursor?: string; +} ⋮---- -/** - * Public events - */ +export interface RealityStockInfoV3 { + symbol: string; + code: string; + name: string; + tradingPeriod: string[]; + weekendTradable: 'yes' | 'no' | string; +} ⋮---- -// You can subscribe to one topic at a time +export interface RealityMarketSessionStateV3 { + state: string; + timeZone: string; + startTime: string; + endTime: string; +} ⋮---- -WS_KEY_MAP.v3Public, // This parameter points to private or public +export interface RealityMarketStateV3 { + market: string; + daylightType: string; + stateList: RealityMarketSessionStateV3[]; +} ⋮---- -// Or multiple at once: +export interface RealityMarketSpecificConfigV3 { + remark: string; + startTime: string; + endTime: string; +} ⋮---- -// Topics are tracked per websocket type -// The below example will pull a list of subscribed topics on that connection (e.g. all public topics), after a 5 second delay: +export interface RealityMarketCalendarV3 { + timeZone: string; + specificConfig: RealityMarketSpecificConfigV3[]; + regularConfig: string[]; +} ================ -File: examples/V3 - UTA/WS-API/ws-api-trade-raw.ts +File: webpack/webpack.config.cjs ================ -import { - DefaultLogger, - WebsocketClientV3, - WS_KEY_MAP, -} from '../../../src/index.js'; +function generateConfig(name) ⋮---- -// or -// import { DefaultLogger, WS_KEY_MAP, WebsocketClientV3 } from 'bitget-api'; +// Add '.ts' and '.tsx' as resolvable extensions. ⋮---- -// 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 +// Node.js core modules not available in browsers +// The REST client's https.Agent (for keepAlive) is Node.js-only and won't work in browsers ⋮---- -// console.log('WS raw message received ', JSON.stringify(data, null, 2)); +// Code is already transpiled from TypeScript, no additional loaders needed + +================ +File: .npmrc +================ +min-release-age=30 +save-exact=true + +================ +File: .nvmrc +================ +v24.18.0 + +================ +File: src/types/request/v2/common.ts +================ +import { FuturesProductTypeV2, MarginType } from '../shared.js'; ⋮---- /** - * Bitget's WebSocket API can be used via the sendWSAPIRequest() method. - * - * Use the `WS_KEY_MAP.v3Private` connection key for any requests. - * - * Note: this requires V3/UTA API keys! - * Note: for a better user experience, it is recommended to use the WebsocketAPIClient. - */ + * + * * Common | Notice + * + */ ⋮---- -// Use the V3 private wss connection URL +export interface GetAnnouncementsRequestV2 { + annType?: string; + startTime?: string; + endTime?: string; + language: string; +} ⋮---- /** - * Place Order - * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters - */ + * + * * Common | Public + * + */ ⋮---- -/** - 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 GetTradeRateRequestV2 { + symbol: string; + businessType: string; +} ⋮---- -/** - * Batch Place Order Channel - * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel - */ +export interface GetAllTradeRatesRequestV2 { + businessType: 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. - */ -⋮---- -/** - 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/request/v2/common.ts -================ -import { FuturesProductTypeV2, MarginType } from '../shared.js'; -⋮---- -/** - * - * * Common | Notice - * - */ -⋮---- -export interface GetAnnouncementsRequestV2 { - annType?: string; - startTime?: string; - endTime?: string; - language: string; -} -⋮---- -/** - * - * * Common | Public - * - */ -⋮---- -export interface GetTradeRateRequestV2 { - symbol: string; - businessType: string; -} -⋮---- -export interface GetAllTradeRatesRequestV2 { - businessType: string; -} -⋮---- -/** - * - * * Common | Tax - * - */ + * + * * Common | Tax + * + */ ⋮---- export interface GetSpotTransactionsRequestV2 { coin?: string; @@ -6680,6 +6848,138 @@ export interface FuturesIsolatedSymbolsRequestV2 { productType: FuturesProductTypeV2; } +================ +File: src/types/request/v3/broker.ts +================ +export interface CreateBrokerSubAccountRequestV3 { + subaccountName: string; + label: string; +} +⋮---- +export interface GetBrokerSubAccountListRequestV3 { + limit?: string; + cursor?: string; + status?: 'normal' | 'freeze'; +} +⋮---- +export interface ModifyBrokerSubAccountRequestV3 { + subUid: string; + status?: 'normal' | 'freeze'; + permList?: string[]; +} +⋮---- +export interface BrokerSubWithdrawalRequestV3 { + subUid: string; + coin: string; + dest: 'on_chain' | 'internal_transfer'; + address: string; + amount: string; + chain?: string; + tag?: string; + clientOid?: string; +} +⋮---- +export interface GetBrokerSubDepositAddressRequestV3 { + subUid: string; + coin: string; + chain?: string; +} +⋮---- +export interface GetBrokerAllSubDepositWithdrawalRequestV3 { + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; + status?: 'pending' | 'fail' | 'success'; +} +⋮---- +export interface GetBrokerCommissionRequestV3 { + startTime?: string; + endTime?: string; + pageSize?: string; + pageNo?: string; + bizType?: 'spot' | 'futures'; + subBizType?: + | 'spot_trade' + | 'spot_margin' + | 'usdt_futures' + | 'usdc_futures' + | 'coin_futures'; +} +⋮---- +export interface CreateBrokerSubApiKeyRequestV3 { + subUid: string; + passphrase: string; + label: string; + ipList?: string[]; + permType: 'read_write' | 'read_only'; + permList: string[]; +} +⋮---- +export interface ModifyBrokerSubApiKeyRequestV3 { + subUid: string; + passphrase: string; + apiKey: string; + label?: string; + ipList?: string[]; + permType?: 'read_write' | 'read_only'; + permList?: string[]; +} +⋮---- +export interface DeleteBrokerSubApiKeyRequestV3 { + subUid: string; + apiKey: string; +} +⋮---- +export interface GetBrokerSubApiKeyRequestV3 { + subUid: string; +} +⋮---- +/** + * + * + * Broker | Email and Commissions + * + * + */ +⋮---- +export interface ModifySubaccountEmailRequestV3 { + subUid: string; + subaccountEmail: string; +} +⋮---- +export interface GetSubaccountEmailRequestV3 { + subUid: string; +} +⋮---- +export interface GetBrokerTradeVolumeRequestV3 { + startTime?: string; + endTime?: string; + pageSize?: string; + pageNo?: string; +} +⋮---- +export interface GetBrokerTotalCommissionRequestV3 { + startTime?: string; + endTime?: string; +} +⋮---- +export interface GetBrokerOrderCommissionRequestV3 { + startTime?: string; + endTime?: string; + limit?: string; + uid?: string; + orderid?: string; + /** Pass endId from the previous response. Omit on the first page. */ + idLessThan?: string; +} +⋮---- +/** Pass endId from the previous response. Omit on the first page. */ +⋮---- +export interface GetBrokerRebateInfoRequestV3 { + uid: string; +} + ================ File: src/types/request/v3/cfd.ts ================ @@ -8517,26 +8817,211 @@ export interface SpotDepositRecordV2 { } ================ -File: src/types/response/v3/stockplus.ts +File: src/types/response/v3/broker.ts ================ -/** - * - * - * Stock+ (UTA) - * - * - */ +export interface CreateBrokerSubAccountResponseV3 { + subUid: string; + subaccountName: string; + subaccountEmail: string; + status: 'normal' | 'freeze'; + permList: string[]; + label: string; + cTime: string; +} ⋮---- -export interface StockPlusOptionQuoteItemV3 { - symbol: string; - lastDone: string; - prevClose: string; - open: string; - high: string; - low: string; - timestamp: string; - volume: string; - turnover: 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; +} +⋮---- +/** + * + * + * Broker | Email and Commissions + * + * + */ +⋮---- +export type ModifySubaccountEmailResponseV3 = string; +⋮---- +export interface SubaccountEmailV3 { + subUid: string; + subaccountName: string; + subaccountEmail: string; + cTime: string; + uTime: string; +} +⋮---- +export interface BrokerTradeVolumeV3 { + uid: string; + volume: string; + spotVolume: string; + futureVolume: string; +} +⋮---- +export interface BrokerSpotCommissionV3 { + spotTradingVolume: string; + spotTradingFee: string; + spotPureTradingFee: string; + spotCommission: string; +} +⋮---- +export interface BrokerFuturesCommissionV3 { + futuresTradingVolume: string; + futuresTradingFee: string; + futuresPureTradingFee: string; + futuresCommission: string; +} +⋮---- +export interface BrokerTotalCommissionV3 { + date: string; + totalTradingVolume: string; + totalActiveTraders: string; + totalCommission: string; + spot: BrokerSpotCommissionV3; + futures: BrokerFuturesCommissionV3; +} +⋮---- +export interface BrokerOrderCommissionItemV3 { + fillId: string; + orderId: string; + ts: string; + clientOid: string; + bizType: string; + subBizType: string; + symbol: string; + volume: string; + fee: string; + pureFee: string; + rebateAmount: string; +} +⋮---- +export interface BrokerOrderCommissionV3 { + commissionlist: BrokerOrderCommissionItemV3[]; + endId: string; +} +⋮---- +export interface BrokerRebateInfoV3 { + affiliationType: string; + userLevel: string; + clientSpotRebateRatio: string; + clientFuturesRebateRatio: string; +} + +================ +File: src/types/response/v3/stockplus.ts +================ +/** + * + * + * Stock+ (UTA) + * + * + */ +⋮---- +export interface StockPlusOptionQuoteItemV3 { + symbol: string; + lastDone: string; + prevClose: string; + open: string; + high: string; + low: string; + timestamp: string; + volume: string; + turnover: string; tradeStatus: string; impliedVolatility: string; openInterest: string; @@ -8872,3136 +9357,2225 @@ export interface StockPlusTransferRecordsV3 { } ================ -File: src/websocket-api-client.ts +File: src/types/request/v2/broker.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. + * * Broker | Subaccount * - * 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 +export interface GetSubAccountsRequestV2 { + limit?: string; + idLessThan?: string; + status?: 'normal' | 'freeze' | 'del'; + startTime?: string; + endTime?: string; +} ⋮---- -/* - * Bitget WebSocket API Methods - * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel - */ +export type SubAccountPermissionV2 = + | 'withdraw' + | 'transfer' + | 'spot_trade' + | 'contract_trade' + | 'read' + | 'deposit' + | 'margin_trade'; ⋮---- -/** - * Submit a new order - * - * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel - * - * Sends top-level apiCode (SDK broker code, unless params.apiCode is set). - * - * @returns - */ -submitNewOrder( - category: BitgetInstTypeV3, - params: WSAPIPlaceOrderRequestV3, - ): Promise> +export type SubAccountLanguageV2 = + | 'en_US' + | 'zh_CN' + | 'ja_JP' + | 'vi_VN' + | 'zh_TW' + | 'ru_RU' + | 'es_ES' + | 'tr_TR' + | 'fr_FR' + | 'de_DE' + | 'pt_PT' + | 'th_TH'; ⋮---- -/** - * Submit a batch of orders - * - * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel - * - * Sends the same top-level apiCode as place-order. - * If any order sets apiCode, the first one is used for the request. - * - * @returns - */ -placeBatchOrders( - category: BitgetInstTypeV3, - params: WSAPIPlaceOrderRequestV3[], - ): Promise> +export type SubAccountStatusV2 = 'normal' | 'freeze'; ⋮---- -/* - * Bitget WebSocket API Methods - * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel - */ +export interface ModifySubRequestV2 { + subUid: string; + permList: SubAccountPermissionV2[]; + status: SubAccountStatusV2; + language?: SubAccountLanguageV2; +} ⋮---- -/** - * Cancel Order - * - * https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel - * - * @returns - */ -cancelOrder( - category: BitgetInstTypeV3, - params: CancelOrderRequestV3, - ): Promise> +export interface SubWithdrawalRequestV2 { + subUid: string; + coin: string; + dest: 'on_chain' | 'internal_transfer'; + chain?: string; + address: string; + amount: string; + tag?: string; + clientOid?: string; +} +⋮---- +export interface SubDepositRecordsRequestV2 { + orderId?: string; + userId?: string; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} +⋮---- +export interface SubWithdrawalRecordsRequestV2 { + orderId?: string; + userId?: string; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} ⋮---- /** - * Batch Cancel Order - * - * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Cancel-Order-Channel - * - * @returns - */ -cancelBatchOrders( - category: BitgetInstTypeV3, - params: CancelOrderRequestV3[], - ): Promise> + * + * * Broker | Subaccount + * + */ ⋮---- -updateOrder( - category: BitgetInstTypeV3, - params: ModifyOrderRequestV3, - ): Promise> +export interface CreateSubAccountApiKeyRequestV2 { + subUid: string; + passphrase: string; + label?: string; + ipList: string[]; + permType: string; + permList: string[]; +} ⋮---- -batchUpdateOrders( - category: BitgetInstTypeV3, - params: ModifyOrderRequestV3[], - ): Promise> +export interface ModifySubAccountApiKeyRequestV2 { + subUid: string; + apiKey: string; + label?: string; + passphrase: string; + ipList?: string[]; + permType?: string; + permList: string[]; +} +⋮---- +export interface DeleteSubAccountApiKeyRequestV2 { + subUid: string; + apiKey: string; +} ⋮---- /** - * - * - * - * - * - * - * - * Private methods for handling some of the convenience/automation provided by the WS API Client - * - * - * - * - * - * - * - */ + * + * * Broker | All Sub-accounts Deposit and Withdrawal Records + * + */ ⋮---- -private setupDefaultEventListeners() +export interface GetAllSubDepositWithdrawalRequestV2 { + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; + type?: 'all' | 'deposit' | 'withdrawal'; +} ⋮---- /** - * General event handlers for monitoring the WebsocketClient - */ + * + * * Broker | Subaccounts + * + */ ⋮---- -// Blind JSON.stringify can fail on circular references +export interface GetBrokerSubaccountsRequestV2 { + startTime?: string; + endTime?: string; + pageSize?: string; + pageNo?: string; +} ⋮---- -// JSON.stringify({ ...data, target: 'WebSocket' }), - -================ -File: examples/V3 - UTA/WS-API/ws-api-client-trade.ts -================ -import { DefaultLogger, WebsocketAPIClient } from '../../../src/index.js'; +/** + * + * * Broker | Commissions + * + */ ⋮---- -// or -// import { DefaultLogger, WS_KEY_MAP, WebsocketAPIClient } from 'bitget-api'; +export interface GetBrokerCommissionsRequestV2 { + startTime?: string; + endTime?: string; + pageSize?: string; + pageNo?: string; + bizType?: 'spot' | 'futures'; + subBizType?: + | 'spot_trade' + | 'spot_margin' + | 'usdt_futures' + | 'usdc_futures' + | 'coin_futures'; +} ⋮---- -// 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); -// }); -// } +/** + * + * * Broker | Trade Volume + * + */ ⋮---- -// 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 GetBrokerTradeVolumeRequestV2 { + startTime?: string; + endTime?: string; + pageSize?: string; + pageNo?: string; +} ⋮---- -// Whether to use the demo trading wss connection -// demoTrading: true, +/** + * + * * Broker | Total Commission + * + */ ⋮---- -// 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. - */ +export interface GetBrokerTotalCommissionRequestV2 { + startTime?: string; + endTime?: string; +} ⋮---- /** - const res = { - "event": "trade", - "id": "1750035029506", - "category": "spot", - "topic": "batch-place", - "args": [ - { - "code": "0", - "msg": "Success", - "symbol": "BTCUSDT", - "orderId": "xxxxxxxx", - "clientOid": "xxxxxxxx" - }, - { - "code": "0", - "msg": "Success", - "symbol": "BTCUSDT", - "orderId": "xxxxxxxx", - "clientOid": "xxxxxxxx" - } - ], - "code": "0", - "msg": "Success", - "ts": "1750035029925" - } - */ + * + * * Broker | Order Commission + * + */ ⋮---- -/** - * Cancel Order - * https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel - */ +export interface GetBrokerOrderCommissionRequestV2 { + startTime?: string; + endTime?: string; + limit?: string; + uid?: string; + orderId?: string; + idLessThan?: string; +} ⋮---- /** - const res = { - "event": "trade", - "id": "1750034870205", - "topic": "cancel-order", - "args": [ - { - "orderId": "xxxxxxxx", - "clientOid": "xxxxxxxx" - } - ], - "code": "0", - "msg": "Success", - "ts": "1750034870597" - } - */ + * + * * Broker | Rebate Info + * + */ ⋮---- -/** - * Batch Cancel Order - * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Cancel-Order-Channel - */ +export interface GetBrokerRebateInfoRequestV2 { + uid: string; +} ⋮---- -/** - const res = { - "event": "trade", - "id": "bb553cc0-c1fa-454e-956d-c96c8d715760", - "topic": "batch-cancel", - "args": [ - { - "code": "0", - "msg": "Success", - "orderId": "xxxxxxxxxxxxx" - }, - { - "code": "25204", - "msg": "Order does not exist", - "orderId": "xxxxxxxxxxxxx" - } - ], - "code": "0", - "msg": "Success", - "ts": "1751980011084" - } - */ - -================ -File: src/types/request/v2/broker.ts -================ /** * - * * Broker | Subaccount + * * Broker | Agent (affiliate) customer APIs * */ ⋮---- -export interface GetSubAccountsRequestV2 { - limit?: string; +export interface GetAgentCustomerCommissionsRequestV2 { + startTime?: string; + endTime?: string; idLessThan?: string; - status?: 'normal' | 'freeze' | 'del'; + limit?: string; + uid?: string; + coin?: string; + symbol?: string; + showSub?: 'yes' | 'no'; +} +⋮---- +export interface GetAgentSubCustomerListRequestV2 { startTime?: string; endTime?: string; + idLessThan?: string; + limit?: string; + uid?: string; + showSub?: 'yes' | 'no'; } ⋮---- -export type SubAccountPermissionV2 = - | 'withdraw' - | 'transfer' - | 'spot_trade' - | 'contract_trade' - | 'read' - | 'deposit' - | 'margin_trade'; +export interface AgentCustomerTradeVolumeRequestV2 { + startTime?: string; + endTime?: string; + pageNo?: string; + pageSize?: string; + uid?: string; + showSub?: 'yes' | 'no'; +} ⋮---- -export type SubAccountLanguageV2 = - | 'en_US' - | 'zh_CN' - | 'ja_JP' - | 'vi_VN' - | 'zh_TW' - | 'ru_RU' - | 'es_ES' - | 'tr_TR' - | 'fr_FR' - | 'de_DE' - | 'pt_PT' - | 'th_TH'; +export interface AgentCustomerListRequestV2 { + startTime?: string; + endTime?: string; + pageNo?: string; + pageSize?: string; + uid?: string; + referralCode?: string; + showSub?: 'yes' | 'no'; +} ⋮---- -export type SubAccountStatusV2 = 'normal' | 'freeze'; +export interface GetAgentCustomerKycResultRequestV2 { + startTime?: string; + endTime?: string; + idLessThan?: string; + limit?: string; + uid?: string; + showSub?: 'yes' | 'no'; +} ⋮---- -export interface ModifySubRequestV2 { - subUid: string; - permList: SubAccountPermissionV2[]; - status: SubAccountStatusV2; - language?: SubAccountLanguageV2; +export interface AgentCustomerDepositRequestV2 { + startTime?: string; + endTime?: string; + pageNo?: string; + pageSize?: string; + uid?: string; + showSub?: 'yes' | 'no'; } ⋮---- -export interface SubWithdrawalRequestV2 { - subUid: string; - coin: string; - dest: 'on_chain' | 'internal_transfer'; - chain?: string; - address: string; - amount: string; - tag?: string; - clientOid?: string; +export interface AgentCustomerAssetRequestV2 { + pageNo?: string; + pageSize?: string; + uid?: string; + showSub?: 'yes' | 'no'; } ⋮---- -export interface SubDepositRecordsRequestV2 { - orderId?: string; - userId?: string; +export interface GetAgentCommissionDetailRequestV2 { startTime?: string; endTime?: string; limit?: string; idLessThan?: string; } ⋮---- -export interface SubWithdrawalRecordsRequestV2 { - orderId?: string; - userId?: string; +export interface GetSubAffiliateInfoRequestV2 { + uid?: string; startTime?: string; endTime?: string; - limit?: string; idLessThan?: string; + limit?: string; + includeDownLine?: 'yes' | 'no'; } -⋮---- + +================ +File: src/types/request/v3/earn.ts +================ /** * - * * Broker | Subaccount + * + * Earn | On-Chain Elite (UTA) + * * */ ⋮---- -export interface CreateSubAccountApiKeyRequestV2 { - subUid: string; - passphrase: string; - label?: string; - ipList: string[]; - permType: string; - permList: string[]; +export interface GetEarnEliteRecordsRequestV3 { + type: 'subscribe' | 'redeem' | 'interest'; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; } ⋮---- -export interface ModifySubAccountApiKeyRequestV2 { - subUid: string; - apiKey: string; - label?: string; - passphrase: string; - ipList?: string[]; - permType?: string; - permList: string[]; +export interface GetEarnEliteSubscribeInfoRequestV3 { + productId: string; } ⋮---- -export interface DeleteSubAccountApiKeyRequestV2 { - subUid: string; - apiKey: string; +export interface EarnEliteSubscribeRequestV3 { + productSubId: string; + amount: string; + coin?: string; + paymentAccount?: 'spot' | 'unified'; } ⋮---- -/** - * - * * Broker | All Sub-accounts Deposit and Withdrawal Records - * - */ +export interface GetEarnEliteSubscribeResultRequestV3 { + orderId: string; +} ⋮---- -export interface GetAllSubDepositWithdrawalRequestV2 { - startTime?: string; - endTime?: string; - limit?: string; - idLessThan?: string; - type?: 'all' | 'deposit' | 'withdrawal'; +export interface GetEarnEliteRedeemInfoRequestV3 { + productId: string; +} +⋮---- +export interface RedeemEarnEliteRequestV3 { + productId: string; + productSubId: string; + redeemType: 'fast' | 'standard'; + amount: string; + receiveAccount: 'spot' | 'unified'; + advancedSettle?: 'yes' | 'no'; + coin?: string; } ⋮---- /** * - * * Broker | Subaccounts + * + * Earn | Cash+ (UTA) + * Master and sub-accounts can call these. + * * */ ⋮---- -export interface GetBrokerSubaccountsRequestV2 { - startTime?: string; - endTime?: string; - pageSize?: string; - pageNo?: string; +export type EarnCashPlusRecordTypeV3 = + | 'subscribe' + | 'redeem' + | 'compound_interest' + | 'liquidation_redeem'; +⋮---- +export interface EarnCashPlusSubscribeRequestV3 { + /** From subscribe-info */ + productSubId: string; + /** Subscription amount, in the subscription coin */ + amount: string; + /** + * Debit account. funding (default), uta, or otc. + * Comma-separated when more than one, e.g. funding,uta. + */ + accountType?: string; + /** Prevents a duplicate submit of the same subscription */ + idempotentNo?: string; } ⋮---- +/** From subscribe-info */ +⋮---- +/** Subscription amount, in the subscription coin */ +⋮---- /** - * - * * Broker | Commissions - * - */ + * Debit account. funding (default), uta, or otc. + * Comma-separated when more than one, e.g. funding,uta. + */ ⋮---- -export interface GetBrokerCommissionsRequestV2 { - startTime?: string; - endTime?: string; - pageSize?: string; - pageNo?: string; - bizType?: 'spot' | 'futures'; - subBizType?: - | 'spot_trade' - | 'spot_margin' - | 'usdt_futures' - | 'usdc_futures' - | 'coin_futures'; +/** Prevents a duplicate submit of the same subscription */ +⋮---- +export interface GetEarnCashPlusSubscribeResultRequestV3 { + orderId: string; } ⋮---- -/** - * - * * Broker | Trade Volume - * - */ +export interface EarnCashPlusRedeemRequestV3 { + productSubId: string; + /** Amount of Cash+ to redeem */ + amount: string; + /** Credit account. funding (default) or uta */ + accountType?: 'funding' | 'uta'; +} ⋮---- -export interface GetBrokerTradeVolumeRequestV2 { +/** Amount of Cash+ to redeem */ +⋮---- +/** Credit account. funding (default) or uta */ +⋮---- +export interface GetEarnCashPlusRedeemResultRequestV3 { + orderId: string; +} +⋮---- +export interface GetEarnCashPlusHistoryOrdersRequestV3 { startTime?: string; endTime?: string; - pageSize?: string; - pageNo?: string; + recordType?: EarnCashPlusRecordTypeV3; + /** Default 20, max 100 */ + limit?: string; + /** Pass nextCursor from the previous page. Omit on the first page */ + cursor?: string; } ⋮---- +/** Default 20, max 100 */ +⋮---- +/** Pass nextCursor from the previous page. Omit on the first page */ +⋮---- /** * - * * Broker | Total Commission + * + * Earn | Savings (UTA) + * * */ ⋮---- -export interface GetBrokerTotalCommissionRequestV2 { +export interface GetEarnSavingsProductsRequestV3 { + coin?: string; + filter?: 'available' | 'held' | 'available_and_held' | 'all'; +} +⋮---- +export interface GetEarnSavingsAssetsRequestV3 { + periodType: 'flexible' | 'fixed'; startTime?: string; endTime?: string; + limit?: string; + /** Pass endId from the previous response. Omit on the first page. */ + cursor?: string; } ⋮---- -/** - * - * * Broker | Order Commission - * - */ +/** Pass endId from the previous response. Omit on the first page. */ ⋮---- -export interface GetBrokerOrderCommissionRequestV2 { +export interface GetEarnSavingsRecordsRequestV3 { + coin?: string; + periodType: 'flexible' | 'fixed'; + orderType?: 'subscribe' | 'redeem' | 'pay_interest' | 'deduction'; startTime?: string; endTime?: string; limit?: string; - uid?: string; + /** Pass endId from the previous response. Omit on the first page. */ + cursor?: string; +} +⋮---- +/** Pass endId from the previous response. Omit on the first page. */ +⋮---- +export interface GetEarnSavingsSubscriptionRequestV3 { + productId: string; + periodType: 'flexible' | 'fixed'; +} +⋮---- +export interface SubscribeSavingsRequestV3 { + productId: string; + periodType: 'flexible' | 'fixed'; + amount: string; +} +⋮---- +export interface GetEarnSavingsSubscriptionResultRequestV3 { + orderId: string; + periodType: 'flexible' | 'fixed'; +} +⋮---- +export interface RedeemSavingsRequestV3 { + productId: string; + /** Assets order ID returned by getEarnSavingsAssets */ orderId?: string; - idLessThan?: string; + periodType: 'flexible' | 'fixed'; + amount: string; } ⋮---- -/** - * - * * Broker | Rebate Info - * - */ +/** Assets order ID returned by getEarnSavingsAssets */ ⋮---- -export interface GetBrokerRebateInfoRequestV2 { - uid: string; +export interface GetEarnSavingsRedemptionResultRequestV3 { + orderId: string; + periodType: 'flexible' | 'fixed'; } ⋮---- /** * - * * Broker | Agent (affiliate) customer APIs + * + * Earn | SharkFin (UTA) + * * */ ⋮---- -export interface GetAgentCustomerCommissionsRequestV2 { - startTime?: string; - endTime?: string; - idLessThan?: string; +export interface GetSharkfinProductsRequestV3 { + coin: string; limit?: string; - uid?: string; - coin?: string; - symbol?: string; - showSub?: 'yes' | 'no'; + /** Pass endId from the previous response. Omit on the first page. */ + cursor?: string; } ⋮---- -export interface GetAgentSubCustomerListRequestV2 { +/** Pass endId from the previous response. Omit on the first page. */ +⋮---- +export interface GetSharkfinAssetsRequestV3 { + status: 'subscribed' | 'settled'; startTime?: string; endTime?: string; - idLessThan?: string; limit?: string; - uid?: string; - showSub?: 'yes' | 'no'; + /** Pass endId from the previous response. Omit on the first page. */ + cursor?: string; } ⋮---- -export interface AgentCustomerTradeVolumeRequestV2 { +/** Pass endId from the previous response. Omit on the first page. */ +⋮---- +export interface GetSharkfinRecordsRequestV3 { + coin?: string; + type: 'subscription' | 'redemption' | 'interest'; startTime?: string; endTime?: string; - pageNo?: string; - pageSize?: string; - uid?: string; - showSub?: 'yes' | 'no'; -} -⋮---- -export interface AgentCustomerListRequestV2 { - startTime?: string; - endTime?: string; - pageNo?: string; - pageSize?: string; - uid?: string; - referralCode?: string; - showSub?: 'yes' | 'no'; -} -⋮---- -export interface GetAgentCustomerKycResultRequestV2 { - startTime?: string; - endTime?: string; - idLessThan?: string; limit?: string; - uid?: string; - showSub?: 'yes' | 'no'; + /** Pass endId from the previous response. Omit on the first page. */ + cursor?: string; } ⋮---- -export interface AgentCustomerDepositRequestV2 { - startTime?: string; - endTime?: string; - pageNo?: string; - pageSize?: string; - uid?: string; - showSub?: 'yes' | 'no'; -} +/** Pass endId from the previous response. Omit on the first page. */ ⋮---- -export interface AgentCustomerAssetRequestV2 { - pageNo?: string; - pageSize?: string; - uid?: string; - showSub?: 'yes' | 'no'; +export interface GetSharkfinSubscriptionRequestV3 { + productId: string; } ⋮---- -export interface GetAgentCommissionDetailRequestV2 { - startTime?: string; - endTime?: string; - limit?: string; - idLessThan?: string; +export interface SubscribeSharkfinRequestV3 { + productId: string; + amount: string; } ⋮---- -export interface GetSubAffiliateInfoRequestV2 { - uid?: string; - startTime?: string; - endTime?: string; - idLessThan?: string; - limit?: string; - includeDownLine?: 'yes' | 'no'; +export interface GetSharkfinSubscriptionResultRequestV3 { + orderId: string; } ================ -File: src/types/request/v3/broker.ts +File: src/types/response/v3/cfd.ts ================ -export interface CreateBrokerSubAccountRequestV3 { - subaccountName: string; - label: string; -} +import type { CfdOrderTypeV3, CfdSideV3 } from '../../request/v3/cfd.js'; ⋮---- -export interface GetBrokerSubAccountListRequestV3 { - limit?: string; - cursor?: string; - status?: 'normal' | 'freeze'; +export interface CfdTickerV3 { + symbol: string; + /** Replaced by askOpenPriceChange and bidOpenPriceChange */ + openPriceChange?: string; + askOpenPriceChange?: string; + bidOpenPriceChange?: string; + highPrice: string; + lowPrice: string; + quoteTime: string; + ask1?: string; + bid1?: string; } ⋮---- -export interface ModifyBrokerSubAccountRequestV3 { - subUid: string; - status?: 'normal' | 'freeze'; - permList?: string[]; -} +/** Replaced by askOpenPriceChange and bidOpenPriceChange */ ⋮---- -export interface BrokerSubWithdrawalRequestV3 { - subUid: string; - coin: string; - dest: 'on_chain' | 'internal_transfer'; - address: string; - amount: string; - chain?: string; - tag?: string; - clientOid?: string; +export interface CfdCandlestickV3 extends Array { + 0: string; + 1: string; + 2: string; + 3: string; + 4: string; } ⋮---- -export interface GetBrokerSubDepositAddressRequestV3 { - subUid: string; - coin: string; - chain?: string; +export interface PlaceCfdOrderResponseV3 { + trxId: string; } ⋮---- -export interface GetBrokerAllSubDepositWithdrawalRequestV3 { - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; - status?: 'pending' | 'fail' | 'success'; +export interface ModifyCfdOrderResponseV3 { + orderId: string; } ⋮---- -export interface GetBrokerCommissionRequestV3 { - startTime?: string; - endTime?: string; - pageSize?: string; - pageNo?: string; - bizType?: 'spot' | 'futures'; - subBizType?: - | 'spot_trade' - | 'spot_margin' - | 'usdt_futures' - | 'usdc_futures' - | 'coin_futures'; +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 CreateBrokerSubApiKeyRequestV3 { - subUid: string; - passphrase: string; - label: string; - ipList?: string[]; - permType: 'read_write' | 'read_only'; - permList: 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 ModifyBrokerSubApiKeyRequestV3 { - subUid: string; - passphrase: string; - apiKey: string; - label?: string; - ipList?: string[]; - permType?: 'read_write' | 'read_only'; - permList?: string[]; +export interface CfdOrderHistoryV3 { + list: CfdHistoryOrderV3[]; } ⋮---- -export interface DeleteBrokerSubApiKeyRequestV3 { - subUid: string; - apiKey: string; +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 GetBrokerSubApiKeyRequestV3 { - subUid: 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; } ⋮---- -/** - * - * - * Broker | Email and Commissions - * - * - */ -⋮---- -export interface ModifySubaccountEmailRequestV3 { - subUid: string; - subaccountEmail: string; +export interface CfdTransferResponseV3 { + transferId: string; } ⋮---- -export interface GetSubaccountEmailRequestV3 { - subUid: string; +export interface CfdTransferRecordV3 { + transferId: string; + coin: string; + amount: string; + direction: string; + status: string; + accountType: string; + createdTime: string; + updatedTime: string; } ⋮---- -export interface GetBrokerTradeVolumeRequestV3 { - startTime?: string; - endTime?: string; - pageSize?: string; - pageNo?: string; +export interface CfdTransferRecordsV3 { + list: CfdTransferRecordV3[]; + cursor?: string; } ⋮---- -export interface GetBrokerTotalCommissionRequestV3 { - startTime?: string; - endTime?: 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 GetBrokerOrderCommissionRequestV3 { - startTime?: string; - endTime?: string; - limit?: string; - uid?: string; - orderid?: string; - /** Pass endId from the previous response. Omit on the first page. */ - idLessThan?: string; +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; + /** Instrument trading timezone as UTC offset hours, e.g. "+2" */ + currentTimezone: string; + commissionType: string; + commissionRate: string; + symbolCategory: string; + exchangeRate: string; + marginUsdRate: string; } ⋮---- -/** Pass endId from the previous response. Omit on the first page. */ -⋮---- -export interface GetBrokerRebateInfoRequestV3 { - uid: string; -} +/** Instrument trading timezone as UTC offset hours, e.g. "+2" */ ================ -File: src/types/request/v3/earn.ts +File: docs/BITGET_SDK_QUICKSTART_GUIDE.md ================ -/** - * - * - * Earn | On-Chain Elite (UTA) - * - * - */ -⋮---- -export interface GetEarnEliteRecordsRequestV3 { - type: 'subscribe' | 'redeem' | 'interest'; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; -} -⋮---- -export interface GetEarnEliteSubscribeInfoRequestV3 { - productId: string; -} -⋮---- -export interface EarnEliteSubscribeRequestV3 { - productSubId: string; - amount: string; - coin?: string; - paymentAccount?: 'spot' | 'unified'; -} -⋮---- -export interface GetEarnEliteSubscribeResultRequestV3 { - orderId: string; -} -⋮---- -export interface GetEarnEliteRedeemInfoRequestV3 { - productId: string; -} -⋮---- -export interface RedeemEarnEliteRequestV3 { - productId: string; - productSubId: string; - redeemType: 'fast' | 'standard'; - amount: string; - receiveAccount: 'spot' | 'unified'; - advancedSettle?: 'yes' | 'no'; - coin?: string; -} -⋮---- -/** - * - * - * Earn | Cash+ (UTA) - * Master and sub-accounts can call these. - * - * - */ -⋮---- -export type EarnCashPlusRecordTypeV3 = - | 'subscribe' - | 'redeem' - | 'compound_interest' - | 'liquidation_redeem'; -⋮---- -export interface EarnCashPlusSubscribeRequestV3 { - /** From subscribe-info */ - productSubId: string; - /** Subscription amount, in the subscription coin */ - amount: string; - /** - * Debit account. funding (default), uta, or otc. - * Comma-separated when more than one, e.g. funding,uta. - */ - accountType?: string; - /** Prevents a duplicate submit of the same subscription */ - idempotentNo?: string; -} -⋮---- -/** From subscribe-info */ -⋮---- -/** Subscription amount, in the subscription coin */ -⋮---- -/** - * Debit account. funding (default), uta, or otc. - * Comma-separated when more than one, e.g. funding,uta. - */ -⋮---- -/** Prevents a duplicate submit of the same subscription */ -⋮---- -export interface GetEarnCashPlusSubscribeResultRequestV3 { - orderId: string; -} -⋮---- -export interface EarnCashPlusRedeemRequestV3 { - productSubId: string; - /** Amount of Cash+ to redeem */ - amount: string; - /** Credit account. funding (default) or uta */ - accountType?: 'funding' | 'uta'; -} -⋮---- -/** Amount of Cash+ to redeem */ -⋮---- -/** Credit account. funding (default) or uta */ -⋮---- -export interface GetEarnCashPlusRedeemResultRequestV3 { - orderId: string; -} -⋮---- -export interface GetEarnCashPlusHistoryOrdersRequestV3 { - startTime?: string; - endTime?: string; - recordType?: EarnCashPlusRecordTypeV3; - /** Default 20, max 100 */ - limit?: string; - /** Pass nextCursor from the previous page. Omit on the first page */ - cursor?: string; -} -⋮---- -/** Default 20, max 100 */ -⋮---- -/** Pass nextCursor from the previous page. Omit on the first page */ -⋮---- -/** - * - * - * Earn | Savings (UTA) - * - * - */ -⋮---- -export interface GetEarnSavingsProductsRequestV3 { - coin?: string; - filter?: 'available' | 'held' | 'available_and_held' | 'all'; -} -⋮---- -export interface GetEarnSavingsAssetsRequestV3 { - periodType: 'flexible' | 'fixed'; - startTime?: string; - endTime?: string; - limit?: string; - /** Pass endId from the previous response. Omit on the first page. */ - cursor?: string; -} -⋮---- -/** Pass endId from the previous response. Omit on the first page. */ -⋮---- -export interface GetEarnSavingsRecordsRequestV3 { - coin?: string; - periodType: 'flexible' | 'fixed'; - orderType?: 'subscribe' | 'redeem' | 'pay_interest' | 'deduction'; - startTime?: string; - endTime?: string; - limit?: string; - /** Pass endId from the previous response. Omit on the first page. */ - cursor?: string; -} -⋮---- -/** Pass endId from the previous response. Omit on the first page. */ -⋮---- -export interface GetEarnSavingsSubscriptionRequestV3 { - productId: string; - periodType: 'flexible' | 'fixed'; -} -⋮---- -export interface SubscribeSavingsRequestV3 { - productId: string; - periodType: 'flexible' | 'fixed'; - amount: string; -} -⋮---- -export interface GetEarnSavingsSubscriptionResultRequestV3 { - orderId: string; - periodType: 'flexible' | 'fixed'; -} -⋮---- -export interface RedeemSavingsRequestV3 { - productId: string; - /** Assets order ID returned by getEarnSavingsAssets */ - orderId?: string; - periodType: 'flexible' | 'fixed'; - amount: string; -} -⋮---- -/** Assets order ID returned by getEarnSavingsAssets */ -⋮---- -export interface GetEarnSavingsRedemptionResultRequestV3 { - orderId: string; - periodType: 'flexible' | 'fixed'; -} -⋮---- -/** - * - * - * Earn | SharkFin (UTA) - * - * - */ -⋮---- -export interface GetSharkfinProductsRequestV3 { - coin: string; - limit?: string; - /** Pass endId from the previous response. Omit on the first page. */ - cursor?: string; -} -⋮---- -/** Pass endId from the previous response. Omit on the first page. */ -⋮---- -export interface GetSharkfinAssetsRequestV3 { - status: 'subscribed' | 'settled'; - startTime?: string; - endTime?: string; - limit?: string; - /** Pass endId from the previous response. Omit on the first page. */ - cursor?: string; -} -⋮---- -/** Pass endId from the previous response. Omit on the first page. */ -⋮---- -export interface GetSharkfinRecordsRequestV3 { - coin?: string; - type: 'subscription' | 'redemption' | 'interest'; - startTime?: string; - endTime?: string; - limit?: string; - /** Pass endId from the previous response. Omit on the first page. */ - cursor?: string; -} -⋮---- -/** Pass endId from the previous response. Omit on the first page. */ -⋮---- -export interface GetSharkfinSubscriptionRequestV3 { - productId: string; -} -⋮---- -export interface SubscribeSharkfinRequestV3 { - productId: string; - amount: string; -} -⋮---- -export interface GetSharkfinSubscriptionResultRequestV3 { - orderId: string; -} + +# Bitget API JavaScript Tutorial for Node.js and TypeScript -================ -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; + +> [!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, + }); } -⋮---- -export interface GetBrokerAllSubDepositWithdrawalResponseV3 { - list: BrokerSubDepositWithdrawalRecordV3[]; - endId: string; + +main().catch(console.error); +``` + +If that prints data, public REST is working. + +See also: [V3 public REST examples](../examples/V3%20-%20UTA/Rest) + +### 2. First private REST API request + +Private REST uses the same `RestClientV3` with credentials - the SDK signs requests for you. + + +```typescript +import { RestClientV3 } from 'bitget-api'; + +function readBitgetCredentials() { + const apiKey = process.env.BITGET_API_KEY; + const apiSecret = process.env.BITGET_API_SECRET; + const apiPass = process.env.BITGET_API_PASS; + + if (!apiKey || !apiSecret || !apiPass) { + throw new Error( + 'Set BITGET_API_KEY, BITGET_API_SECRET, and BITGET_API_PASS before running private examples.', + ); + } + + return { apiKey, apiSecret, apiPass }; } -⋮---- -export interface BrokerCommissionRecordV3 { - uid: string; - coin: string; - symbol: string; - dealtAmount: string; - totalFee: string; - deductedFee: string; - paidFee: string; - markUpFee: string; - totalCommission: 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 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; -} -⋮---- -/** - * - * - * Broker | Email and Commissions - * - * - */ -⋮---- -export type ModifySubaccountEmailResponseV3 = string; -⋮---- -export interface SubaccountEmailV3 { - subUid: string; - subaccountName: string; - subaccountEmail: string; - cTime: string; - uTime: string; -} -⋮---- -export interface BrokerTradeVolumeV3 { - uid: string; - volume: string; - spotVolume: string; - futureVolume: string; -} -⋮---- -export interface BrokerSpotCommissionV3 { - spotTradingVolume: string; - spotTradingFee: string; - spotPureTradingFee: string; - spotCommission: string; -} -⋮---- -export interface BrokerFuturesCommissionV3 { - futuresTradingVolume: string; - futuresTradingFee: string; - futuresPureTradingFee: string; - futuresCommission: string; -} -⋮---- -export interface BrokerTotalCommissionV3 { - date: string; - totalTradingVolume: string; - totalActiveTraders: string; - totalCommission: string; - spot: BrokerSpotCommissionV3; - futures: BrokerFuturesCommissionV3; -} -⋮---- -export interface BrokerOrderCommissionItemV3 { - fillId: string; - orderId: string; - ts: string; - clientOid: string; - bizType: string; - subBizType: string; - symbol: string; - volume: string; - fee: string; - pureFee: string; - rebateAmount: string; -} -⋮---- -export interface BrokerOrderCommissionV3 { - commissionlist: BrokerOrderCommissionItemV3[]; - endId: 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 BrokerRebateInfoV3 { - affiliationType: string; - userLevel: string; - clientSpotRebateRatio: string; - clientFuturesRebateRatio: 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 }; } -================ -File: src/types/response/v3/cfd.ts -================ -import type { CfdOrderTypeV3, CfdSideV3 } from '../../request/v3/cfd.js'; -⋮---- -export interface CfdTickerV3 { - symbol: string; - /** Replaced by askOpenPriceChange and bidOpenPriceChange */ - openPriceChange?: string; - askOpenPriceChange?: string; - bidOpenPriceChange?: string; - highPrice: string; - lowPrice: string; - quoteTime: string; - ask1?: string; - bid1?: string; -} -⋮---- -/** Replaced by askOpenPriceChange and bidOpenPriceChange */ -⋮---- -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; +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 CfdUnfilledOrderV3 { - symbol: string; - orderType: CfdOrderTypeV3 | string; - side: CfdSideV3 | string; - price: string; - qty: string; - takeProfit?: string; - stopLoss?: string; - trxId: string; - orderId: string; + +main().catch(console.error); +``` + +Check order status via private streams or REST: `getOrderInfo`, `getUnfilledOrders`, `getHistoryOrders`, or `getTradeFills`. + +See also: [V3 spot trading example](../examples/V3%20-%20UTA/Rest/rest-trade-UTA-spot.ts) + +### 6. First WebSocket API order command + +The WebSocket API sends order commands over a persistent connection and waits for a response. `WebsocketAPIClient` wraps that in promises - write orders like normal `async` calls. + +This example uses `demoTrading: true` with demo API keys. + + +```typescript +import { WebsocketAPIClient } from 'bitget-api'; + +function readBitgetCredentials() { + const apiKey = process.env.BITGET_API_KEY; + const apiSecret = process.env.BITGET_API_SECRET; + const apiPass = process.env.BITGET_API_PASS; + + if (!apiKey || !apiSecret || !apiPass) { + throw new Error( + 'Set BITGET_API_KEY, BITGET_API_SECRET, and BITGET_API_PASS with demo API credentials before placing demo orders.', + ); + } + + return { apiKey, apiSecret, apiPass }; } -⋮---- -export 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; + +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 CfdOrderHistoryV3 { - list: CfdHistoryOrderV3[]; + +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 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; + +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 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; - /** Instrument trading timezone as UTC offset hours, e.g. "+2" */ - currentTimezone: string; - commissionType: string; - commissionRate: string; - symbolCategory: string; - exchangeRate: string; - marginUsdRate: string; + +main().catch(console.error); +``` + +### Common trading calls + +```typescript +import { RestClientV3 } from 'bitget-api'; + +const client = new RestClientV3({ + apiKey: process.env.BITGET_API_KEY!, + apiSecret: process.env.BITGET_API_SECRET!, + apiPass: process.env.BITGET_API_PASS!, + demoTrading: true, +}); + +async function main() { + const clientOid = `rest-${Date.now()}`; + + const placed = await client.submitNewOrder({ + category: 'SPOT', + symbol: 'BTCUSDT', + side: 'buy', + orderType: 'limit', + price: '10000', + qty: '0.001', + timeInForce: 'gtc', + clientOid, + }); + + const orderInfo = await client.getOrderInfo({ + clientOid, + }); + + const cancelled = await client.cancelOrder({ + clientOid, + }); + + console.log({ placed, orderInfo, cancelled }); } -⋮---- -/** Instrument trading timezone as UTC offset hours, e.g. "+2" */ -================ -File: src/websocket-client-v3.ts -================ -import { - WsAPIOperationResponseMap, - WSAPIRequestBitgetV3, - WSAPIRequestFlags, - WsAPITopicRequestParamMap, - WsAPIWsKeyTopicMap, - WSOperation, - WSOperationLoginParams, - WsRequestOperationBitget, -} from './types/websockets/ws-api.js'; -import { MessageEventLike } from './types/websockets/ws-events.js'; -import { - BitgetInstTypeV3, - WsKey, - WsTopicV3, -} from './types/websockets/ws-general.js'; -import { - BaseWebsocketClient, - EmittableEvent, - MidflightWsRequestEvent, -} from './util/BaseWSClient.js'; -import { CHANNEL_API_CODE, isWsPong } from './util/requestUtils.js'; -import { isWSAPIResponse } from './util/type-guards.js'; -import { SignAlgorithm, signMessage } from './util/webCryptoAPI.js'; -import { - getMaxTopicsPerSubscribeEvent, - getNormalisedTopicRequests, - getPromiseRefForWSAPIRequest, - getWsUrl, - WS_AUTH_ON_CONNECT_KEYS, - WS_KEY_MAP, - WS_LOGGER_CATEGORY, - WsTopicRequest, -} from './util/websocket-util.js'; -import { WSConnectedResult } from './util/WsStore.types.js'; -⋮---- -/** - * WebSocket client dedicated to the unified account (V3) WebSockets. - * - * Your Bitget account needs to be upgraded to unified account mode, to use the account-level WebSocket topics. - */ -export class WebsocketClientV3 extends BaseWebsocketClient< -⋮---- -WsRequestOperationBitget // subscribe requests have an "args" parameter with an object within -⋮---- -/** - * Request connection of all dependent (public & private) websockets, instead of waiting for automatic connection by library - */ -public connectAll(): Promise[] -⋮---- -/** - * Ensures the WS API connection is active and ready. - * - * You do not need to call this, but if you call this before making any WS API requests, - * it can accelerate the first request (by preparing the connection in advance). - */ -public connectWSAPI(): Promise -⋮---- -/** This call automatically ensures the connection is active AND authenticated before resolving */ -⋮---- -/** - * Request subscription to one or more topics. Pass topics as either an array of strings, - * or array of objects (if the topic has parameters). - * - * Objects should be formatted as {topic: string, params: object, category: CategoryV5}. - * - * - Subscriptions are automatically routed to the correct websocket connection. - * - Authentication/connection is automatic. - * - Resubscribe after network issues is automatic. - * - * Call `unsubscribe(topics)` to remove topics - */ -public subscribe( - requests: - | (WsTopicRequest | WsTopicV3) - | (WsTopicRequest | WsTopicV3)[], - wsKey: WsKey, - ): Promise -⋮---- -/** - * Unsubscribe from one or more topics. Similar to subscribe() but in reverse. - * - * - Requests are automatically routed to the correct websocket connection. - * - These topics will be removed from the topic cache, so they won't be subscribed to again. - */ -public unsubscribe( - requests: - | (WsTopicRequest | WsTopicV3) - | (WsTopicRequest | WsTopicV3)[], - wsKey: WsKey, - ) -⋮---- -/** - * - * - * Internal methods required to integrate with the BaseWSClient - * - * - */ -⋮---- -protected sendPingEvent(wsKey: WsKey): void -⋮---- -protected sendPongEvent(wsKey: WsKey): void -⋮---- -protected isWsPing(data: any): boolean -⋮---- -protected isWsPong(data: any): boolean -⋮---- -protected isPrivateTopicRequest( - _request: WsTopicRequest, - wsKey: WsKey, - ): boolean -⋮---- -protected getPrivateWSKeys(): WsKey[] -⋮---- -protected isAuthOnConnectWsKey(wsKey: WsKey): boolean -⋮---- -protected async getWsUrl(wsKey: WsKey): Promise -⋮---- -protected getMaxTopicsPerSubscribeEvent(wsKey: WsKey): number | null -⋮---- -/** - * @returns one or more correctly structured request events for performing a operations over WS. This can vary per exchange spec. - */ -protected async getWsRequestEvents( - operation: WSOperation, - requests: WsTopicRequest[], - ): Promise>[]> -⋮---- -// Previously used to track topics in a request. Keeping this for subscribe/unsubscribe requests, no need for incremental values -⋮---- -/** - { - "op":"subscribe", - "args":[ - { - "instType":"spot", - "topic":"ticker", - "symbol":"BTCUSDT" - }, - { - "instType":"spot", - "topic":"candle5m", - "symbol":"BTCUSDT" - } - ] - } - */ -⋮---- -// const request = { -// topic: 'ticker', -// payload: { instType: 'spot', symbol: 'BTCUSDT' }, -// }; -// becomes: -// const request = { -// topic: 'ticker', -// instType: 'spot', -// symbol: 'BTCUSDT', -// }; -⋮---- -private async getWsAuthSignature( - wsKey: WsKey, - ): Promise<{ expiresAt: number; signature: string }> -⋮---- -private async signMessage( - paramsStr: string, - secret: string, - method: 'hex' | 'base64', - algorithm: SignAlgorithm, - ): Promise -⋮---- -protected async getWsAuthRequestEvent( - wsKey: WsKey, - ): Promise> -⋮---- -/** - * Abstraction called to sort ws events into emittable event types (response to a request, data update, etc) - */ -protected resolveEmittableEvents( - wsKey: WsKey, - event: MessageEventLike, - ): EmittableEvent[] -⋮---- -/** - * WS API response handling - */ -⋮---- -// const eg1 = { -// event: 'error', -// id: '1', -// code: '43012', -// msg: 'Insufficient balance', -// }; -⋮---- -// WS API Success -⋮---- -/** - * V3 event handling for consumers - behaves the same as V2 - */ -⋮---- -// v2 authentication event -⋮---- -// messageType: typeof msg, -// messageString: JSON.stringify(msg), -⋮---- -// Service upgrade (30033): Bitget sends this ~60s before disconnect. Log and let automatic reconnect handle when connection drops. -⋮---- -// messageType: typeof msg, -// messageString: JSON.stringify(msg), -⋮---- -// fallback emit anyway -⋮---- -/** - * V3/UTA supports order placement via WebSockets. This is the WS API: - * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel - * - * @returns a promise that resolves/rejects when a matching response arrives - */ -async sendWSAPIRequest< - TWSKey extends keyof WsAPIWsKeyTopicMap, - TWSOperation extends WsAPIWsKeyTopicMap[TWSKey], - TWSParams extends WsAPITopicRequestParamMap[TWSOperation], - TWSAPIResponse extends - WsAPIOperationResponseMap[TWSOperation] = WsAPIOperationResponseMap[TWSOperation], - >( - wsKey: WsKey, - operation: TWSOperation, - category: BitgetInstTypeV3, - params: TWSParams & { signRequest?: boolean }, - requestFlags?: WSAPIRequestFlags, - ): Promise -⋮---- -// this.logger.trace('sendWSAPIRequest(): assertIsAuthenticated(${wsKey})...'); -⋮---- -// this.logger.trace('sendWSAPIRequest(): assertIsAuthenticated(${wsKey}) ok'); -⋮---- -// apiCode is a top-level field on the trade envelope, not an arg. -// A caller value replaces the SDK broker code. One code per request. -⋮---- -// Ensure "args" is always wrapped as array -⋮---- -// Store deferred promise, resolved within the "resolveEmittableEvents" method while parsing incoming events -⋮---- -// eslint-disable-next-line @typescript-eslint/no-explicit-any -⋮---- -// Enrich returned promise with request context for easier debugging -⋮---- -// throw e; -⋮---- -// Send event -⋮---- -// Return deferred promise, so caller can await this call +main().catch(console.error); +``` -================ -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** +For futures close-only orders, V3 REST uses lower-case `reduceOnly` values: -- 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) +```typescript +await client.submitNewOrder({ + category: 'USDT-FUTURES', + symbol: 'BTCUSDT', + side: 'sell', + orderType: 'limit', + price: '100000', + qty: '0.001', + timeInForce: 'gtc', + posSide: 'long', + reduceOnly: 'yes', +}); +``` --- - -## Why use the SDK - -Bitget has several API surfaces, and they don't all work the same way: + +## V3 WebSocket streams -- 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. +For live market or account updates, use `WebsocketClientV3`. -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. +### Common events -The main SDK surfaces are: +```typescript +import { WebsocketClientV3 } from 'bitget-api'; -| 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 | +const ws = new WebsocketClientV3({}); -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. +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. - -## Installation & API Keys +### Public topics -Install the SDK with npm: +```typescript +import { WebsocketClientV3, WS_KEY_MAP } from 'bitget-api'; -```bash -npm install bitget-api -``` +const ws = new WebsocketClientV3({}); -Or use another npm-compatible package manager: +ws.on('update', (data) => { + console.log('public update', JSON.stringify(data)); +}); -```bash -pnpm install bitget-api -yarn add bitget-api +ws.subscribe( + [ + { + topic: 'ticker', + payload: { + instType: 'spot', + symbol: 'BTCUSDT', + }, + }, + { + topic: 'books', + payload: { + instType: 'usdt-futures', + symbol: 'BTCUSDT', + }, + }, + ], + WS_KEY_MAP.v3Public, +); ``` -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: +V3 public `instType` values are lower-case: `spot`, `usdt-futures`, `usdc-futures`, and `coin-futures`. -| SDK option | Bitget credential | -| ----------- | ---------------------------------------------- | -| `apiKey` | API key | -| `apiSecret` | API secret | -| `apiPass` | API passphrase set when the API key is created | +### Private topics -`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. +```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!, +}); - -## Bitget concepts in this guide +ws.on('update', (data) => { + console.log('private update', JSON.stringify(data)); +}); -Bitget has a few naming differences across their API: +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, +); +``` -| 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` | +V3 private account topics use `instType: 'UTA'`. -REST, WebSocket streams, and the WebSocket API are separate integration flows: +### Unsubscribe -| 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 | +```typescript +ws.unsubscribe( + { + topic: 'ticker', + payload: { + instType: 'spot', + symbol: 'BTCUSDT', + }, + }, + WS_KEY_MAP.v3Public, +); +``` -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. +The SDK remembers subscriptions per connection and resubscribes after reconnects. --- - -## Start building: first REST API calls - -Want the quickest path to something working? Start here. - -### 1. First public REST API request + +## V3 WebSocket API -Public REST calls work without credentials. +`WebsocketAPIClient` sends V3 order commands over WebSocket and returns a promise for each response. - ```typescript -import { RestClientV3 } from 'bitget-api'; +import { WebsocketAPIClient } from 'bitget-api'; -const client = new RestClientV3(); +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() { - 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', + await wsApi.getWSClient().connectWSAPI(); + + const clientOid = `wsapi-${Date.now()}`; + + const placed = await wsApi.submitNewOrder('spot', { symbol: 'BTCUSDT', - interval: '1m', - limit: '5', + side: 'buy', + orderType: 'limit', + price: '10000', + qty: '0.001', + timeInForce: 'gtc', + clientOid, }); - 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, + const cancelled = await wsApi.cancelOrder('spot', { + clientOid, }); + + console.log({ placed, cancelled }); } main().catch(console.error); ``` -If that prints data, public REST is working. +The helper methods are: -See also: [V3 public REST examples](../examples/V3%20-%20UTA/Rest) +| Method | WebSocket API operation | +| ---------------------------------------- | ----------------------- | +| `submitNewOrder(category, orderRequest)` | `place-order` | +| `placeBatchOrders(category, orders)` | `batch-place` | +| `cancelOrder(category, cancelRequest)` | `cancel-order` | +| `cancelBatchOrders(category, cancels)` | `batch-cancel` | -### 2. First private REST API request +For batch operations, check each item in the returned `args` array - one batch can mix accepted and rejected orders. -Private REST uses the same `RestClientV3` with credentials - the SDK signs requests for you. +For futures close-only orders over the WebSocket API, use upper-case `reduceOnly` values: - ```typescript -import { RestClientV3 } from 'bitget-api'; +await wsApi.submitNewOrder('usdt-futures', { + symbol: 'BTCUSDT', + side: 'sell', + orderType: 'limit', + price: '100000', + qty: '0.001', + timeInForce: 'gtc', + posSide: 'long', + reduceOnly: 'YES', +}); +``` -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.', - ); - } + +## V2/Classic APIs - return { apiKey, apiSecret, apiPass }; -} +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. -const client = new RestClientV3(readBitgetCredentials()); +### Classic public REST + +```typescript +import { RestClientV2 } from 'bitget-api'; + +const client = new RestClientV2(); async function main() { - const balances = await client.getBalances(); - const settings = await client.getAccountSettings(); + 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({ - assetMode: settings.data.assetMode, - holdMode: settings.data.holdMode, - usdtEquity: balances.data.usdtEquity, - assets: balances.data.assets.slice(0, 5), + spotCandles: spotCandles.data.length, + futuresCandles: futuresCandles.data.length, }); } 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 +See also: [V2 public REST examples](../examples/V2%20-%20Classic/Rest) -`WebsocketClientV3` handles V3/UTA streams. Public ones don't need credentials. +### Classic WebSocket streams - ```typescript -import { WebsocketClientV3, WS_KEY_MAP } from 'bitget-api'; +import { WebsocketClientV2 } from 'bitget-api'; -const ws = new WebsocketClientV3({}); +const ws = new WebsocketClientV2({}); -ws.on('open', (data) => { - console.log('connected', data.wsKey); +ws.on('update', (data) => { + console.log('classic update', JSON.stringify(data)); }); ws.on('response', (data) => { - console.log('response', JSON.stringify(data)); + console.log('classic response', JSON.stringify(data)); }); -ws.on('update', (data) => { - console.log('market update', JSON.stringify(data)); -}); +ws.on('exception', console.error); -ws.on('reconnect', ({ wsKey }) => { - console.log('reconnecting', wsKey); -}); +ws.subscribeTopic('SPOT', 'ticker', 'BTCUSDT'); +``` -ws.on('reconnected', (data) => { - console.log('reconnected', data?.wsKey); -}); +V2 WebSocket `instType` values are upper-case, such as `SPOT`, `USDT-FUTURES`, `USDC-FUTURES`, and `COIN-FUTURES`. -ws.on('exception', console.error); +See also: [V2 WebSocket examples](../examples/V2%20-%20Classic/Websocket) -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. + +## Proxies for REST API and WebSocket -See also: [V3 public WebSocket example](../examples/V3%20-%20UTA/Websocket/ws-public.ts) +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`. -### 4. First private account WebSocket stream +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. -Private streams are where trading systems usually watch account and order changes instead of polling constantly. +Proxy agents are a Node.js networking feature. Browser applications cannot select a raw socket agent. - -```typescript -import { WebsocketClientV3, WS_KEY_MAP } from 'bitget-api'; +### HTTP or HTTPS proxy -function readBitgetCredentials() { - const apiKey = process.env.BITGET_API_KEY; - const apiSecret = process.env.BITGET_API_SECRET; - const apiPass = process.env.BITGET_API_PASS; +Install the agent: - if (!apiKey || !apiSecret || !apiPass) { - throw new Error( - 'Set BITGET_API_KEY, BITGET_API_SECRET, and BITGET_API_PASS before running private WebSocket examples.', - ); - } +```bash +npm install bitget-api https-proxy-agent +``` - return { apiKey, apiSecret, apiPass }; +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 ws = new WebsocketClientV3(readBitgetCredentials()); +const proxyAgent = new HttpsProxyAgent(proxyUrl); -ws.on('authenticated', (data) => { - console.log('authenticated', data.wsKey); -}); +const rest = new RestClientV3( + {}, + { + httpsAgent: proxyAgent, + proxy: false, + }, +); -ws.on('update', (data) => { - console.log('account update', JSON.stringify(data)); +const ws = new WebsocketClientV3({ + wsOptions: { + agent: proxyAgent, + }, }); -ws.on('response', (data) => { - console.log('response', JSON.stringify(data)); +ws.on('open', ({ wsKey }) => { + console.log('WebSocket connected through proxy:', wsKey); }); - -ws.on('reconnect', ({ wsKey }) => { - console.log('reconnecting', wsKey); +ws.on('update', (event) => { + console.log('stream update', event); }); +ws.on('exception', console.error); -ws.on('reconnected', (data) => { - console.log('reconnected', data?.wsKey); - // After reconnect, use REST to reconcile balances, positions, open orders, or recent fills. -}); +async function main() { + const serverTime = await rest.getServerTime(); + console.log('REST API connected through proxy:', serverTime); -ws.on('exception', console.error); + ws.subscribe( + { + topic: 'ticker', + payload: { + instType: 'spot', + symbol: 'BTCUSDT', + }, + }, + WS_KEY_MAP.v3Public, + ); +} -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, -); +process.once('SIGINT', () => { + ws.closeAll(); +}); + +main().catch(console.error); ``` -For V3 private account streams, use `instType: 'UTA'`. +REST API networking options belong in the second constructor argument for both `RestClientV3` and `RestClientV2`: -See also: [V3 private WebSocket example](../examples/V3%20-%20UTA/Websocket/ws-private.ts) +- `httpsAgent` sends the HTTPS request through the agent. +- `proxy: false` prevents Axios from applying another proxy configuration on top of that agent. -### 5. First REST API order in demo trading +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. -Test with demo keys before going live. Demo uses separate Bitget API keys. +### Private streams and WebSocket API through a proxy -The snippet below sets `demoTrading: true` - leave it on while testing. A successful response means Bitget accepted the order, not that it filled. +This example authenticates a V3 private stream and a V3 WebSocket API connection without placing an order: - -```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; +```typescript +import { + WebsocketAPIClient, + WebsocketClientV3, + WS_KEY_MAP, +} from 'bitget-api'; +import { HttpsProxyAgent } from 'https-proxy-agent'; - 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.', - ); - } +const proxyUrl = process.env.BITGET_PROXY_URL; - return { apiKey, apiSecret, apiPass }; +if (!proxyUrl) { + throw new Error('Set BITGET_PROXY_URL before running this example.'); } -const credentials = readBitgetCredentials(); +const apiKey = process.env.BITGET_API_KEY; +const apiSecret = process.env.BITGET_API_SECRET; +const apiPass = process.env.BITGET_API_PASS; -const client = new RestClientV3({ - apiKey: credentials.apiKey, - apiSecret: credentials.apiSecret, - apiPass: credentials.apiPass, - demoTrading: true, -}); +if (!apiKey || !apiSecret || !apiPass) { + throw new Error( + 'Set BITGET_API_KEY, BITGET_API_SECRET, and BITGET_API_PASS before running this example.', + ); +} -async function main() { - const ticker = await client.getTickers({ - category: 'SPOT', - symbol: 'BTCUSDT', - }); +const proxyAgent = new HttpsProxyAgent(proxyUrl); +const credentials = { apiKey, apiSecret, apiPass }; - const lastPrice = ticker.data[0]?.lastPrice; +const streams = new WebsocketClientV3({ + ...credentials, + wsOptions: { + agent: proxyAgent, + }, +}); - if (!lastPrice) { - throw new Error('No BTCUSDT ticker price returned.'); - } +const wsApi = new WebsocketAPIClient({ + ...credentials, + attachEventListeners: false, + wsOptions: { + agent: proxyAgent, + }, +}); +const wsApiConnection = wsApi.getWSClient(); - const orderRequest = { - category: 'SPOT', - symbol: 'BTCUSDT', - side: 'buy', - orderType: 'limit', - price: lastPrice, - qty: '0.001', - timeInForce: 'gtc', - clientOid: `demo-rest-${Date.now()}`, - } as const; +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); - const result = await client.submitNewOrder(orderRequest); +async function main() { + streams.subscribe( + [ + { topic: 'account', payload: { instType: 'UTA' } }, + { topic: 'order', payload: { instType: 'UTA' } }, + ], + WS_KEY_MAP.v3Private, + ); - console.log(result); + await wsApiConnection.connectWSAPI(); + console.log('Private connections are ready'); } +process.once('SIGINT', () => { + streams.closeAll(); + wsApiConnection.closeAll(); +}); + main().catch(console.error); ``` -Check order status via private streams or REST: `getOrderInfo`, `getUnfilledOrders`, `getHistoryOrders`, or `getTradeFills`. +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. -See also: [V3 spot trading example](../examples/V3%20-%20UTA/Rest/rest-trade-UTA-spot.ts) +### SOCKS5 proxy -### 6. First WebSocket API order command +Install the SOCKS agent: -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. +```bash +npm install bitget-api socks-proxy-agent +``` -This example uses `demoTrading: true` with demo API keys. +Use `SocksProxyAgent` in the same REST API and WebSocket positions: - -```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; +```typescript +import { RestClientV3, WebsocketClientV3, WS_KEY_MAP } from 'bitget-api'; +import { SocksProxyAgent } from 'socks-proxy-agent'; - 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.', - ); - } +const proxyUrl = process.env.BITGET_SOCKS_PROXY_URL; - return { apiKey, apiSecret, apiPass }; +if (!proxyUrl) { + throw new Error('Set BITGET_SOCKS_PROXY_URL before running this example.'); } -const credentials = readBitgetCredentials(); - -const wsApi = new WebsocketAPIClient({ - apiKey: credentials.apiKey, - apiSecret: credentials.apiSecret, - apiPass: credentials.apiPass, - demoTrading: true, -}); +const proxyAgent = new SocksProxyAgent(proxyUrl); -const ws = wsApi.getWSClient(); +const rest = new RestClientV3( + {}, + { + httpsAgent: proxyAgent, + proxy: false, + }, +); -ws.on('open', (data) => console.log('ws open', data.wsKey)); -ws.on('authenticated', (data) => console.log('authenticated', data.wsKey)); -ws.on('exception', console.error); +const ws = new WebsocketClientV3({ + wsOptions: { + agent: proxyAgent, + }, +}); 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, - }); + const serverTime = await rest.getServerTime(); + console.log('REST API connected through SOCKS5:', serverTime); - console.log('cancelled', cancelled); + ws.subscribe( + { + topic: 'ticker', + payload: { + instType: 'spot', + symbol: 'BTCUSDT', + }, + }, + WS_KEY_MAP.v3Public, + ); } +process.once('SIGINT', () => { + ws.closeAll(); +}); + main().catch(console.error); ``` -`connectWSAPI()` is optional - call it before your first command if you want the connection warm and ready. +### Proxy checks -See also: [V3 WebSocket API client example](../examples/V3%20-%20UTA/WS-API/ws-api-client-trade.ts) +- 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. --- - -## V3 REST API - -`RestClientV3` is the client for current Bitget UTA REST endpoints. - -### Create public and private clients + +## Production notes -Public client: +### 1. Roll out in layers -```typescript -import { RestClientV3 } from 'bitget-api'; +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. -const publicClient = new RestClientV3(); -``` +### 2. Use client-generated order IDs -Private client: +Set `clientOid` on every order and store it before you send. You'll need it to match state after retries, reconnects, or restarts. -```typescript -import { RestClientV3 } from 'bitget-api'; +### 3. Reconcile after reconnects -const privateClient = new RestClientV3({ - apiKey: process.env.BITGET_API_KEY!, - apiSecret: process.env.BITGET_API_SECRET!, - apiPass: process.env.BITGET_API_PASS!, -}); -``` +Reconnects happen. After a private stream comes back, hit REST for balances, positions, open orders, history, and recent fills before trusting local state. -Demo trading client: +### 4. Check exchange acceptance -```typescript -import { RestClientV3 } from '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. -const demoClient = new RestClientV3({ - apiKey: process.env.BITGET_API_KEY!, - apiSecret: process.env.BITGET_API_SECRET!, - apiPass: process.env.BITGET_API_PASS!, - demoTrading: true, -}); -``` +### 5. Keep clocks healthy -### Common public market data calls +Private requests are timestamp-sensitive. Keep the host clock synced. Only touch `recvWindow` if you know you have clock skew. -```typescript -import { RestClientV3 } from 'bitget-api'; +### 6. Keep credentials scoped -const client = new RestClientV3(); +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. -async function main() { - const instruments = await client.getInstruments({ - category: 'SPOT', - symbol: 'BTCUSDT', - }); +### 7. Log carefully - const tickers = await client.getTickers({ - category: 'USDT-FUTURES', - symbol: 'BTCUSDT', - }); +`BITGETTRACE=true` is handy for local debugging - it logs raw requests and responses. Don't turn it on where logs might leak account data. - const orderBook = await client.getOrderBook({ - category: 'SPOT', - symbol: 'BTCUSDT', - limit: '20', - }); +--- - const candles = await client.getCandles({ - category: 'SPOT', - symbol: 'BTCUSDT', - interval: '1m', - limit: '20', - }); + +## FAQ - const openInterest = await client.getOpenInterest({ - category: 'USDT-FUTURES', - symbol: 'BTCUSDT', - }); +### Do I need API keys for public market data? - const fundingRate = await client.getCurrentFundingRate({ - symbol: 'BTCUSDT', - }); +No. Public REST market data and public WebSocket streams can be used without API keys. - console.log({ - instrument: instruments.data[0], - ticker: tickers.data[0], - orderBook, - candles: candles.data.length, - openInterest, - fundingRate, - }); -} +### What is the Bitget API passphrase? -main().catch(console.error); -``` +The API passphrase is the passphrase set when creating the Bitget API key. In the SDK constructor it is passed as `apiPass`. -### Common private account calls +### Which client should I use for a new project? -```typescript -import { RestClientV3 } from 'bitget-api'; +Start with `RestClientV3`, `WebsocketClientV3`, and `WebsocketAPIClient` for current V3/UTA workflows. -const client = new RestClientV3({ - apiKey: process.env.BITGET_API_KEY!, - apiSecret: process.env.BITGET_API_SECRET!, - apiPass: process.env.BITGET_API_PASS!, -}); +### When should I use V2/Classic clients? -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', - }); +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. - console.log({ - settings: settings.data, - balanceCount: balances.data.assets.length, - positions: positions.data.list, - openOrders: openOrders.data.list, - recentFills: recentFills.data.list, - }); -} +### Why do category names have different casing? -main().catch(console.error); -``` +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`. -### Common trading calls +### What is the difference between WebSocket streams and the WebSocket API? -```typescript -import { RestClientV3 } from 'bitget-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. -const client = new RestClientV3({ - apiKey: process.env.BITGET_API_KEY!, - apiSecret: process.env.BITGET_API_SECRET!, - apiPass: process.env.BITGET_API_PASS!, - demoTrading: true, -}); +### Can I use this SDK from plain JavaScript? -async function main() { - const clientOid = `rest-${Date.now()}`; +Yes. The SDK works in JavaScript and TypeScript. TypeScript users also get request and response types from the package. - const placed = await client.submitNewOrder({ - category: 'SPOT', - symbol: 'BTCUSDT', - side: 'buy', - orderType: 'limit', - price: '10000', - qty: '0.001', - timeInForce: 'gtc', - clientOid, - }); +### Does the SDK support RSA keys? - const orderInfo = await client.getOrderInfo({ - clientOid, - }); +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). - const cancelled = await client.cancelOrder({ - clientOid, - }); +### What should I do after a WebSocket reconnect? - console.log({ placed, orderInfo, cancelled }); -} +Normal - let the SDK reconnect and resubscribe. Then reconcile balances, orders, and fills over REST before acting on cached state. -main().catch(console.error); -``` +### Where can I find more examples? -For futures close-only orders, V3 REST uses lower-case `reduceOnly` values: +More in the repo: -```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/UTA examples](../examples/V3%20-%20UTA) +- [V2/Classic examples](../examples/V2%20-%20Classic) +- [Auth examples](../examples/Auth) +- [Bitget JavaScript Endpoint Reference](./endpointFunctionList.md) --- - -## V3 WebSocket streams - -For live market or account updates, use `WebsocketClientV3`. - -### Common events + +## Next steps -```typescript -import { WebsocketClientV3 } from 'bitget-api'; +- [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) -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 }); +================ +File: src/types/request/v3/copytrading.ts +================ +export interface GetCopyFuturesMaxTransferableRequestV3 { + coin: 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 GetCopyFuturesCopyMaxTransferableRequestV3 { + projectId: string; + /** e.g. USDT */ + coin: 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.'); -} - -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, - ); +⋮---- +/** e.g. USDT */ +⋮---- +export interface CopyFuturesTransferRequestV3 { + type: 'in' | 'out'; + coin: string; + amount: string; + /** Source account type(s) for transfer-in. Comma-separated: funding, uta, otc */ + inAccountType?: 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.'); +⋮---- +/** Source account type(s) for transfer-in. Comma-separated: funding, uta, otc */ +⋮---- +export interface GetCopyFuturesTransferRecordRequestV3 { + startTime?: string; + endTime?: string; + limit?: string; + /** Pass transferId from the previous page to paginate forward */ + cursor?: 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.', - ); +⋮---- +/** Pass transferId from the previous page to paginate forward */ +⋮---- +export interface GetCopyFuturesFollowersRequestV3 { + limit?: string; + cursor?: 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'); +⋮---- +export interface GetCopyFuturesProfitDetailsRequestV3 { + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; } - -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.'); +⋮---- +export type CopyFuturesCopyTypeV3 = 'fixed_ratio' | 'fixed_margin'; +⋮---- +export interface GetCopyFuturesPortfolioOverviewRequestV3 { + period: '7D' | '30D' | '90D' | '180D'; } - -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/sieblyio/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/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) - -================ -File: src/types/request/v3/copytrading.ts -================ -export interface GetCopyFuturesMaxTransferableRequestV3 { - coin: string; -} -⋮---- -export interface GetCopyFuturesCopyMaxTransferableRequestV3 { - projectId: string; - /** e.g. USDT */ - coin: string; -} -⋮---- -/** e.g. USDT */ -⋮---- -export interface CopyFuturesTransferRequestV3 { - type: 'in' | 'out'; - coin: string; - amount: string; - /** Source account type(s) for transfer-in. Comma-separated: funding, uta, otc */ - inAccountType?: string; -} -⋮---- -/** Source account type(s) for transfer-in. Comma-separated: funding, uta, otc */ -⋮---- -export interface GetCopyFuturesTransferRecordRequestV3 { - startTime?: string; - endTime?: string; - limit?: string; - /** Pass transferId from the previous page to paginate forward */ - cursor?: string; -} -⋮---- -/** Pass transferId from the previous page to paginate forward */ -⋮---- -export interface GetCopyFuturesFollowersRequestV3 { - limit?: string; - cursor?: string; -} -⋮---- -export interface GetCopyFuturesProfitDetailsRequestV3 { - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; -} -⋮---- -export type CopyFuturesCopyTypeV3 = 'fixed_ratio' | 'fixed_margin'; -⋮---- -export interface GetCopyFuturesPortfolioOverviewRequestV3 { - period: '7D' | '30D' | '90D' | '180D'; -} -⋮---- -export interface CreateCopyFuturesRequestV3 { - projectId: string; - type: CopyFuturesCopyTypeV3; - amount: string; - /** Comma-separated: funding, uta, otc */ - accountType?: string; - /** Comma-separated symbols. Omit to copy every pair */ - tradingPairList?: string; - /** Required when type is fixed_margin */ - marginPerOrder?: string; - autoCopy?: 'on' | 'off'; - leverage?: string; - maxEntrySlippage?: string; - maxMarginRatio?: string; - /** API field name (Bitget spelling). */ - maxPostionValue?: string; +⋮---- +export interface CreateCopyFuturesRequestV3 { + projectId: string; + type: CopyFuturesCopyTypeV3; + amount: string; + /** Comma-separated: funding, uta, otc */ + accountType?: string; + /** Comma-separated symbols. Omit to copy every pair */ + tradingPairList?: string; + /** Required when type is fixed_margin */ + marginPerOrder?: string; + autoCopy?: 'on' | 'off'; + leverage?: string; + maxEntrySlippage?: string; + maxMarginRatio?: string; + /** API field name (Bitget spelling). */ + maxPostionValue?: string; } ⋮---- /** Comma-separated: funding, uta, otc */ @@ -12120,234 +11694,45 @@ export interface GetCopyFuturesTpSlOrderHistoryRequestV3 { } ================ -File: src/types/websockets/ws-api.ts +File: src/types/websockets/ws-events.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'; +export interface MessageEventLike { + target: WebSocket; + type: 'message'; + data: 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' - | 'modify-order' - | 'batch-modify'; +export function isMessageEvent(msg: unknown): msg is MessageEventLike ⋮---- -export interface WSOperationLoginParams { - apiKey: string; - passphrase: string; - timestamp: number; - sign: string; +export interface WsBaseEvent { + action: TAction; + arg: unknown; + data: TData[]; } ⋮---- -export interface WSAPIRequestBitgetV3 { - op: 'trade'; - id: string; - category: BitgetInstTypeV3; - topic: WSAPIOperation; - args: TWSParams | TWSParams[]; - /** - * Broker rebate code. Top-level, not inside args. - * Place-order docs name this field. Sent on place-order and batch-place. - * Defaults to the SDK broker code unless the caller sets apiCode. - */ - apiCode?: string; - /** Client-side request timestamp; required for receiveWindow on place-order */ - requestTime?: string; +export interface WsSnapshotChannelEvent extends WsBaseEvent<'snapshot'> { + arg: { + instType: string; + channel: string; + instId: string; + }; } ⋮---- -/** - * Broker rebate code. Top-level, not inside args. - * Place-order docs name this field. Sent on place-order and batch-place. - * Defaults to the SDK broker code unless the caller sets apiCode. - */ -⋮---- -/** 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; +export interface WsSnapshotAccountEvent extends WsBaseEvent<'snapshot'> { + arg: { + instType: string; + channel: 'account'; + instId: string; + }; } ⋮---- -/** If true, will skip auth requirement for WS API connection */ -⋮---- -export type Exact = { - // This part says: if there's any key that's not in T, it's an error - [K: string]: never; -} & { - [K in keyof T]: T[K]; -}; -⋮---- -// This part says: if there's any key that's not in T, it's an error -⋮---- -/** - -/** - * V2 request looks like this: -{ - "op":"subscribe", - "args":[ - { - "instType":"SPOT", - "channel":"ticker", - "instId":"BTCUSDT" - }, - { - "instType":"SPOT", - "channel":"candle5m", - "instId":"BTCUSDT" - } - ] -} - */ -export interface WsRequestOperationBitget { - op: WSOperation; - args?: (TWSRequestArg | string | number)[]; -} -export interface WSAPIRateLimitV3 { - limit: string; - remaining: string; -} -⋮---- -export interface WSAPIResponse< - TResponseData extends object = object, - TOperation extends WSAPIOperation = WSAPIOperation, -> { - wsKey: WsKey; - /** Auto-generated */ - id: string; - event: 'trade'; - category: BitgetInstTypeV3; - topic: TOperation; - args: TResponseData; - code: '0' | string; - msg: 'success' | string; - ts: string; - /** Connection ID (trade operation responses, May 2026+) */ - connId?: string; - /** Gateway receive time, Unix microseconds */ - receiveTime?: string; - /** Gateway push time, Unix microseconds */ - pushTime?: string; - rateLimit?: WSAPIRateLimitV3[]; -} -⋮---- -/** Auto-generated */ -⋮---- -/** Connection ID (trade operation responses, May 2026+) */ -⋮---- -/** Gateway receive time, Unix microseconds */ -⋮---- -/** Gateway push time, Unix microseconds */ -⋮---- -/** - * List of operations supported for this WsKey (connection) - */ -export interface WsAPIWsKeyTopicMap { - [WS_KEY_MAP.v3Private]: WSAPIOperation; -} -⋮---- -/** - * Request parameters expected per operation - */ -export interface WsAPITopicRequestParamMap { - // https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters - 'place-order': WSAPIPlaceOrderRequestV3; - // https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel - 'batch-place': WSAPIPlaceOrderRequestV3[]; - // https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel - 'cancel-order': CancelOrderRequestV3; - // https://www.bitget.com/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 -⋮---- -// https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel -⋮---- -// https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel -⋮---- -// https://www.bitget.com/docs/uta/websocket/private/Batch-Cancel-Order-Channel -⋮---- -/** - * Response structure expected for each operation - */ -export interface WsAPIOperationResponseMap { - // https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters - 'place-order': WSAPIResponse<[WSAPIPlaceOrderResponseV3], 'place-order'>; - // https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel - 'batch-place': WSAPIResponse; - // https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel - 'cancel-order': WSAPIResponse<[CancelOrderResponseV3], 'cancel-order'>; - // https://www.bitget.com/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 -⋮---- -// https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel -⋮---- -// https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel -⋮---- -// https://www.bitget.com/docs/uta/websocket/private/Batch-Cancel-Order-Channel - -================ -File: src/types/websockets/ws-events.ts -================ -export interface MessageEventLike { - target: WebSocket; - type: 'message'; - data: string; -} -⋮---- -export function isMessageEvent(msg: unknown): msg is MessageEventLike -⋮---- -export interface WsBaseEvent { - action: TAction; - arg: unknown; - data: TData[]; -} -⋮---- -export interface WsSnapshotChannelEvent extends WsBaseEvent<'snapshot'> { - arg: { - instType: string; - channel: string; - instId: string; - }; -} -⋮---- -export interface WsSnapshotAccountEvent extends WsBaseEvent<'snapshot'> { - arg: { - instType: string; - channel: 'account'; - instId: string; - }; -} -⋮---- -export interface WsSnapshotPositionsEvent extends WsBaseEvent<'snapshot'> { - arg: { - instType: string; - channel: 'positions'; - instId: string; - }; -} +export interface WsSnapshotPositionsEvent extends WsBaseEvent<'snapshot'> { + arg: { + instType: string; + channel: 'positions'; + instId: string; + }; +} ⋮---- export interface WsAccountSnapshotDataUMCBL { marginCoin: string; @@ -13375,172 +12760,191 @@ export interface StrategySubOrderV3 { } ================ -File: src/types/request/v3/strategy.ts +File: src/types/websockets/ws-api.ts ================ -export type StrategyOrderTypeV3 = - | 'tpsl' - | 'trigger' - | 'oco' - | 'trailing_stop' - | 'iceberg' - | 'twap'; -⋮---- -export type StrategyOrderStatusV3 = - | 'pending' - | 'success' - | 'failed' - | 'cancelled' - | 'submitting'; +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 StrategyTriggerByV3 = 'market' | 'mark'; +export type WSOperation = 'subscribe' | 'unsubscribe' | 'login'; ⋮---- -export type StrategyTriggerOrderTypeV3 = 'limit' | 'market'; +// 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 StrategyOcoParamsV3 { - ocoLimitPrice?: string; - ocoTriggerPrice?: string; - ocoOrderType?: StrategyTriggerOrderTypeV3; - ocoOrderPrice?: string; +export interface WSOperationLoginParams { + apiKey: string; + passphrase: string; + timestamp: number; + sign: string; } ⋮---- -export interface StrategyTrailingStopParamsV3 { - activationPrice?: string; - activationType?: string; - trailType?: string; - trailVariance?: string; - preOrderType?: StrategyTriggerOrderTypeV3; - preOrderPrice?: string; +export interface WSAPIRequestBitgetV3 { + op: 'trade'; + id: string; + category: BitgetInstTypeV3; + topic: WSAPIOperation; + args: TWSParams | TWSParams[]; + /** + * Broker rebate code. Top-level, not inside args. + * Place-order docs name this field. Sent on place-order and batch-place. + */ + apiCode?: string; + /** Client-side request timestamp; required for receiveWindow on place-order */ + requestTime?: string; } ⋮---- -export interface StrategyIcebergParamsV3 { - splitMode?: string; - qtyPerOrder?: string; - splitOrderNumbers?: string; - orderPreference?: string; - executionStrategy?: string; - fixedDistanceType?: string; - distance?: string; - fixedPrice?: string; - priceLimit?: string; +/** + * Broker rebate code. Top-level, not inside args. + * Place-order docs name this field. Sent on place-order and batch-place. + */ +⋮---- +/** 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; } ⋮---- -export interface StrategyTwapParamsV3 { - duration?: string; - interval?: string; - orderType?: StrategyTriggerOrderTypeV3; - limitOffsetType?: string; - limitOffsetPercentage?: string; - limitOffsetSpread?: string; - twapTriggerPrice?: string; - twapTerminationPrice?: string; -} +/** If true, will skip auth requirement for WS API connection */ ⋮---- -export interface PlaceStrategyOrderRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol: string; - clientOid?: string; - type?: StrategyOrderTypeV3; - tpslMode?: 'full' | 'partial'; - /** Required when tpslMode=partial or for trigger orders */ - qty?: string; - side?: 'buy' | 'sell'; - posSide?: 'long' | 'short'; - reduceOnly?: 'yes' | 'no'; - /** - * Margin mode. Defaults to crossed. Required for isolated positions - * (isolated TP/SL fails with 31008 if omitted). - * Not in Bitget's official API docs yet. Confirmed by Bitget API devs - * in their OpenAPI Telegram: https://t.me/bitgetOpenapi/152235 - */ - marginMode?: 'isolated' | 'crossed'; - tpTriggerBy?: StrategyTriggerByV3; - slTriggerBy?: StrategyTriggerByV3; - takeProfit?: string; - stopLoss?: string; - tpOrderType?: StrategyTriggerOrderTypeV3; - slOrderType?: StrategyTriggerOrderTypeV3; - tpLimitPrice?: string; - slLimitPrice?: string; - triggerBy?: StrategyTriggerByV3; - triggerPrice?: string; - triggerOrderType?: StrategyTriggerOrderTypeV3; - triggerOrderPrice?: string; - ocoParams?: StrategyOcoParamsV3; - trailingStopParams?: StrategyTrailingStopParamsV3; - icebergParams?: StrategyIcebergParamsV3; - twapParams?: StrategyTwapParamsV3; -} +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]; +}; ⋮---- -/** Required when tpslMode=partial or for trigger orders */ +// This part says: if there's any key that's not in T, it's an error ⋮---- /** - * Margin mode. Defaults to crossed. Required for isolated positions - * (isolated TP/SL fails with 31008 if omitted). - * Not in Bitget's official API docs yet. Confirmed by Bitget API devs - * in their OpenAPI Telegram: https://t.me/bitgetOpenapi/152235 - */ -⋮---- -export interface ModifyStrategyOrderRequestV3 { - orderId?: string; - clientOid?: string; - qty: string; - tpTriggerBy?: StrategyTriggerByV3; - slTriggerBy?: StrategyTriggerByV3; - takeProfit?: string; - stopLoss?: string; - tpOrderType?: StrategyTriggerOrderTypeV3; - slOrderType?: StrategyTriggerOrderTypeV3; - tpLimitPrice?: string; - slLimitPrice?: string; - triggerBy?: StrategyTriggerByV3; - triggerPrice?: string; - triggerOrderType?: StrategyTriggerOrderTypeV3; - triggerOrderPrice?: string; + +/** + * V2 request looks like this: +{ + "op":"subscribe", + "args":[ + { + "instType":"SPOT", + "channel":"ticker", + "instId":"BTCUSDT" + }, + { + "instType":"SPOT", + "channel":"candle5m", + "instId":"BTCUSDT" + } + ] +} + */ +export interface WsRequestOperationBitget { + op: WSOperation; + args?: (TWSRequestArg | string | number)[]; +} +export interface WSAPIRateLimitV3 { + limit: string; + remaining: string; } ⋮---- -export interface CancelStrategyOrderRequestV3 { - orderId?: string; - clientOid?: string; +export interface WSAPIResponse< + TResponseData extends object = object, + TOperation extends WSAPIOperation = WSAPIOperation, +> { + wsKey: WsKey; + /** Auto-generated */ + id: string; + event: 'trade'; + category: BitgetInstTypeV3; + topic: TOperation; + args: TResponseData; + code: '0' | string; + msg: 'success' | string; + ts: string; + /** Connection ID (trade operation responses, May 2026+) */ + connId?: string; + /** Gateway receive time, Unix microseconds */ + receiveTime?: string; + /** Gateway push time, Unix microseconds */ + pushTime?: string; + rateLimit?: WSAPIRateLimitV3[]; } ⋮---- -export interface GetUnfilledStrategyOrdersRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - type?: StrategyOrderTypeV3; +/** Auto-generated */ +⋮---- +/** Connection ID (trade operation responses, May 2026+) */ +⋮---- +/** Gateway receive time, Unix microseconds */ +⋮---- +/** Gateway push time, Unix microseconds */ +⋮---- +/** + * List of operations supported for this WsKey (connection) + */ +export interface WsAPIWsKeyTopicMap { + [WS_KEY_MAP.v3Private]: WSAPIOperation; } ⋮---- -export interface GetHistoryStrategyOrdersRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - type?: StrategyOrderTypeV3; - startTime?: string; - endTime?: string; - limit?: string; - /** Observed as a number though the docs say string. */ - cursor?: string | number; +/** + * Request parameters expected per operation + */ +export interface WsAPITopicRequestParamMap { + // https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters + 'place-order': WSAPIPlaceOrderRequestV3; + // https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel + 'batch-place': WSAPIPlaceOrderRequestV3[]; + // https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel + 'cancel-order': CancelOrderRequestV3; + // https://www.bitget.com/docs/uta/websocket/private/Batch-Cancel-Order-Channel + 'batch-cancel': CancelOrderRequestV3[]; + 'modify-order': ModifyOrderRequestV3; + 'batch-modify': ModifyOrderRequestV3[]; } ⋮---- -/** Observed as a number though the docs say string. */ +// https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters ⋮---- -export interface GetStrategySubOrdersRequestV3 { - orderId?: string; - clientOid?: string; - limit?: string; - cursor?: string; +// https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel +⋮---- +// https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel +⋮---- +// https://www.bitget.com/docs/uta/websocket/private/Batch-Cancel-Order-Channel +⋮---- +/** + * Response structure expected for each operation + */ +export interface WsAPIOperationResponseMap { + // https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters + 'place-order': WSAPIResponse<[WSAPIPlaceOrderResponseV3], 'place-order'>; + // https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel + 'batch-place': WSAPIResponse; + // https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel + 'cancel-order': WSAPIResponse<[CancelOrderResponseV3], 'cancel-order'>; + // https://www.bitget.com/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 +⋮---- +// https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel +⋮---- +// https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel +⋮---- +// https://www.bitget.com/docs/uta/websocket/private/Batch-Cancel-Order-Channel ================ File: src/index.ts @@ -13548,5850 +12952,6422 @@ File: src/index.ts ================ -File: src/rest-client-v2.ts +File: src/websocket-api-client.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, - GetSubAffiliateInfoRequestV2, - ModifySubAccountApiKeyRequestV2, - ModifySubRequestV2, - SubDepositRecordsRequestV2, - SubWithdrawalRecordsRequestV2, - SubWithdrawalRequestV2, -} from './types/request/v2/broker.js'; + CancelOrderRequestV3, + ModifyOrderRequestV3, +} from './types/request/v3/trade.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'; + 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 { - 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'; + 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 +⋮---- +/* + * Bitget WebSocket API Methods + * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel + */ +⋮---- +/** + * Submit a new order + * + * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel + * + * @returns + */ +submitNewOrder( + category: BitgetInstTypeV3, + params: WSAPIPlaceOrderRequestV3, + ): Promise> +⋮---- +/** + * Submit a batch of orders + * + * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Place-Order-Channel + * + * @returns + */ +placeBatchOrders( + category: BitgetInstTypeV3, + params: WSAPIPlaceOrderRequestV3[], + ): Promise> +⋮---- +/* + * Bitget WebSocket API Methods + * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel + */ +⋮---- +/** + * Cancel Order + * + * https://www.bitget.com/api-doc/uta/websocket/private/Cancel-Order-Channel + * + * @returns + */ +cancelOrder( + category: BitgetInstTypeV3, + params: CancelOrderRequestV3, + ): Promise> +⋮---- +/** + * Batch Cancel Order + * + * https://www.bitget.com/api-doc/uta/websocket/private/Batch-Cancel-Order-Channel + * + * @returns + */ +cancelBatchOrders( + category: BitgetInstTypeV3, + params: CancelOrderRequestV3[], + ): Promise> +⋮---- +updateOrder( + category: BitgetInstTypeV3, + params: ModifyOrderRequestV3, + ): Promise> +⋮---- +batchUpdateOrders( + category: BitgetInstTypeV3, + params: ModifyOrderRequestV3[], + ): Promise> +⋮---- +/** + * + * + * + * + * + * + * + * Private methods for handling some of the convenience/automation provided by the WS API Client + * + * + * + * + * + * + * + */ +⋮---- +private setupDefaultEventListeners() +⋮---- +/** + * General event handlers for monitoring the WebsocketClient + */ +⋮---- +// Blind JSON.stringify can fail on circular references +⋮---- +// JSON.stringify({ ...data, target: 'WebSocket' }), + +================ +File: src/websocket-client-v3.ts +================ 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'; + WsAPIOperationResponseMap, + WSAPIRequestBitgetV3, + WSAPIRequestFlags, + WsAPITopicRequestParamMap, + WsAPIWsKeyTopicMap, + WSOperation, + WSOperationLoginParams, + WsRequestOperationBitget, +} from './types/websockets/ws-api.js'; +import { MessageEventLike } from './types/websockets/ws-events.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, - SubAffiliateInfoV2, -} 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'; + BitgetInstTypeV3, + WsKey, + WsTopicV3, +} from './types/websockets/ws-general.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'; + BaseWebsocketClient, + EmittableEvent, + MidflightWsRequestEvent, +} from './util/BaseWSClient.js'; +import { CHANNEL_API_CODE, isWsPong } from './util/requestUtils.js'; +import { isWSAPIResponse } from './util/type-guards.js'; +import { SignAlgorithm, signMessage } from './util/webCryptoAPI.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'; + getMaxTopicsPerSubscribeEvent, + getNormalisedTopicRequests, + getPromiseRefForWSAPIRequest, + getWsUrl, + WS_AUTH_ON_CONNECT_KEYS, + WS_KEY_MAP, + WS_LOGGER_CATEGORY, + WsTopicRequest, +} from './util/websocket-util.js'; +import { WSConnectedResult } from './util/WsStore.types.js'; ⋮---- /** - * REST API client for all V2 endpoints + * WebSocket client dedicated to the unified account (V3) WebSockets. + * + * Your Bitget account needs to be upgraded to unified account mode, to use the account-level WebSocket topics. */ -export class RestClientV2 extends BaseRestClient +export class WebsocketClientV3 extends BaseWebsocketClient< ⋮---- -getClientType() +WsRequestOperationBitget // subscribe requests have an "args" parameter with an object within ⋮---- /** - * - * Custom SDK functions - * + * Request connection of all dependent (public & private) websockets, instead of waiting for automatic connection by library */ +public connectAll(): Promise[] ⋮---- /** - * This method is used to get the latency and time sync between the client and the server. - * This is not official API endpoint and is only used for internal testing purposes. - * Use this method to check the latency and time sync between the client and the server. - * Final values might vary slightly, but it should be within few ms difference. - * If you have any suggestions or improvements to this measurement, please create an issue or pull request on GitHub. + * Ensures the WS API connection is active and ready. + * + * You do not need to call this, but if you call this before making any WS API requests, + * it can accelerate the first request (by preparing the connection in advance). */ -async fetchLatencySummary(): Promise -⋮---- -// Adjust server time by adding estimated one-way latency -⋮---- -// Calculate time difference between adjusted server time and local time +public connectWSAPI(): Promise ⋮---- -async fetchServerTime(): Promise +/** This call automatically ensures the connection is active AND authenticated before resolving */ ⋮---- /** + * Request subscription to one or more topics. Pass topics as either an array of strings, + * or array of objects (if the topic has parameters). * - * Bitget misc functions + * Objects should be formatted as {topic: string, params: object, category: CategoryV5}. + * + * - Subscriptions are automatically routed to the correct websocket connection. + * - Authentication/connection is automatic. + * - Resubscribe after network issues is automatic. * + * Call `unsubscribe(topics)` to remove topics */ +public subscribe( + requests: + | (WsTopicRequest | WsTopicV3) + | (WsTopicRequest | WsTopicV3)[], + wsKey: WsKey, + ): Promise ⋮---- /** + * Unsubscribe from one or more topics. Similar to subscribe() but in reverse. * - * - * Common - * - * + * - Requests are automatically routed to the correct websocket connection. + * - These topics will be removed from the topic cache, so they won't be subscribed to again. */ +public unsubscribe( + requests: + | (WsTopicRequest | WsTopicV3) + | (WsTopicRequest | WsTopicV3)[], + wsKey: WsKey, + ) ⋮---- /** * - * * Common | Notice * - */ -⋮---- -getAnnouncements( - params?: GetAnnouncementsRequestV2, - ): Promise> -⋮---- -/** + * Internal methods required to integrate with the BaseWSClient * - * * Common | Public * */ ⋮---- -getServerTime(): Promise< - APIResponse<{ - serverTime: string; - }> - > +protected sendPingEvent(wsKey: WsKey): void ⋮---- -getTradeRate(params: GetTradeRateRequestV2): Promise< - APIResponse<{ - makerFeeRate: string; - takerFeeRate: string; - }> - > +protected sendPongEvent(wsKey: WsKey): void ⋮---- -getAllTradeRates(params: GetAllTradeRatesRequestV2): Promise< - APIResponse< - { - symbol: string; - makerFeeRate: string; - takerFeeRate: string; - }[] - > - > +protected isWsPing(data: any): boolean ⋮---- -/** - * - * * Common | Tax - * - */ +protected isWsPong(data: any): boolean ⋮---- -getSpotTransactionRecords( - params: GetSpotTransactionsRequestV2, - ): Promise> +protected isPrivateTopicRequest( + _request: WsTopicRequest, + wsKey: WsKey, + ): boolean ⋮---- -getFuturesTransactionRecords( - params: GetFuturesTransactionsRequestV2, - ): Promise> +protected getPrivateWSKeys(): WsKey[] ⋮---- -getMarginTransactionRecords( - params: GetMarginTransactionsRequestV2, - ): Promise> +protected isAuthOnConnectWsKey(wsKey: WsKey): boolean ⋮---- -getP2PTransactionRecords( - params: GetP2PTransactionsRequestV2, - ): Promise> +protected async getWsUrl(wsKey: WsKey): Promise +⋮---- +protected getMaxTopicsPerSubscribeEvent(wsKey: WsKey): number | null ⋮---- /** - * - * * Common | P2P - * + * @returns one or more correctly structured request events for performing a operations over WS. This can vary per exchange spec. */ +protected async getWsRequestEvents( + operation: WSOperation, + requests: WsTopicRequest[], + ): Promise>[]> ⋮---- -getP2PMerchantList(params?: GetP2PMerchantsRequestV2): Promise< - APIResponse<{ - merchantList: P2PMerchantV2[]; - minMerchantId: string; - }> - > +// Previously used to track topics in a request. Keeping this for subscribe/unsubscribe requests, no need for incremental values ⋮---- -getP2PMerchantInfo(): Promise> +/** + { + "op":"subscribe", + "args":[ + { + "instType":"spot", + "topic":"ticker", + "symbol":"BTCUSDT" + }, + { + "instType":"spot", + "topic":"candle5m", + "symbol":"BTCUSDT" + } + ] + } + */ ⋮---- -getP2PMerchantOrders(params: GetMerchantP2POrdersRequestV2): Promise< - APIResponse<{ - orderList: P2PMerchantOrderV2[]; - minOrderId: string; - }> - > +// const request = { +// topic: 'ticker', +// payload: { instType: 'spot', symbol: 'BTCUSDT' }, +// }; +// becomes: +// const request = { +// topic: 'ticker', +// instType: 'spot', +// symbol: 'BTCUSDT', +// }; ⋮---- -getP2PMerchantAdvertisementList( - params: GetMerchantAdvertisementsRequestV2, - ): Promise< - APIResponse<{ - advList: P2PMerchantAdvertismentV2[]; - minAdvId: string; - }> - > +private async getWsAuthSignature( + wsKey: WsKey, + ): Promise<{ expiresAt: number; signature: string }> +⋮---- +private async signMessage( + paramsStr: string, + secret: string, + method: 'hex' | 'base64', + algorithm: SignAlgorithm, + ): Promise +⋮---- +protected async getWsAuthRequestEvent( + wsKey: WsKey, + ): Promise> ⋮---- /** - * - * * Common | Trading insights - * + * Abstraction called to sort ws events into emittable event types (response to a request, data update, etc) */ +protected resolveEmittableEvents( + wsKey: WsKey, + event: MessageEventLike, + ): EmittableEvent[] ⋮---- -getSpotWhaleNetFlowData(params: { - symbol: string; - }): Promise> +/** + * WS API response handling + */ ⋮---- -getFuturesActiveTakerBuySellVolumeData(params: { - symbol: string; - period?: string; - }): Promise> +// const eg1 = { +// event: 'error', +// id: '1', +// code: '43012', +// msg: 'Insufficient balance', +// }; ⋮---- -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> +// WS API Success ⋮---- -getIsolatedMarginBorrowingRatio(params: { - symbol: string; - period?: string; - }): Promise> +/** + * V3 event handling for consumers - behaves the same as V2 + */ ⋮---- -getFuturesActiveBuySellVolumeData(params: { - symbol: string; - period?: string; - }): Promise> +// v2 authentication event ⋮---- -getSpotFundFlow(params: { - symbol: string; - period?: string; - }): Promise> +// messageType: typeof msg, +// messageString: JSON.stringify(msg), ⋮---- -getTradeDataSupportSymbols(): Promise< - APIResponse<{ - spotList: string[]; - futureList: string[]; - }> - > +// Service upgrade (30033): Bitget sends this ~60s before disconnect. Log and let automatic reconnect handle when connection drops. ⋮---- -getSpotFundNetFlowData(params: { symbol: string }): Promise< - APIResponse< - { - netFlow: string; - ts: string; - }[] - > - > +// messageType: typeof msg, +// messageString: JSON.stringify(msg), ⋮---- -getFuturesActiveLongShortAccountData(params: { - symbol: string; - period?: string; - }): Promise> +// fallback emit anyway ⋮---- /** + * V3/UTA supports order placement via WebSockets. This is the WS API: + * https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel * - * * Common | Virtual Subaccount - * + * @returns a promise that resolves/rejects when a matching response arrives */ +async sendWSAPIRequest< + TWSKey extends keyof WsAPIWsKeyTopicMap, + TWSOperation extends WsAPIWsKeyTopicMap[TWSKey], + TWSParams extends WsAPITopicRequestParamMap[TWSOperation], + TWSAPIResponse extends + WsAPIOperationResponseMap[TWSOperation] = WsAPIOperationResponseMap[TWSOperation], + >( + wsKey: WsKey, + operation: TWSOperation, + category: BitgetInstTypeV3, + params: TWSParams & { signRequest?: boolean }, + requestFlags?: WSAPIRequestFlags, + ): Promise ⋮---- -createVirtualSubaccount(params: { - subAccountList: string[]; - }): Promise> +// this.logger.trace('sendWSAPIRequest(): assertIsAuthenticated(${wsKey})...'); ⋮---- -modifyVirtualSubaccount(params: ModifyVirtualSubRequestV2): Promise< - APIResponse<{ - result: string; - }> - > +// this.logger.trace('sendWSAPIRequest(): assertIsAuthenticated(${wsKey}) ok'); ⋮---- -batchCreateVirtualSubaccountAndAPIKey( - params: CreateVirtualSubRequestV2, - ): Promise> +// Ensure "args" is always wrapped as array ⋮---- -getVirtualSubaccounts(params?: { - limit?: string; - idLessThan?: string; - status?: 'normal' | 'freeze'; - }): Promise< - APIResponse<{ - endId: string; - subAccountList: VirtualSubAccountV2[]; - }> - > +// Store deferred promise, resolved within the "resolveEmittableEvents" method while parsing incoming events ⋮---- -createVirtualSubaccountAPIKey( - params: CreateVirtualSubApiKeyRequestV2, - ): Promise> +// eslint-disable-next-line @typescript-eslint/no-explicit-any ⋮---- -modifyVirtualSubaccountAPIKey( - params: ModifyVirtualSubApiKeyRequestV2, - ): Promise> +// Enrich returned promise with request context for easier debugging ⋮---- -getVirtualSubaccountAPIKeys(params: { - subAccountUid: string; - }): Promise> +// throw e; ⋮---- -/** - * 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> +// Send event ⋮---- -/** - * - * * Common | Assets - * - */ -getFundingAssets(params?: { - coin?: string; - }): Promise> +// Return deferred promise, so caller can await this call + +================ +File: src/types/request/v3/public.ts +================ +export interface GetPublicFillsRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol?: string; + limit?: string; +} ⋮---- -getBotAccount(params?: { - accountType?: string; - }): Promise> +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; +} ⋮---- -/** Get assets overview */ -getBalances(): Promise< - APIResponse< - { - accountType: string; - usdtBalance: 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; +} ⋮---- -/** - * - * * Common | Convert - * - */ +export interface GetContractsOiRequestV3 { + symbol?: string; + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; +} ⋮---- -getConvertCoins(): Promise> +export interface GetCurrentFundingRateRequestV3 { + category?: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; +} ⋮---- -getConvertQuotedPrice( - params: ConvertQuoteRequestV2, - ): Promise> +export interface GetLiquidationsRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; + limit?: string; + cursor?: string; +} ⋮---- -convert( - params: ConvertRequestV2, - ): Promise> +export interface GetHistoryFundingRateRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol: string; + cursor?: string; + limit?: string; +} ⋮---- -getConvertHistory(params: GetConvertHistoryRequestV2): Promise< - APIResponse<{ - dataList: ConvertRecordV2[]; - endId: 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'; +} ⋮---- -/** - * - * * Common | BGB Convert - * - */ +/** User level. Default: vip0 */ ⋮---- -getConvertBGBCoins(): Promise< - APIResponse<{ - coinList: BGBConvertCoinV2[]; - }> - > +export interface GetSplitRecordsRequestV3 { + symbol?: string; +} ⋮---- -convertBGB(params: { - coinList: string; - }): Promise> +export interface GetOpenInterestRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; +} ⋮---- -getConvertBGBHistory( - params: GetConvertBGBHistoryRequestV2, - ): Promise> +export type OpenInterestHistoryPeriodV3 = + | '5m' + | '15m' + | '30m' + | '1h' + | '2h' + | '4h' + | '6h' + | '12h' + | '1d'; ⋮---- -/** - * - * - * Spot - * - * - */ +export interface GetOpenInterestHistoryRequestV3 { + symbol: string; + /** Default 5m */ + period: OpenInterestHistoryPeriodV3; +} ⋮---- -/** - * - * * Spot | Market - * - */ +/** Default 5m */ ⋮---- -getSpotCoinInfo(params?: { - coin?: string; - }): Promise> +export type InterestRateLevelV3 = + | 'vip0' + | 'vip1' + | 'vip2' + | 'vip3' + | 'vip4' + | 'vip5' + | 'vip6' + | 'vip7' + | 'pro1' + | 'pro2' + | 'pro3' + | 'pro4' + | 'pro5' + | 'pro6'; ⋮---- -getSpotSymbolInfo(params?: { - symbol?: string; - }): Promise> +export interface GetMarginLoansAllRequestV3 { + /** Omit to return every supported coin */ + coin?: string; + /** User level. Default: vip0 */ + level?: InterestRateLevelV3; +} ⋮---- -getSpotVIPFeeRate(): Promise> +/** Omit to return every supported coin */ ⋮---- -getSpotTicker(params?: { - symbol?: string; - }): Promise> +/** User level. Default: vip0 */ ⋮---- -getSpotMergeDepth(params: { - symbol: string; - precision?: string; - limit?: string; - }): Promise> +export interface GetInterestRateHistoryRequestV3 { + coin: string; + /** + * VIP tier. Query name is level, not vipLevel (vipLevel is ignored). + * Omitting it returns the vip0 series. + */ + level?: InterestRateLevelV3; + limit?: string; + /** Pass the cursor from the previous response. */ + cursor?: string; +} ⋮---- -getSpotOrderBookDepth(params: { - symbol: string; - type?: string; - limit?: string; - }): Promise> +/** + * VIP tier. Query name is level, not vipLevel (vipLevel is ignored). + * Omitting it returns the vip0 series. + */ ⋮---- -getSpotCandles( - params: SpotCandlesRequestV2, - ): Promise> +/** Pass the cursor from the previous response. */ ⋮---- -getSpotHistoricCandles( - params: SpotHistoricCandlesRequestV2, - ): Promise> +export type AnnouncementTypeV3 = + | 'latest_news' + | 'coin_listings' + | 'product_updates' + | 'security' + | 'api_trading' + | 'maintenance_system_updates' + | 'symbol_delisting'; ⋮---- -getSpotRecentTrades(params: { - symbol: string; - limit?: string; - }): Promise> +export interface GetAnnouncementsRequestV3 { + /** zh_CN or en_US. Unsupported languages fall back to English. */ + language: string; + annType?: AnnouncementTypeV3; + startTime?: string; + endTime?: string; + /** Last annId from the previous page. Omit on the first call. */ + cursor?: string; + /** Default 10. Maximum 10. */ + limit?: string; +} ⋮---- -getSpotHistoricTrades( - params: SpotHistoricTradesRequestV2, - ): Promise> +/** zh_CN or en_US. Unsupported languages fall back to English. */ ⋮---- -getSpotCallAuction( - params: SpotCallAuctionRequestV2, - ): Promise> +/** Last annId from the previous page. Omit on the first call. */ ⋮---- -/** - * - * * Spot | Trade - * - */ +/** Default 10. Maximum 10. */ ⋮---- -spotSubmitOrder(params: SpotOrderRequestV2): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > +export interface GetCoinsRequestV3 { + /** Omit to return every coin. */ + coin?: string; +} ⋮---- -spotCancelandSubmitOrder( - params: SpotCancelandSubmitOrderRequestV2, - ): Promise> +/** Omit to return every coin. */ ⋮---- -spotBatchCancelandSubmitOrder(params: { - orderList: SpotCancelandSubmitOrderRequestV2[]; - }): Promise> +export interface GetPositionTierRequestV3 { + category: 'MARGIN' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; + coin?: string; +} ⋮---- -spotCancelOrder(params: SpotCancelOrderRequestV2): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > +export interface GetRiskReserveRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol: string; + marginCoin?: string; +} ⋮---- -spotBatchSubmitOrders( - params: SpotBatchOrderRequestV2, - ): Promise> +export interface GetRiskReserveAllRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; +} ⋮---- -spotBatchCancelOrders( - params: SpotBatchCancelOrderRequestV2, - ): Promise> +export interface GetInstrumentsRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol?: string; +} ⋮---- -spotCancelSymbolOrder(params: { symbol: string }): Promise< - APIResponse<{ - symbol: string; - }> - > +export interface GetMarketFeeGroupRequestV3 { + category: 'SPOT' | 'FUTURES'; + group?: 'DEFAULT' | 'GROUP_A' | 'GROUP_B' | 'GROUP_C'; +} ⋮---- -getSpotOrder( - params?: GetSpotOrderInfoRequestV2, - ): Promise> +export interface GetMarketScoreWeightsRequestV3 { + category?: 'SPOT' | 'FUTURES'; +} ⋮---- -getSpotOpenOrders( - params?: GetSpotOpenOrdersRequestV2, - ): Promise> +export interface GetOrderBookRequestV3 { + category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol: string; + limit?: string; +} ⋮---- -getSpotHistoricOrders( - params?: GetSpotHistoryOrdersRequestV2, - ): Promise> +export interface GetTickersRequestV3 { + category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; +} ⋮---- -getSpotFills( - params: GetSpotFillsRequestV2, - ): Promise> +export interface GetIndexComponentsRequestV3 { + symbol: string; +} ⋮---- -/** - * - * * Spot | Trigger Orders - * - */ +export interface GetRpiOrderBookRequestV3 { + category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol: string; + limit?: string; +} ⋮---- -spotSubmitPlanOrder(params: SpotPlanOrderRequestV2): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > +export interface GetCashDividendRecordsRequestV3 { + symbol: string; + type: 'pending' | 'paid'; + cursor?: string; + limit?: string; +} ⋮---- -spotModifyPlanOrder(params: SpotModifyPlanOrderRequestV2): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > -⋮---- -spotCancelPlanOrder(params: { - clientOid?: string; - orderId?: string; - }): Promise< - APIResponse<{ - result: string; - }> - > +export interface GetSpotWhaleFlowRequestV3 { + symbol: string; +} ⋮---- -getSpotCurrentPlanOrders(params: GetSpotCurrentPlanOrdersRequestV2): Promise< - APIResponse<{ - nextFlag: boolean; - idLessThan: string; - orderList: SpotCurrentPlanOrderV2[]; - }> - > +export interface GetSpotFundFlowRequestV3 { + symbol: string; + period?: string; +} ⋮---- -getSpotPlanSubOrder(params: { - planOrderId: string; - }): Promise> +export interface GetSpotNetFlowRequestV3 { + symbol: string; +} ⋮---- -getSpotHistoricPlanOrders(params: GetSpotHistoryPlanOrdersRequestV2): Promise< - APIResponse<{ - nextFlag: boolean; - idLessThan: string; - orderList: SpotHistoryPlanOrderV2[]; - }> - > +export interface GetMarginLongShortRequestV3 { + symbol: string; + period?: '24h' | '30d'; + coin?: string; +} ⋮---- -spotCancelPlanOrders(params?: { - symbolList?: string[]; - }): Promise> +export interface GetMarginLoanGrowthRequestV3 { + symbol: string; + period?: string; + coin?: string; +} ⋮---- -/** - * - * * Spot | Account - * - */ +export interface GetMarginIsolatedBorrowRequestV3 { + symbol: string; + period?: string; +} ⋮---- -getSpotAccount(): Promise> +export interface GetFuturesTradingDataRequestV3 { + symbol: string; + period?: string; +} + +================ +File: src/types/request/v3/strategy.ts +================ +export type StrategyOrderTypeV3 = + | 'tpsl' + | 'trigger' + | 'oco' + | 'trailing_stop' + | 'iceberg' + | 'twap'; ⋮---- -getSpotAccountAssets(params?: { - coin?: string; - assetType?: string; - }): Promise> +export type StrategyOrderStatusV3 = + | 'pending' + | 'success' + | 'failed' + | 'cancelled' + | 'submitting'; ⋮---- -getSpotSubAccountAssets(): Promise> +export type StrategyTriggerByV3 = 'market' | 'mark'; ⋮---- -spotModifyDepositAccount(params: { - accountType: string; - coin: string; - }): Promise> +export type StrategyTriggerOrderTypeV3 = 'limit' | 'market'; ⋮---- -getSpotAccountBills( - params?: GetSpotAccountBillsRequestV2, - ): Promise> +export interface StrategyOcoParamsV3 { + ocoLimitPrice?: string; + ocoTriggerPrice?: string; + ocoOrderType?: StrategyTriggerOrderTypeV3; + ocoOrderPrice?: string; +} ⋮---- -spotTransfer(params: SpotTransferRequestV2): Promise< - APIResponse<{ - transferId: string; - clientOid: string; - }> - > +export interface StrategyTrailingStopParamsV3 { + activationPrice?: string; + activationType?: string; + trailType?: string; + trailVariance?: string; + preOrderType?: StrategyTriggerOrderTypeV3; + preOrderPrice?: string; +} ⋮---- -getSpotTransferableCoins(params: { - fromType: SpotAccountTypeV2; - toType: SpotAccountTypeV2; - }): Promise> +export interface StrategyIcebergParamsV3 { + splitMode?: string; + qtyPerOrder?: string; + splitOrderNumbers?: string; + orderPreference?: string; + executionStrategy?: string; + fixedDistanceType?: string; + distance?: string; + fixedPrice?: string; + priceLimit?: string; +} ⋮---- -spotSubTransfer(params: SpotSubAccountTransferRequestV2): Promise< - APIResponse<{ - transferId: string; - clientOid: string; - }> - > +export interface StrategyTwapParamsV3 { + duration?: string; + interval?: string; + orderType?: StrategyTriggerOrderTypeV3; + limitOffsetType?: string; + limitOffsetPercentage?: string; + limitOffsetSpread?: string; + twapTriggerPrice?: string; + twapTerminationPrice?: string; +} ⋮---- -spotWithdraw(params: SpotWithdrawalRequestV2): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > +export interface PlaceStrategyOrderRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol: string; + clientOid?: string; + type?: StrategyOrderTypeV3; + tpslMode?: 'full' | 'partial'; + /** Required when tpslMode=partial or for trigger orders */ + qty?: string; + side?: 'buy' | 'sell'; + posSide?: 'long' | 'short'; + reduceOnly?: 'yes' | 'no'; + /** + * Margin mode. Defaults to crossed. Required for isolated positions + * (isolated TP/SL fails with 31008 if omitted). + * Not in Bitget's official API docs yet. Confirmed by Bitget API devs + * in their OpenAPI Telegram: https://t.me/bitgetOpenapi/152235 + */ + marginMode?: 'isolated' | 'crossed'; + tpTriggerBy?: StrategyTriggerByV3; + slTriggerBy?: StrategyTriggerByV3; + takeProfit?: string; + stopLoss?: string; + tpOrderType?: StrategyTriggerOrderTypeV3; + slOrderType?: StrategyTriggerOrderTypeV3; + tpLimitPrice?: string; + slLimitPrice?: string; + triggerBy?: StrategyTriggerByV3; + triggerPrice?: string; + triggerOrderType?: StrategyTriggerOrderTypeV3; + triggerOrderPrice?: string; + ocoParams?: StrategyOcoParamsV3; + trailingStopParams?: StrategyTrailingStopParamsV3; + icebergParams?: StrategyIcebergParamsV3; + twapParams?: StrategyTwapParamsV3; +} ⋮---- -getSpotMainSubTransferRecord( - params: SpotMainSubTransferRecordRequestV2, - ): Promise> +/** Required when tpslMode=partial or for trigger orders */ ⋮---- -getSpotTransferHistory( - params: GetSpotTransferRecordRequestV2, - ): Promise> +/** + * Margin mode. Defaults to crossed. Required for isolated positions + * (isolated TP/SL fails with 31008 if omitted). + * Not in Bitget's official API docs yet. Confirmed by Bitget API devs + * in their OpenAPI Telegram: https://t.me/bitgetOpenapi/152235 + */ ⋮---- -spotSwitchBGBDeduct(params: { - deduct: boolean; - }): Promise> +export interface ModifyStrategyOrderRequestV3 { + orderId?: string; + clientOid?: string; + qty: string; + tpTriggerBy?: StrategyTriggerByV3; + slTriggerBy?: StrategyTriggerByV3; + takeProfit?: string; + stopLoss?: string; + tpOrderType?: StrategyTriggerOrderTypeV3; + slOrderType?: StrategyTriggerOrderTypeV3; + tpLimitPrice?: string; + slLimitPrice?: string; + triggerBy?: StrategyTriggerByV3; + triggerPrice?: string; + triggerOrderType?: StrategyTriggerOrderTypeV3; + triggerOrderPrice?: string; +} ⋮---- -getSpotDepositAddress(params: { - coin: string; - chain?: string; - size: string; - }): Promise> +export interface CancelStrategyOrderRequestV3 { + orderId?: string; + clientOid?: string; +} ⋮---- -getSpotSubDepositAddress(params: { - subUid: string; - coin: string; - chain?: string; - size: string; - }): Promise> +export interface GetUnfilledStrategyOrdersRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + type?: StrategyOrderTypeV3; +} ⋮---- -getSpotBGBDeductInfo(): Promise< - APIResponse<{ - deduct: string; - }> - > +export interface GetHistoryStrategyOrdersRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + type?: StrategyOrderTypeV3; + startTime?: string; + endTime?: string; + limit?: string; + /** Observed as a number though the docs say string. */ + cursor?: string | number; +} ⋮---- -spotCancelWithdrawal(params: { +/** Observed as a number though the docs say string. */ +⋮---- +export interface GetStrategySubOrdersRequestV3 { + orderId?: string; + clientOid?: string; + limit?: string; + cursor?: string; +} + +================ +File: src/types/response/v3/trade.ts +================ +export interface BatchModifyOrderResponseV3 { + orderId: string; + clientOid: string; +} +⋮---- +export interface CancelAllOrdersResponseV3 { + list: { orderId: string; - }): Promise> + clientOid: string; + code: string; + msg: string; + }[]; +} ⋮---- -getSubAccountDepositRecords( - params: GetSpotSubAccountDepositRecordRequestV2, - ): Promise> +export interface CancelBatchOrdersResponseV3 { + orderId: string; + clientOid: string; + code?: string; + msg?: string; +} ⋮---- -getSpotWithdrawalHistory( - params: GetSpotWithdrawalRecordRequestV2, - ): Promise> +export interface CloseAllPositionsResponseV3 { + list: { + orderId: string; + clientOid: string; + code: string; + msg: string; + }[]; +} ⋮---- -getSpotDepositHistory( - params: GetSpotDepositRecordRequestV2, - ): Promise> +export interface CancelOrderResponseV3 { + orderId: string; + clientOid: string; +} ⋮---- -/** - * 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> +export interface GetMaxOpenAvailableResponseV3 { + available: string; + maxOpen: string; + buyOpenCost: string; + sellOpenCost: string; + maxBuyOpen: string; + maxSellOpen: string; + maxBuyAvailable?: string; + maxSellAvailable?: string; +} ⋮---- -/** - * 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'; - }> - > +export interface FeeDetailV3 { + feeCoin: string; + fee: string; +} ⋮---- -/** - * - * - * Futures - * - * +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; + /** + * rToken routing returned on order details / WS order channel. + * internal_market = on-exchange only; lit_market = broker only; + * default = internal first then broker (former lit_market meaning, since 5 Nov 2026). */ + venue?: 'internal_market' | 'lit_market' | 'default' | string; + /** rToken time in force. gtd = current session, gtc = 90 days. */ + rTokenTimeInForce?: 'gtd' | 'gtc' | string; + orderStatus: string; + posSide: string; + holdMode: string; + delegateType?: string; + reduceOnly: string; + feeDetail: FeeDetailV3[]; + cancelReason: string; + execType: string; + stpMode?: string; + createdTime: string; + updatedTime: string; +} ⋮---- /** - * - * * Futures | Market - * + * rToken routing returned on order details / WS order channel. + * internal_market = on-exchange only; lit_market = broker only; + * default = internal first then broker (former lit_market meaning, since 5 Nov 2026). */ ⋮---- -getFuturesVIPFeeRate(): Promise> -⋮---- -getFuturesInterestRateHistory(params: { coin: string }): Promise< - APIResponse<{ - coin: string; - historyInterestRateList: FuturesHistoryInterestRateV2[]; - }> - > -⋮---- -getFuturesInterestExchangeRate(): Promise< - APIResponse< - { - coin: string; - exchangeRateList: FuturesInterestExchangeRateV2[]; - }[] - > - > +/** rToken time in force. gtd = current session, gtc = 90 days. */ ⋮---- -getFuturesDiscountRate(): Promise> +export type FillCategoryV3 = + | 'spot' + | 'margin' + | 'usdt-futures' + | 'coin-futures' + | 'usdc-futures' + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; ⋮---- -getFuturesMergeDepth( - params: FuturesMergeDepthRequestV2, - ): Promise> +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; +} ⋮---- -getFuturesTicker(params: { - symbol: string; - productType: FuturesProductTypeV2; - }): Promise> +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; +} ⋮---- -getFuturesAllTickers(params: { - productType: FuturesProductTypeV2; - }): Promise> +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; +} ⋮---- -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; - }> - > -⋮---- -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; - }[] - > - > -⋮---- -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; - }[] - > - > -⋮---- -/** - * - * * Futures | Account - * - */ -⋮---- -getFuturesAccountAsset( - params: FuturesSingleAccountRequestV2, - ): Promise> -⋮---- -getFuturesAccountAssets(params: { - productType: FuturesProductTypeV2; - }): Promise> -⋮---- -getFuturesSubAccountAssets(params: { - productType: FuturesProductTypeV2; - }): Promise< - APIResponse< - { - userId: number; - assetList: FuturesSubAccountAssetV2[]; - }[] - > - > -⋮---- -getFuturesInterestHistory( - params: FuturesInterestHistoryRequestV2, - ): Promise> -⋮---- -getFuturesOpenCount(params: FuturesOpenCountRequestV2): Promise< - APIResponse<{ - size: string; - }> - > -⋮---- -setFuturesPositionAutoMargin( - params: FuturesSetAutoMarginRequestV2, - ): Promise> -⋮---- -setFuturesLeverage( - params: FuturesSetLeverageRequestV2, - ): Promise> +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; +} ⋮---- -setFuturesPositionMargin( - params: FuturesSetPositionMarginRequestV2, - ): Promise> +/** Cash dividend, USDT */ ⋮---- -setFuturesAssetMode(params: { - productType: 'USDT-FUTURES' | 'SUSDT-FUTURES'; - assetMode: 'single' | 'union'; - }): Promise> +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; +} ⋮---- -setFuturesMarginMode( - params: FuturesSetMarginModeRequestV2, - ): Promise> +/** Cash dividend, USDT */ ⋮---- -setFuturesPositionMode(params: { - productType: FuturesProductTypeV2; - posMode: 'one_way_mode' | 'hedge_mode'; - }): Promise< - APIResponse<{ - posMode: 'one_way_mode' | 'hedge_mode'; - }> - > +export interface LoanDataDebtCoinV3 { + coin: string; + debt: string; + interestFreeAmount: string; + interestRateNextHour: string; +} ⋮---- -getFuturesAccountBills(params: FuturesAccountBillRequestV2): Promise< - APIResponse<{ - bills: FuturesAccountBillV2[]; - endId: string; - }> - > +export interface LoanDataV3 { + currentLoans: string; + interestPaymentTime: string; + debtCoinList: LoanDataDebtCoinV3[]; +} ⋮---- -/** - * Get Union Transfer Limits - * - * - Rate limit: 1 time/1s (uid) - * - Get union margin currency transfer limits - */ -getUnionTransferLimits( - params: GetUnionTransferLimitsRequestV2, - ): Promise> +export interface ModifyOrderResponseV3 { + orderId: string; + clientOid: string; +} ⋮---- -/** - * 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> +export interface PlaceBatchOrdersResponseV3 { + orderId: string; + clientOid: string; + code?: string; + msg?: string; +} ⋮---- -/** - * Get Switch Union USDT - * - * - Rate limit: 1 time/1s (uid) - * - Get USDT quota for switching from union margin to single margin - */ -getSwitchUnionUsdt(): Promise> +export interface PlaceOrderResponseV3 { + orderId: string; + clientOid: string; +} ⋮---- -/** - * 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; - }> - > -⋮---- -getFuturesPositionAdlRank( - params: FuturesPositionAdlRankRequestV2, - ): Promise> -⋮---- -/** - * - * * Futures | Trade - * - */ -⋮---- -futuresSubmitOrder(params: FuturesPlaceOrderRequestV2): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > -⋮---- -futuresSubmitReversal(params: FuturesReversalOrderRequestV2): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > -⋮---- -futuresBatchSubmitOrders( - params: FuturesBatchOrderRequestV2, - ): Promise> -⋮---- -futuresModifyOrder(params: FuturesModifyOrderRequestV2): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > -⋮---- -futuresCancelOrder(params: FuturesCancelOrderRequestV2): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > -⋮---- -futuresBatchCancelOrders( - params: FuturesBatchCancelOrderRequestV2, - ): Promise> -⋮---- -futuresFlashClosePositions( - params: FuturesFlashClosePositionsRequestV2, - ): Promise> -⋮---- -getFuturesOrder( - params: FuturesGetOrderRequestV2, - ): Promise> -⋮---- -getFuturesFills(params: FuturesGetOrderFillsRequestV2): Promise< - APIResponse<{ - fillList: FuturesOrderFillV2[]; - endId: string; - }> - > -⋮---- -getFuturesHistoricOrderFills( - params: FuturesGetHistoricalFillsRequestV2, - ): Promise< - APIResponse<{ - fillList: FuturesOrderFillV2[]; - endId: string; - }> - > -⋮---- -getFuturesOpenOrders(params: FuturesGetOpenOrdersRequestV2): Promise< - APIResponse<{ - /** - * Undocumented but staff-confirmed: null and [] can both represent an empty page. - * @see https://t.me/bitgetOpenapi/153977 - */ - entrustedList: FuturesOpenOrderV2[] | null; - endId: string; - }> - > -⋮---- -/** - * Undocumented but staff-confirmed: null and [] can both represent an empty page. - * @see https://t.me/bitgetOpenapi/153977 - */ -⋮---- -getFuturesHistoricOrders(params: FuturesGetHistoryOrdersRequestV2): Promise< - APIResponse<{ - entrustedList: FuturesHistoryOrderV2[]; - endId: string; - }> - > -⋮---- -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; - }> - > -⋮---- -futuresSubmitPositionTPSL(params: FuturesPositionTPSLOrderRequestV2): Promise< - APIResponse< - { - orderId: string; - stopSurplusClientOid: string; - stopLossClientOid: string; - }[] - > - > -⋮---- -futuresSubmitPlanOrder(params: FuturesPlanOrderRequestV2): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > -⋮---- -futuresModifyTPSLPOrder(params: FuturesModifyTPSLOrderRequestV2): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > -⋮---- -futuresModifyPlanOrder(params: FuturesModifyPlanOrderRequestV2): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > -⋮---- -getFuturesPlanOrders(params: FuturesGetPlanOrdersRequestV2): Promise< - APIResponse<{ - /** - * Undocumented but staff-confirmed: null and [] can both represent an empty page. - * @see https://t.me/bitgetOpenapi/153977 - */ - entrustedList: FuturesPendingPlanOrderV2[] | null; - endId: string; - }> - > -⋮---- -/** - * Undocumented but staff-confirmed: null and [] can both represent an empty page. - * @see https://t.me/bitgetOpenapi/153977 - */ -⋮---- -futuresCancelPlanOrder( - params: FuturesCancelPlanOrderRequestV2, - ): Promise> -⋮---- -getFuturesHistoricPlanOrders( - params: FuturesGetHistoryPlanOrdersRequestV2, - ): Promise< - APIResponse<{ - entrustedList: FuturesHistoryPlanOrderV2[]; - endId: string; - }> - > -⋮---- -/** - * - * - * Broker - * - * - */ -⋮---- -/** - * - * * Broker | Subaccount - * - */ -⋮---- -modifySubaccountEmail(params: { - subUid: string; - subaccountEmail: string; - }): Promise> -⋮---- -getBrokerInfo(): Promise< - APIResponse<{ - subAccountSize: string; - maxSubAccountSize: string; - uTime: string; - }> - > -⋮---- -createSubaccount(params: { - subaccountName: string; - label: string; - }): Promise> -⋮---- -getSubaccounts(params?: GetSubAccountsRequestV2): Promise< - APIResponse<{ - hasNextPage: boolean; - idLessThan: number; - subList: BrokerSubaccountV2[]; - }> - > -⋮---- -modifySubaccount( - params: ModifySubRequestV2, - ): Promise> -⋮---- -getSubaccountEmail(params: { - subUid: string; - }): Promise> -⋮---- -getSubaccountSpotAssets(params: { - subUid: string; - coin?: string; - assetType?: 'hold_only' | 'all'; - }): Promise< - APIResponse<{ - assetsList: BrokerSubaccountSpotAssetV2[]; - }> - > -⋮---- -getSubaccountFuturesAssets(params: { - subUid: string; - productType: FuturesProductTypeV2; - }): Promise< - APIResponse<{ - assetsList: BrokerSubaccountFutureAssetV2[]; - }> - > -⋮---- -createSubaccountDepositAddress(params: { - subUid: string; - coin: string; - chain?: string; - }): Promise> -⋮---- -subaccountWithdrawal(params: SubWithdrawalRequestV2): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > -⋮---- -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; - }> - > -⋮---- -/** - * - * 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; - }> - > -⋮---- -/** - * 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> -⋮---- -getSubAffiliateInfo( - params?: GetSubAffiliateInfoRequestV2, - ): 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; - }> - > -⋮---- -getMarginRepayHistory( - marginType: MarginType, - params: GetRepayHistoryRequestV2, - ): Promise< - APIResponse<{ - resultList: MarginRepaymentHistoryItemV2[]; - maxId: string; - minId: string; - }> - > -⋮---- -getMarginInterestHistory( - marginType: MarginType, - params: GetInterestHistoryRequestV2, - ): Promise< - APIResponse<{ - resultList: MarginInterestHistoryItemV2[]; - maxId: string; - minId: string; - }> - > -⋮---- -getMarginLiquidationHistory( - marginType: MarginType, - params: GetLiquidationHistoryRequestV2, - ): Promise< - APIResponse<{ - resultList: MarginLiquidationHistoryItemV2[]; - maxId: string; - minId: string; - }> - > -⋮---- -getMarginFinancialHistory( - marginType: MarginType, - params: GetFinancialHistoryRequestV2, - ): Promise< - APIResponse<{ - resultList: MarginFinancialHistoryItemV2[]; - maxId: string; - minId: string; - }> - > -⋮---- -/** - * - * * 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; - }> - > -⋮---- -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; - }> - > -⋮---- -getMarginRiskRate(marginType: MarginType): Promise< - APIResponse< - { - symbol: string; - riskRateRatio: string; - }[] - > - > -⋮---- -getMarginMaxBorrowable( - marginType: MarginType, - params: { coin: string }, - ): Promise< - APIResponse - > -⋮---- -getMarginMaxTransferable( - marginType: MarginType, - params: { coin: string }, - ): Promise< - APIResponse< - CrossMaxTransferableResponseV2 | IsolatedMaxTransferableResponseV2 - > - > -⋮---- -getMarginInterestRateAndMaxBorrowable( - marginType: MarginType, - params: { coin: string }, - ): Promise< - APIResponse< - | IsolatedInterestRateAndLimitResponseV2[] - | CrossInterestRateAndLimitResponseV2[] - > - > -⋮---- -getMarginTierConfiguration( - marginType: MarginType, - params: { coin: string }, - ): Promise< - APIResponse< - CrossTierConfigurationResponseV2[] | IsolatedTierConfigurationResponseV2[] - > - > -⋮---- -marginFlashRepay( - marginType: MarginType, - params: { coin: string }, - ): Promise< - APIResponse<{ - repayId: string; - coin?: string; - symbol?: string; - result?: string; - }> - > -⋮---- -getMarginFlashRepayResult( - marginType: MarginType, - params: { idList: string }, - ): Promise< - APIResponse< - { - repayId: string; - status: string; - }[] - > - > -⋮---- -/** - * - * * Margin | Cross/Isolated | Trade - * - */ -⋮---- -marginSubmitOrder( - marginType: MarginType, - params: MarginPlaceOrderRequestV2, - ): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > -⋮---- -marginBatchSubmitOrders( - marginType: MarginType, - params: MarginBatchOrdersRequestV2, - ): Promise> -⋮---- -marginCancelOrder( - marginType: MarginType, - params: { - symbol: string; - orderId?: string; - clientOid?: string; - }, - ): Promise< - APIResponse<{ - orderId: string; - clientOid: string; - }> - > -⋮---- -marginBatchCancelOrders( - marginType: MarginType, - params: { - symbol: string; - orderIdList: string[]; - }, - ): Promise> -⋮---- -getMarginOpenOrders( - marginType: MarginType, - params: GetMarginCurrentOrdersRequestV2, - ): Promise< - APIResponse<{ - orderList: MarginCurrentOrderV2[]; - maxId: string; - minId: string; - }> - > -⋮---- -getMarginHistoricOrders( - marginType: MarginType, - params: GetHistoryOrdersRequestV2, - ): Promise< - APIResponse<{ - orderList: MarginHistoryOrderV2[]; - maxId: string; - minId: string; - }> - > -⋮---- -getMarginHistoricOrderFills( - marginType: MarginType, - params: GetMarginOrderFillsRequestV2, - ): Promise< - APIResponse<{ - fills: MarginOrderFillV2[]; - minId: string; - maxId: string; - }> - > -⋮---- -getMarginLiquidationOrders( - marginType: MarginType, - params: GetMarginLiquidationOrdersRequestV2, - ): Promise< - APIResponse<{ - resultList: MarginLiquidationOrderV2[]; - idLessThan: string; - }> - > -⋮---- -/** - * - * - * Copy Trading - * - * - */ -⋮---- -/** - * - * - * Copy Trading | Future copy trading | Trader Api - * - * - */ -⋮---- -getFuturesTraderCurrentOrder( - params: GetFuturesTraderCurrentOrdersRequestV2, - ): Promise> -⋮---- -getFuturesTraderHistoryOrders( - params: GetFuturesTraderHistoryOrdersRequestV2, - ): Promise> -⋮---- -modifyFuturesTraderOrderTPSL( - params: ModifyFuturesTraderOrderTPSLRequestV2, - ): Promise> -⋮---- -getFuturesTraderOrder(): Promise< - APIResponse - > -⋮---- -getFuturesTraderProfitHistory(): Promise< - APIResponse - > -⋮---- -getFuturesTraderProfitShareHistory( - params: GetFuturesTraderProfitShareDetailRequestV2, - ): Promise> -⋮---- -closeFuturesTraderOrder(params: { - trackingNo: string; - symbol: string; - productType: CopyTradingProductTypeV2; - }): Promise< - APIResponse< - { - trackingNo: string; - symbol: string; - productType: string; - }[] - > - > -⋮---- -getFuturesTraderProfitShare(params?: { - coin?: string; - pageSize?: string; - pageNo?: string; - }): Promise< - APIResponse< - { - coin: string; - profit: string; - nickName: string; - }[] - > - > -⋮---- -getFuturesTraderProfitShareGroup(params?: { - pageSize?: string; - pageNo?: string; - }): Promise< - APIResponse< - { - coin: string; - profit: string; - profitTime: string; - }[] - > - > -⋮---- -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[]; - }> - > -⋮---- -getFuturesFollowerTraders( - params: GetFuturesFollowerTradersRequestV2, - ): Promise> -⋮---- -getFuturesFollowerFollowLimit(params: { - symbol: string; - productType: CopyTradingProductTypeV2; - }): Promise< - APIResponse< - { - maxFollowSize: string; - minFollowSize: string; - symbol: string; - }[] - > - > -⋮---- -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[]; - }> - > -⋮---- -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; - }> - > -⋮---- -getEarnSavingsSubscriptionResult(params: { - productId: string; - periodType: string; - }): Promise< - APIResponse<{ - result: 'success' | 'fail'; - msg: string; - }> - > -⋮---- -earnRedeemSavings(params: RedeemSavingsRequestV2): Promise< - APIResponse<{ - orderId: string; - status: string; - }> - > -⋮---- -getEarnSavingsRedemptionResult(params: { - orderId: string; - periodType: string; - }): Promise< - APIResponse<{ - result: 'success' | 'fail'; - msg: string; - }> - > -⋮---- -/** - * - * - * Earn | Earn Account - * - * - */ -⋮---- -getEarnAccount(params?: { coin?: string }): Promise< - APIResponse< - { - coin: string; - amount: string; - }[] - > - > -⋮---- -/** - * - * - * 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; - }> - > -⋮---- -getSharkfinSubscriptionResult(params: { orderId: string }): Promise< - APIResponse<{ - result: 'success' | 'fail'; - msg: string; - }> - > -⋮---- -/** - * - * - * Earn | Loan - * - * - */ -⋮---- -getLoanCurrencies(params?: { - coin?: string; - }): Promise> -⋮---- -getLoanEstInterestAndBorrowable( - params: GetLoanEstInterestAndBorrowableRequestV2, - ): Promise< - APIResponse<{ - hourInterest: string; - loanAmount: string; - }> - > -⋮---- -borrowLoan(params: BorrowLoanRequestV2): Promise< - APIResponse<{ - orderId: string; - }> - > -⋮---- -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; - }> - > -⋮---- -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[]; - }> - > -⋮---- -/** - * - * * Inst Loan | Account - * - */ -⋮---- -getLoanRiskUnit(): Promise< - APIResponse<{ - riskUnitId: string[]; - }> - > -⋮---- -getLoanLTVConvert( - params?: GetInstLoanLTVConvertRequestV2, - ): Promise> -⋮---- -/** - * - * * Inst Loan | Orders - * - */ -⋮---- -getLoanRepaidHistory( - params?: GetInstLoanRepaidHistoryRequestV2, - ): Promise> -⋮---- -getLoanOrder( - params?: GetInstLoanOrderRequestV2, - ): Promise> - -================ -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 type OpenInterestHistoryPeriodV3 = - | '5m' - | '15m' - | '30m' - | '1h' - | '2h' - | '4h' - | '6h' - | '12h' - | '1d'; -⋮---- -export interface GetOpenInterestHistoryRequestV3 { - symbol: string; - /** Default 5m */ - period: OpenInterestHistoryPeriodV3; -} -⋮---- -/** Default 5m */ -⋮---- -export type InterestRateLevelV3 = - | 'vip0' - | 'vip1' - | 'vip2' - | 'vip3' - | 'vip4' - | 'vip5' - | 'vip6' - | 'vip7' - | 'pro1' - | 'pro2' - | 'pro3' - | 'pro4' - | 'pro5' - | 'pro6'; -⋮---- -export interface GetMarginLoansAllRequestV3 { - /** Omit to return every supported coin */ - coin?: string; - /** User level. Default: vip0 */ - level?: InterestRateLevelV3; -} -⋮---- -/** Omit to return every supported coin */ -⋮---- -/** User level. Default: vip0 */ -⋮---- -export interface GetInterestRateHistoryRequestV3 { - coin: string; - /** - * VIP tier. Query name is level, not vipLevel (vipLevel is ignored). - * Omitting it returns the vip0 series. - */ - level?: InterestRateLevelV3; - limit?: string; - /** Pass the cursor from the previous response. */ - cursor?: string; -} -⋮---- -/** - * VIP tier. Query name is level, not vipLevel (vipLevel is ignored). - * Omitting it returns the vip0 series. - */ -⋮---- -/** Pass the cursor from the previous response. */ -⋮---- -export type AnnouncementTypeV3 = - | 'latest_news' - | 'coin_listings' - | 'product_updates' - | 'security' - | 'api_trading' - | 'maintenance_system_updates' - | 'symbol_delisting'; -⋮---- -export interface GetAnnouncementsRequestV3 { - /** zh_CN or en_US. Unsupported languages fall back to English. */ - language: string; - annType?: AnnouncementTypeV3; - startTime?: string; - endTime?: string; - /** Last annId from the previous page. Omit on the first call. */ - cursor?: string; - /** Default 10. Maximum 10. */ - limit?: string; -} -⋮---- -/** zh_CN or en_US. Unsupported languages fall back to English. */ -⋮---- -/** Last annId from the previous page. Omit on the first call. */ -⋮---- -/** Default 10. Maximum 10. */ -⋮---- -export interface GetCoinsRequestV3 { - /** Omit to return every coin. */ - coin?: string; -} -⋮---- -/** Omit to return every coin. */ -⋮---- -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/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; - /** - * rToken routing returned on order details / WS order channel. - * internal_market = on-exchange only; lit_market = broker only; - * default = internal first then broker (former lit_market meaning, since 5 Nov 2026). - */ - venue?: 'internal_market' | 'lit_market' | 'default' | string; - /** rToken time in force. gtd = current session, gtc = 90 days. */ - rTokenTimeInForce?: 'gtd' | 'gtc' | string; - orderStatus: string; - posSide: string; - holdMode: string; - delegateType?: string; - reduceOnly: string; - feeDetail: FeeDetailV3[]; - cancelReason: string; - execType: string; - stpMode?: string; - createdTime: string; - updatedTime: string; -} -⋮---- -/** - * rToken routing returned on order details / WS order channel. - * internal_market = on-exchange only; lit_market = broker only; - * default = internal first then broker (former lit_market meaning, since 5 Nov 2026). - */ -⋮---- -/** rToken time in force. gtd = current session, gtc = 90 days. */ -⋮---- -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/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 - | 'uta' - | '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 - * - * Spot/futures candle and trade channels send only action=update, without a - * subscription snapshot, from 4 Nov 2026 on demo; live expected 17 Nov 2026. - * Use the corresponding REST API for historical candles and trades. - * https://www.bitget.com/docs/classic/changelog/2026-11 - */ -⋮---- -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 - * - * kline and publicTrade send only action=update, without a subscription snapshot, - * from 4 Nov 2026 on demo; live expected 17 Nov 2026. - * Use the corresponding REST API for historical candles and trades. - * https://www.bitget.com/docs/uta/update-preview - */ -export type WsPublicTopicV3 = - | 'ticker' - | 'kline' - | 'books' - | 'books1' - | 'books5' - | 'books50' - | 'publicTrade' - /** Futures public liquidations. Optional payload.symbol filters to that symbol */ - | 'liquidation' - | 'instruments' - | 'open-interest-limit' - | 'position-tier' - | 'funding-rate' - | 'margin-loan' - | 'margin-coins'; -⋮---- -/** Futures public liquidations. Optional payload.symbol filters to that symbol */ -⋮---- -// Also update PRIVATE_TOPICS_V3 if this is updated. -// `order` includes venue and rTokenTimeInForce for rToken orders. -export type WsPrivateTopicV3 = - | 'account' - | 'position' - | 'fill' - | 'order' - | 'strategy-order' - | 'reality-orderbook' - | 'reality-orderbook-segmented'; -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/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'; - /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ - pxAmendType?: 'yes' | 'no'; - /** Limit orders only. queue1, queue5, counterparty1, or counterparty5. Ignored for market orders */ - bboLevel?: 'queue1' | 'queue5' | 'counterparty1' | 'counterparty5'; - /** Market orders only. Decimal, default 0.02, range 0.01-0.05 */ - slippageTolerance?: string; - /** - * rToken routing. Accepted: internal_market | lit_market. Omit for default. - * internal_market = on-exchange only; lit_market = broker only. - * Omit / default = internal first, then broker. Ignored for non-rToken symbols. - * Live since 5 Nov 2026. - */ - venue?: 'internal_market' | 'lit_market'; - /** rToken time in force. gtd (default) or gtc (90 days). */ - rTokenTimeInForce?: 'gtd' | 'gtc'; - /** - * Broker rebate code. Lifted onto the WS request envelope. - * It is not sent inside args. Omit it to use the SDK broker code. - * Place-order docs: top-level apiCode. Batch-place uses the same field. - * Staff-confirmed: t.me/bitgetOpenapi/153820. - */ - apiCode?: 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 */ -⋮---- -/** Spot only. Default: no */ -⋮---- -/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ -⋮---- -/** Limit orders only. queue1, queue5, counterparty1, or counterparty5. Ignored for market orders */ -⋮---- -/** Market orders only. Decimal, default 0.02, range 0.01-0.05 */ -⋮---- -/** - * rToken routing. Accepted: internal_market | lit_market. Omit for default. - * internal_market = on-exchange only; lit_market = broker only. - * Omit / default = internal first, then broker. Ignored for non-rToken symbols. - * Live since 5 Nov 2026. - */ -⋮---- -/** rToken time in force. gtd (default) or gtc (90 days). */ -⋮---- -/** - * Broker rebate code. Lifted onto the WS request envelope. - * It is not sent inside args. Omit it to use the SDK broker code. - * Place-order docs: top-level apiCode. Batch-place uses the same field. - * Staff-confirmed: t.me/bitgetOpenapi/153820. - */ - -================ -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) -[![Bitget Tutorial](https://img.shields.io/badge/Bitget%20Tutorial-siebly.io-blue)](https://siebly.io/sdk/bitget/javascript/tutorial) - -

- - - - 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. +export interface PositionAdlRankV3 { + symbol: string; + marginCoin: string; + adlRank: string; + holdSide: 'long' | 'short'; +} - /** - * 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, + GetSubAffiliateInfoRequestV2, + 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, + SubAffiliateInfoV2, +} 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; + }> + > +⋮---- +getTradeRate(params: GetTradeRateRequestV2): Promise< + APIResponse<{ + makerFeeRate: string; + takerFeeRate: string; + }> + > +⋮---- +getAllTradeRates(params: GetAllTradeRatesRequestV2): Promise< + APIResponse< + { + symbol: string; + makerFeeRate: string; + takerFeeRate: string; + }[] + > + > +⋮---- +/** + * + * * 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; + }> + > +⋮---- +getP2PMerchantInfo(): Promise> +⋮---- +getP2PMerchantOrders(params: GetMerchantP2POrdersRequestV2): Promise< + APIResponse<{ + orderList: P2PMerchantOrderV2[]; + minOrderId: string; + }> + > +⋮---- +getP2PMerchantAdvertisementList( + params: GetMerchantAdvertisementsRequestV2, + ): Promise< + APIResponse<{ + advList: P2PMerchantAdvertismentV2[]; + minAdvId: string; + }> + > +⋮---- +/** + * + * * 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[]; + }> + > +⋮---- +getSpotFundNetFlowData(params: { symbol: string }): Promise< + APIResponse< + { + netFlow: string; + ts: string; + }[] + > + > +⋮---- +getFuturesActiveLongShortAccountData(params: { + symbol: string; + period?: string; + }): Promise> +⋮---- +/** + * + * * Common | Virtual Subaccount + * + */ +⋮---- +createVirtualSubaccount(params: { + subAccountList: string[]; + }): Promise> +⋮---- +modifyVirtualSubaccount(params: ModifyVirtualSubRequestV2): Promise< + APIResponse<{ + result: string; + }> + > +⋮---- +batchCreateVirtualSubaccountAndAPIKey( + params: CreateVirtualSubRequestV2, + ): Promise> +⋮---- +getVirtualSubaccounts(params?: { + limit?: string; + idLessThan?: string; + status?: 'normal' | 'freeze'; + }): Promise< + APIResponse<{ + endId: string; + subAccountList: VirtualSubAccountV2[]; + }> + > +⋮---- +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; + }[] + > + > +⋮---- +/** + * + * * Common | Convert + * + */ +⋮---- +getConvertCoins(): Promise> +⋮---- +getConvertQuotedPrice( + params: ConvertQuoteRequestV2, + ): Promise> +⋮---- +convert( + params: ConvertRequestV2, + ): Promise> +⋮---- +getConvertHistory(params: GetConvertHistoryRequestV2): Promise< + APIResponse<{ + dataList: ConvertRecordV2[]; + endId: string; + }> + > +⋮---- +/** + * + * * Common | BGB Convert + * + */ +⋮---- +getConvertBGBCoins(): Promise< + APIResponse<{ + coinList: BGBConvertCoinV2[]; + }> + > +⋮---- +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; + }> + > +⋮---- +spotCancelandSubmitOrder( + params: SpotCancelandSubmitOrderRequestV2, + ): Promise> +⋮---- +spotBatchCancelandSubmitOrder(params: { + orderList: SpotCancelandSubmitOrderRequestV2[]; + }): Promise> +⋮---- +spotCancelOrder(params: SpotCancelOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > +⋮---- +spotBatchSubmitOrders( + params: SpotBatchOrderRequestV2, + ): Promise> +⋮---- +spotBatchCancelOrders( + params: SpotBatchCancelOrderRequestV2, + ): Promise> +⋮---- +spotCancelSymbolOrder(params: { symbol: string }): Promise< + APIResponse<{ + symbol: string; + }> + > +⋮---- +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; + }> + > +⋮---- +spotModifyPlanOrder(params: SpotModifyPlanOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > +⋮---- +spotCancelPlanOrder(params: { + clientOid?: string; + orderId?: string; + }): Promise< + APIResponse<{ + result: string; + }> + > +⋮---- +getSpotCurrentPlanOrders(params: GetSpotCurrentPlanOrdersRequestV2): Promise< + APIResponse<{ + nextFlag: boolean; + idLessThan: string; + orderList: SpotCurrentPlanOrderV2[]; + }> + > +⋮---- +getSpotPlanSubOrder(params: { + planOrderId: string; + }): Promise> +⋮---- +getSpotHistoricPlanOrders(params: GetSpotHistoryPlanOrdersRequestV2): Promise< + APIResponse<{ + nextFlag: boolean; + idLessThan: string; + orderList: SpotHistoryPlanOrderV2[]; + }> + > +⋮---- +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; + }> + > +⋮---- +getSpotTransferableCoins(params: { + fromType: SpotAccountTypeV2; + toType: SpotAccountTypeV2; + }): Promise> +⋮---- +spotSubTransfer(params: SpotSubAccountTransferRequestV2): Promise< + APIResponse<{ + transferId: string; + clientOid: string; + }> + > +⋮---- +spotWithdraw(params: SpotWithdrawalRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > +⋮---- +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; + }> + > +⋮---- +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'; + }> + > +⋮---- +/** + * + * + * Futures + * + * + */ +⋮---- +/** + * + * * Futures | Market + * + */ +⋮---- +getFuturesVIPFeeRate(): Promise> +⋮---- +getFuturesInterestRateHistory(params: { coin: string }): Promise< + APIResponse<{ + coin: string; + historyInterestRateList: FuturesHistoryInterestRateV2[]; + }> + > +⋮---- +getFuturesInterestExchangeRate(): Promise< + APIResponse< + { + coin: string; + exchangeRateList: FuturesInterestExchangeRateV2[]; + }[] + > + > +⋮---- +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; + }> + > +⋮---- +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; + }[] + > + > +⋮---- +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; + }[] + > + > +⋮---- +/** + * + * * Futures | Account + * + */ +⋮---- +getFuturesAccountAsset( + params: FuturesSingleAccountRequestV2, + ): Promise> +⋮---- +getFuturesAccountAssets(params: { + productType: FuturesProductTypeV2; + }): Promise> +⋮---- +getFuturesSubAccountAssets(params: { + productType: FuturesProductTypeV2; + }): Promise< + APIResponse< + { + userId: number; + assetList: FuturesSubAccountAssetV2[]; + }[] + > + > +⋮---- +getFuturesInterestHistory( + params: FuturesInterestHistoryRequestV2, + ): Promise> +⋮---- +getFuturesOpenCount(params: FuturesOpenCountRequestV2): Promise< + APIResponse<{ + size: string; + }> + > +⋮---- +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'; + }> + > +⋮---- +getFuturesAccountBills(params: FuturesAccountBillRequestV2): Promise< + APIResponse<{ + bills: FuturesAccountBillV2[]; + endId: string; + }> + > +⋮---- +/** + * 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; + }> + > +⋮---- +getFuturesPositionAdlRank( + params: FuturesPositionAdlRankRequestV2, + ): Promise> +⋮---- +/** + * + * * Futures | Trade + * + */ +⋮---- +futuresSubmitOrder(params: FuturesPlaceOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > +⋮---- +futuresSubmitReversal(params: FuturesReversalOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > +⋮---- +futuresBatchSubmitOrders( + params: FuturesBatchOrderRequestV2, + ): Promise> +⋮---- +futuresModifyOrder(params: FuturesModifyOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > +⋮---- +futuresCancelOrder(params: FuturesCancelOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > +⋮---- +futuresBatchCancelOrders( + params: FuturesBatchCancelOrderRequestV2, + ): Promise> +⋮---- +futuresFlashClosePositions( + params: FuturesFlashClosePositionsRequestV2, + ): Promise> +⋮---- +getFuturesOrder( + params: FuturesGetOrderRequestV2, + ): Promise> +⋮---- +getFuturesFills(params: FuturesGetOrderFillsRequestV2): Promise< + APIResponse<{ + fillList: FuturesOrderFillV2[]; + endId: string; + }> + > +⋮---- +getFuturesHistoricOrderFills( + params: FuturesGetHistoricalFillsRequestV2, + ): Promise< + APIResponse<{ + fillList: FuturesOrderFillV2[]; + endId: string; + }> + > +⋮---- +getFuturesOpenOrders(params: FuturesGetOpenOrdersRequestV2): Promise< + APIResponse<{ + /** + * Undocumented but staff-confirmed: null and [] can both represent an empty page. + * @see https://t.me/bitgetOpenapi/153977 + */ + entrustedList: FuturesOpenOrderV2[] | null; + endId: string; + }> + > +⋮---- +/** + * Undocumented but staff-confirmed: null and [] can both represent an empty page. + * @see https://t.me/bitgetOpenapi/153977 + */ +⋮---- +getFuturesHistoricOrders(params: FuturesGetHistoryOrdersRequestV2): Promise< + APIResponse<{ + entrustedList: FuturesHistoryOrderV2[]; + endId: string; + }> + > +⋮---- +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; + }> + > +⋮---- +futuresSubmitPositionTPSL(params: FuturesPositionTPSLOrderRequestV2): Promise< + APIResponse< + { + orderId: string; + stopSurplusClientOid: string; + stopLossClientOid: string; + }[] + > + > +⋮---- +futuresSubmitPlanOrder(params: FuturesPlanOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > +⋮---- +futuresModifyTPSLPOrder(params: FuturesModifyTPSLOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > +⋮---- +futuresModifyPlanOrder(params: FuturesModifyPlanOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > +⋮---- +getFuturesPlanOrders(params: FuturesGetPlanOrdersRequestV2): Promise< + APIResponse<{ + /** + * Undocumented but staff-confirmed: null and [] can both represent an empty page. + * @see https://t.me/bitgetOpenapi/153977 + */ + entrustedList: FuturesPendingPlanOrderV2[] | null; + endId: string; + }> + > +⋮---- +/** + * Undocumented but staff-confirmed: null and [] can both represent an empty page. + * @see https://t.me/bitgetOpenapi/153977 + */ +⋮---- +futuresCancelPlanOrder( + params: FuturesCancelPlanOrderRequestV2, + ): Promise> +⋮---- +getFuturesHistoricPlanOrders( + params: FuturesGetHistoryPlanOrdersRequestV2, + ): Promise< + APIResponse<{ + entrustedList: FuturesHistoryPlanOrderV2[]; + endId: string; + }> + > +⋮---- +/** + * + * + * Broker + * + * + */ +⋮---- +/** + * + * * Broker | Subaccount + * + */ +⋮---- +modifySubaccountEmail(params: { + subUid: string; + subaccountEmail: string; + }): Promise> +⋮---- +getBrokerInfo(): Promise< + APIResponse<{ + subAccountSize: string; + maxSubAccountSize: string; + uTime: string; + }> + > +⋮---- +createSubaccount(params: { + subaccountName: string; + label: string; + }): Promise> +⋮---- +getSubaccounts(params?: GetSubAccountsRequestV2): Promise< + APIResponse<{ + hasNextPage: boolean; + idLessThan: number; + subList: BrokerSubaccountV2[]; + }> + > +⋮---- +modifySubaccount( + params: ModifySubRequestV2, + ): Promise> +⋮---- +getSubaccountEmail(params: { + subUid: string; + }): Promise> +⋮---- +getSubaccountSpotAssets(params: { + subUid: string; + coin?: string; + assetType?: 'hold_only' | 'all'; + }): Promise< + APIResponse<{ + assetsList: BrokerSubaccountSpotAssetV2[]; + }> + > +⋮---- +getSubaccountFuturesAssets(params: { + subUid: string; + productType: FuturesProductTypeV2; + }): Promise< + APIResponse<{ + assetsList: BrokerSubaccountFutureAssetV2[]; + }> + > +⋮---- +createSubaccountDepositAddress(params: { + subUid: string; + coin: string; + chain?: string; + }): Promise> +⋮---- +subaccountWithdrawal(params: SubWithdrawalRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > +⋮---- +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; + }> + > +⋮---- +/** + * + * 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; + }> + > +⋮---- +/** + * 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> +⋮---- +getSubAffiliateInfo( + params?: GetSubAffiliateInfoRequestV2, + ): 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; + }> + > +⋮---- +getMarginRepayHistory( + marginType: MarginType, + params: GetRepayHistoryRequestV2, + ): Promise< + APIResponse<{ + resultList: MarginRepaymentHistoryItemV2[]; + maxId: string; + minId: string; + }> + > +⋮---- +getMarginInterestHistory( + marginType: MarginType, + params: GetInterestHistoryRequestV2, + ): Promise< + APIResponse<{ + resultList: MarginInterestHistoryItemV2[]; + maxId: string; + minId: string; + }> + > +⋮---- +getMarginLiquidationHistory( + marginType: MarginType, + params: GetLiquidationHistoryRequestV2, + ): Promise< + APIResponse<{ + resultList: MarginLiquidationHistoryItemV2[]; + maxId: string; + minId: string; + }> + > +⋮---- +getMarginFinancialHistory( + marginType: MarginType, + params: GetFinancialHistoryRequestV2, + ): Promise< + APIResponse<{ + resultList: MarginFinancialHistoryItemV2[]; + maxId: string; + minId: string; + }> + > +⋮---- +/** + * + * * 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; + }> + > +⋮---- +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; + }> + > +⋮---- +getMarginRiskRate(marginType: MarginType): Promise< + APIResponse< + { + symbol: string; + riskRateRatio: string; + }[] + > + > +⋮---- +getMarginMaxBorrowable( + marginType: MarginType, + params: { coin: string }, + ): Promise< + APIResponse + > +⋮---- +getMarginMaxTransferable( + marginType: MarginType, + params: { coin: string }, + ): Promise< + APIResponse< + CrossMaxTransferableResponseV2 | IsolatedMaxTransferableResponseV2 + > + > +⋮---- +getMarginInterestRateAndMaxBorrowable( + marginType: MarginType, + params: { coin: string }, + ): Promise< + APIResponse< + | IsolatedInterestRateAndLimitResponseV2[] + | CrossInterestRateAndLimitResponseV2[] + > + > +⋮---- +getMarginTierConfiguration( + marginType: MarginType, + params: { coin: string }, + ): Promise< + APIResponse< + CrossTierConfigurationResponseV2[] | IsolatedTierConfigurationResponseV2[] + > + > +⋮---- +marginFlashRepay( + marginType: MarginType, + params: { coin: string }, + ): Promise< + APIResponse<{ + repayId: string; + coin?: string; + symbol?: string; + result?: string; + }> + > +⋮---- +getMarginFlashRepayResult( + marginType: MarginType, + params: { idList: string }, + ): Promise< + APIResponse< + { + repayId: string; + status: string; + }[] + > + > +⋮---- +/** + * + * * Margin | Cross/Isolated | Trade + * + */ +⋮---- +marginSubmitOrder( + marginType: MarginType, + params: MarginPlaceOrderRequestV2, + ): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > +⋮---- +marginBatchSubmitOrders( + marginType: MarginType, + params: MarginBatchOrdersRequestV2, + ): Promise> +⋮---- +marginCancelOrder( + marginType: MarginType, + params: { + symbol: string; + orderId?: string; + clientOid?: string; + }, + ): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > +⋮---- +marginBatchCancelOrders( + marginType: MarginType, + params: { + symbol: string; + orderIdList: string[]; + }, + ): Promise> +⋮---- +getMarginOpenOrders( + marginType: MarginType, + params: GetMarginCurrentOrdersRequestV2, + ): Promise< + APIResponse<{ + orderList: MarginCurrentOrderV2[]; + maxId: string; + minId: string; + }> + > +⋮---- +getMarginHistoricOrders( + marginType: MarginType, + params: GetHistoryOrdersRequestV2, + ): Promise< + APIResponse<{ + orderList: MarginHistoryOrderV2[]; + maxId: string; + minId: string; + }> + > +⋮---- +getMarginHistoricOrderFills( + marginType: MarginType, + params: GetMarginOrderFillsRequestV2, + ): Promise< + APIResponse<{ + fills: MarginOrderFillV2[]; + minId: string; + maxId: string; + }> + > +⋮---- +getMarginLiquidationOrders( + marginType: MarginType, + params: GetMarginLiquidationOrdersRequestV2, + ): Promise< + APIResponse<{ + resultList: MarginLiquidationOrderV2[]; + idLessThan: string; + }> + > +⋮---- +/** + * + * + * Copy Trading + * + * + */ +⋮---- +/** + * + * + * Copy Trading | Future copy trading | Trader Api + * + * + */ +⋮---- +getFuturesTraderCurrentOrder( + params: GetFuturesTraderCurrentOrdersRequestV2, + ): Promise> +⋮---- +getFuturesTraderHistoryOrders( + params: GetFuturesTraderHistoryOrdersRequestV2, + ): Promise> +⋮---- +modifyFuturesTraderOrderTPSL( + params: ModifyFuturesTraderOrderTPSLRequestV2, + ): Promise> +⋮---- +getFuturesTraderOrder(): Promise< + APIResponse + > +⋮---- +getFuturesTraderProfitHistory(): Promise< + APIResponse + > +⋮---- +getFuturesTraderProfitShareHistory( + params: GetFuturesTraderProfitShareDetailRequestV2, + ): Promise> +⋮---- +closeFuturesTraderOrder(params: { + trackingNo: string; + symbol: string; + productType: CopyTradingProductTypeV2; + }): Promise< + APIResponse< + { + trackingNo: string; + symbol: string; + productType: string; + }[] + > + > +⋮---- +getFuturesTraderProfitShare(params?: { + coin?: string; + pageSize?: string; + pageNo?: string; + }): Promise< + APIResponse< + { + coin: string; + profit: string; + nickName: string; + }[] + > + > +⋮---- +getFuturesTraderProfitShareGroup(params?: { + pageSize?: string; + pageNo?: string; + }): Promise< + APIResponse< + { + coin: string; + profit: string; + profitTime: string; + }[] + > + > +⋮---- +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[]; + }> + > +⋮---- +getFuturesFollowerTraders( + params: GetFuturesFollowerTradersRequestV2, + ): Promise> +⋮---- +getFuturesFollowerFollowLimit(params: { + symbol: string; + productType: CopyTradingProductTypeV2; + }): Promise< + APIResponse< + { + maxFollowSize: string; + minFollowSize: string; + symbol: string; + }[] + > + > +⋮---- +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[]; + }> + > +⋮---- +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; + }> + > +⋮---- +getEarnSavingsSubscriptionResult(params: { + productId: string; + periodType: string; + }): Promise< + APIResponse<{ + result: 'success' | 'fail'; + msg: string; + }> + > +⋮---- +earnRedeemSavings(params: RedeemSavingsRequestV2): Promise< + APIResponse<{ + orderId: string; + status: string; + }> + > +⋮---- +getEarnSavingsRedemptionResult(params: { + orderId: string; + periodType: string; + }): Promise< + APIResponse<{ + result: 'success' | 'fail'; + msg: string; + }> + > +⋮---- +/** + * + * + * Earn | Earn Account + * + * */ - 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); -}); +⋮---- +getEarnAccount(params?: { coin?: string }): Promise< + APIResponse< + { + coin: string; + amount: string; + }[] + > + > +⋮---- +/** + * + * + * 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; + }> + > +⋮---- +getSharkfinSubscriptionResult(params: { orderId: string }): Promise< + APIResponse<{ + result: 'success' | 'fail'; + msg: string; + }> + > +⋮---- +/** + * + * + * Earn | Loan + * + * + */ +⋮---- +getLoanCurrencies(params?: { + coin?: string; + }): Promise> +⋮---- +getLoanEstInterestAndBorrowable( + params: GetLoanEstInterestAndBorrowableRequestV2, + ): Promise< + APIResponse<{ + hourInterest: string; + loanAmount: string; + }> + > +⋮---- +borrowLoan(params: BorrowLoanRequestV2): Promise< + APIResponse<{ + orderId: string; + }> + > +⋮---- +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; + }> + > +⋮---- +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[]; + }> + > +⋮---- +/** + * + * * Inst Loan | Account + * + */ +⋮---- +getLoanRiskUnit(): Promise< + APIResponse<{ + riskUnitId: string[]; + }> + > +⋮---- +getLoanLTVConvert( + params?: GetInstLoanLTVConvertRequestV2, + ): Promise> +⋮---- +/** + * + * * Inst Loan | Orders + * + */ +⋮---- +getLoanRepaidHistory( + params?: GetInstLoanRepaidHistoryRequestV2, + ): Promise> +⋮---- +getLoanOrder( + params?: GetInstLoanOrderRequestV2, + ): Promise> +================ +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 + | 'uta' + | 'spot' + | 'usdt-futures' + | 'coin-futures' + | 'usdc-futures'; +⋮---- +| 'UTA' // for account-level topics +⋮---- /** - * Subscribe to topics as you wish + * + * V1 list of topics for WebSocket consumers + * */ - -// 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: () => {}, +⋮---- +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 + * + * Spot/futures candle and trade channels send only action=update, without a + * subscription snapshot, from 4 Nov 2026 on demo; live expected 17 Nov 2026. + * Use the corresponding REST API for historical candles and trades. + * https://www.bitget.com/docs/classic/changelog/2026-11 + */ +⋮---- +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 + * + * kline and publicTrade send only action=update, without a subscription snapshot, + * from 4 Nov 2026 on demo; live expected 17 Nov 2026. + * Use the corresponding REST API for historical candles and trades. + * https://www.bitget.com/docs/uta/update-preview + */ +export type WsPublicTopicV3 = + | 'ticker' + | 'kline' + | 'books' + | 'books1' + | 'books5' + | 'books50' + | 'publicTrade' + /** Futures public liquidations. Optional payload.symbol filters to that symbol */ + | 'liquidation' + | 'instruments' + | 'open-interest-limit' + | 'position-tier' + | 'funding-rate' + | 'margin-loan' + | 'margin-coins'; +⋮---- +/** Futures public liquidations. Optional payload.symbol filters to that symbol */ +⋮---- +// Also update PRIVATE_TOPICS_V3 if this is updated. +// `order` includes venue and rTokenTimeInForce for rToken orders. +export type WsPrivateTopicV3 = + | 'account' + | 'position' + | 'fill' + | 'order' + | 'strategy-order' + | 'reality-orderbook' + | 'reality-orderbook-segmented'; +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; -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 + /** Your API secret */ + apiSecret?: string; -Have my projects helped you? Share the love, there are many ways you can show your thanks: + /** The passphrase you set when creating the API Key (NOT your account password) */ + apiPass?: string; -- 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 + /** + * 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; - - + // Disable ping/pong ws heartbeat mechanism (not recommended) + disableHeartbeat?: boolean; -### Contributions & Pull Requests + /** How often to check if the connection is alive */ + pingInterval?: number; -Contributions are encouraged, I will review any incoming pull requests. See the issues tab for todo items. + /** 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; -## Star History + requestOptions?: RestClientOptions; -[![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) + wsOptions?: { + protocols?: string[]; + agent?: any; + } & ( + | Omit, 'agent'> + | Omit, 'agent'> + ); - + wsUrl?: string; -================ -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 since 30 Sep 2026 */ - symbol: string; - /** Required since 30 Sep 2026 */ - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ - pxAmendType?: 'yes' | 'no'; + /** + * 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; } ⋮---- -/** Custom request ID. Numbers within 18 digits. */ -⋮---- -/** Required since 30 Sep 2026 */ -⋮---- -/** Required since 30 Sep 2026 */ +/** Your API key */ ⋮---- -/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ +/** Your API secret */ ⋮---- -export interface CancelAllOrdersRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol?: string; -} +/** The passphrase you set when creating the API Key (NOT your account password) */ ⋮---- -export interface CancelBatchOrdersRequestV3 { - orderId?: string; - clientOid?: string; - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol: string; -} +/** + * Set to `true` to connect to Bitget's demo trading WebSockets: + * + * - V2: https://www.bitget.com/api-doc/common/demotrading/websocket + * - V3/UTA: https://www.bitget.com/api-doc/uta/guide#demo-trading + */ ⋮---- -export interface CloseAllPositionsRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - posSide?: 'long' | 'short'; -} +/** Define a recv window when preparing a private websocket signature. This is in milliseconds, so 5000 == 5 seconds */ ⋮---- -export interface CancelOrderRequestV3 { - orderId?: string; - clientOid?: string; - category?: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; -} +// Disable ping/pong ws heartbeat mechanism (not recommended) ⋮---- -export type FuturesMarginModeV3 = 'crossed' | 'isolated'; +/** How often to check if the connection is alive */ ⋮---- -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'; - /** - * crossed (default) or isolated. - * Under isolated margin, available excludes futures trial funds. - */ - marginMode?: FuturesMarginModeV3; -} +/** How long to wait for a pong (heartbeat reply) before assuming the connection is dead */ ⋮---- -/** Spot only. Default: no */ +/** Delay in milliseconds before respawning the connection */ ⋮---- /** - * crossed (default) or isolated. - * Under isolated margin, available excludes futures trial funds. + * 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 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 WebsocketClientOptions extends WSClientConfigurableOptions { + pingInterval: number; + pongTimeout: number; + reconnectTimeout: number; + recvWindow: number; + authPrivateConnectionsOnConnect: boolean; + authPrivateRequests: boolean; } -⋮---- -export interface GetHistoryOrdersRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - symbol?: string; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; + +================ +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 GetPositionHistoryRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - startTime?: string; - endTime?: string; - limit?: string; - cursor?: string; +export interface CandlestickV3 extends Array { + 0: string; // timestamp + 1: string; // open price + 2: string; // high price + 3: string; // low price + 4: string; // close price + 5: string; // volume + 6: string; // turnover } ⋮---- -export interface GetCurrentPositionRequestV3 { - category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; - symbol?: string; - posSide?: 'long' | 'short'; -} +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 ModifyOrderRequestV3 { - orderId?: string; - clientOid?: string; - qty?: string; - price?: string; - /** Custom request ID. Numbers within 18 digits. */ - requestId?: number; - autoCancel?: 'yes' | 'no'; - /** Required since 30 Sep 2026 */ +export interface ContractOiV3 { symbol: string; - /** Required since 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; - /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ - pxAmendType?: 'yes' | 'no'; + notionalValue: string; + totalNotionalValue: string; + /** Single UID position ratio. Decimal, 0.1 means 10% */ + singlePositionRatio?: string; + /** Master and sub-account position ratio. Decimal, 0.1 means 10% */ + totalPositionRatio?: string; } ⋮---- -/** Custom request ID. Numbers within 18 digits. */ -⋮---- -/** Required since 30 Sep 2026 */ -⋮---- -/** Required since 30 Sep 2026 */ +/** Single UID position ratio. Decimal, 0.1 means 10% */ ⋮---- -/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ +/** Master and sub-account position ratio. Decimal, 0.1 means 10% */ ⋮---- -export interface PlaceRealityOrderRequestV3 { - category?: 'SPOT' | 'MARGIN'; +export interface CurrentFundingRateV3 { symbol: string; - side: 'buy' | 'sell'; - orderType: 'limit' | 'market'; - qty: string; - price?: string; - clientOid?: string; - /** - * rToken routing. Accepted: internal_market | lit_market. Omit for default. - * internal_market = on-exchange only (not submitted to the U.S. stock broker). - * lit_market = broker only (not matched on-exchange). - * Omit / default = internal first at best price, then unfilled to broker. - * Live since 5 Nov 2026 (internalization renamed; old lit_market meaning is now default). - */ - venue?: 'internal_market' | 'lit_market'; + fundingRate: string; + fundingRateInterval: string; + nextUpdate: string; + minFundingRate: string; + maxFundingRate: string; + /** Previous settlement, decimal */ + lastFundingRate?: string; + /** Upcoming settlement, decimal */ + nextFundingRate?: string; + /** Decimal. 0.0001 means 0.01%. Docs name. Live rows still use baselnterestRate. */ + baseInterestRate?: string; /** - * rToken time in force. gtd (default) = current session. - * gtc = 90 days. Same changelog note as venue. + * Live spelling of baseInterestRate (lowercase L, not i). + * Decimal. 0.0001 means 0.01%. */ - rTokenTimeInForce?: 'gtd' | 'gtc'; + baselnterestRate?: string; + /** Quote-coin notional used for the impact price */ + impactMarginNotional?: string; + cashDividend?: string; + cashDividendNextUpdate?: string; } ⋮---- -/** - * rToken routing. Accepted: internal_market | lit_market. Omit for default. - * internal_market = on-exchange only (not submitted to the U.S. stock broker). - * lit_market = broker only (not matched on-exchange). - * Omit / default = internal first at best price, then unfilled to broker. - * Live since 5 Nov 2026 (internalization renamed; old lit_market meaning is now default). - */ +/** Previous settlement, decimal */ +⋮---- +/** Upcoming settlement, decimal */ +⋮---- +/** Decimal. 0.0001 means 0.01%. Docs name. Live rows still use baselnterestRate. */ ⋮---- /** - * rToken time in force. gtd (default) = current session. - * gtc = 90 days. Same changelog note as venue. + * Live spelling of baseInterestRate (lowercase L, not i). + * Decimal. 0.0001 means 0.01%. */ ⋮---- -export interface CancelRealityOrderRequestV3 { - category?: 'SPOT' | 'MARGIN'; - symbol: string; - orderId?: string; - clientOid?: string; +/** Quote-coin notional used for the impact price */ +⋮---- +export interface DiscountRateTierV3 { + tierStartValue: string; + discountRate: string; } ⋮---- -export interface PlaceBatchOrdersRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; +export interface DiscountRateV3 { + coin: string; + list: DiscountRateTierV3[]; +} +⋮---- +export interface HistoryFundingRateV3 { 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'; - /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ - pxAmendType?: 'yes' | 'no'; - /** - * Unix ms. Used with receiveWindow. - * If omitted, receiveWindow has no effect. - * An order that reaches the matching engine after requestTime + receiveWindow is canceled. - */ - requestTime?: string; - /** Validity window in ms. Range [10, 60000]. Requires requestTime. */ - receiveWindow?: string; + fundingRate: string; + fundingRateTimestamp: string; } ⋮---- -/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ +export interface MarginLoanV3 { + dailyInterest: string; + annualInterest: string; + limit: string; + masterSubLimit?: string; + /** Bitget spelling */ + platformRemaingQuota?: string; +} ⋮---- -/** - * Unix ms. Used with receiveWindow. - * If omitted, receiveWindow has no effect. - * An order that reaches the matching engine after requestTime + receiveWindow is canceled. - */ +/** Bitget spelling */ ⋮---- -/** Validity window in ms. Range [10, 60000]. Requires requestTime. */ +export interface MarginLoanAllV3 extends MarginLoanV3 { + coin: string; +} ⋮---- -export interface PlaceOrderRequestV3 { - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; +export interface OpenInterestItemV3 { symbol: string; - /** - * Futures qty must be a multiple of quantityMultiplier - * and have at most quantityPrecision decimal places. - * Both come from /api/v3/market/instruments. Futures only. - */ - qty: string; - price?: string; - side: 'buy' | 'sell'; - /** - * Market orders always run as IOC. - * Staff-confirmed: t.me/bitgetOpenapi/153169. - * timeInForce does not change that. - */ - 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'; - /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ - pxAmendType?: 'yes' | 'no'; - /** Limit orders only. queue1, queue5, counterparty1, or counterparty5 */ - bboLevel?: 'queue1' | 'queue5' | 'counterparty1' | 'counterparty5'; - /** Market orders only. Decimal, default 0.02, range 0.01-0.05 */ - slippageTolerance?: string; - /** - * rToken routing. Accepted: internal_market | lit_market. Omit for default. - * internal_market = on-exchange only (not submitted to the U.S. stock broker). - * lit_market = broker only (not matched on-exchange). - * Omit / default = internal first at best price, then unfilled to broker. - * Ignored for non-rToken symbols. timeInForce is also ignored for rToken. - * Live since 5 Nov 2026 (internalization renamed; old lit_market meaning is now default). - */ - venue?: 'internal_market' | 'lit_market'; - /** - * rToken time in force. gtd (default) lasts the current session. - * gtc lasts 90 days. Ignored for non-rToken symbols. - */ - rTokenTimeInForce?: 'gtd' | 'gtc'; - /** - * Unix ms. Used with receiveWindow. - * If omitted, receiveWindow has no effect. - * An order that reaches the matching engine after requestTime + receiveWindow is canceled. - */ - requestTime?: string; - /** Validity window in ms. Range [10, 60000]. Requires requestTime. */ - receiveWindow?: string; + openInterest: string; } ⋮---- -/** - * Futures qty must be a multiple of quantityMultiplier - * and have at most quantityPrecision decimal places. - * Both come from /api/v3/market/instruments. Futures only. - */ +export interface OpenInterestV3 { + list: OpenInterestItemV3[]; + ts: string; +} ⋮---- -/** - * Market orders always run as IOC. - * Staff-confirmed: t.me/bitgetOpenapi/153169. - * timeInForce does not change that. - */ +export interface OpenInterestHistoryItemV3 { + symbol: string; + openInterest: string; + oneSideOpenInterest: string; + openInterestValue: string; + oneSideOpenInterestValue: string; + timestamp: string; +} ⋮---- -/** Futures only. Defaults to crossed */ +export interface OpenInterestHistoryV3 { + list: OpenInterestHistoryItemV3[]; +} ⋮---- -/** Spot only. Default: no */ +export interface InterestRateHistoryItemV3 { + coin: string; + dailyInterestRate: string; + annualInterestRate: string; + ts: string; +} ⋮---- -/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ +export interface InterestRateHistoryV3 { + list: InterestRateHistoryItemV3[]; + cursor?: string; +} ⋮---- -/** Limit orders only. queue1, queue5, counterparty1, or counterparty5 */ +export interface AnnouncementV3 { + annId: string; + annTitle: string; + language: string; + annUrl: string; + annType: string; + annSubType?: string; + /** Documented release time. The live payload uses cTime instead. */ + createdTime?: string; + /** Observed live. Unix ms. Docs call this createdTime. */ + cTime?: string; + /** Observed live. Not in the docs example. */ + annDesc?: string; +} ⋮---- -/** Market orders only. Decimal, default 0.02, range 0.01-0.05 */ +/** Documented release time. The live payload uses cTime instead. */ ⋮---- -/** - * rToken routing. Accepted: internal_market | lit_market. Omit for default. - * internal_market = on-exchange only (not submitted to the U.S. stock broker). - * lit_market = broker only (not matched on-exchange). - * Omit / default = internal first at best price, then unfilled to broker. - * Ignored for non-rToken symbols. timeInForce is also ignored for rToken. - * Live since 5 Nov 2026 (internalization renamed; old lit_market meaning is now default). +/** Observed live. Unix ms. Docs call this createdTime. */ +⋮---- +/** Observed live. Not in the docs example. */ +⋮---- +export interface MarketCoinChainV3 { + chain: string; + needTag: string; + withdrawable: string; + rechargeable: string; + withdrawFee: string; + extraWithdrawFee: string; + depositConfirm: string; + withdrawConfirm: string; + minDepositAmount: string; + minWithdrawAmount: string; + browserUrl: string; + contractAddress: string | null; + withdrawStep: string; + /** + * Live field. The docs example names this withdrawPrecision. */ + withdrawMinScale: string; + congestion: string; +} ⋮---- /** - * rToken time in force. gtd (default) lasts the current session. - * gtc lasts 90 days. Ignored for non-rToken symbols. + * Live field. The docs example names this withdrawPrecision. */ ⋮---- -/** - * Unix ms. Used with receiveWindow. - * If omitted, receiveWindow has no effect. - * An order that reaches the matching engine after requestTime + receiveWindow is canceled. - */ +export interface MarketCoinV3 { + coinId?: string; + coin: string; + /** "true" / "false" */ + transfer: string; + areaCoin?: string; + chains: MarketCoinChainV3[]; +} ⋮---- -/** Validity window in ms. Range [10, 60000]. Requires requestTime. */ +/** "true" / "false" */ ⋮---- -export interface CountdownCancelAllRequestV3 { - countdown: string; // seconds until auto-cancel (5-60, or 0 to disable) +export interface PositionTierV3 { + tier: string; + minTierValue: string; + maxTierValue: string; + leverage: string; + mmr: string; } ⋮---- -countdown: string; // seconds until auto-cancel (5-60, or 0 to disable) - -================ -File: src/types/response/v3/account.ts -================ -// Account Management Response Types -import type { - CollateralTypeV3, - FinancialRecordTypeV3, -} from '../../request/v3/account.js'; +export interface RiskReserveRecordV3 { + balance: string; + amount: string; + ts: string; + type?: string; +} ⋮---- -export interface AccountSymbolConfigV3 { - category: string; - symbol: string; - marginMode: string; - leverage: string; +export interface RiskReserveV3 { + totalBalance?: string; + coin: string; + riskReserveRecords: RiskReserveRecordV3[]; } ⋮---- -export interface AccountCoinConfigV3 { +export interface RiskReserveHourRecordV3 { + amount: string; + balance: string; + ts: string; +} +⋮---- +export interface RiskReserveHourV3 { coin: string; - leverage: string; + riskReserveRecords: RiskReserveHourRecordV3[]; } ⋮---- -export type AccountPermissionV3 = - | 'uta_mgt' - | 'uta_trade' - | 'withdraw' - | 'copy_futures_position' - | 'copy_futures_order'; +export interface RiskReserveAllItemV3 { + symbols: string[]; + coin: string; + balance: string; +} ⋮---- -export interface AccountInfoV3 { - userId: string; - inviterId: 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; /** - * Only set when the calling account is a sub-account. - * Confirmed by Bitget devs but not yet in their docs: the API returns - * parentId as an integer, not only the string shown in the docs. + * Max decimal places for qty. + * Futures qty must stay within this and be a multiple of quantityMultiplier. + * Spot qty is not bound by quantityMultiplier. */ - parentId: string | number; - channelCode: string; - channel: string; - ips: string; + quantityPrecision: string; + quotePrecision: string; + minOrderAmount: string; + maxSymbolOrderNum: string; + maxProductOrderNum: string; + status: + | 'listed' + | 'online' + | 'limit_open' + | 'limit_close' + | 'offline' + | 'restrictedAPI'; + offTime: string; + limitOpenTime: string; + maintainTime: string; + areaSymbol?: string; + + isRwa?: 'YES' | 'NO'; + /** yes = Reality stock token, no = non-Reality stock token */ + isReality?: 'yes' | 'no'; + + // Futures specific fields + makerFeeRate?: string; + takerFeeRate?: string; + openCostUpRatio?: string; + priceMultiplier?: string; /** - * Confirmed by Bitget devs but not yet in their docs: permType uses - * underscores (read_and_write). readonly is also possible on demo keys. + * Futures only. Order qty must be a multiple of this, + * with at most quantityPrecision decimal places. */ - permType: - | 'read-only' - | 'read-and-write' - | 'read_only' - | 'read_and_write' - | 'readonly'; - permissions: AccountPermissionV3[]; - regisTime: string; - traderType?: 'trader' | 'not_trader'; + quantityMultiplier?: string; + type?: 'perpetual' | 'delivery'; + symbolType?: 'crypto' | 'metal' | 'stock' | 'commodity'; + /** Display name. Returned alongside symbolType. */ + fullName?: string; + /** + * metal / energy / stock / etf / crypto. + * Independent of symbolType, which is still returned. + */ + instrumentType?: 'metal' | 'energy' | 'stock' | 'etf' | 'crypto'; + /** Set for traditional-finance pairs. Null for crypto. */ + marketRegion?: string | null; + /** ISIN for traditional-finance pairs. Null for crypto. */ + isin?: string | null; + maxPositionNum?: string; + deliveryTime?: string; + deliveryStartTime?: string; + deliveryPeriod?: string; + /** Launch time - Unix millisecond timestamp. Null for some margin pairs. */ + launchTime?: string | null; + fundInterval?: string; + minLeverage?: string; + maxLeverage?: string; + + // Margin specific fields + isIsolatedBaseBorrowable?: 'YES' | 'NO'; + isIsolatedQuotedBorrowable?: 'YES' | 'NO'; + warningRiskRatio?: string; + liquidationRiskRatio?: string; + maxCrossedLeverage?: string; + maxIsolatedLeverage?: string; + userMinBorrow?: string; } ⋮---- -/** - * Only set when the calling account is a sub-account. - * Confirmed by Bitget devs but not yet in their docs: the API returns - * parentId as an integer, not only the string shown in the docs. - */ +/** Spot only. Max amount for a single market order. */ ⋮---- /** - * Confirmed by Bitget devs but not yet in their docs: permType uses - * underscores (read_and_write). readonly is also possible on demo keys. + * Max decimal places for qty. + * Futures qty must stay within this and be a multiple of quantityMultiplier. + * Spot qty is not bound by quantityMultiplier. */ ⋮---- -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'; - repayMode?: 'auto' | 'manual'; - 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 */ +/** yes = Reality stock token, no = non-Reality stock token */ ⋮---- -/** Deprecated, no longer used as a hedge-eligibility criterion */ +// Futures specific fields ⋮---- -export interface AccountAssetV3 { - coin: string; - equity: string; - usdValue: string; - balance: string; - /** Coin balance before borrowing-related amounts are deducted */ - balanceOriginal?: string; - available: string; - debt: string; - locked: string; - /** Position value in USD */ - positionValue?: string; - /** Account leverage (non-negative) */ - leverage?: string; - /** USDT bonus amount */ - bonus?: string; - /** Interest calculation base */ - interestBase?: string; -} +/** + * Futures only. Order qty must be a multiple of this, + * with at most quantityPrecision decimal places. + */ ⋮---- -/** Coin balance before borrowing-related amounts are deducted */ +/** Display name. Returned alongside symbolType. */ ⋮---- -/** Position value in USD */ +/** + * metal / energy / stock / etf / crypto. + * Independent of symbolType, which is still returned. + */ ⋮---- -/** Account leverage (non-negative) */ +/** Set for traditional-finance pairs. Null for crypto. */ ⋮---- -/** USDT bonus amount */ +/** ISIN for traditional-finance pairs. Null for crypto. */ ⋮---- -/** Interest calculation base */ +/** Launch time - Unix millisecond timestamp. Null for some margin pairs. */ ⋮---- -export interface BorrowResponseV3 { - orderId: string; - clientOid?: string; -} +// Margin specific fields ⋮---- -export interface MaxBorrowableV3 { - maxBorrowable: string; +export interface MarketFeeGroupLabelV3 { + weight: string; + label: string; + symbols: string[]; } ⋮---- -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 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; } ⋮---- -export interface ConvertRecordV3 { - fromCoin: string; - fromCoinSize: string; - toCoin: string; - toCoinSize: string; - price: string; - ts: 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 FinancialRecordV3 { +export interface MarketScoreWeightV3 { category: string; - id: string; + label: string; symbol: string; - coin: string; - type: FinancialRecordTypeV3; + requiredSpread: string; + minMakerVolume: string; + weight: string; +} +⋮---- +export interface LiquidationV3 { + symbol: string; + side: 'buy' | 'sell'; + price: 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 LiquidationsV3 { + list: LiquidationV3[]; + cursor?: string; } ⋮---- -export interface RepayableCoinV3 { - coin: string; - size: string; - amount: string; +export interface OrderBookV3 { + a: string[][]; // asks - [price, size] + b: string[][]; // bids - [price, size] + ts: string; } ⋮---- -export interface RepayResponseV3 { - result: string; - repayAmount: string; +a: string[][]; // asks - [price, size] +b: string[][]; // bids - [price, size] +⋮---- +export interface RealityOrderBookV3 { + symbol: string; + a: string[][]; + b: string[][]; + ts: string; } ⋮---- -// Sub-account Management Response Types +/** [price, onshoreQty, offshoreQty] */ +export type RealitySegmentedLevelV3 = [string, string, string]; ⋮---- -export interface CreateSubAccountApiKeyResponseV3 { - note: string; - apiKey: string; - secret: string; - type: string; - permissions: string[]; - ips: string[]; +export interface RealityOrderBookSegmentedV3 { + symbol: string; + a: RealitySegmentedLevelV3[]; + b: RealitySegmentedLevelV3[]; + ts: string; } -export interface SubAccountApiKeyV3 { - apiKey: string; - note: string; - type: string; - permissions: string[]; - ips: string[]; - ts?: string; +⋮---- +export interface RealityFillV3 { + execId: string; + price: string; + size: string; + side: 'buy' | 'sell'; + ts: string; } ⋮---- -export interface UpdateSubAccountApiKeyResponseV3 { - note: string; - apiKey: string; - type: string; - permissions: string[]; - ips: 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; } ⋮---- -export interface CreateSubAccountResponseV3 { - username: string; - subUid: string; - status: string; - note: string; - createdTime: string; - updatedTime: 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 CreateAgentSubAccountResponseV3 { - username: string; - subUid: string; - apiKey: string; - secret: string; - note: string; - createdTime: string; +export interface IndexComponentV3 { + exchange: string; + spotPair: string; + equivalentPrice: string; + weight: 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 IndexPriceComponentsV3 { + symbol: string; + componentList: IndexComponentV3[]; } ⋮---- -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 RpiSymbolV3 { + category: 'spot' | 'usdt-futures' | 'coin-futures' | 'usdc-futures'; + symbol: string; } ⋮---- -export interface WithdrawAddressBookV3 { - addressList: WithdrawAddressBookEntryV3[]; - cursor?: string; +/** RPI order book depth: [price, nonRpiQty, rpiQty] */ +export interface RpiOrderBookV3 { + a: [string, string, string][]; + b: [string, string, string][]; + ts: string; } ⋮---- -// Transfer Response Types +export interface CashDividendRecordV3 { + symbol: string; + exDividendDate: string; + cashDividendPerShare: string; + cashDividendTimestamp: string; +} ⋮---- -export interface AllSymbolFeeRateV3 { +export interface SplitRecordV3 { symbol: string; - makerFeeRate: string; - takerFeeRate: string; + type: 'split' | 'reverse_split' | string; + status: 'pending' | 'ongoing' | 'completed' | string; + adjustmentRatio: string; + exDividendDate: string; + exDividendDateTimezone: string; + tradingHaltStartTime: string; + tradingHaltEndTime: string; } ⋮---- -export interface TransferResponseV3 { - transferId: string; - clientOid?: string; +export interface SpotWhaleFlowV3 { + volume: string; + date: 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 SpotNetFlowV3 { + netFlow: string; + ts: string; } ⋮---- -export interface SubUnifiedAssetV3 { - coin: string; - equity: string; - usdValue: string; - balance: string; - available: string; - debt: string; - locked: 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 SubUnifiedAssetV3 { - subUid: string; - cursor: string; - assets: SubUnifiedAssetV3[]; +export interface MarginLongShortV3 { + longShortRatio: string; + ts: string; } ⋮---- -export interface GetFeeRateResponseV3 { - makerFeeRate: string; - takerFeeRate: string; +export interface MarginLoanGrowthV3 { + growthRate: string; + ts: string; } ⋮---- -export interface FundingAssetV3 { - coin: string; - available: string; - frozen: string; - balance: string; +export interface MarginIsolatedBorrowV3 { + borrowRate: string; + ts: string; } ⋮---- -// Deposit Response Types -⋮---- -export interface DepositAddressV3 { - address: string; - chain: string; - coin: string; - tag: string; - url: string; +export interface FuturesActiveBuySellV3 { + buyVolume: string; + sellVolume: string; + ts: 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; +export interface FuturesLongShortV3 { + longRatio: string; + shortRatio: string; + longShortRatio: string; + ts: string; } ⋮---- -// Withdraw Response Types -⋮---- -export interface WithdrawResponseV3 { - orderId: string; - clientOid: string; +export interface FuturesPositionLongShortV3 { + longPositionRatio: string; + shortPositionRatio: string; + longShortPositionRatio: string; + ts: 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 FuturesAccountLongShortV3 { + longAccountRatio: string; + shortAccountRatio: string; + longShortAccountRatio: string; + ts: string; } -⋮---- -export interface MaxTransferableV3 { - coin: string; - maxTransfer: string; - borrowMaxTransfer: string; + +================ +File: README.md +================ +# Node.js & Typescript Bitget API SDK + +[![Build & Test](https://github.com/sieblyio/bitget-api/actions/workflows/e2etests.yml/badge.svg?branch=master)](https://github.com/sieblyio/bitget-api/actions/workflows/e2etests.yml) +[![npm version](https://img.shields.io/npm/v/bitget-api)][1] +[![npm size](https://img.shields.io/bundlephobia/min/bitget-api/latest)][1] +[![npm downloads](https://img.shields.io/npm/dt/bitget-api)][1] +[![last commit](https://img.shields.io/github/last-commit/sieblyio/bitget-api)][1] +[![CodeFactor](https://www.codefactor.io/repository/github/sieblyio/bitget-api/badge)](https://www.codefactor.io/repository/github/sieblyio/bitget-api) +[![Telegram](https://img.shields.io/badge/chat-on%20telegram-blue.svg)](https://t.me/nodetraders) +[![Bitget Tutorial](https://img.shields.io/badge/Bitget%20Tutorial-siebly.io-blue)](https://siebly.io/sdk/bitget/javascript/tutorial) + +

+ + + + 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 + */ + 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); + } } -⋮---- -export interface OpenInterestLimitV3 { + +start().catch((e) => console.error('Exception in example: '.e)); +``` + +###### Receiving realtime data + +Use the WebsocketClientV3 to receive data via the V3 WebSockets + +```typescript +import { WebsocketClientV3 } from "bitget-api"; +// or if you prefer require: +// const { WebsocketClientV3 } = require("bitget-api"); + +const API_KEY = "yourAPIKeyHere"; +const API_SECRET = "yourAPISecretHere; +const API_PASS = "yourAPIPassHere"; + +const wsClient = new WebsocketClientV3( + { + // Only necessary if you plan on using private/account websocket topics + apiKey: API_KEY, + apiSecret: API_SECRET, + apiPass: API_PASS, + } +); + +// Connect event handlers to process incoming events +wsClient.on('update', (data) => { + console.log('WS raw message received ', data); + // console.log('WS raw message received ', JSON.stringify(data, null, 2)); +}); + +wsClient.on('open', (data) => { + console.log('WS connection opened:', data.wsKey); +}); +wsClient.on('response', (data) => { + console.log('WS response: ', JSON.stringify(data, null, 2)); +}); +wsClient.on('reconnect', ({ wsKey }) => { + console.log('WS automatically reconnecting.... ', wsKey); +}); +wsClient.on('reconnected', (data) => { + console.log('WS reconnected ', data?.wsKey); +}); +wsClient.on('exception', (data) => { + console.log('WS error', data); +}); + +/** + * Subscribe to topics as you wish + */ + +// You can subscribe to one topic at a time +wsClient.subscribe( + { + topic: 'account', + payload: { + instType: 'UTA', // Note: all account events go on the UTA instType + }, + }, + WS_KEY_MAP.v3Private, // This parameter points to private or public +); + +// Note: all account events go on the UTA instType +const ACCOUNT_INST_TYPE = 'UTA'; +const ACCOUNT_WS_KEY = WS_KEY_MAP.v3Private; + +// Or multiple at once: +wsClient.subscribe( + [ + { + topic: 'account', + payload: { + instType: ACCOUNT_INST_TYPE, + }, + }, + { + topic: 'position', + payload: { + instType: ACCOUNT_INST_TYPE, + }, + }, + { + topic: 'fill', + payload: { + instType: ACCOUNT_INST_TYPE, + }, + }, + { + topic: 'order', + payload: { + instType: ACCOUNT_INST_TYPE, + }, + }, + ], + ACCOUNT_WS_KEY, +); + +// Example public events +wsClient.subscribe( + [ + { + topic: 'ticker', + payload: { + instType: 'spot', + symbol: 'BTCUSDT', + }, + }, + { + topic: 'ticker', + payload: { + instType: 'spot', + symbol: 'ETHUSDT', + }, + }, + { + topic: 'ticker', + payload: { + instType: 'spot', + symbol: 'XRPUSDT', + }, + }, + { + topic: 'ticker', + payload: { + instType: 'usdt-futures', + symbol: 'BTCUSDT', + }, + }, + { + topic: 'ticker', + payload: { + instType: 'usdt-futures', + symbol: 'BTCUSDT', + }, + }, + ], + WS_KEY_MAP.v3Public, +); +``` + +For more examples, including how to use websockets with Bitget, check the [examples](./examples/) and [test](./test/) folders. + +### V2 WebSockets + +If you haven't upgraded to the Unified Trading Account, use the V2 WebSocket client: + +```javascript +import { WebsocketClientV2 } from 'bitget-api'; +// or if you prefer require: +// const { WebsocketClientV2 } = require('bitget-api'); + +const API_KEY = 'xxx'; +const API_SECRET = 'yyy'; +const API_PASS = 'zzz'; + +const wsClient = new WebsocketClientV2({ + apiKey: API_KEY, + apiSecret: API_SECRET, + apiPass: API_PASS, + // Optional: connect to demo trading environment + // demoTrading: true, +}); + +// Handle incoming messages +wsClient.on('update', (data) => { + console.log('WS update received: ', data); +}); + +wsClient.on('open', (data) => { + console.log('WS connection opened: ', data.wsKey); +}); + +wsClient.on('reconnected', (data) => { + console.log('WS reconnected: ', data?.wsKey); +}); + +wsClient.on('exception', (data) => { + console.log('WS error: ', data); +}); + +// Subscribe to public data streams +wsClient.subscribeTopic('SPOT', 'ticker', symbol); + +// Subscribe to private data streams (requires authentication) +wsClient.subscribeTopic('SPOT', 'account'); +``` + +--- + +## Logging + +### Customise logging + +Pass a custom logger which supports the log methods `trace`, `info` and `error`, or override methods from the default logger as desired. + +```javascript +import { WebsocketClientV2, DefaultLogger } from 'bitget-api'; +// or if you prefer require: +// const { WebsocketClientV2, DefaultLogger } = require('bitget-api'); + +// Disable all logging on the trace level (less console logs) +const customLogger = { + ...DefaultLogger, + trace: () => {}, +}; + +const ws = new WebsocketClientV2( + { + apiKey: 'API_KEY', + apiSecret: 'API_SECRET', + apiPass: 'API_PASS', + }, + customLogger, +); +``` + +### Debug HTTP requests + +In rare situations, you may want to see the raw HTTP requets being built as well as the API response. These can be enabled by setting the `BITGETTRACE` env var to `true`. + +## Browser Usage + +### Import + +This is the "modern" way, allowing the package to be directly imported into frontend projects with full typescript support. + +1. Install these dependencies + ```sh + npm install crypto-browserify stream-browserify + ``` +2. Add this to your `tsconfig.json` + ```json + { + "compilerOptions": { + "paths": { + "crypto": [ + "./node_modules/crypto-browserify" + ], + "stream": [ + "./node_modules/stream-browserify" + ] + } + ``` +3. Declare this in the global context of your application (ex: in polyfills for angular) + ```js + (window as any).global = window; + ``` + +### Webpack + +This is the "old" way of using this package on webpages. This will build a minified js bundle that can be pulled in using a script tag on a website. + +Build a bundle using webpack: + +- `npm install` +- `npm build` +- `npm pack` + +The bundle can be found in `dist/`. Altough usage should be largely consistent, smaller differences will exist. Documentation is still TODO - contributions welcome. + +## Use with LLMs & AI + +This SDK includes a bundled `llms.txt` file in the root of the repository. If you're developing with LLMs, use the included `llms.txt` with your LLM - it will significantly improve the LLMs understanding of how to correctly use this SDK. + +This file contains AI optimised structure of all the functions in this package, and their parameters for easier use with any learning models or artificial intelligence. + +--- + +## Used By + +[![Repository Users Preview Image](https://dependents.info/sieblyio/bitget-api/image)](https://github.com/sieblyio/bitget-api/network/dependents) + +--- + + + +### Contributions & Thanks + +Have my projects helped you? Share the love, there are many ways you can show your thanks: + +- Star & share my projects. +- Are my projects useful? Sponsor me on Github and support my effort to maintain & improve them: https://github.com/sponsors/tiagosiebler +- Have an interesting project? Get in touch & invite me to it. +- Or buy me all the coffee: + - ETH(ERC20): `0xA3Bda8BecaB4DCdA539Dc16F9C54a592553Be06C` +- Sign up with my referral links: + - OKX (receive a 20% fee discount!): https://www.okx.com/join/42013004 + - Binance (receive a 20% fee discount!): https://accounts.binance.com/register?ref=OKFFGIJJ + - HyperLiquid (receive a 4% fee discount!): https://app.hyperliquid.xyz/join/SIEBLY + - Gate: https://www.gate.io/signup/NODESDKS?ref_type=103 + + + + +### Contributions & Pull Requests + +Contributions are encouraged, I will review any incoming pull requests. See the issues tab for todo items. + + + +## Star History + +[![Star History Chart](https://api.star-history.com/svg?repos=sieblyio/bybit-api,sieblyio/okx-api,sieblyio/binance,sieblyio/bitget-api,sieblyio/bitmart-api,sieblyio/gateio-api,sieblyio/kucoin-api,sieblyio/coinbase-api,sieblyio/orderbooks,sieblyio/accountstate,sieblyio/awesome-crypto-examples&type=Date)](https://star-history.com/#sieblyio/bybit-api&sieblyio/okx-api&sieblyio/binance&sieblyio/bitget-api&sieblyio/bitmart-api&sieblyio/gateio-api&sieblyio/kucoin-api&sieblyio/coinbase-api&sieblyio/orderbooks&sieblyio/accountstate&sieblyio/awesome-crypto-examples&Date) + + + +================ +File: src/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 since 30 Sep 2026 */ symbol: string; - singleUserLimit: string; - masterSubLimit: string; - marketMakerLimit: string; + /** Required since 30 Sep 2026 */ + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ + pxAmendType?: 'yes' | 'no'; } ⋮---- -export interface TaxRecordV3 { - id: string; - coin: string; - type: string; - amount: string; - fee: string; - balance: string; - ts: string; -} +/** Custom request ID. Numbers within 18 digits. */ ⋮---- -export interface CollateralTypeConfigV3 { - collateralType: CollateralTypeV3; - /** Returned when collateralType=custom */ - collateralCoins?: string; -} +/** Required since 30 Sep 2026 */ ⋮---- -/** Returned when collateralType=custom */ +/** Required since 30 Sep 2026 */ ⋮---- -export interface CustomCollateralCoinV3 { - collateralCoin: string; -} +/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ ⋮---- -export interface PreSetLeverageV3 { - estMaxOpen?: string; - estMaxBorrowable?: string; - requiredMargin: string; - marginChange: string; +export interface CancelAllOrdersRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol?: string; } ⋮---- -export interface MaxWithdrawalV3 { - coin: string; - otcMaxWithdrawal: string; - spotMaxWithdrawal: string; - utaMaxWithdrawal: string; - totalMaxWithdrawal: string; +export interface CancelBatchOrdersRequestV3 { + orderId?: string; + clientOid?: string; + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol: string; } ⋮---- -export interface MovePositionOrderResultV3 { - orderId: string; - clientOid: string; - code: string; - msg: string; +export interface CloseAllPositionsRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; + posSide?: 'long' | 'short'; } ⋮---- -export interface MovePositionsResponseV3 { - closePosition: MovePositionOrderResultV3[]; - openPosition: MovePositionOrderResultV3[]; +export interface CancelOrderRequestV3 { + orderId?: string; + clientOid?: string; + category?: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; } ⋮---- -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 type FuturesMarginModeV3 = 'crossed' | 'isolated'; ⋮---- -export interface EligibleSymbolV3 { +export interface GetMaxOpenAvailableRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; 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; + orderType: 'limit' | 'market'; + side: 'buy' | 'sell'; + price?: string; + size?: string; + /** Spot only. Default: no */ + autoBorrow?: 'yes' | 'no'; + /** + * crossed (default) or isolated. + * Under isolated margin, available excludes futures trial funds. + */ + marginMode?: FuturesMarginModeV3; } ⋮---- -export interface EligibleMarginTierItemV3 { - tier: string; - minTierValue: string; - maxTierValue: string; - leverage: string; - mmr: string; -} +/** Spot only. Default: no */ ⋮---- -export interface EligibleMarginTierV3 { - coin: string; - tiers: EligibleMarginTierItemV3[]; -} +/** + * crossed (default) or isolated. + * Under isolated margin, available excludes futures trial funds. + */ ⋮---- -export interface EligibleLoanInfoV3 { - limit: string; - masterSubLimit: string; - /** Bitget spelling */ - platformRemaingQuota: string; +export interface GetOrderInfoRequestV3 { + orderId?: string; + clientOid?: string; } ⋮---- -/** Bitget spelling */ -⋮---- -export interface EligibleDiscountRateTierV3 { - tierStartValue: string; - discountRate: 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 EligibleDiscountRateV3 { - coin: string; - list: EligibleDiscountRateTierV3[]; +export interface GetUnfilledOrdersRequestV3 { + category?: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol?: string; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; } ⋮---- -export interface FundingFinancialRecordV3 { - id: string; - coin: string; - groupType: string; - type: string; - amount: string; - balance: string; - ts: 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 SmallAssetFeeDetailV3 { - feeRate?: string; - fee?: string; - feeCoin?: string; +export interface GetPositionHistoryRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; + startTime?: string; + endTime?: string; + limit?: string; + cursor?: string; } ⋮---- -export interface SmallAssetV3 { - coin: string; - available?: string; - estimatedCoin?: string; - estimatedAmount?: string; - feeDetail?: SmallAssetFeeDetailV3; - cTime?: string; - size?: string; - usdtValue?: string; +export interface GetCurrentPositionRequestV3 { + category: 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; + symbol?: string; + posSide?: 'long' | 'short'; } ⋮---- -export interface SmallAssetsTradeResponseV3 { - fromCoin?: string; - toCoin?: string; +export interface ModifyOrderRequestV3 { orderId?: string; - result?: string; + clientOid?: string; + qty?: string; + price?: string; + /** Custom request ID. Numbers within 18 digits. */ + requestId?: number; + autoCancel?: 'yes' | 'no'; + /** Required since 30 Sep 2026 */ + symbol: string; + /** Required since 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; + /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ + pxAmendType?: 'yes' | 'no'; } ⋮---- -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; -} +/** Custom request ID. Numbers within 18 digits. */ ⋮---- -export interface RateLimitQuotaItemV3 { - uid: string; - quota: string; -} +/** Required since 30 Sep 2026 */ ⋮---- -export interface RateLimitQuotaV3 { - category: 'spot' | 'futures' | string; - quotaList: RateLimitQuotaItemV3[]; - masterSubQuota: string; - masterSubCap: string; - cursor: string; -} +/** Required since 30 Sep 2026 */ ⋮---- -export interface StpGroupMemberV3 { - uid: string; - joinedTime: string; -} +/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ ⋮---- -export interface StpGroupV3 { - groupId: string; - groupName: string; - createdTime: string; - members?: StpGroupMemberV3[]; +export interface PlaceRealityOrderRequestV3 { + category?: 'SPOT' | 'MARGIN'; + symbol: string; + side: 'buy' | 'sell'; + orderType: 'limit' | 'market'; + qty: string; + price?: string; + clientOid?: string; + /** + * rToken routing. Accepted: internal_market | lit_market. Omit for default. + * internal_market = on-exchange only (not submitted to the U.S. stock broker). + * lit_market = broker only (not matched on-exchange). + * Omit / default = internal first at best price, then unfilled to broker. + * Live since 5 Nov 2026 (internalization renamed; old lit_market meaning is now default). + */ + venue?: 'internal_market' | 'lit_market'; + /** + * rToken time in force. gtd (default) = current session. + * gtc = 90 days. Same changelog note as venue. + */ + rTokenTimeInForce?: 'gtd' | 'gtc'; } ⋮---- -export interface StpGroupListV3 { - groups: StpGroupV3[]; -} +/** + * rToken routing. Accepted: internal_market | lit_market. Omit for default. + * internal_market = on-exchange only (not submitted to the U.S. stock broker). + * lit_market = broker only (not matched on-exchange). + * Omit / default = internal first at best price, then unfilled to broker. + * Live since 5 Nov 2026 (internalization renamed; old lit_market meaning is now default). + */ ⋮---- -export interface CreateStpGroupResponseV3 { - groupId: string; - groupName: string; - createdTime: string; -} +/** + * rToken time in force. gtd (default) = current session. + * gtc = 90 days. Same changelog note as venue. + */ ⋮---- -export interface StpGroupUidResultV3 { - uid: string; +export interface CancelRealityOrderRequestV3 { + category?: 'SPOT' | 'MARGIN'; + symbol: string; + orderId?: string; + clientOid?: string; } ⋮---- -export interface StpGroupMembersResponseV3 { - createdTime: string; - successUids: StpGroupUidResultV3[]; - failedUids: StpGroupUidResultV3[]; -} - -================ -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 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'; + /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ + pxAmendType?: 'yes' | 'no'; + /** + * Unix ms. Used with receiveWindow. + * If omitted, receiveWindow has no effect. + * An order that reaches the matching engine after requestTime + receiveWindow is canceled. + */ + requestTime?: string; + /** Validity window in ms. Range [10, 60000]. Requires requestTime. */ + receiveWindow?: 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 +/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ +⋮---- +/** + * Unix ms. Used with receiveWindow. + * If omitted, receiveWindow has no effect. + * An order that reaches the matching engine after requestTime + receiveWindow is canceled. + */ +⋮---- +/** Validity window in ms. Range [10, 60000]. Requires requestTime. */ +⋮---- +export interface PlaceOrderRequestV3 { + category: + | 'SPOT' + | 'MARGIN' + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + symbol: string; + /** + * Futures qty must be a multiple of quantityMultiplier + * and have at most quantityPrecision decimal places. + * Both come from /api/v3/market/instruments. Futures only. + */ + qty: string; + price?: string; + side: 'buy' | 'sell'; + /** + * Market orders always run as IOC. + * Staff-confirmed: t.me/bitgetOpenapi/153169. + * timeInForce does not change that. + */ + 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'; + /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ + pxAmendType?: 'yes' | 'no'; + /** Limit orders only. queue1, queue5, counterparty1, or counterparty5 */ + bboLevel?: 'queue1' | 'queue5' | 'counterparty1' | 'counterparty5'; + /** Market orders only. Decimal, default 0.02, range 0.01-0.05 */ + slippageTolerance?: string; + /** + * rToken routing. Accepted: internal_market | lit_market. Omit for default. + * internal_market = on-exchange only (not submitted to the U.S. stock broker). + * lit_market = broker only (not matched on-exchange). + * Omit / default = internal first at best price, then unfilled to broker. + * Ignored for non-rToken symbols. timeInForce is also ignored for rToken. + * Live since 5 Nov 2026 (internalization renamed; old lit_market meaning is now default). + */ + venue?: 'internal_market' | 'lit_market'; + /** + * rToken time in force. gtd (default) lasts the current session. + * gtc lasts 90 days. Ignored for non-rToken symbols. + */ + rTokenTimeInForce?: 'gtd' | 'gtc'; + /** + * Unix ms. Used with receiveWindow. + * If omitted, receiveWindow has no effect. + * An order that reaches the matching engine after requestTime + receiveWindow is canceled. + */ + requestTime?: string; + /** Validity window in ms. Range [10, 60000]. Requires requestTime. */ + receiveWindow?: string; } ⋮---- -0: string; // timestamp -1: string; // open price -2: string; // high price -3: string; // low price -4: string; // close price -5: string; // volume -6: string; // turnover +/** + * Futures qty must be a multiple of quantityMultiplier + * and have at most quantityPrecision decimal places. + * Both come from /api/v3/market/instruments. Futures only. + */ ⋮---- -export interface ContractOiV3 { - symbol: string; - notionalValue: string; - totalNotionalValue: string; - /** Single UID position ratio. Decimal, 0.1 means 10% */ - singlePositionRatio?: string; - /** Master and sub-account position ratio. Decimal, 0.1 means 10% */ - totalPositionRatio?: string; -} +/** + * Market orders always run as IOC. + * Staff-confirmed: t.me/bitgetOpenapi/153169. + * timeInForce does not change that. + */ ⋮---- -/** Single UID position ratio. Decimal, 0.1 means 10% */ +/** Futures only. Defaults to crossed */ ⋮---- -/** Master and sub-account position ratio. Decimal, 0.1 means 10% */ +/** Spot only. Default: no */ ⋮---- -export interface CurrentFundingRateV3 { - symbol: string; - fundingRate: string; - fundingRateInterval: string; - nextUpdate: string; - minFundingRate: string; - maxFundingRate: string; - /** Previous settlement, decimal */ - lastFundingRate?: string; - /** Upcoming settlement, decimal */ - nextFundingRate?: string; - /** Decimal. 0.0001 means 0.01%. Docs name. Live rows still use baselnterestRate. */ - baseInterestRate?: string; - /** - * Live spelling of baseInterestRate (lowercase L, not i). - * Decimal. 0.0001 means 0.01%. - */ - baselnterestRate?: string; - /** Quote-coin notional used for the impact price */ - impactMarginNotional?: string; - cashDividend?: string; - cashDividendNextUpdate?: string; -} +/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ ⋮---- -/** Previous settlement, decimal */ +/** Limit orders only. queue1, queue5, counterparty1, or counterparty5 */ ⋮---- -/** Upcoming settlement, decimal */ +/** Market orders only. Decimal, default 0.02, range 0.01-0.05 */ ⋮---- -/** Decimal. 0.0001 means 0.01%. Docs name. Live rows still use baselnterestRate. */ +/** + * rToken routing. Accepted: internal_market | lit_market. Omit for default. + * internal_market = on-exchange only (not submitted to the U.S. stock broker). + * lit_market = broker only (not matched on-exchange). + * Omit / default = internal first at best price, then unfilled to broker. + * Ignored for non-rToken symbols. timeInForce is also ignored for rToken. + * Live since 5 Nov 2026 (internalization renamed; old lit_market meaning is now default). + */ ⋮---- /** - * Live spelling of baseInterestRate (lowercase L, not i). - * Decimal. 0.0001 means 0.01%. + * rToken time in force. gtd (default) lasts the current session. + * gtc lasts 90 days. Ignored for non-rToken symbols. */ ⋮---- -/** Quote-coin notional used for the impact price */ +/** + * Unix ms. Used with receiveWindow. + * If omitted, receiveWindow has no effect. + * An order that reaches the matching engine after requestTime + receiveWindow is canceled. + */ ⋮---- -export interface DiscountRateTierV3 { - tierStartValue: string; - discountRate: string; -} +/** Validity window in ms. Range [10, 60000]. Requires requestTime. */ ⋮---- -export interface DiscountRateV3 { - coin: string; - list: DiscountRateTierV3[]; +export interface CountdownCancelAllRequestV3 { + countdown: string; // seconds until auto-cancel (5-60, or 0 to disable) } ⋮---- -export interface HistoryFundingRateV3 { +countdown: string; // seconds until auto-cancel (5-60, or 0 to disable) + +================ +File: src/types/response/v3/account.ts +================ +// Account Management Response Types +import type { + CollateralTypeV3, + FinancialRecordTypeV3, +} from '../../request/v3/account.js'; +⋮---- +export interface AccountSymbolConfigV3 { + category: string; symbol: string; - fundingRate: string; - fundingRateTimestamp: string; + marginMode: string; + leverage: string; } ⋮---- -export interface MarginLoanV3 { - dailyInterest: string; - annualInterest: string; - limit: string; - masterSubLimit?: string; - /** Bitget spelling */ - platformRemaingQuota?: string; +export interface AccountCoinConfigV3 { + coin: string; + leverage: string; } ⋮---- -/** Bitget spelling */ +export type AccountPermissionV3 = + | 'uta_mgt' + | 'uta_trade' + | 'withdraw' + | 'copy_futures_position' + | 'copy_futures_order'; ⋮---- -export interface MarginLoanAllV3 extends MarginLoanV3 { - coin: string; +export interface AccountInfoV3 { + userId: string; + inviterId: string; + /** + * Only set when the calling account is a sub-account. + * Confirmed by Bitget devs but not yet in their docs: the API returns + * parentId as an integer, not only the string shown in the docs. + */ + parentId: string | number; + channelCode: string; + channel: string; + ips: string; + /** + * Confirmed by Bitget devs but not yet in their docs: permType uses + * underscores (read_and_write). readonly is also possible on demo keys. + */ + permType: + | 'read-only' + | 'read-and-write' + | 'read_only' + | 'read_and_write' + | 'readonly'; + permissions: AccountPermissionV3[]; + regisTime: string; + traderType?: 'trader' | 'not_trader'; } ⋮---- -export interface OpenInterestItemV3 { - symbol: string; - openInterest: string; -} +/** + * Only set when the calling account is a sub-account. + * Confirmed by Bitget devs but not yet in their docs: the API returns + * parentId as an integer, not only the string shown in the docs. + */ ⋮---- -export interface OpenInterestV3 { - list: OpenInterestItemV3[]; - ts: string; -} +/** + * Confirmed by Bitget devs but not yet in their docs: permType uses + * underscores (read_and_write). readonly is also possible on demo keys. + */ ⋮---- -export interface OpenInterestHistoryItemV3 { - symbol: string; - openInterest: string; - oneSideOpenInterest: string; - openInterestValue: string; - oneSideOpenInterestValue: string; - timestamp: string; -} +export type AccountLevelV3 = 'basic' | 'advanced' | 'isolated' | 'delta'; ⋮---- -export interface OpenInterestHistoryV3 { - list: OpenInterestHistoryItemV3[]; +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'; + repayMode?: 'auto' | 'manual'; + symbolConfigList: AccountSymbolConfigV3[]; + coinConfigList: AccountCoinConfigV3[]; } ⋮---- -export interface InterestRateHistoryItemV3 { +export interface AccountDeltaCoinPositionV3 { coin: string; - dailyInterestRate: string; - annualInterestRate: string; - ts: string; -} -⋮---- -export interface InterestRateHistoryV3 { - list: InterestRateHistoryItemV3[]; - cursor?: string; + positionRatio: string; } ⋮---- -export interface AnnouncementV3 { - annId: string; - annTitle: string; - language: string; - annUrl: string; - annType: string; - annSubType?: string; - /** Documented release time. The live payload uses cTime instead. */ - createdTime?: string; - /** Observed live. Unix ms. Docs call this createdTime. */ - cTime?: string; - /** Observed live. Not in the docs example. */ - annDesc?: 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[]; } ⋮---- -/** Documented release time. The live payload uses cTime instead. */ -⋮---- -/** Observed live. Unix ms. Docs call this createdTime. */ +/** Deprecated, no longer used as a hedge-eligibility criterion */ ⋮---- -/** Observed live. Not in the docs example. */ +/** Deprecated, no longer used as a hedge-eligibility criterion */ ⋮---- -export interface MarketCoinChainV3 { - chain: string; - needTag: string; - withdrawable: string; - rechargeable: string; - withdrawFee: string; - extraWithdrawFee: string; - depositConfirm: string; - withdrawConfirm: string; - minDepositAmount: string; - minWithdrawAmount: string; - browserUrl: string; - contractAddress: string | null; - withdrawStep: string; - /** - * Live field. The docs example names this withdrawPrecision. - */ - withdrawMinScale: string; - congestion: string; +export interface AccountAssetV3 { + coin: string; + equity: string; + usdValue: string; + balance: string; + /** Coin balance before borrowing-related amounts are deducted */ + balanceOriginal?: string; + available: string; + debt: string; + locked: string; + /** Position value in USD */ + positionValue?: string; + /** Account leverage (non-negative) */ + leverage?: string; + /** USDT bonus amount */ + bonus?: string; + /** Interest calculation base */ + interestBase?: string; } ⋮---- -/** - * Live field. The docs example names this withdrawPrecision. - */ +/** Coin balance before borrowing-related amounts are deducted */ ⋮---- -export interface MarketCoinV3 { - coinId?: string; - coin: string; - /** "true" / "false" */ - transfer: string; - areaCoin?: string; - chains: MarketCoinChainV3[]; +/** Position value in USD */ +⋮---- +/** Account leverage (non-negative) */ +⋮---- +/** USDT bonus amount */ +⋮---- +/** Interest calculation base */ +⋮---- +export interface BorrowResponseV3 { + orderId: string; + clientOid?: string; } ⋮---- -/** "true" / "false" */ +export interface MaxBorrowableV3 { + maxBorrowable: string; +} ⋮---- -export interface PositionTierV3 { - tier: string; - minTierValue: string; - maxTierValue: string; - leverage: string; +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 RiskReserveRecordV3 { - balance: string; - amount: string; +export interface ConvertRecordV3 { + fromCoin: string; + fromCoinSize: string; + toCoin: string; + toCoinSize: string; + price: string; ts: string; - type?: string; } ⋮---- -export interface RiskReserveV3 { - totalBalance?: string; +export interface FinancialRecordV3 { + category: string; + id: string; + symbol: string; coin: string; - riskReserveRecords: RiskReserveRecordV3[]; -} -⋮---- -export interface RiskReserveHourRecordV3 { + type: FinancialRecordTypeV3; amount: string; + fee: string; balance: string; ts: string; + /** crossed | isolated */ + positionType?: string; + positionAmount?: string; + positionBalance?: string; } ⋮---- -export interface RiskReserveHourV3 { +/** crossed | isolated */ +⋮---- +export interface PaymentCoinV3 { coin: string; - riskReserveRecords: RiskReserveHourRecordV3[]; + size: string; + amount: string; } ⋮---- -export interface RiskReserveAllItemV3 { - symbols: string[]; +export interface RepayableCoinV3 { coin: string; - balance: string; + size: string; + amount: string; } ⋮---- -export interface RiskReserveAllV3 { - list: RiskReserveAllItemV3[]; +export interface RepayResponseV3 { + result: string; + repayAmount: string; } ⋮---- -export interface InstrumentV3 { - symbol: string; - category: - | 'SPOT' - | 'MARGIN' - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES'; - baseCoin: string; - quoteCoin: string; - buyLimitPriceRatio: string; - sellLimitPriceRatio: string; - feeRateUpRatio: string; - minOrderQty: string; - maxOrderQty: string; - maxMarketOrderQty: string; - /** Spot only. Max amount for a single market order. */ - maxMarketOrderAmount?: string; - pricePrecision: string; - /** - * Max decimal places for qty. - * Futures qty must stay within this and be a multiple of quantityMultiplier. - * Spot qty is not bound by quantityMultiplier. - */ - quantityPrecision: string; - quotePrecision: string; - minOrderAmount: string; - maxSymbolOrderNum: string; - maxProductOrderNum: string; - status: - | 'listed' - | 'online' - | 'limit_open' - | 'limit_close' - | 'offline' - | 'restrictedAPI'; - offTime: string; - limitOpenTime: string; - maintainTime: string; - areaSymbol?: string; - - isRwa?: 'YES' | 'NO'; - /** yes = Reality stock token, no = non-Reality stock token */ - isReality?: 'yes' | 'no'; - - // Futures specific fields - makerFeeRate?: string; - takerFeeRate?: string; - openCostUpRatio?: string; - priceMultiplier?: string; - /** - * Futures only. Order qty must be a multiple of this, - * with at most quantityPrecision decimal places. - */ - quantityMultiplier?: string; - type?: 'perpetual' | 'delivery'; - symbolType?: 'crypto' | 'metal' | 'stock' | 'commodity'; - /** Display name. Returned alongside symbolType. */ - fullName?: string; - /** - * metal / energy / stock / etf / crypto. - * Independent of symbolType, which is still returned. - */ - instrumentType?: 'metal' | 'energy' | 'stock' | 'etf' | 'crypto'; - /** Set for traditional-finance pairs. Null for crypto. */ - marketRegion?: string | null; - /** ISIN for traditional-finance pairs. Null for crypto. */ - isin?: string | null; - maxPositionNum?: string; - deliveryTime?: string; - deliveryStartTime?: string; - deliveryPeriod?: string; - /** Launch time - Unix millisecond timestamp. Null for some margin pairs. */ - launchTime?: string | null; - fundInterval?: string; - minLeverage?: string; - maxLeverage?: string; - - // Margin specific fields - isIsolatedBaseBorrowable?: 'YES' | 'NO'; - isIsolatedQuotedBorrowable?: 'YES' | 'NO'; - warningRiskRatio?: string; - liquidationRiskRatio?: string; - maxCrossedLeverage?: string; - maxIsolatedLeverage?: string; - userMinBorrow?: string; +// 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; } ⋮---- -/** Spot only. Max amount for a single market order. */ +export interface UpdateSubAccountApiKeyResponseV3 { + note: string; + apiKey: string; + type: string; + permissions: string[]; + ips: string[]; +} ⋮---- -/** - * Max decimal places for qty. - * Futures qty must stay within this and be a multiple of quantityMultiplier. - * Spot qty is not bound by quantityMultiplier. - */ +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; +} ⋮---- -/** yes = Reality stock token, no = non-Reality stock token */ +// Transfer Response Types ⋮---- -// Futures specific fields +export interface AllSymbolFeeRateV3 { + symbol: string; + makerFeeRate: string; + takerFeeRate: string; +} ⋮---- -/** - * Futures only. Order qty must be a multiple of this, - * with at most quantityPrecision decimal places. - */ +export interface TransferResponseV3 { + transferId: string; + clientOid?: string; +} ⋮---- -/** Display name. Returned alongside symbolType. */ +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; +} ⋮---- -/** - * metal / energy / stock / etf / crypto. - * Independent of symbolType, which is still returned. - */ +export interface SubUnifiedAssetV3 { + coin: string; + equity: string; + usdValue: string; + balance: string; + available: string; + debt: string; + locked: string; +} ⋮---- -/** Set for traditional-finance pairs. Null for crypto. */ +export interface SubUnifiedAssetV3 { + subUid: string; + cursor: string; + assets: SubUnifiedAssetV3[]; +} ⋮---- -/** ISIN for traditional-finance pairs. Null for crypto. */ +export interface GetFeeRateResponseV3 { + makerFeeRate: string; + takerFeeRate: string; +} ⋮---- -/** Launch time - Unix millisecond timestamp. Null for some margin pairs. */ +export interface FundingAssetV3 { + coin: string; + available: string; + frozen: string; + balance: string; +} ⋮---- -// Margin specific fields +// Deposit Response Types ⋮---- -export interface MarketFeeGroupLabelV3 { - weight: string; - label: string; - symbols: string[]; +export interface DepositAddressV3 { + address: string; + chain: string; + coin: string; + tag: string; + url: 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; +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; } ⋮---- -/** PRO1~PRO6 only. Taker fee rate in decimal form */ +// Withdraw Response Types ⋮---- -/** Market maker RPI maker fee rate in decimal form */ +export interface WithdrawResponseV3 { + orderId: string; + clientOid: string; +} ⋮---- -export interface MarketFeeGroupV3 { - category: string; - group: string; - labelList: MarketFeeGroupLabelV3[]; - tierList: MarketFeeGroupTierV3[]; +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 MarketScoreWeightV3 { - category: string; - label: string; - symbol: string; - requiredSpread: string; - minMakerVolume: string; - weight: string; +export interface MaxTransferableV3 { + coin: string; + maxTransfer: string; + borrowMaxTransfer: string; } ⋮---- -export interface LiquidationV3 { +export interface OpenInterestLimitV3 { symbol: string; - side: 'buy' | 'sell'; - price: 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 LiquidationsV3 { - list: LiquidationV3[]; - cursor?: string; +export interface CollateralTypeConfigV3 { + collateralType: CollateralTypeV3; + /** Returned when collateralType=custom */ + collateralCoins?: string; } ⋮---- -export interface OrderBookV3 { - a: string[][]; // asks - [price, size] - b: string[][]; // bids - [price, size] - ts: string; +/** Returned when collateralType=custom */ +⋮---- +export interface CustomCollateralCoinV3 { + collateralCoin: string; } ⋮---- -a: string[][]; // asks - [price, size] -b: string[][]; // bids - [price, size] +export interface PreSetLeverageV3 { + estMaxOpen?: string; + estMaxBorrowable?: string; + requiredMargin: string; + marginChange: string; +} ⋮---- -export interface RealityOrderBookV3 { - symbol: string; - a: string[][]; - b: string[][]; - ts: string; +export interface MaxWithdrawalV3 { + coin: string; + otcMaxWithdrawal: string; + spotMaxWithdrawal: string; + utaMaxWithdrawal: string; + totalMaxWithdrawal: string; } ⋮---- -/** [price, onshoreQty, offshoreQty] */ -export type RealitySegmentedLevelV3 = [string, string, string]; +export interface MovePositionOrderResultV3 { + orderId: string; + clientOid: string; + code: string; + msg: string; +} ⋮---- -export interface RealityOrderBookSegmentedV3 { - symbol: string; - a: RealitySegmentedLevelV3[]; - b: RealitySegmentedLevelV3[]; - ts: string; +export interface MovePositionsResponseV3 { + closePosition: MovePositionOrderResultV3[]; + openPosition: MovePositionOrderResultV3[]; } ⋮---- -export interface RealityFillV3 { - execId: string; +export interface MovePositionHistoryV3 { + category: string; + fromUid: string; + toUid: string; + orderId: string; + openExecId: string; + closeExecId: string; + symbol: string; + posSide: 'long' | 'short'; + qty: string; price: string; - size: string; - side: 'buy' | 'sell'; - ts: string; + status: 'processing' | 'completed' | 'failed'; + createdTime: string; + updatedTime: string; } ⋮---- -export interface TickerV3 { - category: 'SPOT' | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; +export interface EligibleSymbolV3 { 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; + 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; } ⋮---- -/** 24h platform turnover; only available for rtoken */ -⋮---- -// Futures specific fields +export interface EligibleMarginTierItemV3 { + tier: string; + minTierValue: string; + maxTierValue: string; + leverage: string; + mmr: string; +} ⋮---- -export interface ProofOfReservesV3 { - merkleRootHash: string; - totalReserveRatio: string; - list: { - coin: string; - userAssets: string; - platformAssets: string; - reserveRatio: string; - }[]; +export interface EligibleMarginTierV3 { + coin: string; + tiers: EligibleMarginTierItemV3[]; } ⋮---- -export interface IndexComponentV3 { - exchange: string; - spotPair: string; - equivalentPrice: string; - weight: string; +export interface EligibleLoanInfoV3 { + limit: string; + masterSubLimit: string; + /** Bitget spelling */ + platformRemaingQuota: string; } ⋮---- -export interface IndexPriceComponentsV3 { - symbol: string; - componentList: IndexComponentV3[]; +/** Bitget spelling */ +⋮---- +export interface EligibleDiscountRateTierV3 { + tierStartValue: string; + discountRate: string; } ⋮---- -export interface RpiSymbolV3 { - category: 'spot' | 'usdt-futures' | 'coin-futures' | 'usdc-futures'; - symbol: string; +export interface EligibleDiscountRateV3 { + coin: string; + list: EligibleDiscountRateTierV3[]; } ⋮---- -/** RPI order book depth: [price, nonRpiQty, rpiQty] */ -export interface RpiOrderBookV3 { - a: [string, string, string][]; - b: [string, string, string][]; +export interface FundingFinancialRecordV3 { + id: string; + coin: string; + groupType: string; + type: string; + amount: string; + balance: string; ts: string; } ⋮---- -export interface CashDividendRecordV3 { - symbol: string; - exDividendDate: string; - cashDividendPerShare: string; - cashDividendTimestamp: string; +export interface SmallAssetFeeDetailV3 { + feeRate?: string; + fee?: string; + feeCoin?: 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 SmallAssetV3 { + coin: string; + available?: string; + estimatedCoin?: string; + estimatedAmount?: string; + feeDetail?: SmallAssetFeeDetailV3; + cTime?: string; + size?: string; + usdtValue?: string; } ⋮---- -export interface SpotWhaleFlowV3 { - volume: string; - date: string; +export interface SmallAssetsTradeResponseV3 { + fromCoin?: string; + toCoin?: string; + orderId?: string; + result?: string; } ⋮---- -export interface SpotNetFlowV3 { - netFlow: string; - ts: 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 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 RateLimitQuotaItemV3 { + uid: string; + quota: string; } ⋮---- -export interface MarginLongShortV3 { - longShortRatio: string; - ts: string; +export interface RateLimitQuotaV3 { + category: 'spot' | 'futures' | string; + quotaList: RateLimitQuotaItemV3[]; + masterSubQuota: string; + masterSubCap: string; + cursor: string; } ⋮---- -export interface MarginLoanGrowthV3 { - growthRate: string; - ts: string; +export interface StpGroupMemberV3 { + uid: string; + joinedTime: string; } ⋮---- -export interface MarginIsolatedBorrowV3 { - borrowRate: string; - ts: string; +export interface StpGroupV3 { + groupId: string; + groupName: string; + createdTime: string; + members?: StpGroupMemberV3[]; } ⋮---- -export interface FuturesActiveBuySellV3 { - buyVolume: string; - sellVolume: string; - ts: string; +export interface StpGroupListV3 { + groups: StpGroupV3[]; } ⋮---- -export interface FuturesLongShortV3 { - longRatio: string; - shortRatio: string; - longShortRatio: string; - ts: string; +export interface CreateStpGroupResponseV3 { + groupId: string; + groupName: string; + createdTime: string; } ⋮---- -export interface FuturesPositionLongShortV3 { - longPositionRatio: string; - shortPositionRatio: string; - longShortPositionRatio: string; - ts: string; +export interface StpGroupUidResultV3 { + uid: string; } ⋮---- -export interface FuturesAccountLongShortV3 { - longAccountRatio: string; - shortAccountRatio: string; - longShortAccountRatio: string; - ts: string; +export interface StpGroupMembersResponseV3 { + createdTime: string; + successUids: StpGroupUidResultV3[]; + failedUids: StpGroupUidResultV3[]; +} + +================ +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'; + /** Limit orders only. no rejects a price outside the band (default). yes clamps it */ + pxAmendType?: 'yes' | 'no'; + /** Limit orders only. queue1, queue5, counterparty1, or counterparty5. Ignored for market orders */ + bboLevel?: 'queue1' | 'queue5' | 'counterparty1' | 'counterparty5'; + /** Market orders only. Decimal, default 0.02, range 0.01-0.05 */ + slippageTolerance?: string; + /** + * rToken routing. Accepted: internal_market | lit_market. Omit for default. + * internal_market = on-exchange only; lit_market = broker only. + * Omit / default = internal first, then broker. Ignored for non-rToken symbols. + * Live since 5 Nov 2026. + */ + venue?: 'internal_market' | 'lit_market'; + /** rToken time in force. gtd (default) or gtc (90 days). */ + rTokenTimeInForce?: 'gtd' | 'gtc'; } +⋮---- +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 */ +⋮---- +/** Limit orders only. no rejects a price outside the band (default). yes clamps it */ +⋮---- +/** Limit orders only. queue1, queue5, counterparty1, or counterparty5. Ignored for market orders */ +⋮---- +/** Market orders only. Decimal, default 0.02, range 0.01-0.05 */ +⋮---- +/** + * rToken routing. Accepted: internal_market | lit_market. Omit for default. + * internal_market = on-exchange only; lit_market = broker only. + * Omit / default = internal first, then broker. Ignored for non-rToken symbols. + * Live since 5 Nov 2026. + */ +⋮---- +/** rToken time in force. gtd (default) or gtc (90 days). */ ================ File: src/types/request/v3/account.ts