diff --git a/package-lock.json b/package-lock.json index 19b85ce0..3843b279 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bybit-api", - "version": "3.10.3", + "version": "3.10.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "bybit-api", - "version": "3.10.3", + "version": "3.10.4", "license": "MIT", "dependencies": { "axios": "^1.6.6", diff --git a/package.json b/package.json index 67a5d68c..546c64af 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bybit-api", - "version": "3.10.3", + "version": "3.10.4", "description": "Complete & robust Node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & strong end to end tests.", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/rest-client-v5.ts b/src/rest-client-v5.ts index d053fb45..3634703d 100644 --- a/src/rest-client-v5.ts +++ b/src/rest-client-v5.ts @@ -82,6 +82,7 @@ import { GetRiskLimitParamsV5, GetSettlementRecordParamsV5, GetSpotLeveragedTokenOrderHistoryParamsV5, + GetSubAccountAllApiKeysParamsV5, GetSubAccountDepositRecordParamsV5, GetTickersParamsV5, GetTransactionLogParamsV5, @@ -126,6 +127,7 @@ import { SettlementRecordV5, SpotBorrowCheckResultV5, SpotLeveragedTokenOrderHistoryV5, + SubAccountAllApiKeysResultV5, SubMemberV5, SwitchIsolatedMarginParamsV5, SwitchPositionModeParamsV5, @@ -1295,6 +1297,17 @@ export class RestClientV5 extends BaseRestClient { return this.getPrivate('/v5/user/query-sub-members'); } + /** + * Query all api keys information of a sub UID. + */ + getSubAccountAllApiKeys( + params: GetSubAccountAllApiKeysParamsV5, + ): Promise< + APIResponseV3WithTime + > { + return this.getPrivate('/v5/user/sub-apikeys', params); + } + /** * Froze sub uid. Use master user's api key only. * @@ -1361,12 +1374,16 @@ export class RestClientV5 extends BaseRestClient { * * TIP: * The API key must have one of the permissions to be allowed to call the following API endpoint. - * - sub API key: "Account Transfer" + * - sub API key: "Account Transfer", "Sub Member Transfer" + * - master API Key: "Account Transfer", "Sub Member Transfer", "Withdrawal" * - * DANGER: BE CAREFUL! The API key used to call this interface will be invalid immediately. + * DANGER: BE CAREFUL! The sub API key used to call this interface will be invalid immediately. */ - deleteSubApiKey(): Promise> { - return this.postPrivate('/v5/user/delete-sub-api'); + deleteSubApiKey(params?: { apikey?: string; }): Promise> { + return this.postPrivate( + '/v5/user/delete-sub-api', + params, + ); } /** diff --git a/src/types/request/v5-user.ts b/src/types/request/v5-user.ts index c8a3f5ec..09e65c2e 100644 --- a/src/types/request/v5-user.ts +++ b/src/types/request/v5-user.ts @@ -39,3 +39,9 @@ export interface UpdateSubApiKeyUpdateParamsV5 { export interface DeleteSubMemberParamsV5 { subMemberId: string; } + +export interface GetSubAccountAllApiKeysParamsV5 { + subMemberId: string; + limit?: number; + cursor?: string; +} \ No newline at end of file diff --git a/src/types/response/v5-user.ts b/src/types/response/v5-user.ts index d8e3ed7f..e9f8daea 100644 --- a/src/types/response/v5-user.ts +++ b/src/types/response/v5-user.ts @@ -34,7 +34,7 @@ export interface ApiKeyInfoV5 { secret: string; permissions: PermissionsV5; ips?: string[]; - type: 1 | 2; + type: ApiKeyType; deadlineDay?: number; expiredAt?: string; createdAt: string; @@ -57,3 +57,22 @@ export interface UpdateApiKeyResultV5 { permissions: PermissionsV5; ips: string[]; } + +export interface SubAccountAllApiKeysResultV5 { + result: { + id: string; + ips?: string[]; + apiKey: string; + note: string; + status: number; + expiredAt?: string; + createdAt: string; + type: ApiKeyType; + permissions: PermissionsV5; + secret: string; + readOnly: 0 | 1; + deadlineDay?: number; + flag: string; + }[], + nextPageCursor: string; +} diff --git a/test/v5/private.read.test.ts b/test/v5/private.read.test.ts index 901fb3a9..d8495c82 100644 --- a/test/v5/private.read.test.ts +++ b/test/v5/private.read.test.ts @@ -273,6 +273,16 @@ describe('Private READ V5 REST API Endpoints', () => { ...successResponseObjectV3(), }); }); + + it('getSubAccountAllApiKeys()', async () => { + expect( + await api.getSubAccountAllApiKeys({subMemberId: 'fakeid'}) + ).toMatchObject({ + // ...successResponseObjectV3(), + // Expected, since sub account ID is fake + retCode: API_ERROR_CODE.PARAMS_MISSING_OR_WRONG, + }); + }); }); describe('Spot Leverage Token APIs', () => {