Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

okx-api

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

okx-api - npm Package Compare versions

Comparing version 0.0.2 to 0.0.4

lib/constants/funding.d.ts

1

lib/index.d.ts
export * from './rest-client';
export * from './util/typeGuards';
export * from './constants';

@@ -19,3 +19,4 @@ "use strict";

__exportStar(require("./util/typeGuards"), exports);
__exportStar(require("./constants"), exports);
// export * from './util/WsStore';
//# sourceMappingURL=index.js.map

181

lib/rest-client.d.ts
import { AxiosRequestConfig } from 'axios';
import { OKXEnvironment, RestClientOptions } from './util/requestUtils';
import BaseRestClient, { APICredentials } from './util/BaseRestClient';
import { ContractGridDirection, GridAlgoOrderType, GridAlgoSubOrderType, InstrumentType, MarginMode, numberInString, Ticker, AlgoOrderRequest, AmendOrderRequest, CancelAlgoOrderRequest, OrderIdRequest, ClosePositionRequest, OrderRequest, OrderHistoryRequest, FillsHistoryRequest, AlgoRecentHistoryRequest, AlgoLongHistoryRequest, PaginatedSymbolRequest, OrderResult, CancelledOrderResult, AmendedOrder, ClosedPositions, OrderDetails, OrderListItem, HistoricOrder, OrderFill, AlgoOrderResult, AlgoOrderListItem, HistoricAlgoOrder, BlockCounterParty, CreateBlockRFQRequest, CreateRFQResult, CancelBlockRFQRequest, CancelBlockQuoteResult, CancelMultipleBlockRFQRequest, TimestampObject, ExecuteBlockQuoteResult, ExecuteBlockQuoteRequest, CreateBlockQuoteRequest, CreateBlockQuoteResult, CancelBlockRFQResult, CancelBlockQuoteRequest, CancelMultipleBlockQuoteRequest, BlockRFQResult, GetBlockRFQSParams, GetBlockQuoteParams, GetBlockQuoteResult, FundingCurrency, FundingBalance, AccountAssetValuation, FundTransferResult, FundTransferState, AssetBillDetails, AccountBalance, GetPositionsParams, AccountPosition, GetHistoricPositionParams, HistoricAccountPosition, AccountPositionRisk, AccountBill, AccountConfiguration, AccountPositionModeResult, AccountLeverageResult, AccountMaxOrderAmount, AccountMaxTradableAmount, AccountChangeMarginResult, AccountLeverage, AccountMaxLoan, AccountFeeRate, AccountIsolatedMode, SubAccount, SubAccountAPIReset, SubAccountBalances, SubAccountTransferResult, IndexTicker, OrderBook, Candle, CandleNoVolume, Trade } from './types/rest';
import { ContractGridDirection, GridAlgoOrderType, GridAlgoSubOrderType, InstrumentType, MarginMode, numberInString, Ticker, AlgoOrderRequest, AmendOrderRequest, CancelAlgoOrderRequest, OrderIdRequest, ClosePositionRequest, OrderRequest, OrderHistoryRequest, FillsHistoryRequest, AlgoRecentHistoryRequest, AlgoLongHistoryRequest, PaginatedSymbolRequest, OrderResult, CancelledOrderResult, AmendedOrder, ClosedPositions, OrderDetails, OrderListItem, HistoricOrder, OrderFill, AlgoOrderResult, AlgoOrderListItem, HistoricAlgoOrder, BlockCounterParty, CreateBlockRFQRequest, CreateRFQResult, CancelBlockRFQRequest, CancelBlockQuoteResult, CancelMultipleBlockRFQRequest, TimestampObject, ExecuteBlockQuoteResult, ExecuteBlockQuoteRequest, CreateBlockQuoteRequest, CreateBlockQuoteResult, CancelBlockRFQResult, CancelBlockQuoteRequest, CancelMultipleBlockQuoteRequest, BlockRFQResult, GetBlockRFQSParams, GetBlockQuoteParams, GetBlockQuoteResult, FundingCurrency, FundingBalance, AccountAssetValuation, FundTransferResult, FundTransferState, AssetBillDetails, AccountBalance, GetPositionsParams, AccountPosition, GetHistoricPositionParams, HistoricAccountPosition, AccountPositionRisk, AccountBill, AccountConfiguration, AccountPositionModeResult, AccountLeverageResult, AccountMaxOrderAmount, AccountMaxTradableAmount, AccountChangeMarginResult, AccountLeverage, AccountMaxLoan, AccountFeeRate, AccountIsolatedMode, SubAccount, SubAccountAPIReset, SubAccountBalances, SubAccountTransferResult, IndexTicker, OrderBook, Candle, CandleNoVolume, Trade, Pagination, APIResponse, GetGridAlgoOrdersRequest, FundsTransferRequest, WithdrawRequest, ConvertTradeRequest, ConvertQuoteEstimateRequest, SetLeverageRequest, ChangePositionMarginRequest, SubAccountTransferRequest, GridAlgoOrderRequest, StopGridAlgoOrderRequest } from './types/rest';
import { ASSET_BILL_TYPE } from './constants';
export declare class RestClient extends BaseRestClient {

@@ -16,4 +17,4 @@ /**

*/
placeOrder(params: OrderRequest): Promise<OrderResult[]>;
placeMultipleOrders(params: OrderRequest[]): Promise<OrderResult[]>;
submitOrder(params: OrderRequest): Promise<OrderResult[]>;
submitMultipleOrders(params: OrderRequest[]): Promise<OrderResult[]>;
cancelOrder(params: OrderIdRequest): Promise<CancelledOrderResult[]>;

@@ -47,4 +48,29 @@ cancelMultipleOrders(params: OrderIdRequest[]): Promise<CancelledOrderResult[]>;

getAlgoOrderHistory(params: AlgoLongHistoryRequest): Promise<HistoricAlgoOrder[]>;
/** Get easy convert currency list */
getEasyConvertCurrencies(): Promise<any>;
/**
* Place easy convert : Convert small currencies to mainstream currencies.
* Only applicable to the crypto balance less than $10.
*
* Maximum 5 currencies can be selected in one order.
* If there are multiple currencies, separate them with commas in the "from" field.
*/
submitEasyConvert(fromCcys: string[], toCcy: string): Promise<APIResponse<any>>;
/** Get easy convert history : Get the history and status of easy convert trades. */
getEasyConvertHistory(params?: Pagination): Promise<APIResponse<any>>;
/**
* Get one-click repay currency list : Get list of debt currency data and repay currencies.
* Debt currencies include both cross and isolated debts.
*/
getOneClickRepayCurrencyList(debtType?: 'cross' | 'isolated'): Promise<APIResponse<any>>;
/**
* Trade one-click repay to repay cross debts.
* Isolated debts are not applicable.
* The maximum repayment amount is based on the remaining available balance of funding and trading accounts.
*/
submitOneClickRepay(debtCcys: string[], repayCcy: string): Promise<APIResponse<any>>;
/** Get the history and status of one-click repay trades. */
getOneClickRepayHistory(params?: Pagination): Promise<APIResponse<any>>;
/**
*
* Block trading endpoints (private)

@@ -55,3 +81,3 @@ *

createBlockRFQ(params: CreateBlockRFQRequest): Promise<CreateRFQResult[]>;
cancelBlockRFQ(params?: CancelBlockRFQRequest): Promise<CancelBlockRFQResult[]>;
cancelBlockRFQ(params: CancelBlockRFQRequest): Promise<CancelBlockRFQResult[]>;
cancelMultipleBlockRFQs(params: CancelMultipleBlockRFQRequest): Promise<CancelBlockRFQResult[]>;

@@ -66,4 +92,4 @@ cancelAllRFQs(): Promise<TimestampObject[]>;

getBlockQuotes(params?: GetBlockQuoteParams): Promise<GetBlockQuoteResult[]>;
getBlockTrades(params: unknown): Promise<unknown[]>;
getPublicRFQBlockTrades(params: unknown): Promise<unknown[]>;
getBlockTrades(params?: unknown): Promise<unknown[]>;
getPublicRFQBlockTrades(params?: unknown): Promise<unknown[]>;
/**

@@ -77,3 +103,4 @@ *

getAccountAssetValuation(ccy?: string): Promise<AccountAssetValuation[]>;
fundsTransfer(params: unknown): Promise<FundTransferResult[]>;
fundsTransfer(params: FundsTransferRequest): Promise<FundTransferResult[]>;
/** Either parameter transId or clientId is required. */
getFundsTransferState(params: {

@@ -86,3 +113,3 @@ transId?: string;

ccy?: string;
type?: numberInString;
type?: `${ASSET_BILL_TYPE}`;
clientId?: string;

@@ -95,5 +122,5 @@ after?: numberInString;

getDepositAddress(ccy: string): Promise<unknown[]>;
getDepositHistory(params: unknown): Promise<unknown[]>;
withdraw(params: unknown): Promise<unknown[]>;
withdrawLightning(ccy: string, invoice: string, memo?: string): Promise<unknown[]>;
getDepositHistory(params?: unknown): Promise<unknown[]>;
submitWithdraw(params: WithdrawRequest): Promise<unknown[]>;
submitWithdrawLightning(ccy: string, invoice: string, memo?: string): Promise<unknown[]>;
cancelWithdrawal(wdId: string): Promise<unknown[]>;

@@ -115,4 +142,4 @@ getWithdrawalHistory(params?: unknown): Promise<unknown[]>;

getConvertCurrencyPair(fromCcy: string, toCcy: string): Promise<unknown[]>;
estimateConvertQuote(params: unknown): Promise<unknown[]>;
convertTrade(params: unknown): Promise<unknown[]>;
estimateConvertQuote(params: ConvertQuoteEstimateRequest): Promise<unknown[]>;
convertTrade(params: ConvertTradeRequest): Promise<unknown[]>;
getConvertHistory(params?: unknown): Promise<unknown[]>;

@@ -134,7 +161,20 @@ /**

setPositionMode(posMode: 'long_short_mode' | 'net'): Promise<AccountPositionModeResult[]>;
setLeverage(params: unknown): Promise<AccountLeverageResult[]>;
setLeverage(params: SetLeverageRequest): Promise<AccountLeverageResult[]>;
/** Max buy/sell amount or open amount */
getMaxOrderAmount(params: unknown): Promise<AccountMaxOrderAmount[]>;
getMaxAvailableTradableAmount(params: unknown): Promise<AccountMaxTradableAmount[]>;
changePositionMargin(params: unknown): Promise<AccountChangeMarginResult[]>;
getMaxBuySellAmount(params: {
instId: string;
tdMode: 'cross' | 'isolated' | 'cash';
ccy?: string;
px?: string;
leverage?: string;
unSpotOffset?: boolean;
}): Promise<AccountMaxOrderAmount[]>;
getMaxAvailableTradableAmount(params: {
instId: string;
ccy?: string;
tdMode: 'cross' | 'isolated' | 'cash';
reduceOnly?: boolean;
unSpotOffset?: boolean;
}): Promise<AccountMaxTradableAmount[]>;
changePositionMargin(params: ChangePositionMarginRequest): Promise<AccountChangeMarginResult[]>;
getLeverage(instId: string, mgnMode: MarginMode): Promise<AccountLeverage[]>;

@@ -149,3 +189,3 @@ getMaxLoan(instId: string, mgnMode: MarginMode, mgnCcy?: string): Promise<AccountMaxLoan[]>;

getAccountRiskState(): Promise<unknown[]>;
VIPLoanBorrowRepay(ccy: string, side: 'borrow' | 'repay', amt: numberInString): Promise<unknown[]>;
borrowRepayVIPLoan(ccy: string, side: 'borrow' | 'repay', amt: numberInString): Promise<unknown[]>;
getVIPLoanBorrowRepayHistory(params?: unknown): Promise<unknown[]>;

@@ -158,3 +198,7 @@ getBorrowInterestLimits(params?: {

getGreeks(ccy?: string): Promise<unknown[]>;
getPMLimitation(instType: 'SWAP' | 'FUTURES' | 'OPTION', uly: string): Promise<unknown[]>;
getPMLimitation(params: {
instType: 'SWAP' | 'FUTURES' | 'OPTION';
uly?: string;
instFamily?: string;
}): Promise<unknown[]>;
/**

@@ -165,3 +209,5 @@ *

*/
/** View sub-account list */
getSubAccountList(params?: unknown): Promise<SubAccount[]>;
/** Reset the APIKey of a sub-account */
resetSubAccountAPIKey(subAcct: string, apiKey: string, options?: {

@@ -172,8 +218,21 @@ label?: string;

}): Promise<SubAccountAPIReset[]>;
/** Get sub-account trading balance */
getSubAccountBalances(subAcct: string): Promise<SubAccountBalances[]>;
/** Get sub-account funding balance */
getSubAccountFundingBalances(subAcct: string, ccy?: string): Promise<FundingBalance[]>;
getSubAccountTransferHistory(params?: unknown): Promise<unknown[]>;
transferSubAccountBalance(params: unknown): Promise<SubAccountTransferResult[]>;
/** History of sub-account transfer */
getSubAccountTransferHistory(params?: {
ccy?: string;
type?: '0' | '1';
subAcct?: string;
after?: string;
before?: string;
limit?: string;
}): Promise<unknown[]>;
/** Master accounts manage the transfers between sub-accounts */
transferSubAccountBalance(params: SubAccountTransferRequest): Promise<SubAccountTransferResult[]>;
/** Set Permission Of Transfer Out */
setSubAccountTransferOutPermission(subAcct: string, canTransOut?: boolean): Promise<unknown[]>;
getSubAccountListCustodyTrading(subAcct?: string): Promise<unknown[]>;
/** Get custody trading sub-account list */
getSubAccountCustodyTradingList(subAcct?: string): Promise<unknown[]>;
/**

@@ -184,3 +243,3 @@ *

*/
placeGridAlgoOrder(params: unknown): Promise<unknown[]>;
placeGridAlgoOrder(params: GridAlgoOrderRequest): Promise<unknown[]>;
amendGridAlgoOrder(algoId: string, instId: string, triggerPx: {

@@ -190,5 +249,5 @@ slTriggerPx?: numberInString;

}): Promise<unknown[]>;
stopGridAlgoOrder(algoId: string, instId: string, algoOrdType: GridAlgoOrderType, stopType: '1' | '2'): Promise<unknown[]>;
getGridAlgoOrderList(params: unknown): Promise<unknown[]>;
getGridAlgoOrderHistory(params: unknown): Promise<unknown[]>;
stopGridAlgoOrder(orders: StopGridAlgoOrderRequest[]): Promise<unknown[]>;
getGridAlgoOrderList(params: GetGridAlgoOrdersRequest): Promise<unknown[]>;
getGridAlgoOrderHistory(params: GetGridAlgoOrdersRequest): Promise<unknown[]>;
getGridAlgoOrderDetails(algoOrdType: GridAlgoOrderType, algoId: string): Promise<unknown[]>;

@@ -208,5 +267,41 @@ getGridAlgoSubOrders(algoOrdType: GridAlgoOrderType, algoId: string, type: GridAlgoSubOrderType, groupId?: string, pagination?: {

}): Promise<unknown[]>;
getGridAIParameter(algoOrdType: GridAlgoOrderType, instId: string, direction?: ContractGridDirection, duration?: '7D' | '30D' | '180D'): Promise<unknown[]>;
getGridAIParameter(algoOrdType: GridAlgoOrderType, instId: string, direction: ContractGridDirection, duration?: '7D' | '30D' | '180D'): Promise<unknown[]>;
/**
*
* Earn/staking endpoints (private)
*
*/
/** Get earn offers */
getStakingOffers(params?: {
productId?: string;
protocolType?: 'staking' | 'defi';
ccy?: string;
}): Promise<APIResponse<any>>;
/** Earn/staking purchase */
submitStake(productId: string, investData: {
ccy: string;
amt: string;
}[], term?: string): Promise<APIResponse<any>>;
/** Earn/staking redeem */
redeemStake(ordId: string, protocolType: 'staking' | 'defi', allowEarlyRedeem?: boolean): Promise<APIResponse<any>>;
/** Earn/staking cancel purchases/redemptions */
cancelStakingRequest(ordId: string, protocolType: 'staking' | 'defi'): Promise<APIResponse<any>>;
/** Earn/staking get active orders */
getActiveStakingOrders(params?: {
productId?: string;
protocolType?: 'staking' | 'defi';
ccy?: string;
state?: '8' | '13' | '9' | '1' | '2';
}): Promise<APIResponse<any>>;
/** Earn/staking get order history */
getStakingOrderHistory(params?: {
productId?: string;
protocolType?: string;
ccy?: string;
after?: string;
before?: string;
limit?: string;
}): Promise<APIResponse<any>>;
/**
*
* Market data endpoints (public)

@@ -222,22 +317,8 @@ *

getOrderBook(instId: string, sz?: numberInString): Promise<OrderBook[]>;
getCandles(instId: string, bar?: string, pagination?: {
after?: numberInString;
before?: numberInString;
limit?: numberInString;
}): Promise<Candle[]>;
getHistoricCandles(instId: string, bar?: string, pagination?: {
after?: numberInString;
before?: numberInString;
limit?: numberInString;
}): Promise<Candle[]>;
getIndexCandles(instId: string, bar?: string, pagination?: {
after?: numberInString;
before?: numberInString;
limit?: numberInString;
}): Promise<CandleNoVolume[]>;
getMarkPriceCandles(instId: string, bar?: string, pagination?: {
after?: numberInString;
before?: numberInString;
limit?: numberInString;
}): Promise<CandleNoVolume[]>;
getCandles(instId: string, bar?: string, pagination?: Pagination): Promise<Candle[]>;
getHistoricCandles(instId: string, bar?: string, pagination?: Pagination): Promise<Candle[]>;
getIndexCandles(instId: string, bar?: string, pagination?: Pagination): Promise<CandleNoVolume[]>;
getHistoricIndexCandles(instId: string, bar?: string, pagination?: Pagination): Promise<CandleNoVolume[]>;
getMarkPriceCandles(instId: string, bar?: string, pagination?: Pagination): Promise<CandleNoVolume[]>;
getHistoricMarkPriceCandles(instId: string, bar?: string, pagination?: Pagination): Promise<CandleNoVolume[]>;
getTrades(instId: string, limit?: number): Promise<Trade[]>;

@@ -332,2 +413,8 @@ getHistoricTrades(instId: string, pagination?: {

getSystemStatus(state?: 'scheduled' | 'ongoing' | 'pre_open' | 'completed' | 'canceled'): Promise<unknown[]>;
/**
*
* Broker endpoints (private)
*
*/
getBrokerAccountInformation(): Promise<unknown[]>;
}

@@ -44,6 +44,6 @@ "use strict";

*/
placeOrder(params) {
submitOrder(params) {
return this.postPrivate('/api/v5/trade/order', params);
}
placeMultipleOrders(params) {
submitMultipleOrders(params) {
return this.postPrivate('/api/v5/trade/batch-orders', params);

@@ -111,4 +111,49 @@ }

}
/** Get easy convert currency list */
getEasyConvertCurrencies() {
return this.getPrivate('/api/v5/trade/easy-convert-currency-list');
}
/**
* Place easy convert : Convert small currencies to mainstream currencies.
* Only applicable to the crypto balance less than $10.
*
* Maximum 5 currencies can be selected in one order.
* If there are multiple currencies, separate them with commas in the "from" field.
*/
submitEasyConvert(fromCcys, toCcy) {
return this.postPrivate('/api/v5/trade/easy-convert', {
fromCcy: fromCcys,
toCcy,
});
}
/** Get easy convert history : Get the history and status of easy convert trades. */
getEasyConvertHistory(params) {
return this.getPrivate('/api/v5/trade/easy-convert-history', params);
}
/**
* Get one-click repay currency list : Get list of debt currency data and repay currencies.
* Debt currencies include both cross and isolated debts.
*/
getOneClickRepayCurrencyList(debtType) {
return this.getPrivate('/api/v5/trade/one-click-repay-currency-list', {
debtType,
});
}
/**
* Trade one-click repay to repay cross debts.
* Isolated debts are not applicable.
* The maximum repayment amount is based on the remaining available balance of funding and trading accounts.
*/
submitOneClickRepay(debtCcys, repayCcy) {
return this.postPrivate('/api/v5/trade/one-click-repay', {
debtCcy: debtCcys.join(','),
repayCcy,
});
}
/** Get the history and status of one-click repay trades. */
getOneClickRepayHistory(params) {
return this.getPrivate('/api/v5/trade/one-click-repay-history', params);
}
/**
*
* Block trading endpoints (private)

@@ -176,2 +221,3 @@ *

}
/** Either parameter transId or clientId is required. */
getFundsTransferState(params) {

@@ -192,6 +238,6 @@ return this.getPrivate('/api/v5/asset/transfer-state', params);

}
withdraw(params) {
submitWithdraw(params) {
return this.postPrivate('/api/v5/asset/withdrawal', params);
}
withdrawLightning(ccy, invoice, memo) {
submitWithdrawLightning(ccy, invoice, memo) {
return this.postPrivate('/api/v5/asset/withdrawal-lightning', {

@@ -207,3 +253,3 @@ ccy,

getWithdrawalHistory(params) {
return this.postPrivate('/api/v5/asset/withdrawal-history', params);
return this.getPrivate('/api/v5/asset/withdrawal-history', params);
}

@@ -296,3 +342,3 @@ smallAssetsConvert(ccy) {

/** Max buy/sell amount or open amount */
getMaxOrderAmount(params) {
getMaxBuySellAmount(params) {
return this.getPrivate('/api/v5/account/max-size', params);

@@ -347,3 +393,3 @@ }

}
VIPLoanBorrowRepay(ccy, side, amt) {
borrowRepayVIPLoan(ccy, side, amt) {
return this.postPrivate('/api/v5/account/borrow-repay', { ccy, side, amt });

@@ -363,4 +409,4 @@ }

}
getPMLimitation(instType, uly) {
return this.getPrivate('/api/v5/account/position-tiers', { instType, uly });
getPMLimitation(params) {
return this.getPrivate('/api/v5/account/position-tiers', params);
}

@@ -372,12 +418,16 @@ /**

*/
/** View sub-account list */
getSubAccountList(params) {
return this.getPrivate('/api/v5/users/subaccount/list', params);
}
/** Reset the APIKey of a sub-account */
resetSubAccountAPIKey(subAcct, apiKey, options) {
return this.postPrivate('/api/v5/account/subaccount/balances', Object.assign({ subAcct,
return this.postPrivate('/api/v5/users/subaccount/modify-apikey', Object.assign({ subAcct,
apiKey }, options));
}
/** Get sub-account trading balance */
getSubAccountBalances(subAcct) {
return this.getPrivate('/api/v5/account/subaccount/balances', { subAcct });
}
/** Get sub-account funding balance */
getSubAccountFundingBalances(subAcct, ccy) {

@@ -389,8 +439,11 @@ return this.getPrivate('/api/v5/asset/subaccount/balances', {

}
/** History of sub-account transfer */
getSubAccountTransferHistory(params) {
return this.getPrivate('/api/v5/asset/subaccount/bills', params);
}
/** Master accounts manage the transfers between sub-accounts */
transferSubAccountBalance(params) {
return this.postPrivate('/api/v5/asset/subaccount/transfer', params);
}
/** Set Permission Of Transfer Out */
setSubAccountTransferOutPermission(subAcct, canTransOut = true) {

@@ -402,3 +455,4 @@ return this.postPrivate('/api/v5/users/subaccount/set-transfer-out', {

}
getSubAccountListCustodyTrading(subAcct) {
/** Get custody trading sub-account list */
getSubAccountCustodyTradingList(subAcct) {
return this.getPrivate('/api/v5/users/entrust-subaccount-list', {

@@ -420,9 +474,4 @@ subAcct,

}
stopGridAlgoOrder(algoId, instId, algoOrdType, stopType) {
return this.postPrivate('/api/v5/tradingBot/grid/stop-order-algo', {
algoId,
instId,
algoOrdType,
stopType,
});
stopGridAlgoOrder(orders) {
return this.postPrivate('/api/v5/tradingBot/grid/stop-order-algo', orders);
}

@@ -480,2 +529,42 @@ getGridAlgoOrderList(params) {

*
* Earn/staking endpoints (private)
*
*/
/** Get earn offers */
getStakingOffers(params) {
return this.getPrivate('/api/v5/finance/staking-defi/offers', params);
}
/** Earn/staking purchase */
submitStake(productId, investData, term) {
return this.postPrivate('/api/v5/finance/staking-defi/purchase', {
productId,
investData,
term,
});
}
/** Earn/staking redeem */
redeemStake(ordId, protocolType, allowEarlyRedeem) {
return this.postPrivate('/api/v5/finance/staking-defi/redeem', {
ordId,
protocolType,
allowEarlyRedeem,
});
}
/** Earn/staking cancel purchases/redemptions */
cancelStakingRequest(ordId, protocolType) {
return this.postPrivate('/api/v5/finance/staking-defi/cancel', {
ordId,
protocolType,
});
}
/** Earn/staking get active orders */
getActiveStakingOrders(params) {
return this.getPrivate('/api/v5/finance/staking-defi/orders-active', params);
}
/** Earn/staking get order history */
getStakingOrderHistory(params) {
return this.getPrivate('/api/v5/finance/staking-defi/orders-history', params);
}
/**
*
* Market data endpoints (public)

@@ -513,2 +602,6 @@ *

}
getHistoricIndexCandles(instId, bar = '1m', pagination) {
return this.get('/api/v5/market/history-index-candles', Object.assign({ instId,
bar }, pagination));
}
getMarkPriceCandles(instId, bar = '1m', pagination) {

@@ -518,2 +611,6 @@ return this.get('/api/v5/market/mark-price-candles', Object.assign({ instId,

}
getHistoricMarkPriceCandles(instId, bar = '1m', pagination) {
return this.get('/api/v5/market/historic-mark-price-candles', Object.assign({ instId,
bar }, pagination));
}
getTrades(instId, limit) {

@@ -648,4 +745,13 @@ return this.get('/api/v5/market/trades', { instId, limit });

}
/**
*
* Broker endpoints (private)
*
*/
// TODO: add missing broker endpoints
getBrokerAccountInformation() {
return this.getPrivate('/api/v5/broker/nd/info');
}
}
exports.RestClient = RestClient;
//# sourceMappingURL=rest-client.js.map

@@ -0,4 +1,8 @@

export * from './account';
export * from './convert';
export * from './funding';
export * from './shared';
export * from './private-account';
export * from './private-trade';
export * from './private-block-trading';
export * from './subaccount';
export * from './trade';
export * from './block-trading';
export * from './grid-trading';

@@ -17,6 +17,10 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./account"), exports);
__exportStar(require("./convert"), exports);
__exportStar(require("./funding"), exports);
__exportStar(require("./shared"), exports);
__exportStar(require("./private-account"), exports);
__exportStar(require("./private-trade"), exports);
__exportStar(require("./private-block-trading"), exports);
__exportStar(require("./subaccount"), exports);
__exportStar(require("./trade"), exports);
__exportStar(require("./block-trading"), exports);
__exportStar(require("./grid-trading"), exports);
//# sourceMappingURL=index.js.map

@@ -0,1 +1,2 @@

import { ASSET_BILL_TYPE } from '../../../constants';
export interface FundingCurrency {

@@ -65,4 +66,4 @@ canDep: boolean;

bal: string;
type: string;
type: `${ASSET_BILL_TYPE}`;
ts: string;
}

@@ -10,3 +10,2 @@ export declare type numberInString<T = string> = T;

export declare type ContractGridDirection = 'long' | 'short' | 'neutral';
export declare type GridAlgoOrderType = 'grid' | 'contract_grid';
export declare type GridAlgoSubOrderType = 'live' | 'filled';

@@ -38,1 +37,6 @@ export declare type InstrumentType = 'SPOT' | 'MARGIN' | 'SWAP' | 'FUTURES' | 'OPTION';

}
export interface Pagination {
after?: string;
before?: string;
limit?: string;
}

@@ -7,3 +7,3 @@ import { AxiosRequestConfig } from 'axios';

apiSecret: string;
apiPassphrase: string;
apiPass: string;
}

@@ -17,3 +17,2 @@ export default abstract class BaseRestClient {

private apiPassphrase;
private environment;
constructor(credentials: APICredentials | undefined | null, baseUrl: string, options: RestClientOptions | undefined, requestOptions: AxiosRequestConfig | undefined, environment: OKXEnvironment);

@@ -20,0 +19,0 @@ get(endpoint: string, params?: any): Promise<any>;

@@ -42,4 +42,5 @@ "use strict";

class BaseRestClient {
// private environment: OKXEnvironment;
constructor(credentials, baseUrl, options = {}, requestOptions = {}, environment) {
this.environment = environment;
// this.environment = environment;
this.options = Object.assign({

@@ -51,5 +52,3 @@ // if true, we'll throw errors if any params are undefined

if (credentials &&
(!credentials.apiKey ||
!credentials.apiSecret ||
!credentials.apiPassphrase)) {
(!credentials.apiKey || !credentials.apiSecret || !credentials.apiPass)) {
throw new Error('API Key, Secret AND Passphrase are ALL required for private enpoints');

@@ -68,3 +67,3 @@ }

this.apiSecret = credentials === null || credentials === void 0 ? void 0 : credentials.apiSecret;
this.apiPassphrase = credentials === null || credentials === void 0 ? void 0 : credentials.apiPassphrase;
this.apiPassphrase = credentials === null || credentials === void 0 ? void 0 : credentials.apiPass;
}

@@ -122,2 +121,3 @@ // private isDemoTrading(): boolean {

// sign: signResult.sign,
// options,
// });

@@ -124,0 +124,0 @@ return (0, axios_1.default)(options)

@@ -11,13 +11,13 @@ "use strict";

}
// Original order should be preserved, no sorting allowed here or sign will fail
return ('?' +
Object.keys(params)
.map((key) => {
const value = params[key];
if (strict_validation === true && typeof value === 'undefined') {
throw new Error('Failed to sign API request due to undefined parameter');
}
return `${key}=${value}`;
})
.join('&'));
const queryString = Object.keys(params)
.map((key) => {
const value = params[key];
if (strict_validation === true && typeof value === 'undefined') {
throw new Error('Failed to sign API request due to undefined parameter');
}
return `${key}=${value}`;
})
.join('&');
// Prevent trailing `?` if no params are provided
return queryString ? '?' + queryString : queryString;
}

@@ -24,0 +24,0 @@ exports.serializeParams = serializeParams;

{
"name": "okx-api",
"version": "0.0.2",
"description": "EARLY BETA. Node.js connector for OKX REST APIs and WebSockets, with TypeScript & integration tests.",
"version": "0.0.4",
"description": "Node.js connector for OKX REST APIs and WebSockets, with TypeScript & integration tests.",
"main": "lib/index.js",

@@ -6,0 +6,0 @@ "types": "lib/index.d.ts",

@@ -1,14 +0,22 @@

# okx-api
[![Tests](https://circleci.com/gh/tiagosiebler/okx-api.svg?style=shield)](https://circleci.com/gh/tiagosiebler/okx-api)
[![npm version](https://img.shields.io/npm/v/okx-api)][1] [![npm size](https://img.shields.io/bundlephobia/min/okx-api/latest)][1] [![npm downloads](https://img.shields.io/npm/dt/okx-api)][1]
# Node.js & Typescript OKX (OKEX) API SDK
[![E2E Tests](https://github.com/tiagosiebler/okx-api/actions/workflows/e2etest.yml/badge.svg?branch=master)](https://github.com/tiagosiebler/okx-api/actions/workflows/e2etest.yml) [![npm version](https://img.shields.io/npm/v/okx-api)][1] [![npm size](https://img.shields.io/bundlephobia/min/okx-api/latest)][1] [![npm downloads](https://img.shields.io/npm/dt/okx-api)][1] [![npm version](https://img.shields.io/npm/v/okx-api)][1] [![npm size](https://img.shields.io/bundlephobia/min/okx-api/latest)][1] [![npm downloads](https://img.shields.io/npm/dt/okx-api)][1]
[![last commit](https://img.shields.io/github/last-commit/tiagosiebler/okx-api)][1]
[![CodeFactor](https://www.codefactor.io/repository/github/tiagosiebler/okx-api/badge)](https://www.codefactor.io/repository/github/tiagosiebler/okx-api)
[![connector logo](https://github.com/tiagosiebler/okx-api/blob/master/docs/images/logo1.png?raw=true)][1]
[1]: https://www.npmjs.com/package/okx-api
**WARNING: This package is still early beta! Expect breaking changes until this sees a major release.**
Node.js connector for the OKX APIs ~~and WebSockets~~:
- Complete integration with all OKX APIs.
- WebSocket support coming soon.
- TypeScript support (with type declarations for most API requests & responses).
- Over 100 end-to-end tests making real API calls ~~& WebSocket connections~~, validating any changes before they reach npm.
- Coming soon: robust WebSocket integration with configurable connection heartbeats & automatic reconnect then resubscribe workflows.
- Browser support (via webpack bundle - see "Browser Usage" below).
If you want to stay informed when this may be ready for testing, please get in touch via telegram.
## Beta Release
Node.js connector for the okx APIs and WebSockets, with TypeScript & browser support.
- [x] REST APIs are fully integrated with end to end test coverage
- [ ] WebSocket support is coming soon.

@@ -24,6 +32,6 @@ ## Installation

- Try my connectors:
- [ftx-api](https://www.npmjs.com/package/ftx-api)
- [binance](https://www.npmjs.com/package/binance)
- [bybit-api](https://www.npmjs.com/package/bybit-api)
- [okx-api](https://www.npmjs.com/package/okx-api)
- [binance](https://www.npmjs.com/package/binance)
- [ftx-api](https://www.npmjs.com/package/ftx-api)
- Try my misc utilities:

@@ -35,3 +43,4 @@ - [orderbooks](https://www.npmjs.com/package/orderbooks)

## Documentation
Most methods accept JS objects. These can be populated using parameters specified by okx's API documentation.
Most methods accept JS objects. These can be populated using parameters specified by okx's API documentation, or check the type definition in the rest-client class methods.
- [RestClient](src/rest-client.ts).
- [OKX API Documentation](https://www.okx.com/docs-v5/en/#rest-api).

@@ -78,3 +87,2 @@

- [OKX](https://www.okx.com/join/18504944)
- [FTX](https://ftx.com/referrals#a=ftxapigithub)

@@ -87,1 +95,5 @@ Or buy me a coffee using any of these:

Contributions are encouraged, I will review any incoming pull requests. See the issues tab for todo items.
## Star History
[![Star History Chart](https://api.star-history.com/svg?repos=tiagosiebler/ftx-api,tiagosiebler/bybit-api,tiagosiebler/binance,tiagosiebler/orderbooks,tiagosiebler/okx-api,tiagosiebler/awesome-crypto-examples&type=Date)](https://star-history.com/#tiagosiebler/ftx-api&tiagosiebler/bybit-api&tiagosiebler/binance&tiagosiebler/orderbooks&tiagosiebler/okx-api&tiagosiebler/awesome-crypto-examples&Date)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc