diff --git a/README.md b/README.md index 4fbc7da..b78e642 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ Check out my related projects: - [bitget-api](https://www.npmjs.com/package/bitget-api) - Try my misc utilities: - [orderbooks](https://www.npmjs.com/package/orderbooks) + - [accountstate](https://www.npmjs.com/package/accountstate) - Check out my examples: - [awesome-crypto-examples](https://github.com/tiagosiebler/awesome-crypto-examples) @@ -428,4 +429,4 @@ Contributions are encouraged, I will review any incoming pull requests. See the ## Star History -[![Star History Chart](https://api.star-history.com/svg?repos=tiagosiebler/ftx-api,tiagosiebler/bybit-api,tiagosiebler/binance,tiagosiebler/orderbooks,tiagosiebler/okx-api,tiagosiebler/awesome-crypto-examples&type=Date)](https://star-history.com/#tiagosiebler/ftx-api&tiagosiebler/bybit-api&tiagosiebler/binance&tiagosiebler/orderbooks&tiagosiebler/okx-api&tiagosiebler/awesome-crypto-examples&Date) +[![Star History Chart](https://api.star-history.com/svg?repos=tiagosiebler/ftx-api,tiagosiebler/bybit-api,tiagosiebler/binance,tiagosiebler/orderbooks,tiagosiebler/okx-api,tiagosiebler/awesome-crypto-examples,tiagosiebler/accountstate&type=Date)](https://star-history.com/#tiagosiebler/ftx-api&tiagosiebler/bybit-api&tiagosiebler/binance&tiagosiebler/orderbooks&tiagosiebler/okx-api&tiagosiebler/awesome-crypto-examples&tiagosiebler/accountstate&Date) diff --git a/package-lock.json b/package-lock.json index d2abfd2..7e6cfcd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bybit-api", - "version": "3.9.5", + "version": "3.9.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "bybit-api", - "version": "3.9.5", + "version": "3.9.6", "license": "MIT", "dependencies": { "axios": "^1.6.6", diff --git a/package.json b/package.json index b7194e0..08eba91 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bybit-api", - "version": "3.9.5", + "version": "3.9.6", "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 d3fb058..8146164 100644 --- a/src/rest-client-v5.ts +++ b/src/rest-client-v5.ts @@ -38,6 +38,7 @@ import { CreateSubMemberParamsV5, CreateSubMemberResultV5, CursorListV5, + CursorRowsV5, DeleteSubMemberParamsV5, DeliveryPriceV5, DeliveryRecordV5, @@ -1206,7 +1207,7 @@ export class RestClientV5 extends BaseRestClient { */ getWithdrawalRecords( params?: GetWithdrawalRecordsParamsV5, - ): Promise> { + ): Promise>> { return this.getPrivate('/v5/asset/withdraw/query-record', params); } @@ -1358,7 +1359,7 @@ export class RestClientV5 extends BaseRestClient { /** * Delete a sub UID. Before deleting the UID, please make sure there are no assets. - * + * * TIP: * The API key must have one of the permissions to be allowed to call the following API endpoint. * - master API key: "Account Transfer", "Subaccount Transfer", "Withdrawal" diff --git a/src/types/v5-shared.ts b/src/types/v5-shared.ts index 68d2107..4c7b72c 100644 --- a/src/types/v5-shared.ts +++ b/src/types/v5-shared.ts @@ -200,6 +200,16 @@ export interface CursorListV5 { list: T; } +/** + * A wrapper type for any responses that have a "nextPageCursor" property, and a "rows" property with an array of elements + * + * ```{ nextPageCursor: "something", rows: someData[] }``` + */ +export interface CursorRowsV5 { + nextPageCursor: string; + rows: T; +} + export interface CategoryListV5< T extends unknown[], TCategory extends CategoryV5, diff --git a/test/account-asset/private.read.test.ts b/test/account-asset/private.read.test.ts deleted file mode 100644 index 371f2c7..0000000 --- a/test/account-asset/private.read.test.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { API_ERROR_CODE, AccountAssetClient } from '../../src/'; -import { getTestProxy } from '../proxy.util'; -import { successResponseObject } from '../response.util'; - -describe('Private Account Asset REST API GET Endpoints', () => { - const API_KEY = process.env.API_KEY_COM; - const API_SECRET = process.env.API_SECRET_COM; - - it('should have api credentials to test with', () => { - expect(API_KEY).toStrictEqual(expect.any(String)); - expect(API_SECRET).toStrictEqual(expect.any(String)); - }); - - const api = new AccountAssetClient( - { - key: API_KEY, - secret: API_SECRET, - testnet: false, - }, - getTestProxy(), - ); - - it('getInternalTransfers()', async () => { - expect(await api.getInternalTransfers()).toMatchObject( - successResponseObject(), - ); - }); - - it('getSubAccountTransfers()', async () => { - expect(await api.getSubAccountTransfers()).toMatchObject({ - ...successResponseObject(), - ret_code: API_ERROR_CODE.INCORRECT_API_KEY_PERMISSIONS, - }); - }); - - it('getSubAccounts()', async () => { - expect(await api.getSubAccounts()).toMatchObject({ - ...successResponseObject(), - ret_code: API_ERROR_CODE.INCORRECT_API_KEY_PERMISSIONS, - }); - }); - - it.skip('getUniversalTransfers()', async () => { - expect(await api.getInternalTransfers()).toMatchObject( - successResponseObject(), - ); - }); - - it('getDepositRecords()', async () => { - expect(await api.getDepositRecords()).toMatchObject( - successResponseObject(), - ); - }); - - it('getWithdrawRecords()', async () => { - expect(await api.getWithdrawRecords()).toMatchObject( - successResponseObject(), - ); - }); - - it('getCoinInformation()', async () => { - expect(await api.getCoinInformation()).toMatchObject( - successResponseObject(), - ); - }); - - it('getAssetInformation()', async () => { - expect(await api.getAssetInformation()).toMatchObject( - successResponseObject(), - ); - }); - - it('getDepositAddress()', async () => { - expect(await api.getDepositAddress('BTC')).toMatchObject({ - ...successResponseObject(), - ret_code: API_ERROR_CODE.NOT_SUPPORTED_FOR_SUBACCOUNTS, - }); - }); -}); diff --git a/test/account-asset/public.read.test.ts b/test/account-asset/public.read.test.ts deleted file mode 100644 index 8e6ae7a..0000000 --- a/test/account-asset/public.read.test.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { AccountAssetClient } from '../../src'; -import { getTestProxy } from '../proxy.util'; -import { successResponseObject } from '../response.util'; - -describe('Public Account Asset REST API Endpoints', () => { - const API_KEY = undefined; - const API_SECRET = undefined; - - const api = new AccountAssetClient( - { - key: API_KEY, - secret: API_SECRET, - testnet: false, - }, - getTestProxy(), - ); - - it('getSupportedDepositList()', async () => { - expect(await api.getSupportedDepositList()).toMatchObject( - successResponseObject(), - ); - }); - - it('getServerTime()', async () => { - expect(await api.getServerTime()).toMatchObject(successResponseObject()); - }); -}); diff --git a/test/unified-margin/private.write.test.ts b/test/unified-margin/private.write.test.ts deleted file mode 100644 index 0296b1d..0000000 --- a/test/unified-margin/private.write.test.ts +++ /dev/null @@ -1,196 +0,0 @@ -import { UnifiedMarginClient } from '../../src'; -import { getTestProxy } from '../proxy.util'; - -describe('Private Unified Margin REST API POST Endpoints', () => { - const API_KEY = process.env.API_KEY_COM; - const API_SECRET = process.env.API_SECRET_COM; - - it('should have api credentials to test with', () => { - expect(API_KEY).toStrictEqual(expect.any(String)); - expect(API_SECRET).toStrictEqual(expect.any(String)); - }); - - const api = new UnifiedMarginClient( - { - key: API_KEY, - secret: API_SECRET, - testnet: false, - }, - getTestProxy(), - ); - - const symbol = 'BTCUSDT'; - const category = 'linear'; - - /** - * While it may seem silly, these tests simply validate the request is processed at all. - * Something very wrong would be a sign error or complaints about the endpoint/request method/server error. - */ - - it('submitOrder()', async () => { - expect( - await api.submitOrder({ - symbol, - category, - side: 'Sell', - orderType: 'Limit', - qty: '1', - price: '20000', - orderLinkId: Date.now().toString(), - timeInForce: 'GoodTillCancel', - }), - ).toMatchObject({ - retCode: expect.any(Number), - // retMsg: '', - }); - }); - - it('modifyOrder()', async () => { - expect( - await api.modifyOrder({ - symbol, - category, - orderId: 'somethingFake', - price: '20000', - }), - ).toMatchObject({ - retCode: expect.any(Number), - }); - }); - - it('cancelOrder()', async () => { - expect( - await api.cancelOrder({ - symbol, - category, - orderId: 'somethingFake1', - orderFilter: 'Order', - }), - ).toMatchObject({ - retCode: expect.any(Number), - }); - }); - - it('batchSubmitOrders()', async () => { - expect( - await api.batchSubmitOrders(category, [ - { - symbol, - side: 'Buy', - orderType: 'Limit', - qty: '1', - price: '10000', - timeInForce: 'FillOrKill', - }, - { - symbol, - side: 'Buy', - orderType: 'Limit', - qty: '1', - price: '10001', - timeInForce: 'FillOrKill', - }, - { - symbol, - side: 'Buy', - orderType: 'Limit', - qty: '1', - price: '10002', - timeInForce: 'FillOrKill', - }, - ]), - ).toMatchObject({ - retCode: expect.any(Number), - }); - }); - - it('batchReplaceOrders()', async () => { - expect( - await api.batchReplaceOrders(category, [ - { - symbol, - orderLinkId: 'somethingFake1', - qty: '4', - }, - { - symbol, - orderLinkId: 'somethingFake2', - qty: '5', - }, - { - symbol, - orderLinkId: 'somethingFake3', - qty: '6', - }, - ]), - ).toMatchObject({ - retCode: expect.any(Number), - }); - }); - - it('batchCancelOrders()', async () => { - expect( - await api.batchCancelOrders(category, [ - { - symbol, - orderLinkId: 'somethingFake1', - }, - { - symbol, - orderLinkId: 'somethingFake2', - }, - { - symbol, - orderLinkId: 'somethingFake3', - }, - ]), - ).toMatchObject({ - retCode: expect.any(Number), - }); - }); - - it('cancelAllOrders()', async () => { - expect(await api.cancelAllOrders({ category })).toMatchObject({ - retCode: expect.any(Number), - }); - }); - - it('setLeverage()', async () => { - expect(await api.setLeverage(category, symbol, 5, 5)).toMatchObject({ - retCode: expect.any(Number), - }); - }); - - it('setTPSLMode()', async () => { - expect(await api.setTPSLMode(category, symbol, 1)).toMatchObject({ - retCode: expect.any(Number), - }); - }); - - it('setRiskLimit()', async () => { - expect(await api.setRiskLimit(category, symbol, 1, 0)).toMatchObject({ - retCode: expect.any(Number), - }); - }); - - it('setTPSL()', async () => { - expect(await api.setTPSL({ category, symbol })).toMatchObject({ - retCode: expect.any(Number), - }); - }); - - it('transferFunds()', async () => { - expect( - await api.transferFunds({ - amount: '1', - coin: 'USDT', - from_account_type: 'SPOT', - to_account_type: 'CONTRACT', - transfer_id: 'testtransfer', - }), - ).toMatchObject({ - // seems to fluctuate between these two errors - ret_code: /^10003|10001$/, - }); - }); -});