diff --git a/examples/apidoc/V5/Account/batch-set-collateral-coin.js b/examples/apidoc/V5/Account/batch-set-collateral-coin.js new file mode 100644 index 0000000..187b3bb --- /dev/null +++ b/examples/apidoc/V5/Account/batch-set-collateral-coin.js @@ -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); + }); diff --git a/examples/apidoc/V5/Account/get-borrow-history.js b/examples/apidoc/V5/Account/get-borrow-history.js new file mode 100644 index 0000000..08c29c1 --- /dev/null +++ b/examples/apidoc/V5/Account/get-borrow-history.js @@ -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); + }); diff --git a/examples/apidoc/V5/Account/get-dcp-info.js b/examples/apidoc/V5/Account/get-dcp-info.js new file mode 100644 index 0000000..0d46100 --- /dev/null +++ b/examples/apidoc/V5/Account/get-dcp-info.js @@ -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); + }); diff --git a/examples/apidoc/V5/Account/get-smp-group-id.js b/examples/apidoc/V5/Account/get-smp-group-id.js new file mode 100644 index 0000000..38b6ff2 --- /dev/null +++ b/examples/apidoc/V5/Account/get-smp-group-id.js @@ -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); + }); diff --git a/examples/apidoc/V5/Account/repay-liability.js b/examples/apidoc/V5/Account/repay-liability.js new file mode 100644 index 0000000..6037a8e --- /dev/null +++ b/examples/apidoc/V5/Account/repay-liability.js @@ -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); + }); diff --git a/examples/apidoc/V5/Account/set-collateral-coin.js b/examples/apidoc/V5/Account/set-collateral-coin.js new file mode 100644 index 0000000..414770d --- /dev/null +++ b/examples/apidoc/V5/Account/set-collateral-coin.js @@ -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); + }); diff --git a/examples/apidoc/V5/Account/set-spot-hedging.js b/examples/apidoc/V5/Account/set-spot-hedging.js new file mode 100644 index 0000000..605e3f5 --- /dev/null +++ b/examples/apidoc/V5/Account/set-spot-hedging.js @@ -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); + }); diff --git a/examples/apidoc/V5/Asset/get-exchange-entity-list.js b/examples/apidoc/V5/Asset/get-exchange-entity-list.js new file mode 100644 index 0000000..6083229 --- /dev/null +++ b/examples/apidoc/V5/Asset/get-exchange-entity-list.js @@ -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); + }); diff --git a/examples/apidoc/V5/Broker/get-exchange-broker-account-info.js b/examples/apidoc/V5/Broker/get-exchange-broker-account-info.js new file mode 100644 index 0000000..60bdaea --- /dev/null +++ b/examples/apidoc/V5/Broker/get-exchange-broker-account-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 + .getExchangeBrokerAccountInfo() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Broker/get-exchange-broker-earning.js b/examples/apidoc/V5/Broker/get-exchange-broker-earning.js new file mode 100644 index 0000000..3e4543b --- /dev/null +++ b/examples/apidoc/V5/Broker/get-exchange-broker-earning.js @@ -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); + }); diff --git a/examples/apidoc/V5/Broker/get-subaccount-deposit-records.js b/examples/apidoc/V5/Broker/get-subaccount-deposit-records.js new file mode 100644 index 0000000..83c8bf3 --- /dev/null +++ b/examples/apidoc/V5/Broker/get-subaccount-deposit-records.js @@ -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); + }); diff --git a/examples/apidoc/V5/Institutional-Loan/bind-or-unbind-uid.js b/examples/apidoc/V5/Institutional-Loan/bind-or-unbind-uid.js new file mode 100644 index 0000000..2ebd1ac --- /dev/null +++ b/examples/apidoc/V5/Institutional-Loan/bind-or-unbind-uid.js @@ -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); + }); diff --git a/examples/apidoc/V5/Institutional-Loan/get-LTV.js b/examples/apidoc/V5/Institutional-Loan/get-LTV.js new file mode 100644 index 0000000..cdd54a9 --- /dev/null +++ b/examples/apidoc/V5/Institutional-Loan/get-LTV.js @@ -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); + }); diff --git a/examples/apidoc/V5/Institutional-Loan/get-loan-orders.js b/examples/apidoc/V5/Institutional-Loan/get-loan-orders.js new file mode 100644 index 0000000..da81dd4 --- /dev/null +++ b/examples/apidoc/V5/Institutional-Loan/get-loan-orders.js @@ -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); + }); diff --git a/examples/apidoc/V5/Institutional-Loan/get-margin-coin-info.js b/examples/apidoc/V5/Institutional-Loan/get-margin-coin-info.js new file mode 100644 index 0000000..da8f636 --- /dev/null +++ b/examples/apidoc/V5/Institutional-Loan/get-margin-coin-info.js @@ -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); + }); diff --git a/examples/apidoc/V5/Institutional-Loan/get-product-info.js b/examples/apidoc/V5/Institutional-Loan/get-product-info.js new file mode 100644 index 0000000..154934f --- /dev/null +++ b/examples/apidoc/V5/Institutional-Loan/get-product-info.js @@ -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); + }); diff --git a/examples/apidoc/V5/Institutional-Loan/get-repayment-orders.js b/examples/apidoc/V5/Institutional-Loan/get-repayment-orders.js new file mode 100644 index 0000000..c63b8ab --- /dev/null +++ b/examples/apidoc/V5/Institutional-Loan/get-repayment-orders.js @@ -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); + }); diff --git a/examples/apidoc/V5/Market/get-Bybit-server-time.js b/examples/apidoc/V5/Market/get-Bybit-server-time.js new file mode 100644 index 0000000..2b1139d --- /dev/null +++ b/examples/apidoc/V5/Market/get-Bybit-server-time.js @@ -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); + }); diff --git a/examples/apidoc/V5/Market/get-long-short-ratio.js b/examples/apidoc/V5/Market/get-long-short-ratio.js new file mode 100644 index 0000000..0e96a5f --- /dev/null +++ b/examples/apidoc/V5/Market/get-long-short-ratio.js @@ -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); + }); diff --git a/examples/apidoc/V5/Spot-Margin-Trade-(UTA)/get-status-and-leverage.js b/examples/apidoc/V5/Spot-Margin-Trade-(UTA)/get-status-and-leverage.js new file mode 100644 index 0000000..457da1e --- /dev/null +++ b/examples/apidoc/V5/Spot-Margin-Trade-(UTA)/get-status-and-leverage.js @@ -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); + }); diff --git a/examples/apidoc/V5/Spot-Margin-Trade-(UTA)/get-vip-margin-data.js b/examples/apidoc/V5/Spot-Margin-Trade-(UTA)/get-vip-margin-data.js new file mode 100644 index 0000000..94d467c --- /dev/null +++ b/examples/apidoc/V5/Spot-Margin-Trade-(UTA)/get-vip-margin-data.js @@ -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); + }); diff --git a/examples/apidoc/V5/Trade/confirm-new-risk-limit.js b/examples/apidoc/V5/Trade/confirm-new-risk-limit.js new file mode 100644 index 0000000..8cca9d3 --- /dev/null +++ b/examples/apidoc/V5/Trade/confirm-new-risk-limit.js @@ -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); + }); diff --git a/examples/apidoc/V5/Trade/get-move-position-history.js b/examples/apidoc/V5/Trade/get-move-position-history.js new file mode 100644 index 0000000..a346dbc --- /dev/null +++ b/examples/apidoc/V5/Trade/get-move-position-history.js @@ -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); + }); diff --git a/examples/apidoc/V5/Trade/move-position.js b/examples/apidoc/V5/Trade/move-position.js new file mode 100644 index 0000000..98eb8b6 --- /dev/null +++ b/examples/apidoc/V5/Trade/move-position.js @@ -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); + }); diff --git a/examples/apidoc/V5/User/delete-sub-uid.js b/examples/apidoc/V5/User/delete-sub-uid.js new file mode 100644 index 0000000..1dcb574 --- /dev/null +++ b/examples/apidoc/V5/User/delete-sub-uid.js @@ -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); + }); diff --git a/examples/apidoc/V5/User/get-sub-all-api-keys.js b/examples/apidoc/V5/User/get-sub-all-api-keys.js new file mode 100644 index 0000000..f029e70 --- /dev/null +++ b/examples/apidoc/V5/User/get-sub-all-api-keys.js @@ -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); + }); diff --git a/examples/apidoc/V5/User/get-uid-wallet-type.js b/examples/apidoc/V5/User/get-uid-wallet-type.js new file mode 100644 index 0000000..42713d0 --- /dev/null +++ b/examples/apidoc/V5/User/get-uid-wallet-type.js @@ -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); + }); diff --git a/src/rest-client-v5.ts b/src/rest-client-v5.ts index 8ac98a6..724c573 100644 --- a/src/rest-client-v5.ts +++ b/src/rest-client-v5.ts @@ -1460,6 +1460,17 @@ export class RestClientV5 extends BaseRestClient { 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. *