Merge pull request #369 from JJ-Cro/examplesUpdate

v3.10.16: feat(): added missing API examples, deprecated abandoned functions
This commit is contained in:
Tiago
2024-09-06 09:55:20 +01:00
committed by GitHub
10 changed files with 94 additions and 6 deletions

View File

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

View File

@@ -7,7 +7,12 @@ const client = new RestClientV5({
}); });
client client
.getAllCoinsBalance({ accountType: 'FUND', coin: 'USDC' }) .getCoinBalance({
accountType: 'UNIFIED',
coin: 'USDT',
toAccountType: 'FUND',
withLtvTransferSafeAmount: 1,
})
.then((response) => { .then((response) => {
console.log(response); console.log(response);
}) })

View File

@@ -3,7 +3,7 @@ const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({ const client = new RestClientV5({
testnet: true, testnet: true,
}); });
// linear
client client
.getInstrumentsInfo({ .getInstrumentsInfo({
category: 'linear', category: 'linear',
@@ -15,3 +15,29 @@ client
.catch((error) => { .catch((error) => {
console.error(error); console.error(error);
}); });
// option
client
.getInstrumentsInfo({
category: 'option',
symbol: 'ETH-3JAN23-1250-P',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
// spot
client
.getInstrumentsInfo({
category: 'spot',
symbol: 'BTCUSDT',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -4,6 +4,7 @@ const client = new RestClientV5({
testnet: true, testnet: true,
}); });
// inverse
client client
.getTickers({ .getTickers({
category: 'inverse', category: 'inverse',
@@ -15,3 +16,31 @@ client
.catch((error) => { .catch((error) => {
console.error(error); console.error(error);
}); });
// option
client
.getTickers({
category: 'option',
symbol: 'BTC-30DEC22-18000-C',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
// spot
client
.getTickers({
category: 'spot',
symbol: 'BTCUSDT',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -7,7 +7,7 @@ const client = new RestClientV5({
}); });
client client
.deleteSubApiKey() .getAffiliateUserInfo({ uid: '1513500' })
.then((response) => { .then((response) => {
console.log(response); console.log(response);
}) })

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "bybit-api", "name": "bybit-api",
"version": "3.10.15", "version": "3.10.16",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "bybit-api", "name": "bybit-api",
"version": "3.10.15", "version": "3.10.16",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"axios": "^1.6.6", "axios": "^1.6.6",

View File

@@ -1,6 +1,6 @@
{ {
"name": "bybit-api", "name": "bybit-api",
"version": "3.10.15", "version": "3.10.16",
"description": "Complete & robust Node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & strong end to end tests.", "description": "Complete & robust Node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & strong end to end tests.",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",

View File

@@ -1248,6 +1248,10 @@ export class RestClientV5 extends BaseRestClient {
* Use this endpoint to enable a subaccount to take part in a universal transfer. * Use this endpoint to enable a subaccount to take part in a universal transfer.
* It is a one-time switch which, once thrown, enables a subaccount permanently. * It is a one-time switch which, once thrown, enables a subaccount permanently.
* If not set, your subaccount cannot use universal transfers. * If not set, your subaccount cannot use universal transfers.
*
* @deprecated - You no longer need to configure transferable sub UIDs.
* Now, all sub UIDs are automatically enabled for universal transfer.
*
*/ */
enableUniversalTransferForSubUIDs( enableUniversalTransferForSubUIDs(
subMemberIds: string[], subMemberIds: string[],
@@ -2031,6 +2035,7 @@ export class RestClientV5 extends BaseRestClient {
/** /**
* Get Margin Coin Info * Get Margin Coin Info
* @deprecated
*/ */
getInstitutionalLendingMarginCoinInfo( getInstitutionalLendingMarginCoinInfo(
productId?: string, productId?: string,
@@ -2072,6 +2077,7 @@ export class RestClientV5 extends BaseRestClient {
/** /**
* Get LTV * Get LTV
* @deprecated
*/ */
getInstitutionalLendingLTV(): Promise< getInstitutionalLendingLTV(): Promise<
APIResponseV3WithTime<{ ltvInfo: any[] }> APIResponseV3WithTime<{ ltvInfo: any[] }>

View File

@@ -36,10 +36,13 @@ export interface GetAllCoinsBalanceParamsV5 {
export interface GetAccountCoinBalanceParamsV5 { export interface GetAccountCoinBalanceParamsV5 {
memberId?: string; memberId?: string;
toMemberId?: string;
accountType: AccountTypeV5; accountType: AccountTypeV5;
coin: string; coin: string;
toAccountType?: AccountTypeV5;
withBonus?: number; withBonus?: number;
withTransferSafeAmount?: 0 | 1; withTransferSafeAmount?: 0 | 1;
withLtvTransferSafeAmount?: 0 | 1;
} }
export interface GetInternalTransferParamsV5 { export interface GetInternalTransferParamsV5 {