feat(): add deprecation warnings for v1/v2 REST clients

This commit is contained in:
tiagosiebler
2023-10-30 12:22:04 +00:00
parent 234e674a57
commit 7460cf4b5c
7 changed files with 208 additions and 181 deletions

View File

@@ -17,6 +17,10 @@ import BaseRestClient from './util/BaseRestClient';
/** /**
* REST API client for Account Asset APIs * REST API client for Account Asset APIs
*
* @deprecated WARNING: V1/V2 private endpoints (Rest API & Websocket Stream) for mainnet
* will be switched off gradually from 30 Oct 2023 UTC, so they are not promised a stability.
* Please note that you are at your own risk of using old endpoints going forward, and please move to V5 ASAP.
*/ */
export class AccountAssetClient extends BaseRestClient { export class AccountAssetClient extends BaseRestClient {
getClientType() { getClientType() {
@@ -35,29 +39,29 @@ export class AccountAssetClient extends BaseRestClient {
*/ */
createInternalTransfer( createInternalTransfer(
params: InternalTransferRequest params: InternalTransferRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('/asset/v1/private/transfer', params); return this.postPrivate('/asset/v1/private/transfer', params);
} }
createSubAccountTransfer( createSubAccountTransfer(
params: SubAccountTransferRequest params: SubAccountTransferRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('/asset/v1/private/sub-member/transfer', params); return this.postPrivate('/asset/v1/private/sub-member/transfer', params);
} }
getInternalTransfers( getInternalTransfers(
params?: TransferQueryRequest params?: TransferQueryRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('/asset/v1/private/transfer/list', params); return this.getPrivate('/asset/v1/private/transfer/list', params);
} }
getSubAccountTransfers( getSubAccountTransfers(
params?: TransferQueryRequest params?: TransferQueryRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate( return this.getPrivate(
'/asset/v1/private/sub-member/transfer/list', '/asset/v1/private/sub-member/transfer/list',
params params,
); );
} }
@@ -66,19 +70,19 @@ export class AccountAssetClient extends BaseRestClient {
} }
enableUniversalTransfer( enableUniversalTransfer(
params?: EnableUniversalTransferRequest params?: EnableUniversalTransferRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('/asset/v1/private/transferable-subs/save', params); return this.postPrivate('/asset/v1/private/transferable-subs/save', params);
} }
createUniversalTransfer( createUniversalTransfer(
params: UniversalTransferRequest params: UniversalTransferRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('/asset/v1/private/universal/transfer', params); return this.postPrivate('/asset/v1/private/universal/transfer', params);
} }
getUniversalTransfers( getUniversalTransfers(
params?: TransferQueryRequest params?: TransferQueryRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('/asset/v1/private/universal/transfer/list', params); return this.getPrivate('/asset/v1/private/universal/transfer/list', params);
} }
@@ -90,19 +94,19 @@ export class AccountAssetClient extends BaseRestClient {
*/ */
getSupportedDepositList( getSupportedDepositList(
params?: SupportedDepositListRequest params?: SupportedDepositListRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.get('/asset/v1/public/deposit/allowed-deposit-list', params); return this.get('/asset/v1/public/deposit/allowed-deposit-list', params);
} }
getDepositRecords( getDepositRecords(
params?: DepositRecordsRequest params?: DepositRecordsRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('/asset/v1/private/deposit/record/query', params); return this.getPrivate('/asset/v1/private/deposit/record/query', params);
} }
getWithdrawRecords( getWithdrawRecords(
params?: WithdrawalRecordsRequest params?: WithdrawalRecordsRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('/asset/v1/private/withdraw/record/query', params); return this.getPrivate('/asset/v1/private/withdraw/record/query', params);
} }
@@ -112,13 +116,13 @@ export class AccountAssetClient extends BaseRestClient {
} }
getAssetInformation( getAssetInformation(
params?: AccountAssetInformationRequest params?: AccountAssetInformationRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('/asset/v1/private/asset-info/query', params); return this.getPrivate('/asset/v1/private/asset-info/query', params);
} }
submitWithdrawal( submitWithdrawal(
params: WithdrawalRequest params: WithdrawalRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('/asset/v1/private/withdraw', params); return this.postPrivate('/asset/v1/private/withdraw', params);
} }

View File

@@ -32,6 +32,10 @@ import BaseRestClient from './util/BaseRestClient';
/** /**
* REST API client for Inverse Perpetual Futures APIs (v2) * REST API client for Inverse Perpetual Futures APIs (v2)
*
* @deprecated WARNING: V1/V2 private endpoints (Rest API & Websocket Stream) for mainnet
* will be switched off gradually from 30 Oct 2023 UTC, so they are not promised a stability.
* Please note that you are at your own risk of using old endpoints going forward, and please move to V5 ASAP.
*/ */
export class InverseClient extends BaseRestClient { export class InverseClient extends BaseRestClient {
getClientType() { getClientType() {
@@ -54,7 +58,7 @@ export class InverseClient extends BaseRestClient {
} }
getKline( getKline(
params: SymbolIntervalFromLimitParam params: SymbolIntervalFromLimitParam,
): Promise<APIResponseWithTime<any[]>> { ): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/kline/list', params); return this.get('v2/public/kline/list', params);
} }
@@ -63,7 +67,7 @@ export class InverseClient extends BaseRestClient {
* Get latest information for symbol * Get latest information for symbol
*/ */
getTickers( getTickers(
params?: Partial<SymbolParam> params?: Partial<SymbolParam>,
): Promise<APIResponseWithTime<any[]>> { ): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/tickers', params); return this.get('v2/public/tickers', params);
} }
@@ -77,19 +81,19 @@ export class InverseClient extends BaseRestClient {
} }
getMarkPriceKline( getMarkPriceKline(
params: SymbolIntervalFromLimitParam params: SymbolIntervalFromLimitParam,
): Promise<APIResponseWithTime<any[]>> { ): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/mark-price-kline', params); return this.get('v2/public/mark-price-kline', params);
} }
getIndexPriceKline( getIndexPriceKline(
params: SymbolIntervalFromLimitParam params: SymbolIntervalFromLimitParam,
): Promise<APIResponseWithTime<any[]>> { ): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/index-price-kline', params); return this.get('v2/public/index-price-kline', params);
} }
getPremiumIndexKline( getPremiumIndexKline(
params: SymbolIntervalFromLimitParam params: SymbolIntervalFromLimitParam,
): Promise<APIResponseWithTime<any[]>> { ): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/premium-index-kline', params); return this.get('v2/public/premium-index-kline', params);
} }
@@ -101,19 +105,19 @@ export class InverseClient extends BaseRestClient {
*/ */
getOpenInterest( getOpenInterest(
params: SymbolPeriodLimitParam params: SymbolPeriodLimitParam,
): Promise<APIResponseWithTime<any[]>> { ): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/open-interest', params); return this.get('v2/public/open-interest', params);
} }
getLatestBigDeal( getLatestBigDeal(
params: SymbolLimitParam params: SymbolLimitParam,
): Promise<APIResponseWithTime<any[]>> { ): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/big-deal', params); return this.get('v2/public/big-deal', params);
} }
getLongShortRatio( getLongShortRatio(
params: SymbolPeriodLimitParam params: SymbolPeriodLimitParam,
): Promise<APIResponseWithTime<any[]>> { ): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/account-ratio', params); return this.get('v2/public/account-ratio', params);
} }
@@ -135,25 +139,25 @@ export class InverseClient extends BaseRestClient {
*/ */
getWalletBalance( getWalletBalance(
params?: Partial<CoinParam> params?: Partial<CoinParam>,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/wallet/balance', params); return this.getPrivate('v2/private/wallet/balance', params);
} }
getWalletFundRecords( getWalletFundRecords(
params?: WalletFundRecordsReq params?: WalletFundRecordsReq,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/wallet/fund/records', params); return this.getPrivate('v2/private/wallet/fund/records', params);
} }
getWithdrawRecords( getWithdrawRecords(
params?: WithdrawRecordsReq params?: WithdrawRecordsReq,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/wallet/withdraw/list', params); return this.getPrivate('v2/private/wallet/withdraw/list', params);
} }
getAssetExchangeRecords( getAssetExchangeRecords(
params?: AssetExchangeRecordsReq params?: AssetExchangeRecordsReq,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/exchange-order/list', params); return this.getPrivate('v2/private/exchange-order/list', params);
} }
@@ -183,37 +187,37 @@ export class InverseClient extends BaseRestClient {
*/ */
placeActiveOrder( placeActiveOrder(
orderRequest: InverseOrderRequest orderRequest: InverseOrderRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/order/create', orderRequest); return this.postPrivate('v2/private/order/create', orderRequest);
} }
getActiveOrderList( getActiveOrderList(
params: InverseActiveOrdersRequest params: InverseActiveOrdersRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/order/list', params); return this.getPrivate('v2/private/order/list', params);
} }
cancelActiveOrder( cancelActiveOrder(
params: InverseCancelOrderRequest params: InverseCancelOrderRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/order/cancel', params); return this.postPrivate('v2/private/order/cancel', params);
} }
cancelAllActiveOrders( cancelAllActiveOrders(
params: SymbolParam params: SymbolParam,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/order/cancelAll', params); return this.postPrivate('v2/private/order/cancelAll', params);
} }
replaceActiveOrder( replaceActiveOrder(
params: InverseReplaceOrderRequest params: InverseReplaceOrderRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/order/replace', params); return this.postPrivate('v2/private/order/replace', params);
} }
queryActiveOrder( queryActiveOrder(
params: InverseGetOrderRequest params: InverseGetOrderRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/order', params); return this.getPrivate('v2/private/order', params);
} }
@@ -223,38 +227,38 @@ export class InverseClient extends BaseRestClient {
*/ */
placeConditionalOrder( placeConditionalOrder(
params: InverseConditionalOrderRequest params: InverseConditionalOrderRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/stop-order/create', params); return this.postPrivate('v2/private/stop-order/create', params);
} }
/** get conditional order list. This may see delays, use queryConditionalOrder() for real-time queries */ /** get conditional order list. This may see delays, use queryConditionalOrder() for real-time queries */
getConditionalOrder( getConditionalOrder(
params: InverseActiveConditionalOrderRequest params: InverseActiveConditionalOrderRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/stop-order/list', params); return this.getPrivate('v2/private/stop-order/list', params);
} }
cancelConditionalOrder( cancelConditionalOrder(
params: InverseCancelConditionalOrderRequest params: InverseCancelConditionalOrderRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/stop-order/cancel', params); return this.postPrivate('v2/private/stop-order/cancel', params);
} }
cancelAllConditionalOrders( cancelAllConditionalOrders(
params: SymbolParam params: SymbolParam,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/stop-order/cancelAll', params); return this.postPrivate('v2/private/stop-order/cancelAll', params);
} }
replaceConditionalOrder( replaceConditionalOrder(
params: InverseReplaceConditionalOrderRequest params: InverseReplaceConditionalOrderRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/stop-order/replace', params); return this.postPrivate('v2/private/stop-order/replace', params);
} }
queryConditionalOrder( queryConditionalOrder(
params: InverseGetOrderRequest params: InverseGetOrderRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/stop-order', params); return this.getPrivate('v2/private/stop-order', params);
} }
@@ -264,49 +268,49 @@ export class InverseClient extends BaseRestClient {
*/ */
getPosition( getPosition(
params?: Partial<SymbolParam> params?: Partial<SymbolParam>,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/position/list', params); return this.getPrivate('v2/private/position/list', params);
} }
changePositionMargin( changePositionMargin(
params: InverseChangePositionMarginRequest params: InverseChangePositionMarginRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('position/change-position-margin', params); return this.postPrivate('position/change-position-margin', params);
} }
setTradingStop( setTradingStop(
params: InverseSetTradingStopRequest params: InverseSetTradingStopRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/position/trading-stop', params); return this.postPrivate('v2/private/position/trading-stop', params);
} }
setUserLeverage( setUserLeverage(
params: InverseSetLeverageRequest params: InverseSetLeverageRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/position/leverage/save', params); return this.postPrivate('v2/private/position/leverage/save', params);
} }
getTradeRecords( getTradeRecords(
params: InverseGetTradeRecordsRequest params: InverseGetTradeRecordsRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/execution/list', params); return this.getPrivate('v2/private/execution/list', params);
} }
getClosedPnl( getClosedPnl(
params: InverseGetClosedPnlRequest params: InverseGetClosedPnlRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/trade/closed-pnl/list', params); return this.getPrivate('v2/private/trade/closed-pnl/list', params);
} }
setSlTpPositionMode( setSlTpPositionMode(
params: InverseSetSlTpPositionModeRequest params: InverseSetSlTpPositionModeRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/tpsl/switch-mode', params); return this.postPrivate('v2/private/tpsl/switch-mode', params);
} }
setMarginType( setMarginType(
params: InverseSetMarginTypeRequest params: InverseSetMarginTypeRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/position/switch-isolated', params); return this.postPrivate('v2/private/position/switch-isolated', params);
} }

View File

@@ -16,6 +16,10 @@ import BaseRestClient from './util/BaseRestClient';
/** /**
* REST API client for Inverse Futures APIs (e.g. quarterly futures) (v2) * REST API client for Inverse Futures APIs (e.g. quarterly futures) (v2)
*
* @deprecated WARNING: V1/V2 private endpoints (Rest API & Websocket Stream) for mainnet
* will be switched off gradually from 30 Oct 2023 UTC, so they are not promised a stability.
* Please note that you are at your own risk of using old endpoints going forward, and please move to V5 ASAP.
*/ */
export class InverseFuturesClient extends BaseRestClient { export class InverseFuturesClient extends BaseRestClient {
getClientType() { getClientType() {
@@ -38,7 +42,7 @@ export class InverseFuturesClient extends BaseRestClient {
} }
getKline( getKline(
params: SymbolIntervalFromLimitParam params: SymbolIntervalFromLimitParam,
): Promise<APIResponseWithTime<any[]>> { ): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/kline/list', params); return this.get('v2/public/kline/list', params);
} }
@@ -47,7 +51,7 @@ export class InverseFuturesClient extends BaseRestClient {
* Get latest information for symbol * Get latest information for symbol
*/ */
getTickers( getTickers(
params?: Partial<SymbolParam> params?: Partial<SymbolParam>,
): Promise<APIResponseWithTime<any[]>> { ): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/tickers', params); return this.get('v2/public/tickers', params);
} }
@@ -64,19 +68,19 @@ export class InverseFuturesClient extends BaseRestClient {
} }
getMarkPriceKline( getMarkPriceKline(
params: SymbolIntervalFromLimitParam params: SymbolIntervalFromLimitParam,
): Promise<APIResponseWithTime<any[]>> { ): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/mark-price-kline', params); return this.get('v2/public/mark-price-kline', params);
} }
getIndexPriceKline( getIndexPriceKline(
params: SymbolIntervalFromLimitParam params: SymbolIntervalFromLimitParam,
): Promise<APIResponseWithTime<any[]>> { ): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/index-price-kline', params); return this.get('v2/public/index-price-kline', params);
} }
getPremiumIndexKline( getPremiumIndexKline(
params: SymbolIntervalFromLimitParam params: SymbolIntervalFromLimitParam,
): Promise<APIResponseWithTime<any[]>> { ): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/premium-index-kline', params); return this.get('v2/public/premium-index-kline', params);
} }
@@ -88,19 +92,19 @@ export class InverseFuturesClient extends BaseRestClient {
*/ */
getOpenInterest( getOpenInterest(
params: SymbolPeriodLimitParam params: SymbolPeriodLimitParam,
): Promise<APIResponseWithTime<any[]>> { ): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/open-interest', params); return this.get('v2/public/open-interest', params);
} }
getLatestBigDeal( getLatestBigDeal(
params: SymbolLimitParam params: SymbolLimitParam,
): Promise<APIResponseWithTime<any[]>> { ): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/big-deal', params); return this.get('v2/public/big-deal', params);
} }
getLongShortRatio( getLongShortRatio(
params: SymbolPeriodLimitParam params: SymbolPeriodLimitParam,
): Promise<APIResponseWithTime<any[]>> { ): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/account-ratio', params); return this.get('v2/public/account-ratio', params);
} }
@@ -122,25 +126,25 @@ export class InverseFuturesClient extends BaseRestClient {
*/ */
getWalletBalance( getWalletBalance(
params?: Partial<CoinParam> params?: Partial<CoinParam>,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/wallet/balance', params); return this.getPrivate('v2/private/wallet/balance', params);
} }
getWalletFundRecords( getWalletFundRecords(
params?: WalletFundRecordsReq params?: WalletFundRecordsReq,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/wallet/fund/records', params); return this.getPrivate('v2/private/wallet/fund/records', params);
} }
getWithdrawRecords( getWithdrawRecords(
params?: WithdrawRecordsReq params?: WithdrawRecordsReq,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/wallet/withdraw/list', params); return this.getPrivate('v2/private/wallet/withdraw/list', params);
} }
getAssetExchangeRecords( getAssetExchangeRecords(
params?: AssetExchangeRecordsReq params?: AssetExchangeRecordsReq,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/exchange-order/list', params); return this.getPrivate('v2/private/exchange-order/list', params);
} }
@@ -204,7 +208,7 @@ export class InverseFuturesClient extends BaseRestClient {
} }
cancelAllActiveOrders( cancelAllActiveOrders(
params: SymbolParam params: SymbolParam,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('futures/private/order/cancelAll', params); return this.postPrivate('futures/private/order/cancelAll', params);
} }
@@ -266,7 +270,7 @@ export class InverseFuturesClient extends BaseRestClient {
} }
cancelAllConditionalOrders( cancelAllConditionalOrders(
params: SymbolParam params: SymbolParam,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('futures/private/stop-order/cancelAll', params); return this.postPrivate('futures/private/stop-order/cancelAll', params);
} }
@@ -298,7 +302,7 @@ export class InverseFuturesClient extends BaseRestClient {
* Get position list * Get position list
*/ */
getPosition( getPosition(
params?: Partial<SymbolParam> params?: Partial<SymbolParam>,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('futures/private/position/list', params); return this.getPrivate('futures/private/position/list', params);
} }
@@ -309,7 +313,7 @@ export class InverseFuturesClient extends BaseRestClient {
}): Promise<APIResponseWithTime<any>> { }): Promise<APIResponseWithTime<any>> {
return this.postPrivate( return this.postPrivate(
'futures/private/position/change-position-margin', 'futures/private/position/change-position-margin',
params params,
); );
} }

