Merge pull request #367 from JJ-Cro/examplesUpdate

feat(): updated missing examples and endpoints
This commit is contained in:
Tiago
2024-08-29 16:59:16 +01:00
committed by GitHub
22 changed files with 585 additions and 36 deletions

1
.gitignore vendored
View File

@@ -26,4 +26,5 @@ rawReq.ts
localtest.sh localtest.sh
localtest.ts localtest.ts
privaterepotracker privaterepotracker
restClientRegex.ts

View File

@@ -65,6 +65,7 @@ Check out my related JavaScript/TypeScript/Node.js projects:
Most methods accept JS objects. These can be populated using parameters specified by Bybit's API documentation, or check the type definition in each class within the github repository (see table below for convenient links to each class). Most methods accept JS objects. These can be populated using parameters specified by Bybit's API documentation, or check the type definition in each class within the github repository (see table below for convenient links to each class).
- [Bybit API Docs](https://bybit-exchange.github.io/docs/v5/intro) - [Bybit API Docs](https://bybit-exchange.github.io/docs/v5/intro)
- [REST Endpoint Function List](./docs/endpointFunctionList.md)
- [TSDoc Documentation (generated using typedoc via npm module)](https://tsdocs.dev/docs/bybit-api) - [TSDoc Documentation (generated using typedoc via npm module)](https://tsdocs.dev/docs/bybit-api)
## Structure ## Structure

View File

@@ -0,0 +1,195 @@
# Endpoint maps
<p align="center">
<a href="https://www.npmjs.com/package/bybit-api">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/tiagosiebler/bybit-api/blob/master/docs/images/logoDarkMode2.svg?raw=true#gh-dark-mode-only">
<img alt="SDK Logo" src="https://github.com/tiagosiebler/bybit-api/blob/master/docs/images/logoBrightMode2.svg?raw=true#gh-light-mode-only">
</picture>
</a>
</p>
Each REST client is a JavaScript class, which provides functions individually mapped to each endpoint available in the exchange's API offering.
The following table shows all methods available in each REST client, whether the method requires authentication (automatically handled if API keys are provided), as well as the exact endpoint each method is connected to.
This can be used to easily find which method to call, once you have [found which endpoint you're looking to use](https://github.com/tiagosiebler/awesome-crypto-examples/wiki/How-to-find-SDK-functions-that-match-API-docs-endpoint).
All REST clients are in the [src](/src) folder. For usage examples, make sure to check the [examples](/examples) folder.
List of clients:
- [rest-client-v5](#rest-client-v5ts)
If anything is missing or wrong, please open an issue or let us know in our [Node.js Traders](https://t.me/nodetraders) telegram group!
## How to use table
Table consists of 4 parts:
- Function name
- AUTH
- HTTP Method
- Endpoint
**Function name** is the name of the function that can be called through the SDK. Check examples folder in the repo for more help on how to use them!
**AUTH** is a boolean value that indicates if the function requires authentication - which means you need to pass your API key and secret to the SDK.
**HTTP Method** shows HTTP method that the function uses to call the endpoint. Sometimes endpoints can have same URL, but different HTTP method so you can use this column to differentiate between them.
**Endpoint** is the URL that the function uses to call the endpoint. Best way to find exact function you need for the endpoint is to search for URL in this table and find corresponding function name.
# rest-client-v5.ts
This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in [rest-client-v5.ts](/src/rest-client-v5.ts).
| Function | AUTH | HTTP Method | Endpoint |
| -------- | :------: | :------: | -------- |
| `fetchServerTime()` | | GET | `/v5/market/time` |
| `getServerTime()` | | GET | `/v5/market/time` |
| `requestDemoTradingFunds()` | :closed_lock_with_key: | POST | `/v5/account/demo-apply-money` |
| `getKline()` | | GET | `/v5/market/kline` |
| `getMarkPriceKline()` | | GET | `/v5/market/mark-price-kline` |
| `getIndexPriceKline()` | | GET | `/v5/market/index-price-kline` |
| `getPremiumIndexPriceKline()` | | GET | `/v5/market/premium-index-price-kline` |
| `getOrderbook()` | | GET | `/v5/market/orderbook` |
| `getTickers()` | | GET | `/v5/market/tickers` |
| `getFundingRateHistory()` | | GET | `/v5/market/funding/history` |
| `getPublicTradingHistory()` | | GET | `/v5/market/recent-trade` |
| `getOpenInterest()` | | GET | `/v5/market/open-interest` |
| `getHistoricalVolatility()` | | GET | `/v5/market/historical-volatility` |
| `getInsurance()` | | GET | `/v5/market/insurance` |
| `getRiskLimit()` | | GET | `/v5/market/risk-limit` |
| `getOptionDeliveryPrice()` | | GET | `/v5/market/delivery-price` |
| `getDeliveryPrice()` | | GET | `/v5/market/delivery-price` |
| `getLongShortRatio()` | | GET | `/v5/market/account-ratio` |
| `submitOrder()` | :closed_lock_with_key: | POST | `/v5/order/create` |
| `amendOrder()` | :closed_lock_with_key: | POST | `/v5/order/amend` |
| `cancelOrder()` | :closed_lock_with_key: | POST | `/v5/order/cancel` |
| `getActiveOrders()` | :closed_lock_with_key: | GET | `/v5/order/realtime` |
| `cancelAllOrders()` | :closed_lock_with_key: | POST | `/v5/order/cancel-all` |
| `getHistoricOrders()` | :closed_lock_with_key: | GET | `/v5/order/history` |
| `batchSubmitOrders()` | :closed_lock_with_key: | POST | `/v5/order/create-batch` |
| `batchAmendOrders()` | :closed_lock_with_key: | POST | `/v5/order/amend-batch` |
| `batchCancelOrders()` | :closed_lock_with_key: | POST | `/v5/order/cancel-batch` |
| `getSpotBorrowCheck()` | :closed_lock_with_key: | GET | `/v5/order/spot-borrow-check` |
| `setDisconnectCancelAllWindow()` | :closed_lock_with_key: | POST | `/v5/order/disconnected-cancel-all` |
| `setDisconnectCancelAllWindowV2()` | :closed_lock_with_key: | POST | `/v5/order/disconnected-cancel-all` |
| `getPositionInfo()` | :closed_lock_with_key: | GET | `/v5/position/list` |
| `setLeverage()` | :closed_lock_with_key: | POST | `/v5/position/set-leverage` |
| `switchIsolatedMargin()` | :closed_lock_with_key: | POST | `/v5/position/switch-isolated` |
| `setTPSLMode()` | :closed_lock_with_key: | POST | `/v5/position/set-tpsl-mode` |
| `switchPositionMode()` | :closed_lock_with_key: | POST | `/v5/position/switch-mode` |
| `setRiskLimit()` | :closed_lock_with_key: | POST | `/v5/position/set-risk-limit` |
| `setTradingStop()` | :closed_lock_with_key: | POST | `/v5/position/trading-stop` |
| `setAutoAddMargin()` | :closed_lock_with_key: | POST | `/v5/position/set-auto-add-margin` |
| `addOrReduceMargin()` | :closed_lock_with_key: | POST | `/v5/position/add-margin` |
| `getExecutionList()` | :closed_lock_with_key: | GET | `/v5/execution/list` |
| `getClosedPnL()` | :closed_lock_with_key: | GET | `/v5/position/closed-pnl` |
| `movePosition()` | :closed_lock_with_key: | POST | `/v5/position/move-positions` |
| `getMovePositionHistory()` | :closed_lock_with_key: | GET | `/v5/position/move-history` |
| `confirmNewRiskLimit()` | :closed_lock_with_key: | POST | `/v5/position/confirm-pending-mmr` |
| `getPreUpgradeOrderHistory()` | :closed_lock_with_key: | GET | `/v5/pre-upgrade/order/history` |
| `getPreUpgradeTradeHistory()` | :closed_lock_with_key: | GET | `/v5/pre-upgrade/execution/list` |
| `getPreUpgradeClosedPnl()` | :closed_lock_with_key: | GET | `/v5/pre-upgrade/position/closed-pnl` |
| `getPreUpgradeTransactions()` | :closed_lock_with_key: | GET | `/v5/pre-upgrade/account/transaction-log` |
| `getPreUpgradeOptionDeliveryRecord()` | :closed_lock_with_key: | GET | `/v5/pre-upgrade/asset/delivery-record` |
| `getPreUpgradeUSDCSessionSettlements()` | :closed_lock_with_key: | GET | `/v5/pre-upgrade/asset/settlement-record` |
| `getWalletBalance()` | :closed_lock_with_key: | GET | `/v5/account/wallet-balance` |
| `upgradeToUnifiedAccount()` | :closed_lock_with_key: | POST | `/v5/account/upgrade-to-uta` |
| `getBorrowHistory()` | :closed_lock_with_key: | GET | `/v5/account/borrow-history` |
| `repayLiability()` | :closed_lock_with_key: | POST | `/v5/account/quick-repayment` |
| `setCollateralCoin()` | :closed_lock_with_key: | POST | `/v5/account/set-collateral-switch` |
| `batchSetCollateralCoin()` | :closed_lock_with_key: | POST | `/v5/account/set-collateral-switch-batch` |
| `getCollateralInfo()` | :closed_lock_with_key: | GET | `/v5/account/collateral-info` |
| `getCoinGreeks()` | :closed_lock_with_key: | GET | `/v5/asset/coin-greeks` |
| `getFeeRate()` | :closed_lock_with_key: | GET | `/v5/account/fee-rate` |
| `getAccountInfo()` | :closed_lock_with_key: | GET | `/v5/account/info` |
| `getTransactionLog()` | :closed_lock_with_key: | GET | `/v5/account/transaction-log` |
| `getClassicTransactionLogs()` | :closed_lock_with_key: | GET | `/v5/account/contract-transaction-log` |
| `getSMPGroup()` | :closed_lock_with_key: | GET | `/v5/account/smp-group` |
| `setMarginMode()` | :closed_lock_with_key: | POST | `/v5/account/set-margin-mode` |
| `setSpotHedging()` | :closed_lock_with_key: | POST | `/v5/account/set-hedging-mode` |
| `setMMP()` | :closed_lock_with_key: | POST | `/v5/account/mmp-modify` |
| `resetMMP()` | :closed_lock_with_key: | POST | `/v5/account/mmp-reset` |
| `getMMPState()` | :closed_lock_with_key: | GET | `/v5/account/mmp-state` |
| `getDCPInfo()` | :closed_lock_with_key: | GET | `/v5/account/query-dcp-info` |
| `getCoinExchangeRecords()` | :closed_lock_with_key: | GET | `/v5/asset/exchange/order-record` |
| `getDeliveryRecord()` | :closed_lock_with_key: | GET | `/v5/asset/delivery-record` |
| `getSettlementRecords()` | :closed_lock_with_key: | GET | `/v5/asset/settlement-record` |
| `getAssetInfo()` | :closed_lock_with_key: | GET | `/v5/asset/transfer/query-asset-info` |
| `getAllCoinsBalance()` | :closed_lock_with_key: | GET | `/v5/asset/transfer/query-account-coins-balance` |
| `getCoinBalance()` | :closed_lock_with_key: | GET | `/v5/asset/transfer/query-account-coin-balance` |
| `getTransferableCoinList()` | :closed_lock_with_key: | GET | `/v5/asset/transfer/query-transfer-coin-list` |
| `createInternalTransfer()` | :closed_lock_with_key: | POST | `/v5/asset/transfer/inter-transfer` |
| `getInternalTransferRecords()` | :closed_lock_with_key: | GET | `/v5/asset/transfer/query-inter-transfer-list` |
| `getSubUID()` | :closed_lock_with_key: | GET | `/v5/asset/transfer/query-sub-member-list` |
| `enableUniversalTransferForSubUIDs()` | :closed_lock_with_key: | POST | `/v5/asset/transfer/save-transfer-sub-member` |
| `createUniversalTransfer()` | :closed_lock_with_key: | POST | `/v5/asset/transfer/universal-transfer` |
| `getUniversalTransferRecords()` | :closed_lock_with_key: | GET | `/v5/asset/transfer/query-universal-transfer-list` |
| `getAllowedDepositCoinInfo()` | | GET | `/v5/asset/deposit/query-allowed-list` |
| `setDepositAccount()` | :closed_lock_with_key: | POST | `/v5/asset/deposit/deposit-to-account` |
| `getDepositRecords()` | :closed_lock_with_key: | GET | `/v5/asset/deposit/query-record` |
| `getSubAccountDepositRecords()` | :closed_lock_with_key: | GET | `/v5/asset/deposit/query-sub-member-record` |
| `getInternalDepositRecords()` | :closed_lock_with_key: | GET | `/v5/asset/deposit/query-internal-record` |
| `getMasterDepositAddress()` | :closed_lock_with_key: | GET | `/v5/asset/deposit/query-address` |
| `getSubDepositAddress()` | :closed_lock_with_key: | GET | `/v5/asset/deposit/query-sub-member-address` |
| `querySubMemberAddress()` | :closed_lock_with_key: | GET | `/v5/asset/deposit/query-sub-member-address` |
| `getCoinInfo()` | :closed_lock_with_key: | GET | `/v5/asset/coin/query-info` |
| `getWithdrawalRecords()` | :closed_lock_with_key: | GET | `/v5/asset/withdraw/query-record` |
| `getWithdrawableAmount()` | :closed_lock_with_key: | GET | `/v5/asset/withdraw/withdrawable-amount` |
| `getExchangeEntities()` | :closed_lock_with_key: | GET | `/v5/asset/withdraw/vasp/list` |
| `submitWithdrawal()` | :closed_lock_with_key: | POST | `/v5/asset/withdraw/create` |
| `cancelWithdrawal()` | :closed_lock_with_key: | POST | `/v5/asset/withdraw/cancel` |
| `getConvertCoins()` | :closed_lock_with_key: | GET | `/v5/asset/exchange/query-coin-list` |
| `requestConvertQuote()` | :closed_lock_with_key: | POST | `/v5/asset/exchange/quote-apply` |
| `confirmConvertQuote()` | :closed_lock_with_key: | POST | `/v5/asset/exchange/convert-execute` |
| `getConvertStatus()` | :closed_lock_with_key: | GET | `/v5/asset/exchange/convert-result-query` |
| `getConvertHistory()` | :closed_lock_with_key: | GET | `/v5/asset/exchange/query-convert-history` |
| `createSubMember()` | :closed_lock_with_key: | POST | `/v5/user/create-sub-member` |
| `createSubUIDAPIKey()` | :closed_lock_with_key: | POST | `/v5/user/create-sub-api` |
| `getSubUIDList()` | :closed_lock_with_key: | GET | `/v5/user/query-sub-members` |
| `getSubUIDListUnlimited()` | :closed_lock_with_key: | GET | `/v5/user/submembers` |
| `getSubAccountAllApiKeys()` | :closed_lock_with_key: | GET | `/v5/user/sub-apikeys` |
| `setSubUIDFrozenState()` | :closed_lock_with_key: | POST | `/v5/user/frozen-sub-member` |
| `getQueryApiKey()` | :closed_lock_with_key: | GET | `/v5/user/query-api` |
| `getUIDWalletType()` | :closed_lock_with_key: | GET | `/v5/user/query-api` |
| `updateMasterApiKey()` | :closed_lock_with_key: | POST | `/v5/user/update-api` |
| `updateSubApiKey()` | :closed_lock_with_key: | POST | `/v5/user/update-sub-api` |
| `deleteMasterApiKey()` | :closed_lock_with_key: | POST | `/v5/user/delete-api` |
| `deleteSubApiKey()` | :closed_lock_with_key: | POST | `/v5/user/delete-sub-api` |
| `deleteSubMember()` | :closed_lock_with_key: | POST | `/v5/user/del-submember` |
| `getAffiliateUserInfo()` | :closed_lock_with_key: | GET | `/v5/user/aff-customer-info` |
| `getLeveragedTokenInfo()` | | GET | `/v5/spot-lever-token/info` |
| `getLeveragedTokenMarket()` | | GET | `/v5/spot-lever-token/reference` |
| `purchaseSpotLeveragedToken()` | :closed_lock_with_key: | POST | `/v5/spot-lever-token/purchase` |
| `redeemSpotLeveragedToken()` | :closed_lock_with_key: | POST | `/v5/spot-lever-token/redeem` |
| `getSpotLeveragedTokenOrderHistory()` | :closed_lock_with_key: | GET | `/v5/spot-lever-token/order-record` |
| `getVIPMarginData()` | | GET | `/v5/spot-margin-trade/data` |
| `getHistoricalInterestRate()` | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/interest-rate-history` |
| `toggleSpotMarginTrade()` | :closed_lock_with_key: | POST | `/v5/spot-margin-trade/switch-mode` |
| `setSpotMarginLeverage()` | :closed_lock_with_key: | POST | `/v5/spot-margin-trade/set-leverage` |
| `getSpotMarginState()` | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/state` |
| `getSpotMarginCoinInfo()` | :closed_lock_with_key: | GET | `/v5/spot-cross-margin-trade/pledge-token` |
| `getSpotMarginBorrowableCoinInfo()` | :closed_lock_with_key: | GET | `/v5/spot-cross-margin-trade/borrow-token` |
| `getSpotMarginInterestAndQuota()` | :closed_lock_with_key: | GET | `/v5/spot-cross-margin-trade/loan-info` |
| `getSpotMarginLoanAccountInfo()` | :closed_lock_with_key: | GET | `/v5/spot-cross-margin-trade/account` |
| `spotMarginBorrow()` | :closed_lock_with_key: | POST | `/v5/spot-cross-margin-trade/loan` |
| `spotMarginRepay()` | :closed_lock_with_key: | POST | `/v5/spot-cross-margin-trade/repay` |
| `getSpotMarginBorrowOrderDetail()` | :closed_lock_with_key: | GET | `/v5/spot-cross-margin-trade/orders` |
| `getSpotMarginRepaymentOrderDetail()` | :closed_lock_with_key: | GET | `/v5/spot-cross-margin-trade/repay-history` |
| `toggleSpotCrossMarginTrade()` | :closed_lock_with_key: | POST | `/v5/spot-cross-margin-trade/switch` |
| `getInstitutionalLendingProductInfo()` | | GET | `/v5/ins-loan/product-infos` |
| `getInstitutionalLendingMarginCoinInfo()` | | GET | `/v5/ins-loan/ensure-tokens` |
| `getInstitutionalLendingMarginCoinInfoWithConversionRate()` | | GET | `/v5/ins-loan/ensure-tokens-convert` |
| `getInstitutionalLendingLoanOrders()` | :closed_lock_with_key: | GET | `/v5/ins-loan/loan-order` |
| `getInstitutionalLendingRepayOrders()` | :closed_lock_with_key: | GET | `/v5/ins-loan/repaid-history` |
| `getInstitutionalLendingLTV()` | :closed_lock_with_key: | GET | `/v5/ins-loan/ltv` |
| `getInstitutionalLendingLTVWithLadderConversionRate()` | :closed_lock_with_key: | GET | `/v5/ins-loan/ltv-convert` |
| `bindOrUnbindUID()` | :closed_lock_with_key: | POST | `/v5/ins-loan/association-uid` |
| `getExchangeBrokerEarnings()` | :closed_lock_with_key: | GET | `/v5/broker/earnings-info` |
| `getExchangeBrokerAccountInfo()` | :closed_lock_with_key: | GET | `/v5/broker/account-info` |
| `getBrokerSubAccountDeposits()` | :closed_lock_with_key: | GET | `/v5/broker/asset/query-sub-member-deposit-record` |

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,16 @@
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getMovePositionHistory()
.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: '100307601',
toUid: '592324',
list: [
{
category: 'spot',
symbol: 'BTCUSDT',
price: '100',
side: 'Sell',
qty: '0.01',
},
],
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,20 @@
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getPreUpgradeUSDCSessionSettlement({
category: 'linear',
symbol: 'ETHPERP',
limit: 1,
})
.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
.getPreUpgradeClosedPnl({
category: 'linear',
symbol: 'BTCUSDT',
})
.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
.getPreUpgradeOptionDeliveryRecord({
category: 'option',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

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

View File

@@ -0,0 +1,21 @@
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getPreUpgradeTradeHistory({
category: 'linear',
limit: 1,
type: 'Funding',
symbol: 'BTCUSDT',
})
.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
.getPreUpgradeTransactionLog({
category: 'option',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,21 @@
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getHistoricalInterestRate({
currency: 'USDC',
vipLevel: 'No VIP',
startTime: 1721458800000,
endTime: 1721469600000,
})
.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
.getSubUIDListUnlimited()
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "bybit-api", "name": "bybit-api",
"version": "3.10.14", "version": "3.10.15",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "bybit-api", "name": "bybit-api",
"version": "3.10.14", "version": "3.10.15",
"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.14", "version": "3.10.15",
"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

@@ -91,8 +91,11 @@ import {
GetOptionDeliveryPriceParamsV5, GetOptionDeliveryPriceParamsV5,
GetOrderbookParamsV5, GetOrderbookParamsV5,
GetPreUpgradeClosedPnlParamsV5, GetPreUpgradeClosedPnlParamsV5,
GetPreUpgradeOptionDeliveryRecordParamsV5,
GetPreUpgradeOrderHistoryParamsV5, GetPreUpgradeOrderHistoryParamsV5,
GetPreUpgradeTradeHistoryParamsV5, GetPreUpgradeTradeHistoryParamsV5,
GetPreUpgradeTransactionLogParamsV5,
GetPreUpgradeUSDCSessionParamsV5,
GetPremiumIndexPriceKlineParamsV5, GetPremiumIndexPriceKlineParamsV5,
GetPublicTradingHistoryParamsV5, GetPublicTradingHistoryParamsV5,
GetRiskLimitParamsV5, GetRiskLimitParamsV5,
@@ -129,6 +132,9 @@ import {
OrderbookResponseV5, OrderbookResponseV5,
PositionInfoParamsV5, PositionInfoParamsV5,
PositionV5, PositionV5,
PreUpgradeOptionsDelivery,
PreUpgradeTransaction,
PreUpgradeUSDCSessionSettlement,
PublicTradeV5, PublicTradeV5,
PurchaseSpotLeveragedTokenParamsV5, PurchaseSpotLeveragedTokenParamsV5,
PurchaseSpotLeveragedTokenResultV5, PurchaseSpotLeveragedTokenResultV5,
@@ -767,7 +773,7 @@ export class RestClientV5 extends BaseRestClient {
* *
* Unified account covers: USDT perpetual / USDC contract / Spot / Option * Unified account covers: USDT perpetual / USDC contract / Spot / Option
*/ */
getMovePositionHistory(params: GetMovePositionHistoryParamsV5): Promise< getMovePositionHistory(params?: GetMovePositionHistoryParamsV5): Promise<
APIResponseV3WithTime<{ APIResponseV3WithTime<{
list: MovePositionHistoryV5[]; list: MovePositionHistoryV5[];
nextPageCursor: string; nextPageCursor: string;
@@ -838,6 +844,55 @@ export class RestClientV5 extends BaseRestClient {
return this.getPrivate('/v5/pre-upgrade/position/closed-pnl', params); return this.getPrivate('/v5/pre-upgrade/position/closed-pnl', params);
} }
/**
* Query transaction logs which occurred in the USDC Derivatives wallet before the account was upgraded to a Unified account.
*
* You can get USDC Perpetual, Option records.
*
* INFO
* USDC Perpeual & Option support the recent 6 months data. Please download older data via GUI
*/
getPreUpgradeTransactions(
params: GetPreUpgradeTransactionLogParamsV5,
): Promise<
APIResponseV3WithTime<{
list: PreUpgradeTransaction[];
nextPageCursor: string;
}>
> {
return this.getPrivate('/v5/pre-upgrade/account/transaction-log', params);
}
/**
* Query delivery records of Option before you upgraded the account to a Unified account, sorted by deliveryTime in descending order.
*
* INFO
* Supports the recent 6 months data. Please download older data via GUI
*/
getPreUpgradeOptionDeliveryRecord(
params: GetPreUpgradeOptionDeliveryRecordParamsV5,
): Promise<
APIResponseV3WithTime<CategoryCursorListV5<PreUpgradeOptionsDelivery[]>>
> {
return this.getPrivate('/v5/pre-upgrade/asset/delivery-record', params);
}
/**
* Query session settlement records of USDC perpetual before you upgrade the account to Unified account.
*
* INFO
* USDC Perpetual support the recent 6 months data. Please download older data via GUI
*/
getPreUpgradeUSDCSessionSettlements(
params: GetPreUpgradeUSDCSessionParamsV5,
): Promise<
APIResponseV3WithTime<
CategoryCursorListV5<PreUpgradeUSDCSessionSettlement[]>
>
> {
return this.getPrivate('/v5/pre-upgrade/asset/settlement-record', params);
}
/** /**
* *
****** Account APIs ****** Account APIs
@@ -1504,7 +1559,7 @@ export class RestClientV5 extends BaseRestClient {
} }
/** /**
* This endpoint allows you to get a list of all sub UID of master account. * This endpoint allows you to get a list of all sub UID of master account. At most 10k subaccounts.
*/ */
getSubUIDList(): Promise< getSubUIDList(): Promise<
APIResponseV3WithTime<{ subMembers: SubMemberV5[] }> APIResponseV3WithTime<{ subMembers: SubMemberV5[] }>
@@ -1512,6 +1567,21 @@ export class RestClientV5 extends BaseRestClient {
return this.getPrivate('/v5/user/query-sub-members'); return this.getPrivate('/v5/user/query-sub-members');
} }
/**
* This endpoint allows you to get a list of all sub UID of master account. No limit on the number of subaccounts.
*/
getSubUIDListUnlimited(params?: {
pageSize?: string;
nextCursor?: string;
}): Promise<
APIResponseV3WithTime<{
subMembers: SubMemberV5[];
nextCursor: string;
}>
> {
return this.getPrivate('/v5/user/submembers', params);
}
/** /**
* Query all api keys information of a sub UID. * Query all api keys information of a sub UID.
*/ */
@@ -1712,6 +1782,32 @@ export class RestClientV5 extends BaseRestClient {
return this.get('/v5/spot-margin-trade/data', params); return this.get('/v5/spot-margin-trade/data', params);
} }
/**
* Get Historical Interest Rate
* You can query up to six months borrowing interest rate of Margin trading.
* INFO: Need authentication, the api key needs "Spot" permission. Only supports Unified account.
*/
getHistoricalInterestRate(params: {
currency: string;
vipLevel?: string;
startTime?: number;
endTime?: number;
}): Promise<
APIResponseV3WithTime<{
list: {
timestamp: number;
currency: string;
hourlyBorrowRate: string;
vipLevel: string;
}[];
}>
> {
return this.getPrivate(
'/v5/spot-margin-trade/interest-rate-history',
params,
);
}
/** /**
* Turn spot margin trade on / off in your UTA account. * Turn spot margin trade on / off in your UTA account.
* *
@@ -1766,32 +1862,6 @@ export class RestClientV5 extends BaseRestClient {
}); });
} }
/**
* Get Historical Interest Rate
* You can query up to six months borrowing interest rate of Margin trading.
* INFO: Need authentication, the api key needs "Spot" permission. Only supports Unified account.
*/
getHistoricalInterestRate(params: {
currency: string;
vipLevel?: string;
startTime?: number;
endTime?: number;
}): Promise<
APIResponseV3WithTime<{
list: {
timestamp: number;
currency: string;
hourlyBorrowRate: string;
vipLevel: string;
}[];
}>
> {
return this.getPrivate(
'/v5/spot-margin-trade/interest-rate-history',
params,
);
}
/** /**
* Get Borrowable Coin Info * Get Borrowable Coin Info
*/ */

View File

@@ -35,3 +35,28 @@ export interface GetPreUpgradeClosedPnlParamsV5 {
limit?: number; limit?: number;
cursor?: string; cursor?: string;
} }
export interface GetPreUpgradeTransactionLogParamsV5 {
category: 'linear' | 'option';
baseCoin?: string;
type?: string;
startTime?: number;
endTime?: number;
limit?: number;
cursor?: string;
}
export interface GetPreUpgradeOptionDeliveryRecordParamsV5 {
category: 'option';
symbol?: string;
expDate?: string;
limit?: number;
cursor?: string;
}
export interface GetPreUpgradeUSDCSessionParamsV5 {
category: 'linear';
symbol?: string;
limit?: number;
cursor?: string;
}

View File

@@ -12,3 +12,4 @@ export * from './v5-trade';
export * from './v5-user'; export * from './v5-user';
export * from './v5-spot-leverage-token'; export * from './v5-spot-leverage-token';
export * from './v5-broker'; export * from './v5-broker';
export * from './v5-preupgrade';

View File

@@ -207,8 +207,6 @@ export interface ConvertQuoteV5 {
toAmount: string; toAmount: string;
expiredTime: string; expiredTime: string;
requestId: string; requestId: string;
paramType: string;
paramValue: string;
} }
export interface ConvertStatusV5 { export interface ConvertStatusV5 {

View File

@@ -0,0 +1,42 @@
export interface PreUpgradeTransaction {
symbol: string;
category: string;
side: 'Buy' | 'Sell' | 'None';
transactionTime: string;
type: string;
qty: string;
size: string;
currency: 'USDC' | 'USDT' | 'BTC' | 'ETH';
tradePrice: string;
funding: string;
fee: string;
cashFlow: string;
change: string;
cashBalance: string;
feeRate: string;
bonusChange: string;
tradeId: string;
orderId: string;
orderLinkId: string;
}
export interface PreUpgradeOptionsDelivery {
deliveryTime: number;
symbol: string;
side: 'Buy' | 'Sell';
position: string;
deliveryPrice: string;
strike: string;
fee: string;
deliveryRpl: string;
}
export interface PreUpgradeUSDCSessionSettlement {
symbol: string;
side: 'Buy' | 'Sell';
size: string;
sessionAvgPrice: string;
markPrice: string;
realisedPnl: string;
createdTime: string;
}

View File

@@ -22,6 +22,7 @@ export interface SubMemberV5 {
username: string; username: string;
memberType: number; memberType: number;
status: number; status: number;
accountMode: number;
remark: string; remark: string;
} }
export type ApiKeyType = 1 | 2; export type ApiKeyType = 1 | 2;
@@ -73,11 +74,10 @@ export interface SubAccountAllApiKeysResultV5 {
readOnly: 0 | 1; readOnly: 0 | 1;
deadlineDay?: number; deadlineDay?: number;
flag: string; flag: string;
}[], }[];
nextPageCursor: string; nextPageCursor: string;
} }
export interface AffiliateUserInfoV5 { export interface AffiliateUserInfoV5 {
uid: string; uid: string;
vipLevel: string; vipLevel: string;