feat(): Added all missing examples

This commit is contained in:
Jerko J
2024-06-20 13:51:58 +02:00
parent 6ecc0bd34d
commit 6b6b6f5e13
28 changed files with 548 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.batchSetCollateralCoin({
request: [
{
coin: 'BTC',
collateralSwitch: 'ON',
},
{
coin: 'ETH',
collateralSwitch: 'OFF',
},
],
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,22 @@
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getBorrowHistory({
currency: 'USDT',
startTime: 1670601600000,
endTime: 1673203200000,
limit: 30,
cursor: 'nextPageCursorToken',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,16 @@
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getDCPInfo()
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,16 @@
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getSMPGroup()
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,18 @@
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.repayLiability({
coin: 'USDT',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,19 @@
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.setCollateralCoin({
coin: 'BTC',
collateralSwitch: 'ON',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,18 @@
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.setSpotHedging({
setHedgingMode: 'ON' | 'OFF',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,18 @@
// https://api.bybit.com/v5/asset/withdraw/vasp/list
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getExchangeEntities()
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,18 @@
// https://api.bybit.com/v5/broker/account-info
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getExchangeBrokerAccountInfo()
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,23 @@
// https://api.bybit.com/v5/broker/earnings-info
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getExchangeBrokerEarnings({
bizType: 'SPOT',
begin: '20231201',
end: '20231207',
limit: 1000,
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,20 @@
// https://api.bybit.com/v5/broker/asset/query-sub-member-deposit-record
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getBrokerSubAccountDeposits({
limit: 50,
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,21 @@
// https://api.bybit.com/v5/ins-loan/association-uid
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.bindOrUnbindUID({
uid: 'yourUID',
operate: '0', // 0 for bind, 1 for unbind
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,18 @@
// https://api.bybit.com/v5/ins-loan/ltv-convert
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getInstitutionalLendingLTVWithLadderConversionRate()
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,20 @@
// https://api.bybit.com/v5/ins-loan/loan-order
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getInstitutionalLendingLoanOrders({
limit: 10,
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,20 @@
// https://api.bybit.com/v5/ins-loan/ensure-tokens-convert
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getInstitutionalLendingMarginCoinInfoWithConversionRate({
productId: '81',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,20 @@
// https://api.bybit.com/v5/ins-loan/product-infos
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getInstitutionalLendingProductInfo({
productId: '91',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,20 @@
// https://api.bybit.com/v5/ins-loan/repaid-history
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getInstitutionalLendingRepayOrders({
limit: 100,
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,14 @@
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
});
client
.getServerTime()
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,19 @@
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
});
client
.getLongShortRatio({
category: 'linear',
symbol: 'BTCUSDT',
period: '1h',
limit: 100,
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,18 @@
// https://api.bybit.com/v5/spot-margin-trade/state
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getSpotMarginState()
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,21 @@
// https://api.bybit.com/v5/spot-margin-trade/data
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getVIPMarginData({
vipLevel: 'No VIP',
currency: 'BTC',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,19 @@
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.confirmNewRiskLimit({
category: 'linear',
symbol: 'BTCUSDT',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,23 @@
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getMovePositionHistory({
category: 'linear',
symbol: 'BTCUSDT',
startTime: 1670601600000,
endTime: 1671206400000,
status: 'Filled',
limit: '50',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,28 @@
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.movePosition({
fromUid: 'UTA12345',
toUid: 'UTA67890',
list: [
{
category: 'linear',
symbol: 'BTCUSDT',
price: '50000',
side: 'Sell',
qty: '1',
},
],
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,20 @@
// https://api.bybit.com/v5/user/del-submember
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.deleteSubMember({
subMemberId: 'subUID',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,21 @@
// https://api.bybit.com/v5/user/sub-apikeys
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getSubAccountAllApiKeys({
subMemberId: 'subUID',
limit: 20,
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,20 @@
// https://api.bybit.com/v5/user/get-member-type
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getUIDWalletType({
memberIds: 'subUID1,subUID2',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -1460,6 +1460,17 @@ export class RestClientV5 extends BaseRestClient {
return this.getPrivate('/v5/user/query-api'); return this.getPrivate('/v5/user/query-api');
} }
getUIDWalletType(params: { memberIds: string }): Promise<
APIResponseV3WithTime<{
accounts: {
uid: string;
accountType: string[];
}[];
}>
> {
return this.getPrivate('/v5/user/query-api', params);
}
/** /**
* Modify the settings of a master API key. Use the API key pending to be modified to call the endpoint. Use master user's API key only. * Modify the settings of a master API key. Use the API key pending to be modified to call the endpoint. Use master user's API key only.
* *