feat(): Update per release notes as of 17th July, 2024
- added convert endpoints - added examples for those endpoints - minor param/response changes based on release notes
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -24,4 +24,5 @@ bundleReport.html
|
|||||||
.history/
|
.history/
|
||||||
rawReq.ts
|
rawReq.ts
|
||||||
localtest.sh
|
localtest.sh
|
||||||
|
localtest.ts
|
||||||
|
|
||||||
|
|||||||
18
examples/apidoc/V5/Asset/confirm-convert-quote.js
Normal file
18
examples/apidoc/V5/Asset/confirm-convert-quote.js
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
const { RestClientV5 } = require('bybit-api');
|
||||||
|
|
||||||
|
const client = new RestClientV5({
|
||||||
|
testnet: true,
|
||||||
|
key: 'apikey',
|
||||||
|
secret: 'apisecret',
|
||||||
|
});
|
||||||
|
|
||||||
|
client
|
||||||
|
.confirmConvertQuote({
|
||||||
|
quoteTxId: '10100108106409343501030232064',
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
console.log(response);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
16
examples/apidoc/V5/Asset/get-convert-coins.js
Normal file
16
examples/apidoc/V5/Asset/get-convert-coins.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
const { RestClientV5 } = require('bybit-api');
|
||||||
|
|
||||||
|
const client = new RestClientV5({
|
||||||
|
testnet: true,
|
||||||
|
key: 'apikey',
|
||||||
|
secret: 'apisecret',
|
||||||
|
});
|
||||||
|
|
||||||
|
client
|
||||||
|
.getConvertCoins({ accountType: 'eb_convert_spot' })
|
||||||
|
.then((response) => {
|
||||||
|
console.log(response);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
16
examples/apidoc/V5/Asset/get-convert-history.js
Normal file
16
examples/apidoc/V5/Asset/get-convert-history.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
const { RestClientV5 } = require('bybit-api');
|
||||||
|
|
||||||
|
const client = new RestClientV5({
|
||||||
|
testnet: true,
|
||||||
|
key: 'apikey',
|
||||||
|
secret: 'apisecret',
|
||||||
|
});
|
||||||
|
|
||||||
|
client
|
||||||
|
.getConvertHistory()
|
||||||
|
.then((response) => {
|
||||||
|
console.log(response);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
19
examples/apidoc/V5/Asset/get-convert-status.js
Normal file
19
examples/apidoc/V5/Asset/get-convert-status.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
const { RestClientV5 } = require('bybit-api');
|
||||||
|
|
||||||
|
const client = new RestClientV5({
|
||||||
|
testnet: true,
|
||||||
|
key: 'apikey',
|
||||||
|
secret: 'apisecret',
|
||||||
|
});
|
||||||
|
|
||||||
|
client
|
||||||
|
.getConvertStatus({
|
||||||
|
quoteTxId: 'quoteTransactionId',
|
||||||
|
accountType: 'eb_convert_funding',
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
console.log(response);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
23
examples/apidoc/V5/Asset/request-convert-quote.js
Normal file
23
examples/apidoc/V5/Asset/request-convert-quote.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
const { RestClientV5 } = require('bybit-api');
|
||||||
|
|
||||||
|
const client = new RestClientV5({
|
||||||
|
testnet: true,
|
||||||
|
key: 'apikey',
|
||||||
|
secret: 'apisecret',
|
||||||
|
});
|
||||||
|
|
||||||
|
client
|
||||||
|
.requestConvertQuote({
|
||||||
|
requestId: 'test-00002',
|
||||||
|
fromCoin: 'ETH',
|
||||||
|
toCoin: 'BTC',
|
||||||
|
accountType: 'eb_convert_funding',
|
||||||
|
requestCoin: 'ETH',
|
||||||
|
requestAmount: '0.1',
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
console.log(response);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "bybit-api",
|
"name": "bybit-api",
|
||||||
"version": "3.10.10",
|
"version": "3.10.11",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "bybit-api",
|
"name": "bybit-api",
|
||||||
"version": "3.10.10",
|
"version": "3.10.11",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.6.6",
|
"axios": "^1.6.6",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "bybit-api",
|
"name": "bybit-api",
|
||||||
"version": "3.10.11",
|
"version": "3.10.12",
|
||||||
"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",
|
||||||
@@ -38,8 +38,8 @@
|
|||||||
"eslint-plugin-prettier": "^5.1.3",
|
"eslint-plugin-prettier": "^5.1.3",
|
||||||
"eslint-plugin-simple-import-sort": "^12.0.0",
|
"eslint-plugin-simple-import-sort": "^12.0.0",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
"ts-node": "^10.9.2",
|
|
||||||
"ts-jest": "^29.1.2",
|
"ts-jest": "^29.1.2",
|
||||||
|
"ts-node": "^10.9.2",
|
||||||
"typescript": "^5.3.3"
|
"typescript": "^5.3.3"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
|
|||||||
@@ -35,6 +35,11 @@ import {
|
|||||||
CoinInfoV5,
|
CoinInfoV5,
|
||||||
CollateralInfoV5,
|
CollateralInfoV5,
|
||||||
ConfirmNewRiskLimitParamsV5,
|
ConfirmNewRiskLimitParamsV5,
|
||||||
|
ConvertCoinSpecV5,
|
||||||
|
ConvertCoinsParamsV5,
|
||||||
|
ConvertHistoryRecordV5,
|
||||||
|
ConvertQuoteV5,
|
||||||
|
ConvertStatusV5,
|
||||||
CreateSubApiKeyParamsV5,
|
CreateSubApiKeyParamsV5,
|
||||||
CreateSubApiKeyResultV5,
|
CreateSubApiKeyResultV5,
|
||||||
CreateSubMemberParamsV5,
|
CreateSubMemberParamsV5,
|
||||||
@@ -64,6 +69,7 @@ import {
|
|||||||
GetClassicTransactionLogsParamsV5,
|
GetClassicTransactionLogsParamsV5,
|
||||||
GetClosedPnLParamsV5,
|
GetClosedPnLParamsV5,
|
||||||
GetCoinExchangeRecordParamsV5,
|
GetCoinExchangeRecordParamsV5,
|
||||||
|
GetConvertHistoryParamsV5,
|
||||||
GetDeliveryPriceParamsV5,
|
GetDeliveryPriceParamsV5,
|
||||||
GetDeliveryRecordParamsV5,
|
GetDeliveryRecordParamsV5,
|
||||||
GetDepositRecordParamsV5,
|
GetDepositRecordParamsV5,
|
||||||
@@ -130,6 +136,7 @@ import {
|
|||||||
RedeemSpotLeveragedTokenResultV5,
|
RedeemSpotLeveragedTokenResultV5,
|
||||||
RepayLiabilityParamsV5,
|
RepayLiabilityParamsV5,
|
||||||
RepayLiabilityResultV5,
|
RepayLiabilityResultV5,
|
||||||
|
RequestConvertQuoteParamsV5,
|
||||||
RiskLimitV5,
|
RiskLimitV5,
|
||||||
SetAutoAddMarginParamsV5,
|
SetAutoAddMarginParamsV5,
|
||||||
SetCollateralCoinParamsV5,
|
SetCollateralCoinParamsV5,
|
||||||
@@ -563,6 +570,17 @@ export class RestClientV5 extends BaseRestClient {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TO CHECK!
|
||||||
|
/* setDisconnectCancelAllWindow(
|
||||||
|
product: 'OPTION' | 'SPOT' | 'DERIVATIVES',
|
||||||
|
timeWindow: number,
|
||||||
|
): Promise<APIResponseV3<undefined>> {
|
||||||
|
return this.postPrivate('/v5/order/disconnected-cancel-all', {
|
||||||
|
product,
|
||||||
|
timeWindow,
|
||||||
|
});
|
||||||
|
} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
****** Position APIs
|
****** Position APIs
|
||||||
@@ -1385,6 +1403,68 @@ export class RestClientV5 extends BaseRestClient {
|
|||||||
return this.postPrivate('/v5/asset/withdraw/cancel', { id });
|
return this.postPrivate('/v5/asset/withdraw/cancel', { id });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query the coin list of convert from (to).
|
||||||
|
*/
|
||||||
|
getConvertCoins(params: ConvertCoinsParamsV5): Promise<
|
||||||
|
APIResponseV3WithTime<{
|
||||||
|
coins: ConvertCoinSpecV5[];
|
||||||
|
}>
|
||||||
|
> {
|
||||||
|
return this.getPrivate('/v5/asset/exchange/query-coin-list', params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request a quote for converting coins.
|
||||||
|
*/
|
||||||
|
requestConvertQuote(
|
||||||
|
params: RequestConvertQuoteParamsV5,
|
||||||
|
): Promise<APIResponseV3WithTime<ConvertQuoteV5>> {
|
||||||
|
return this.postPrivate('/v5/asset/exchange/quote-apply', params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Confirm a quote for converting coins.
|
||||||
|
*/
|
||||||
|
confirmConvertQuote(params: { quoteTxId: string }): Promise<
|
||||||
|
APIResponseV3WithTime<{
|
||||||
|
quoteTxId: string;
|
||||||
|
exchangeStatus: 'init' | 'processing' | 'success' | 'failure';
|
||||||
|
}>
|
||||||
|
> {
|
||||||
|
return this.postPrivate('/v5/asset/exchange/convert-execute', params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query the exchange result by sending quoteTxId.
|
||||||
|
*/
|
||||||
|
getConvertStatus(params: {
|
||||||
|
quoteTxId?: string;
|
||||||
|
accountType:
|
||||||
|
| 'eb_convert_funding'
|
||||||
|
| 'eb_convert_uta'
|
||||||
|
| 'eb_convert_spot'
|
||||||
|
| 'eb_convert_contract'
|
||||||
|
| 'eb_convert_inverse';
|
||||||
|
}): Promise<
|
||||||
|
APIResponseV3WithTime<{
|
||||||
|
result: ConvertStatusV5;
|
||||||
|
}>
|
||||||
|
> {
|
||||||
|
return this.getPrivate('/v5/asset/exchange/convert-result-query', params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query the conversion history.
|
||||||
|
*/
|
||||||
|
getConvertHistory(params?: GetConvertHistoryParamsV5): Promise<
|
||||||
|
APIResponseV3WithTime<{
|
||||||
|
list: ConvertHistoryRecordV5[];
|
||||||
|
}>
|
||||||
|
> {
|
||||||
|
return this.getPrivate('/v5/asset/exchange/query-convert-history', params);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
****** User APIs
|
****** User APIs
|
||||||
|
|||||||
@@ -124,3 +124,31 @@ export interface WithdrawParamsV5 {
|
|||||||
forceChain?: number;
|
forceChain?: number;
|
||||||
accountType?: 'SPOT' | 'FUND';
|
accountType?: 'SPOT' | 'FUND';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ConvertCoinsParamsV5 {
|
||||||
|
coin?: string;
|
||||||
|
side?: number;
|
||||||
|
accountType:
|
||||||
|
| 'eb_convert_funding'
|
||||||
|
| 'eb_convert_uta'
|
||||||
|
| 'eb_convert_spot'
|
||||||
|
| 'eb_convert_contract'
|
||||||
|
| 'eb_convert_inverse';
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RequestConvertQuoteParamsV5 {
|
||||||
|
fromCoin: string;
|
||||||
|
toCoin: string;
|
||||||
|
fromCoinType?: string;
|
||||||
|
toCoinType?: string;
|
||||||
|
requestCoin: string;
|
||||||
|
requestAmount: string;
|
||||||
|
accountType: 'eb_convert_funding' | 'eb_convert_uta' | 'eb_convert_spot' | 'eb_convert_contract' | 'eb_convert_inverse';
|
||||||
|
requestId?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetConvertHistoryParamsV5 {
|
||||||
|
accountType?: string;
|
||||||
|
index?: number;
|
||||||
|
limit?: number;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
export interface GetExchangeBrokerEarningsParamsV5 {
|
export interface GetExchangeBrokerEarningsParamsV5 {
|
||||||
bizType?: 'SPOT' | 'DERIVATIVES' | 'OPTIONS';
|
bizType?: 'SPOT' | 'DERIVATIVES' | 'OPTIONS' | 'CONVERT';
|
||||||
begin?: string;
|
begin?: string;
|
||||||
end?: string;
|
end?: string;
|
||||||
uid?: string;
|
uid?: string;
|
||||||
|
|||||||
@@ -89,6 +89,8 @@ export interface FeeRateV5 {
|
|||||||
export interface AccountInfoV5 {
|
export interface AccountInfoV5 {
|
||||||
unifiedMarginStatus: number;
|
unifiedMarginStatus: number;
|
||||||
marginMode: AccountMarginModeV5;
|
marginMode: AccountMarginModeV5;
|
||||||
|
isMasterTrader: boolean;
|
||||||
|
spotHedgingStatus: string;
|
||||||
updatedTime: string;
|
updatedTime: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,5 +136,3 @@ export interface DCPInfoV5 {
|
|||||||
dcpStatus: 'ON';
|
dcpStatus: 'ON';
|
||||||
timeWindow: string;
|
timeWindow: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -169,8 +169,74 @@ export interface WithdrawalRecordV5 {
|
|||||||
updateTime: string;
|
updateTime: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface VaspEntityV5 {
|
export interface VaspEntityV5 {
|
||||||
vaspEntityId: string;
|
vaspEntityId: string;
|
||||||
vaspName: string;
|
vaspName: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ConvertCoinSpecV5 {
|
||||||
|
coin: string;
|
||||||
|
fullName: string;
|
||||||
|
icon: string;
|
||||||
|
iconNight: string;
|
||||||
|
accuracyLength: number;
|
||||||
|
coinType: string;
|
||||||
|
balance: string;
|
||||||
|
uBalance: string;
|
||||||
|
singleFromMinLimit: string;
|
||||||
|
singleFromMaxLimit: string;
|
||||||
|
disableFrom: boolean;
|
||||||
|
disableTo: boolean;
|
||||||
|
timePeriod: number;
|
||||||
|
singleToMinLimit: string;
|
||||||
|
singleToMaxLimit: string;
|
||||||
|
dailyFromMinLimit: string;
|
||||||
|
dailyFromMaxLimit: string;
|
||||||
|
dailyToMinLimit: string;
|
||||||
|
dailyToMaxLimit: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ConvertQuoteV5 {
|
||||||
|
quoteTxId: string;
|
||||||
|
exchangeRate: string;
|
||||||
|
fromCoin: string;
|
||||||
|
fromCoinType: string;
|
||||||
|
toCoin: string;
|
||||||
|
toCoinType: string;
|
||||||
|
fromAmount: string;
|
||||||
|
toAmount: string;
|
||||||
|
expiredTime: string;
|
||||||
|
requestId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ConvertStatusV5 {
|
||||||
|
accountType: string;
|
||||||
|
exchangeTxId: string;
|
||||||
|
userId: string;
|
||||||
|
fromCoin: string;
|
||||||
|
fromCoinType: string;
|
||||||
|
toCoin: string;
|
||||||
|
toCoinType: string;
|
||||||
|
fromAmount: string;
|
||||||
|
toAmount: string;
|
||||||
|
exchangeStatus: 'init' | 'processing' | 'success' | 'failure';
|
||||||
|
extInfo: object;
|
||||||
|
convertRate: string;
|
||||||
|
createdAt: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ConvertHistoryRecordV5 {
|
||||||
|
accountType: string;
|
||||||
|
exchangeTxId: string;
|
||||||
|
userId: string;
|
||||||
|
fromCoin: string;
|
||||||
|
fromCoinType: string;
|
||||||
|
toCoin: string;
|
||||||
|
toCoinType: string;
|
||||||
|
fromAmount: string;
|
||||||
|
toAmount: string;
|
||||||
|
exchangeStatus: 'init' | 'processing' | 'success' | 'failure';
|
||||||
|
extInfo: object;
|
||||||
|
convertRate: string;
|
||||||
|
createdAt: string;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
interface EarningDetailV5 {
|
interface EarningDetailV5 {
|
||||||
userId: string;
|
userId: string;
|
||||||
bizType: 'SPOT' | 'DERIVATIVES' | 'OPTIONS';
|
bizType: 'SPOT' | 'DERIVATIVES' | 'OPTIONS' | 'CONVERT';
|
||||||
symbol: string;
|
symbol: string;
|
||||||
coin: string;
|
coin: string;
|
||||||
earning: string;
|
earning: string;
|
||||||
@@ -20,6 +20,7 @@ export interface ExchangeBrokerEarningResultV5 {
|
|||||||
spot: TotalEarningCategoryV5[];
|
spot: TotalEarningCategoryV5[];
|
||||||
derivatives: TotalEarningCategoryV5[];
|
derivatives: TotalEarningCategoryV5[];
|
||||||
options: TotalEarningCategoryV5[];
|
options: TotalEarningCategoryV5[];
|
||||||
|
convert: TotalEarningCategoryV5[];
|
||||||
total: TotalEarningCategoryV5[];
|
total: TotalEarningCategoryV5[];
|
||||||
};
|
};
|
||||||
details: EarningDetailV5[];
|
details: EarningDetailV5[];
|
||||||
@@ -36,6 +37,7 @@ export interface ExchangeBrokerAccountInfoV5 {
|
|||||||
markupFeeRebateRate: {
|
markupFeeRebateRate: {
|
||||||
spot: string;
|
spot: string;
|
||||||
derivatives: string;
|
derivatives: string;
|
||||||
|
convert: string;
|
||||||
};
|
};
|
||||||
ts: string;
|
ts: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,6 +75,20 @@ export interface LinearInverseInstrumentInfoV5 {
|
|||||||
copyTrading: CopyTradingV5;
|
copyTrading: CopyTradingV5;
|
||||||
upperFundingRate: string;
|
upperFundingRate: string;
|
||||||
lowerFundingRate: string;
|
lowerFundingRate: string;
|
||||||
|
isPreListing: boolean;
|
||||||
|
preListingInfo: {
|
||||||
|
curAuctionPhase: string;
|
||||||
|
phases: {
|
||||||
|
phase: string;
|
||||||
|
startTime: string;
|
||||||
|
endTime: string;
|
||||||
|
}[];
|
||||||
|
auctionFeeInfo: {
|
||||||
|
auctionFeeRate: string;
|
||||||
|
takerFeeRate: string;
|
||||||
|
makerFeeRate: string;
|
||||||
|
};
|
||||||
|
} | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OptionInstrumentInfoV5 {
|
export interface OptionInstrumentInfoV5 {
|
||||||
@@ -170,6 +184,9 @@ export interface TickerLinearInverseV5 {
|
|||||||
bid1Price: string;
|
bid1Price: string;
|
||||||
ask1Price: string;
|
ask1Price: string;
|
||||||
bid1Size: string;
|
bid1Size: string;
|
||||||
|
preOpenPrice: string;
|
||||||
|
preQty: string;
|
||||||
|
curPreListingPhase: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TickerOptionV5 {
|
export interface TickerOptionV5 {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export type InstrumentStatusV5 =
|
|||||||
| 'Delivering'
|
| 'Delivering'
|
||||||
| 'Closed';
|
| 'Closed';
|
||||||
|
|
||||||
|
|
||||||
export type MarginTradingV5 = 'none' | 'both' | 'utaOnly' | 'normalSpotOnly';
|
export type MarginTradingV5 = 'none' | 'both' | 'utaOnly' | 'normalSpotOnly';
|
||||||
|
|
||||||
export type OrderFilterV5 = 'Order' | 'tpslOrder' | 'StopOrder';
|
export type OrderFilterV5 = 'Order' | 'tpslOrder' | 'StopOrder';
|
||||||
|
|||||||
Reference in New Issue
Block a user