Merge pull request #323 from tiagosiebler/rowscursor
v3.9.6: feat(#322) add nextPageCursor type via generic
This commit is contained in:
@@ -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
|
||||
|
||||
[](https://star-history.com/#tiagosiebler/ftx-api&tiagosiebler/bybit-api&tiagosiebler/binance&tiagosiebler/orderbooks&tiagosiebler/okx-api&tiagosiebler/awesome-crypto-examples&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)
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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<APIResponseV3<{ rows: WithdrawalRecordV5[] }>> {
|
||||
): Promise<APIResponseV3<CursorRowsV5<WithdrawalRecordV5[]>>> {
|
||||
return this.getPrivate('/v5/asset/withdraw/query-record', params);
|
||||
}
|
||||
|
||||
|
||||
@@ -200,6 +200,16 @@ export interface CursorListV5<T extends unknown[]> {
|
||||
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<T extends unknown[]> {
|
||||
nextPageCursor: string;
|
||||
rows: T;
|
||||
}
|
||||
|
||||
export interface CategoryListV5<
|
||||
T extends unknown[],
|
||||
TCategory extends CategoryV5,
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -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());
|
||||
});
|
||||
});
|
||||
@@ -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$/,
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user