diff --git a/examples/apidoc/V5/Account/get-transferable-amount-unified.js b/examples/apidoc/V5/Account/get-transferable-amount-unified.js new file mode 100644 index 00000000..e5310208 --- /dev/null +++ b/examples/apidoc/V5/Account/get-transferable-amount-unified.js @@ -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); + }); diff --git a/examples/apidoc/V5/Affiliate/get-affiliate-user-info.js b/examples/apidoc/V5/Affiliate/get-affiliate-user-info.js new file mode 100644 index 00000000..99247631 --- /dev/null +++ b/examples/apidoc/V5/Affiliate/get-affiliate-user-info.js @@ -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); + }); diff --git a/examples/apidoc/V5/User/get-affiliate-user-info.js b/examples/apidoc/V5/Affiliate/get-affiliate-user-list.js similarity index 77% rename from examples/apidoc/V5/User/get-affiliate-user-info.js rename to examples/apidoc/V5/Affiliate/get-affiliate-user-list.js index 5de8fd3b..69eb40a9 100644 --- a/examples/apidoc/V5/User/get-affiliate-user-info.js +++ b/examples/apidoc/V5/Affiliate/get-affiliate-user-list.js @@ -1,3 +1,5 @@ +// https://api.bybit.com/v5/broker/account-info + const { RestClientV5 } = require('bybit-api'); const client = new RestClientV5({ @@ -7,7 +9,7 @@ const client = new RestClientV5({ }); client - .getAffiliateUserInfo({ uid: '1513500' }) + .getAffiliateUserList() .then((response) => { console.log(response); }) diff --git a/examples/rest-v5-next-cursor.ts b/examples/rest-v5-next-cursor.ts new file mode 100644 index 00000000..483394c0 --- /dev/null +++ b/examples/rest-v5-next-cursor.ts @@ -0,0 +1,39 @@ +import { RestClientV5, UniversalTransferRecordV5 } from '../src/index'; + +// or +// import { RestClientV5 } from 'bybit-api'; + +const client = new RestClientV5({ + testnet: false, + key: 'insert_api_key', + secret: 'insert_api_secret', +}); + +async function getAllUniversalTransfers() { + const allTransfers: UniversalTransferRecordV5[] = []; + let nextCursor = ''; + let pages = 0; + + do { + pages++; + console.log(`Fetching data from page ${pages}`); + const response = await client.getUniversalTransferRecords({ + limit: 50, // Maximum page size per request + cursor: nextCursor || undefined, // Only send cursor if we have one + }); + + if (response.result.list && response.result.list.length > 0) { + allTransfers.push(...response.result.list); + } + + nextCursor = response.result.nextPageCursor; + + // Optional: Add a small delay to avoid rate limits + await new Promise((resolve) => setTimeout(resolve, 100)); + } while (nextCursor); + + console.log('Total transfers fetched:', allTransfers.length); + console.log('All transfers:', allTransfers); +} + +getAllUniversalTransfers().catch(console.error); diff --git a/package-lock.json b/package-lock.json index 8ed0e558..940089b5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bybit-api", - "version": "3.10.27", + "version": "3.10.28", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "bybit-api", - "version": "3.10.27", + "version": "3.10.28", "license": "MIT", "dependencies": { "axios": "^1.6.6", diff --git a/package.json b/package.json index c4063f52..7363a0e8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bybit-api", - "version": "3.10.27", + "version": "3.10.29", "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 2b4f7e8e..02624852 100644 --- a/src/rest-client-v5.ts +++ b/src/rest-client-v5.ts @@ -12,6 +12,7 @@ import { AddOrReduceMarginParamsV5, AddOrReduceMarginResultV5, AffiliateUserInfoV5, + AffiliateUserListItemV5, AllCoinsBalanceV5, AllowedDepositCoinInfoV5, AmendOrderParamsV5, @@ -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. * @@ -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. * diff --git a/src/types/response/v5-market.ts b/src/types/response/v5-market.ts index f622dca3..8041b6bd 100644 --- a/src/types/response/v5-market.ts +++ b/src/types/response/v5-market.ts @@ -75,6 +75,10 @@ export interface LinearInverseInstrumentInfoV5 { copyTrading: CopyTradingV5; upperFundingRate: string; lowerFundingRate: string; + riskParameters: { + priceLimitRatioX: string; + priceLimitRatioY: string; + }; isPreListing: boolean; preListingInfo: { curAuctionPhase: string; @@ -97,7 +101,7 @@ export interface OptionInstrumentInfoV5 { status: InstrumentStatusV5; baseCoin: string; quoteCoin: string; - settleCoin: boolean; + settleCoin: string; launchTime: string; deliveryTime: string; deliveryFeeRate: string; @@ -120,6 +124,7 @@ export interface SpotInstrumentInfoV5 { innovation: '0' | '1'; status: InstrumentStatusV5; marginTrading: MarginTradingV5; + stTag: '0' | '1'; lotSizeFilter: { basePrecision: string; quotePrecision: string; @@ -132,8 +137,8 @@ export interface SpotInstrumentInfoV5 { tickSize: string; }; riskParameters: { - limitParameter: string; - marketParameter: string; + priceLimitRatioX: string; + priceLimitRatioY: string; }; } diff --git a/src/types/response/v5-user.ts b/src/types/response/v5-user.ts index 8b4e48cb..b74c5792 100644 --- a/src/types/response/v5-user.ts +++ b/src/types/response/v5-user.ts @@ -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; diff --git a/test/v5/private.read.test.ts b/test/v5/private.read.test.ts index 5161550b..b84d47db 100644 --- a/test/v5/private.read.test.ts +++ b/test/v5/private.read.test.ts @@ -172,7 +172,10 @@ describe('Private READ V5 REST API Endpoints', () => { it('getAllCoinsBalance()', async () => { expect( - await api.getAllCoinsBalance({ accountType: accountType }), + await api.getAllCoinsBalance({ + accountType: accountType, + coin: settleCoin, + }), ).toMatchObject({ ...successResponseObjectV3(), // retMsg: '',