View File

@@ -42,6 +42,10 @@ import BaseRestClient from './util/BaseRestClient';
/** /**
* REST API client for linear/USD perpetual futures APIs (v2) * REST API client for linear/USD perpetual futures APIs (v2)
*
* @deprecated WARNING: V1/V2 private endpoints (Rest API & Websocket Stream) for mainnet
* will be switched off gradually from 30 Oct 2023 UTC, so they are not promised a stability.
* Please note that you are at your own risk of using old endpoints going forward, and please move to V5 ASAP.
*/ */
export class LinearClient extends BaseRestClient { export class LinearClient extends BaseRestClient {
getClientType() { getClientType() {
@@ -64,7 +68,7 @@ export class LinearClient extends BaseRestClient {
} }
getKline( getKline(
params: SymbolIntervalFromLimitParam params: SymbolIntervalFromLimitParam,
): Promise<APIResponseWithTime<any[]>> { ): Promise<APIResponseWithTime<any[]>> {
return this.get('public/linear/kline', params); return this.get('public/linear/kline', params);
} }
@@ -73,7 +77,7 @@ export class LinearClient extends BaseRestClient {
* Get latest information for symbol * Get latest information for symbol
*/ */
getTickers( getTickers(
params?: Partial<SymbolParam> params?: Partial<SymbolParam>,
): Promise<APIResponseWithTime<any[]>> { ): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/tickers', params); return this.get('v2/public/tickers', params);
} }
@@ -91,19 +95,19 @@ export class LinearClient extends BaseRestClient {
} }
getMarkPriceKline( getMarkPriceKline(
params: SymbolIntervalFromLimitParam params: SymbolIntervalFromLimitParam,
): Promise<APIResponseWithTime<any[]>> { ): Promise<APIResponseWithTime<any[]>> {
return this.get('public/linear/mark-price-kline', params); return this.get('public/linear/mark-price-kline', params);
} }
getIndexPriceKline( getIndexPriceKline(
params: SymbolIntervalFromLimitParam params: SymbolIntervalFromLimitParam,
): Promise<APIResponseWithTime<any[]>> { ): Promise<APIResponseWithTime<any[]>> {
return this.get('public/linear/index-price-kline', params); return this.get('public/linear/index-price-kline', params);
} }
getPremiumIndexKline( getPremiumIndexKline(
params: SymbolIntervalFromLimitParam params: SymbolIntervalFromLimitParam,
): Promise<APIResponseWithTime<any[]>> { ): Promise<APIResponseWithTime<any[]>> {
return this.get('public/linear/premium-index-kline', params); return this.get('public/linear/premium-index-kline', params);
} }
@@ -115,19 +119,19 @@ export class LinearClient extends BaseRestClient {
*/ */
getOpenInterest( getOpenInterest(
params: SymbolPeriodLimitParam params: SymbolPeriodLimitParam,
): Promise<APIResponseWithTime<any[]>> { ): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/open-interest', params); return this.get('v2/public/open-interest', params);
} }
getLatestBigDeal( getLatestBigDeal(
params: SymbolLimitParam params: SymbolLimitParam,
): Promise<APIResponseWithTime<any[]>> { ): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/big-deal', params); return this.get('v2/public/big-deal', params);
} }
getLongShortRatio( getLongShortRatio(
params: SymbolPeriodLimitParam params: SymbolPeriodLimitParam,
): Promise<APIResponseWithTime<any[]>> { ): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/account-ratio', params); return this.get('v2/public/account-ratio', params);
} }
@@ -149,25 +153,25 @@ export class LinearClient extends BaseRestClient {
*/ */
getWalletBalance( getWalletBalance(
params?: Partial<CoinParam> params?: Partial<CoinParam>,
): Promise<APIResponseWithTime<WalletBalances>> { ): Promise<APIResponseWithTime<WalletBalances>> {
return this.getPrivate('v2/private/wallet/balance', params); return this.getPrivate('v2/private/wallet/balance', params);
} }
getWalletFundRecords( getWalletFundRecords(
params?: WalletFundRecordsReq params?: WalletFundRecordsReq,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/wallet/fund/records', params); return this.getPrivate('v2/private/wallet/fund/records', params);
} }
getWithdrawRecords( getWithdrawRecords(
params?: WithdrawRecordsReq params?: WithdrawRecordsReq,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/wallet/withdraw/list', params); return this.getPrivate('v2/private/wallet/withdraw/list', params);
} }
getAssetExchangeRecords( getAssetExchangeRecords(
params?: AssetExchangeRecordsReq params?: AssetExchangeRecordsReq,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/exchange-order/list', params); return this.getPrivate('v2/private/exchange-order/list', params);
} }
@@ -193,37 +197,37 @@ export class LinearClient extends BaseRestClient {
*/ */
placeActiveOrder( placeActiveOrder(
params: NewLinearOrder params: NewLinearOrder,
): Promise<APIResponseWithTime<LinearOrder | null>> { ): Promise<APIResponseWithTime<LinearOrder | null>> {
return this.postPrivate('private/linear/order/create', params); return this.postPrivate('private/linear/order/create', params);
} }
getActiveOrderList( getActiveOrderList(
params: LinearGetOrdersRequest params: LinearGetOrdersRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('private/linear/order/list', params); return this.getPrivate('private/linear/order/list', params);
} }
cancelActiveOrder( cancelActiveOrder(
params: LinearCancelOrderRequest params: LinearCancelOrderRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('private/linear/order/cancel', params); return this.postPrivate('private/linear/order/cancel', params);
} }
cancelAllActiveOrders( cancelAllActiveOrders(
params: SymbolParam params: SymbolParam,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('private/linear/order/cancel-all', params); return this.postPrivate('private/linear/order/cancel-all', params);
} }
replaceActiveOrder( replaceActiveOrder(
params: LinearReplaceOrderRequest params: LinearReplaceOrderRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('private/linear/order/replace', params); return this.postPrivate('private/linear/order/replace', params);
} }
queryActiveOrder( queryActiveOrder(
params: LinearGetOrderRequest params: LinearGetOrderRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('private/linear/order/search', params); return this.getPrivate('private/linear/order/search', params);
} }
@@ -233,37 +237,37 @@ export class LinearClient extends BaseRestClient {
*/ */
placeConditionalOrder( placeConditionalOrder(
params: LinearConditionalOrderRequest params: LinearConditionalOrderRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('private/linear/stop-order/create', params); return this.postPrivate('private/linear/stop-order/create', params);
} }
getConditionalOrder( getConditionalOrder(
params: LinearGetConditionalOrderRequest params: LinearGetConditionalOrderRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('private/linear/stop-order/list', params); return this.getPrivate('private/linear/stop-order/list', params);
} }
cancelConditionalOrder( cancelConditionalOrder(
params: LinearCancelConditionalOrderRequest params: LinearCancelConditionalOrderRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('private/linear/stop-order/cancel', params); return this.postPrivate('private/linear/stop-order/cancel', params);
} }
cancelAllConditionalOrders( cancelAllConditionalOrders(
params: SymbolParam params: SymbolParam,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('private/linear/stop-order/cancel-all', params); return this.postPrivate('private/linear/stop-order/cancel-all', params);
} }
replaceConditionalOrder( replaceConditionalOrder(
params: LinearReplaceConditionalOrderRequest params: LinearReplaceConditionalOrderRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('private/linear/stop-order/replace', params); return this.postPrivate('private/linear/stop-order/replace', params);
} }
queryConditionalOrder( queryConditionalOrder(
params: LinearQueryConditionalOrderRequest params: LinearQueryConditionalOrderRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('private/linear/stop-order/search', params); return this.getPrivate('private/linear/stop-order/search', params);
} }
@@ -275,26 +279,26 @@ export class LinearClient extends BaseRestClient {
getPosition(): Promise<APIResponseWithTime<PerpPositionRoot[]>>; getPosition(): Promise<APIResponseWithTime<PerpPositionRoot[]>>;
getPosition( getPosition(
params: Partial<SymbolParam> params: Partial<SymbolParam>,
): Promise<APIResponseWithTime<PerpPosition[]>>; ): Promise<APIResponseWithTime<PerpPosition[]>>;
getPosition( getPosition(
params?: Partial<SymbolParam> params?: Partial<SymbolParam>,
): Promise<APIResponseWithTime<PerpPosition[] | PerpPositionRoot[]>> { ): Promise<APIResponseWithTime<PerpPosition[] | PerpPositionRoot[]>> {
return this.getPrivate('private/linear/position/list', params); return this.getPrivate('private/linear/position/list', params);
} }
setAutoAddMargin( setAutoAddMargin(
params?: LinearSetAutoAddMarginRequest params?: LinearSetAutoAddMarginRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate( return this.postPrivate(
'private/linear/position/set-auto-add-margin', 'private/linear/position/set-auto-add-margin',
params params,
); );
} }
setMarginSwitch( setMarginSwitch(
params?: LinearSetMarginSwitchRequest params?: LinearSetMarginSwitchRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('private/linear/position/switch-isolated', params); return this.postPrivate('private/linear/position/switch-isolated', params);
} }
@@ -303,7 +307,7 @@ export class LinearClient extends BaseRestClient {
* Switch between one-way vs hedge mode. Use `linearPositionModeEnum` for the mode parameter. * Switch between one-way vs hedge mode. Use `linearPositionModeEnum` for the mode parameter.
*/ */
setPositionMode( setPositionMode(
params: LinearSetPositionModeRequest params: LinearSetPositionModeRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('private/linear/position/switch-mode', params); return this.postPrivate('private/linear/position/switch-mode', params);
} }
@@ -313,46 +317,46 @@ export class LinearClient extends BaseRestClient {
* This is set with the setTradingStop() method. Use `positionTpSlModeEnum` for the tp_sl_mode parameter. * This is set with the setTradingStop() method. Use `positionTpSlModeEnum` for the tp_sl_mode parameter.
*/ */
setPositionTpSlMode( setPositionTpSlMode(
params: LinearSetPositionTpSlModeRequest params: LinearSetPositionTpSlModeRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('private/linear/tpsl/switch-mode', params); return this.postPrivate('private/linear/tpsl/switch-mode', params);
} }
setAddReduceMargin( setAddReduceMargin(
params?: LinearSetAddReduceMarginRequest params?: LinearSetAddReduceMarginRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('private/linear/position/add-margin', params); return this.postPrivate('private/linear/position/add-margin', params);
} }
setUserLeverage( setUserLeverage(
params: LinearSetUserLeverageRequest params: LinearSetUserLeverageRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('private/linear/position/set-leverage', params); return this.postPrivate('private/linear/position/set-leverage', params);
} }
setTradingStop( setTradingStop(
params: LinearSetTradingStopRequest params: LinearSetTradingStopRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('private/linear/position/trading-stop', params); return this.postPrivate('private/linear/position/trading-stop', params);
} }
getTradeRecords( getTradeRecords(
params: LinearGetTradeRecordsRequest params: LinearGetTradeRecordsRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('private/linear/trade/execution/list', params); return this.getPrivate('private/linear/trade/execution/list', params);
} }
getHistoryTradeRecords( getHistoryTradeRecords(
params: LinearGetHistoryTradeRecordsRequest params: LinearGetHistoryTradeRecordsRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate( return this.getPrivate(
'/private/linear/trade/execution/history-list', '/private/linear/trade/execution/history-list',
params params,
); );
} }
getClosedPnl( getClosedPnl(
params: LinearGetClosedPnlRequest params: LinearGetClosedPnlRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('private/linear/trade/closed-pnl/list', params); return this.getPrivate('private/linear/trade/closed-pnl/list', params);
} }
@@ -366,7 +370,7 @@ export class LinearClient extends BaseRestClient {
} }
setRiskLimit( setRiskLimit(
params: LinearSetRiskLimitRequest params: LinearSetRiskLimitRequest,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.postPrivate('private/linear/position/set-risk', params); return this.postPrivate('private/linear/position/set-risk', params);
} }
@@ -376,7 +380,7 @@ export class LinearClient extends BaseRestClient {
*/ */
getPredictedFundingFee( getPredictedFundingFee(
params: SymbolParam params: SymbolParam,
): Promise<APIResponseWithTime<any>> { ): Promise<APIResponseWithTime<any>> {
return this.getPrivate('private/linear/funding/predicted-funding', params); return this.getPrivate('private/linear/funding/predicted-funding', params);
} }

View File

@@ -14,8 +14,11 @@ import BaseRestClient from './util/BaseRestClient';
import { REST_CLIENT_TYPE_ENUM } from './util/requestUtils'; import { REST_CLIENT_TYPE_ENUM } from './util/requestUtils';
/** /**
* @deprecated Use SpotV3Client instead, which leverages the newer v3 APIs
* REST API client for Spot APIs (v1) * REST API client for Spot APIs (v1)
*
* @deprecated WARNING: V1/V2 private endpoints (Rest API & Websocket Stream) for mainnet
* will be switched off gradually from 30 Oct 2023 UTC, so they are not promised a stability.
* Please note that you are at your own risk of using old endpoints going forward, and please move to V5 ASAP.
*/ */
export class SpotClient extends BaseRestClient { export class SpotClient extends BaseRestClient {
getClientType() { getClientType() {
@@ -51,7 +54,7 @@ export class SpotClient extends BaseRestClient {
getMergedOrderBook( getMergedOrderBook(
symbol: string, symbol: string,
scale?: number, scale?: number,
limit?: number limit?: number,
): Promise<APIResponse<any>> { ): Promise<APIResponse<any>> {
return this.get('/spot/quote/v1/depth/merged', { return this.get('/spot/quote/v1/depth/merged', {
symbol, symbol,
@@ -72,7 +75,7 @@ export class SpotClient extends BaseRestClient {
interval: KlineInterval, interval: KlineInterval,
limit?: number, limit?: number,
startTime?: number, startTime?: number,
endTime?: number endTime?: number,
): Promise<APIResponse<any[]>> { ): Promise<APIResponse<any[]>> {
return this.get('/spot/quote/v1/kline', { return this.get('/spot/quote/v1/kline', {
symbol, symbol,
@@ -92,7 +95,7 @@ export class SpotClient extends BaseRestClient {
getLastTradedPrice(symbol: string): Promise<APIResponse<SpotLastPrice>>; getLastTradedPrice(symbol: string): Promise<APIResponse<SpotLastPrice>>;
getLastTradedPrice( getLastTradedPrice(
symbol?: string symbol?: string,
): Promise<APIResponse<SpotLastPrice | SpotLastPrice[]>> { ): Promise<APIResponse<SpotLastPrice | SpotLastPrice[]>> {
return this.get('/spot/quote/v1/ticker/price', { symbol }); return this.get('/spot/quote/v1/ticker/price', { symbol });
} }
@@ -135,7 +138,7 @@ export class SpotClient extends BaseRestClient {
getOpenOrders( getOpenOrders(
symbol?: string, symbol?: string,
orderId?: string, orderId?: string,
limit?: number limit?: number,
): Promise<APIResponse<any>> { ): Promise<APIResponse<any>> {
return this.getPrivate('/spot/v1/open-orders', { return this.getPrivate('/spot/v1/open-orders', {
symbol, symbol,
@@ -147,7 +150,7 @@ export class SpotClient extends BaseRestClient {
getPastOrders( getPastOrders(
symbol?: string, symbol?: string,
orderId?: string, orderId?: string,
limit?: number limit?: number,
): Promise<APIResponse<any>> { ): Promise<APIResponse<any>> {
return this.getPrivate('/spot/v1/history-orders', { return this.getPrivate('/spot/v1/history-orders', {
symbol, symbol,
@@ -160,7 +163,7 @@ export class SpotClient extends BaseRestClient {
symbol?: string, symbol?: string,
limit?: number, limit?: number,
fromId?: number, fromId?: number,
toId?: number toId?: number,
): Promise<APIResponse<any>> { ): Promise<APIResponse<any>> {
return this.getPrivate('/spot/v1/myTrades', { return this.getPrivate('/spot/v1/myTrades', {
symbol, symbol,

View File

@@ -25,6 +25,10 @@ import BaseRestClient from './util/BaseRestClient';
/** /**
* REST API client for USDC Option APIs * REST API client for USDC Option APIs
*
* @deprecated WARNING: V1/V2 private endpoints (Rest API & Websocket Stream) for mainnet
* will be switched off gradually from 30 Oct 2023 UTC, so they are not promised a stability.
* Please note that you are at your own risk of using old endpoints going forward, and please move to V5 ASAP.
*/ */
export class USDCOptionClient extends BaseRestClient { export class USDCOptionClient extends BaseRestClient {
getClientType() { getClientType() {
@@ -49,7 +53,7 @@ export class USDCOptionClient extends BaseRestClient {
/** Fetch trading rules (such as min/max qty). Query for all if blank. */ /** Fetch trading rules (such as min/max qty). Query for all if blank. */
getContractInfo( getContractInfo(
params?: USDCOptionsContractInfoRequest params?: USDCOptionsContractInfoRequest,
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.get('/option/usdc/openapi/public/v1/symbols', params); return this.get('/option/usdc/openapi/public/v1/symbols', params);
} }
@@ -61,18 +65,18 @@ export class USDCOptionClient extends BaseRestClient {
/** Get delivery information */ /** Get delivery information */
getDeliveryPrice( getDeliveryPrice(
params?: USDCOptionsDeliveryPriceRequest params?: USDCOptionsDeliveryPriceRequest,
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.get('/option/usdc/openapi/public/v1/delivery-price', params); return this.get('/option/usdc/openapi/public/v1/delivery-price', params);
} }
/** Returned records are Taker Buy in default. */ /** Returned records are Taker Buy in default. */
getLast500Trades( getLast500Trades(
params: USDCOptionsRecentTradesRequest params: USDCOptionsRecentTradesRequest,
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.get( return this.get(
'/option/usdc/openapi/public/v1/query-trade-latest', '/option/usdc/openapi/public/v1/query-trade-latest',
params params,
); );
} }
@@ -84,11 +88,11 @@ export class USDCOptionClient extends BaseRestClient {
* Both startTime & endTime entered together or both are left blank * Both startTime & endTime entered together or both are left blank
*/ */
getHistoricalVolatility( getHistoricalVolatility(
params?: USDCOptionsHistoricalVolatilityRequest params?: USDCOptionsHistoricalVolatilityRequest,
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.get( return this.get(
'/option/usdc/openapi/public/v1/query-historical-volatility', '/option/usdc/openapi/public/v1/query-historical-volatility',
params params,
); );
} }
@@ -108,7 +112,7 @@ export class USDCOptionClient extends BaseRestClient {
submitOrder(params: USDCOptionsOrderRequest): Promise<APIResponseV3<any>> { submitOrder(params: USDCOptionsOrderRequest): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/openapi/private/v1/place-order', '/option/usdc/openapi/private/v1/place-order',
params params,
); );
} }
@@ -116,91 +120,91 @@ export class USDCOptionClient extends BaseRestClient {
* Each request supports a max. of four orders. The reduceOnly parameter should be separate and unique for each order in the request. * Each request supports a max. of four orders. The reduceOnly parameter should be separate and unique for each order in the request.
*/ */
batchSubmitOrders( batchSubmitOrders(
orderRequest: USDCOptionsOrderRequest[] orderRequest: USDCOptionsOrderRequest[],
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/openapi/private/v1/batch-place-orders', '/option/usdc/openapi/private/v1/batch-place-orders',
{ orderRequest } { orderRequest },
); );
} }
/** For Options, at least one of the three parameters — price, quantity or implied volatility — must be input. */ /** For Options, at least one of the three parameters — price, quantity or implied volatility — must be input. */
modifyOrder( modifyOrder(
params: USDCOptionsModifyOrderRequest params: USDCOptionsModifyOrderRequest,
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/openapi/private/v1/replace-order', '/option/usdc/openapi/private/v1/replace-order',
params params,
); );
} }
/** Each request supports a max. of four orders. The reduceOnly parameter should be separate and unique for each order in the request. */ /** Each request supports a max. of four orders. The reduceOnly parameter should be separate and unique for each order in the request. */
batchModifyOrders( batchModifyOrders(
replaceOrderRequest: USDCOptionsModifyOrderRequest[] replaceOrderRequest: USDCOptionsModifyOrderRequest[],
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/openapi/private/v1/batch-replace-orders', '/option/usdc/openapi/private/v1/batch-replace-orders',
{ replaceOrderRequest } { replaceOrderRequest },
); );
} }
/** Cancel order */ /** Cancel order */
cancelOrder( cancelOrder(
params: USDCOptionsCancelOrderRequest params: USDCOptionsCancelOrderRequest,
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/openapi/private/v1/cancel-order', '/option/usdc/openapi/private/v1/cancel-order',
params params,
); );
} }
/** Batch cancel orders */ /** Batch cancel orders */
batchCancelOrders( batchCancelOrders(
cancelRequest: USDCOptionsCancelOrderRequest[] cancelRequest: USDCOptionsCancelOrderRequest[],
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/openapi/private/v1/batch-cancel-orders', '/option/usdc/openapi/private/v1/batch-cancel-orders',
{ cancelRequest } { cancelRequest },
); );
} }
/** This is used to cancel all active orders. The real-time response indicates whether the request is successful, depending on retCode. */ /** This is used to cancel all active orders. The real-time response indicates whether the request is successful, depending on retCode. */
cancelActiveOrders( cancelActiveOrders(
params?: USDCOptionsCancelAllOrdersRequest params?: USDCOptionsCancelAllOrdersRequest,
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/openapi/private/v1/cancel-all', '/option/usdc/openapi/private/v1/cancel-all',
params params,
); );
} }
/** Query Unfilled/Partially Filled Orders(real-time), up to last 7 days of partially filled/unfilled orders */ /** Query Unfilled/Partially Filled Orders(real-time), up to last 7 days of partially filled/unfilled orders */
getActiveRealtimeOrders( getActiveRealtimeOrders(
params?: USDCOptionsActiveOrdersRealtimeRequest params?: USDCOptionsActiveOrdersRealtimeRequest,
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.getPrivate( return this.getPrivate(
'/option/usdc/openapi/private/v1/trade/query-active-orders', '/option/usdc/openapi/private/v1/trade/query-active-orders',
params params,
); );
} }
/** Query Unfilled/Partially Filled Orders */ /** Query Unfilled/Partially Filled Orders */
getActiveOrders( getActiveOrders(
params: USDCOptionsActiveOrdersRequest params: USDCOptionsActiveOrdersRequest,
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/openapi/private/v1/query-active-orders', '/option/usdc/openapi/private/v1/query-active-orders',
params params,
); );
} }
/** Query order history. The endpoint only supports up to 30 days of queried records */ /** Query order history. The endpoint only supports up to 30 days of queried records */
getHistoricOrders( getHistoricOrders(
params: USDCOptionsHistoricOrdersRequest params: USDCOptionsHistoricOrdersRequest,
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/openapi/private/v1/query-order-history', '/option/usdc/openapi/private/v1/query-order-history',
params params,
); );
} }
@@ -210,11 +214,11 @@ export class USDCOptionClient extends BaseRestClient {
* An error will be returned if startTime is more than 30 days. * An error will be returned if startTime is more than 30 days.
*/ */
getOrderExecutionHistory( getOrderExecutionHistory(
params: USDCOptionsOrderExecutionRequest params: USDCOptionsOrderExecutionRequest,
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/openapi/private/v1/execution-list', '/option/usdc/openapi/private/v1/execution-list',
params params,
); );
} }
@@ -222,18 +226,18 @@ export class USDCOptionClient extends BaseRestClient {
/** The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */ /** The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */
getTransactionLog( getTransactionLog(
params: USDCTransactionLogRequest params: USDCTransactionLogRequest,
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/openapi/private/v1/query-transaction-log', '/option/usdc/openapi/private/v1/query-transaction-log',
params params,
); );
} }
/** Wallet info for USDC account. */ /** Wallet info for USDC account. */
getBalances(): Promise<APIResponseV3<any>> { getBalances(): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/openapi/private/v1/query-wallet-balance' '/option/usdc/openapi/private/v1/query-wallet-balance',
); );
} }
@@ -241,7 +245,7 @@ export class USDCOptionClient extends BaseRestClient {
getAssetInfo(baseCoin?: string): Promise<APIResponseV3<any>> { getAssetInfo(baseCoin?: string): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/openapi/private/v1/query-asset-info', '/option/usdc/openapi/private/v1/query-asset-info',
{ baseCoin } { baseCoin },
); );
} }
@@ -252,18 +256,18 @@ export class USDCOptionClient extends BaseRestClient {
* Rest API returns the result of checking prerequisites. You could get the real status of margin mode change by subscribing margin mode. * Rest API returns the result of checking prerequisites. You could get the real status of margin mode change by subscribing margin mode.
*/ */
setMarginMode( setMarginMode(
newMarginMode: 'REGULAR_MARGIN' | 'PORTFOLIO_MARGIN' newMarginMode: 'REGULAR_MARGIN' | 'PORTFOLIO_MARGIN',
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/private/asset/account/setMarginMode', '/option/usdc/private/asset/account/setMarginMode',
{ setMarginMode: newMarginMode } { setMarginMode: newMarginMode },
); );
} }
/** Query margin mode for USDC account. */ /** Query margin mode for USDC account. */
getMarginMode(): Promise<APIResponseV3<any>> { getMarginMode(): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/openapi/private/v1/query-margin-info' '/option/usdc/openapi/private/v1/query-margin-info',
); );
} }
@@ -273,27 +277,27 @@ export class USDCOptionClient extends BaseRestClient {
getPositions(params: USDCPositionsRequest): Promise<APIResponseV3<any>> { getPositions(params: USDCPositionsRequest): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/openapi/private/v1/query-position', '/option/usdc/openapi/private/v1/query-position',
params params,
); );
} }
/** Query Delivery History */ /** Query Delivery History */
getDeliveryHistory( getDeliveryHistory(
params: USDCOptionsDeliveryHistoryRequest params: USDCOptionsDeliveryHistoryRequest,
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/openapi/private/v1/query-delivery-list', '/option/usdc/openapi/private/v1/query-delivery-list',
params params,
); );
} }
/** Query Positions Info Upon Expiry */ /** Query Positions Info Upon Expiry */
getPositionsInfoUponExpiry( getPositionsInfoUponExpiry(
params?: USDCOptionsPositionsInfoExpiryRequest params?: USDCOptionsPositionsInfoExpiryRequest,
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/openapi/private/v1/query-position-exp-date', '/option/usdc/openapi/private/v1/query-position-exp-date',
params params,
); );
} }
@@ -303,7 +307,7 @@ export class USDCOptionClient extends BaseRestClient {
modifyMMP(params: USDCOptionsModifyMMPRequest): Promise<APIResponseV3<any>> { modifyMMP(params: USDCOptionsModifyMMPRequest): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/openapi/private/v1/mmp-modify', '/option/usdc/openapi/private/v1/mmp-modify',
params params,
); );
} }

View File

@@ -23,6 +23,10 @@ import BaseRestClient from './util/BaseRestClient';
/** /**
* REST API client for USDC Perpetual APIs * REST API client for USDC Perpetual APIs
*
* @deprecated WARNING: V1/V2 private endpoints (Rest API & Websocket Stream) for mainnet
* will be switched off gradually from 30 Oct 2023 UTC, so they are not promised a stability.
* Please note that you are at your own risk of using old endpoints going forward, and please move to V5 ASAP.
*/ */
export class USDCPerpetualClient extends BaseRestClient { export class USDCPerpetualClient extends BaseRestClient {
getClientType() { getClientType() {
@@ -47,7 +51,7 @@ export class USDCPerpetualClient extends BaseRestClient {
/** Fetch trading rules (such as min/max qty). Query for all if blank. */ /** Fetch trading rules (such as min/max qty). Query for all if blank. */
getContractInfo( getContractInfo(
params?: USDCSymbolDirectionLimit params?: USDCSymbolDirectionLimit,
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.get('/perpetual/usdc/openapi/public/v1/symbols', params); return this.get('/perpetual/usdc/openapi/public/v1/symbols', params);
} }
@@ -64,48 +68,48 @@ export class USDCPerpetualClient extends BaseRestClient {
getMarkPrice(params: USDCKlineRequest): Promise<APIResponseV3<any>> { getMarkPrice(params: USDCKlineRequest): Promise<APIResponseV3<any>> {
return this.get( return this.get(
'/perpetual/usdc/openapi/public/v1/mark-price-kline', '/perpetual/usdc/openapi/public/v1/mark-price-kline',
params params,
); );
} }
getIndexPrice(params: USDCKlineRequest): Promise<APIResponseV3<any>> { getIndexPrice(params: USDCKlineRequest): Promise<APIResponseV3<any>> {
return this.get( return this.get(
'/perpetual/usdc/openapi/public/v1/index-price-kline', '/perpetual/usdc/openapi/public/v1/index-price-kline',
params params,
); );
} }
getIndexPremium(params: USDCKlineRequest): Promise<APIResponseV3<any>> { getIndexPremium(params: USDCKlineRequest): Promise<APIResponseV3<any>> {
return this.get( return this.get(
'/perpetual/usdc/openapi/public/v1/premium-index-kline', '/perpetual/usdc/openapi/public/v1/premium-index-kline',
params params,
); );
} }
getOpenInterest( getOpenInterest(
params: USDCOpenInterestRequest params: USDCOpenInterestRequest,
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.get('/perpetual/usdc/openapi/public/v1/open-interest', params); return this.get('/perpetual/usdc/openapi/public/v1/open-interest', params);
} }
getLargeOrders( getLargeOrders(
params: SymbolLimitParam<string> params: SymbolLimitParam<string>,
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.get('/perpetual/usdc/openapi/public/v1/big-deal', params); return this.get('/perpetual/usdc/openapi/public/v1/big-deal', params);
} }
getLongShortRatio( getLongShortRatio(
params: SymbolPeriodLimitParam<string> params: SymbolPeriodLimitParam<string>,
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.get('/perpetual/usdc/openapi/public/v1/account-ratio', params); return this.get('/perpetual/usdc/openapi/public/v1/account-ratio', params);
} }
getLast500Trades( getLast500Trades(
params: USDCLast500TradesRequest params: USDCLast500TradesRequest,
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.get( return this.get(
'/option/usdc/openapi/public/v1/query-trade-latest', '/option/usdc/openapi/public/v1/query-trade-latest',
params params,
); );
} }
@@ -125,7 +129,7 @@ export class USDCPerpetualClient extends BaseRestClient {
submitOrder(params: USDCPerpOrderRequest): Promise<APIResponseV3<any>> { submitOrder(params: USDCPerpOrderRequest): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/perpetual/usdc/openapi/private/v1/place-order', '/perpetual/usdc/openapi/private/v1/place-order',
params params,
); );
} }
@@ -133,7 +137,7 @@ export class USDCPerpetualClient extends BaseRestClient {
modifyOrder(params: USDCPerpModifyOrderRequest): Promise<APIResponseV3<any>> { modifyOrder(params: USDCPerpModifyOrderRequest): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/perpetual/usdc/openapi/private/v1/replace-order', '/perpetual/usdc/openapi/private/v1/replace-order',
params params,
); );
} }
@@ -141,14 +145,14 @@ export class USDCPerpetualClient extends BaseRestClient {
cancelOrder(params: USDCPerpCancelOrderRequest): Promise<APIResponseV3<any>> { cancelOrder(params: USDCPerpCancelOrderRequest): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/perpetual/usdc/openapi/private/v1/cancel-order', '/perpetual/usdc/openapi/private/v1/cancel-order',
params params,
); );
} }
/** Cancel all active orders. The real-time response indicates whether the request is successful, depending on retCode. */ /** Cancel all active orders. The real-time response indicates whether the request is successful, depending on retCode. */
cancelActiveOrders( cancelActiveOrders(
symbol: string, symbol: string,
orderFilter: USDCOrderFilter orderFilter: USDCOrderFilter,
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.postPrivate('/perpetual/usdc/openapi/private/v1/cancel-all', { return this.postPrivate('/perpetual/usdc/openapi/private/v1/cancel-all', {
symbol, symbol,
@@ -158,31 +162,31 @@ export class USDCPerpetualClient extends BaseRestClient {
/** Query Unfilled/Partially Filled Orders */ /** Query Unfilled/Partially Filled Orders */
getActiveOrders( getActiveOrders(
params: USDCPerpActiveOrdersRequest params: USDCPerpActiveOrdersRequest,
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/openapi/private/v1/query-active-orders', '/option/usdc/openapi/private/v1/query-active-orders',
params params,
); );
} }
/** Query order history. The endpoint only supports up to 30 days of queried records */ /** Query order history. The endpoint only supports up to 30 days of queried records */
getHistoricOrders( getHistoricOrders(
params: USDCPerpHistoricOrdersRequest params: USDCPerpHistoricOrdersRequest,
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/openapi/private/v1/query-order-history', '/option/usdc/openapi/private/v1/query-order-history',
params params,
); );
} }
/** Query trade history. The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */ /** Query trade history. The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */
getOrderExecutionHistory( getOrderExecutionHistory(
params: USDCPerpActiveOrdersRequest params: USDCPerpActiveOrdersRequest,
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/openapi/private/v1/execution-list', '/option/usdc/openapi/private/v1/execution-list',
params params,
); );
} }
@@ -190,18 +194,18 @@ export class USDCPerpetualClient extends BaseRestClient {
/** The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */ /** The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */
getTransactionLog( getTransactionLog(
params: USDCTransactionLogRequest params: USDCTransactionLogRequest,
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/openapi/private/v1/query-transaction-log', '/option/usdc/openapi/private/v1/query-transaction-log',
params params,
); );
} }
/** Wallet info for USDC account. */ /** Wallet info for USDC account. */
getBalances(): Promise<APIResponseV3<any>> { getBalances(): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/openapi/private/v1/query-wallet-balance' '/option/usdc/openapi/private/v1/query-wallet-balance',
); );
} }
@@ -209,7 +213,7 @@ export class USDCPerpetualClient extends BaseRestClient {
getAssetInfo(baseCoin?: string): Promise<APIResponseV3<any>> { getAssetInfo(baseCoin?: string): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/openapi/private/v1/query-asset-info', '/option/usdc/openapi/private/v1/query-asset-info',
{ baseCoin } { baseCoin },
); );
} }
@@ -220,18 +224,18 @@ export class USDCPerpetualClient extends BaseRestClient {
* Rest API returns the result of checking prerequisites. You could get the real status of margin mode change by subscribing margin mode. * Rest API returns the result of checking prerequisites. You could get the real status of margin mode change by subscribing margin mode.
*/ */
setMarginMode( setMarginMode(
newMarginMode: 'REGULAR_MARGIN' | 'PORTFOLIO_MARGIN' newMarginMode: 'REGULAR_MARGIN' | 'PORTFOLIO_MARGIN',
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/private/asset/account/setMarginMode', '/option/usdc/private/asset/account/setMarginMode',
{ setMarginMode: newMarginMode } { setMarginMode: newMarginMode },
); );
} }
/** Query margin mode for USDC account. */ /** Query margin mode for USDC account. */
getMarginMode(): Promise<APIResponseV3<any>> { getMarginMode(): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/openapi/private/v1/query-margin-info' '/option/usdc/openapi/private/v1/query-margin-info',
); );
} }
@@ -241,7 +245,7 @@ export class USDCPerpetualClient extends BaseRestClient {
getPositions(params: USDCPositionsRequest): Promise<APIResponseV3<any>> { getPositions(params: USDCPositionsRequest): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/openapi/private/v1/query-position', '/option/usdc/openapi/private/v1/query-position',
params params,
); );
} }
@@ -249,17 +253,17 @@ export class USDCPerpetualClient extends BaseRestClient {
setLeverage(symbol: string, leverage: string): Promise<APIResponseV3<any>> { setLeverage(symbol: string, leverage: string): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/perpetual/usdc/openapi/private/v1/position/leverage/save', '/perpetual/usdc/openapi/private/v1/position/leverage/save',
{ symbol, leverage } { symbol, leverage },
); );
} }
/** Query Settlement History */ /** Query Settlement History */
getSettlementHistory( getSettlementHistory(
params?: USDCSymbolDirectionLimitCursor params?: USDCSymbolDirectionLimitCursor,
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/option/usdc/openapi/private/v1/session-settlement', '/option/usdc/openapi/private/v1/session-settlement',
params params,
); );
} }
@@ -271,7 +275,7 @@ export class USDCPerpetualClient extends BaseRestClient {
'/perpetual/usdc/openapi/public/v1/risk-limit/list', '/perpetual/usdc/openapi/public/v1/risk-limit/list',
{ {
symbol, symbol,
} },
); );
} }
@@ -279,7 +283,7 @@ export class USDCPerpetualClient extends BaseRestClient {
setRiskLimit(symbol: string, riskId: number): Promise<APIResponseV3<any>> { setRiskLimit(symbol: string, riskId: number): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/perpetual/usdc/openapi/private/v1/position/set-risk-limit', '/perpetual/usdc/openapi/private/v1/position/set-risk-limit',
{ symbol, riskId } { symbol, riskId },
); );
} }
@@ -296,7 +300,7 @@ export class USDCPerpetualClient extends BaseRestClient {
getPredictedFundingRate(symbol: string): Promise<APIResponseV3<any>> { getPredictedFundingRate(symbol: string): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/perpetual/usdc/openapi/private/v1/predicted-funding', '/perpetual/usdc/openapi/private/v1/predicted-funding',
{ symbol } { symbol },
); );
} }