Skip to content

Commit

Permalink
Merge pull request #401 from JJ-Cro/Update06012025
Browse files Browse the repository at this point in the history
v3.10.28 feat(): added new endpoints, updated examples
  • Loading branch information
tiagosiebler authored Jan 8, 2025
2 parents a88c500 + 4fed000 commit ee78e63
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 5 deletions.
18 changes: 18 additions & 0 deletions examples/apidoc/V5/Account/get-transferable-amount-unified.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const { RestClientV5 } = require('bybit-api');

const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});

client
.getTransferableAmount({
coinName: 'USDT',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
18 changes: 18 additions & 0 deletions examples/apidoc/V5/Affiliate/get-affiliate-user-info.js
Original file line number Diff line number Diff line change
@@ -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
.getAffiliateUserInfo({ uid: '1234567890' })
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// https://api.bybit.com/v5/broker/account-info

const { RestClientV5 } = require('bybit-api');

const client = new RestClientV5({
Expand All @@ -7,7 +9,7 @@ const client = new RestClientV5({
});

client
.getAffiliateUserInfo({ uid: '1513500' })
.getAffiliateUserList()
.then((response) => {
console.log(response);
})
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bybit-api",
"version": "3.10.27",
"version": "3.10.28",
"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",
Expand Down Expand Up @@ -80,4 +80,4 @@
"url": "https://github.com/tiagosiebler/bybit-api/issues"
},
"homepage": "https://github.com/tiagosiebler/bybit-api#readme"
}
}
37 changes: 37 additions & 0 deletions src/rest-client-v5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
AddOrReduceMarginParamsV5,
AddOrReduceMarginResultV5,
AffiliateUserInfoV5,
AffiliateUserListItemV5,
AllCoinsBalanceV5,
AllowedDepositCoinInfoV5,
AmendOrderParamsV5,
Expand Down Expand Up @@ -995,6 +996,19 @@ export class RestClientV5 extends BaseRestClient {
return this.getPrivate('/v5/account/wallet-balance', params);
}

/**
* Query the available amount to transfer of a specific coin in the Unified wallet.
*
* @param coinName Coin name, uppercase only
*/
getTransferableAmount(params: { coinName: string }): Promise<
APIResponseV3WithTime<{
availableWithdrawal: string;
}>
> {
return this.getPrivate('/v5/account/withdrawal', params);
}

/**
* Upgrade to unified account.
*
Expand Down Expand Up @@ -1782,6 +1796,29 @@ export class RestClientV5 extends BaseRestClient {
return this.postPrivate('/v5/user/del-submember', params);
}

/**
*
****** Affiliate APIs
*
*/

/**
* Get Affiliate User List.
* To use this endpoint, you should have an affiliate account and only tick "affiliate" permission while creating the API key.
*
* TIP:
* - Use master UID only
* - The api key can only have "Affiliate" permission
*/
getAffiliateUserList(params?: { size?: number; cursor?: string }): Promise<
APIResponseV3WithTime<{
list: AffiliateUserListItemV5[];
nextPageCursor: string;
}>
> {
return this.getPrivate('/v5/affiliate/aff-user-list', params);
}

/**
* Get Affiliate User Info.
*
Expand Down
8 changes: 8 additions & 0 deletions src/types/response/v5-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ export interface SubAccountAllApiKeysResultV5 {
nextPageCursor: string;
}

export interface AffiliateUserListItemV5 {
userId: string;
registerTime: string;
source: string;
remarks: string;
isKyc: boolean;
}

export interface AffiliateUserInfoV5 {
uid: string;
vipLevel: string;
Expand Down

0 comments on commit ee78e63

Please sign in to comment.