Skip to content

Commit 1a2f07a

Browse files
committed
feat(v3.1.3): enhance API request/response types with new fields and documentation
1 parent 24f46ef commit 1a2f07a

8 files changed

Lines changed: 53 additions & 7 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "okx-api",
3-
"version": "3.1.2",
3+
"version": "3.1.3",
44
"description": "Complete Node.js SDK for OKX's REST APIs and WebSockets, with TypeScript & end-to-end tests",
55
"scripts": {
66
"test": "jest",

src/rest-client.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ import {
297297
OptionTrade,
298298
OptionTrades,
299299
OrderBook,
300+
PublicBorrowHistoryRecord,
300301
SystemTime,
301302
Ticker,
302303
Trade,
@@ -566,6 +567,7 @@ export class RestClient extends BaseRestClient {
566567
instId?: string;
567568
uly?: string;
568569
instFamily?: string;
570+
groupId?: string;
569571
ruleType?: string;
570572
}): Promise<AccountFeeRate[]> {
571573
return this.getPrivate('/api/v5/account/trade-fee', params);
@@ -2493,6 +2495,8 @@ export class RestClient extends BaseRestClient {
24932495
getConvertCurrencyPair(params: {
24942496
fromCcy: string;
24952497
toCcy: string;
2498+
/** 0: standard convert (default), 1: large order convert for VIP */
2499+
convertMode?: '0' | '1';
24962500
}): Promise<any[]> {
24972501
return this.getPrivate('/api/v5/asset/convert/currency-pair', params);
24982502
}
@@ -2772,7 +2776,9 @@ export class RestClient extends BaseRestClient {
27722776
return this.get('/api/v5/finance/savings/lending-rate-summary', params);
27732777
}
27742778

2775-
getPublicBorrowHistory(params?: PaginatedSymbolRequest): Promise<any[]> {
2779+
getPublicBorrowHistory(
2780+
params?: PaginatedSymbolRequest,
2781+
): Promise<PublicBorrowHistoryRecord[]> {
27762782
return this.get('/api/v5/finance/savings/lending-rate-history', params);
27772783
}
27782784

src/types/rest/request/convert.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export interface ConvertQuoteEstimateRequest {
66
rfqSzCcy: string;
77
clTReqId?: string;
88
tag?: string;
9+
/** 0: standard convert (default), 1: large order convert for VIP */
10+
convertMode?: '0' | '1';
911
}
1012
export interface ConvertTradeRequest {
1113
quoteId: string;
@@ -16,4 +18,6 @@ export interface ConvertTradeRequest {
1618
szCcy: string;
1719
clTReqId?: string;
1820
tag?: string;
21+
/** 0: standard convert (default), 1: large order convert for VIP */
22+
convertMode?: '0' | '1';
1923
}

src/types/rest/request/trade.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,10 @@ export interface FillsHistoryRequest {
157157
}
158158

159159
export interface OrderIdRequest {
160-
instId: string;
160+
/** Instrument ID. Deprecated March 2026 for WS; use instIdCode for lower latency. */
161+
instId?: string;
162+
/** Instrument ID code. Takes precedence over instId if both provided. Use Get instruments to map. WS only. */
163+
instIdCode?: number;
161164
ordId?: string;
162165
clOrdId?: string;
163166
}
@@ -202,6 +205,8 @@ export interface OrderRequest {
202205
tradeQuoteCcy?: string;
203206
/** Self trade prevention mode: cancel_maker, cancel_taker, cancel_both. Default is cancel_maker */
204207
stpMode?: 'cancel_maker' | 'cancel_taker' | 'cancel_both';
208+
/** ELP taker access. true = can trade with ELP orders (speed bump applied). Default false. Only applicable to ioc orders */
209+
isElpTakerAccess?: boolean;
205210
/** Take Profit & Stop Loss params */
206211
tpTriggerPx?: string;
207212
tpOrdPx?: string;

src/types/rest/response/private-account.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,17 +396,27 @@ export interface AccountInstrument {
396396
quoteCcy: string;
397397
tradeQuoteCcyList: string[]; // List of quote currencies available for trading, e.g. ["USD", "USDC"]
398398
settleCcy: string;
399+
/** Instrument status: live, suspend, rebase (SWAP only), preopen, test */
399400
state: string;
400401
stk: string;
401402
tickSz: string;
403+
/** Trading rule types: normal, pre_market, rebase_contract */
402404
ruleType: string;
403405
auctionEndTime: string;
404406
futureSettlement: boolean; // Whether daily settlement for expiry feature is enabled. Applicable to FUTURES cross.
405407
instIdCode: number; // Instrument ID code. For simple binary encoding, must use instIdCode instead of instId.
408+
/** Category of instrument's base currency. "1" = Crypto, "3" = Stocks */
409+
instCategory?: string;
406410
posLmtAmt: string; // Maximum position value (USD) for this instrument at the user level. Applicable to SWAP/FUTURES.
407411
posLmtPct: string; // Maximum position ratio (e.g., 30 for 30%) a user may hold relative to platform's current total position value. Applicable to SWAP/FUTURES.
408412
maxPlatOILmt: string; // Platform-wide maximum position value (USD) for this instrument. Applicable to SWAP/FUTURES.
413+
/** Remaining long position value (USD) the user is permitted to open. Applicable to SWAP/FUTURES. */
414+
longPosRemainingQuota?: string;
415+
/** Remaining short position value (USD) the user is permitted to open. Applicable to SWAP/FUTURES. */
416+
shortPosRemainingQuota?: string;
409417
groupId?: string; // Instrument trading fee group ID
418+
/** ELP maker permission. "0" = not enabled, "1" = enabled but no permission, "2" = enabled with permission */
419+
elp?: string;
410420
}
411421

412422
export interface QuickMarginBorrowRepayResult {

src/types/rest/response/public-data.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ export interface Instrument {
105105
minSz: string;
106106
ctType: string;
107107
alias: string;
108+
/** Instrument status: live, suspend, rebase (SWAP only), preopen, test */
108109
state: string;
109110
openType?: string; // Open type: fix_price (fix price opening), pre_quote (pre-quote), call_auction (call auction). Only applicable to SPOT/MARGIN.
110111
maxLmtSz: string;
@@ -115,11 +116,14 @@ export interface Instrument {
115116
maxIcebergSz: string;
116117
maxTriggerSz: string;
117118
maxStopSz: string;
119+
/** Trading rule types: normal, pre_market, rebase_contract */
118120
ruleType: string;
119121
auctionEndTime: string;
120122
futureSettlement?: boolean; // Whether daily settlement for expiry feature is enabled. Applicable to FUTURES cross.
121123
tradeQuoteCcyList?: string[]; // List of quote currencies available for trading, e.g. ["USD", "USDC"]
122124
instIdCode?: number; // Instrument ID code. For simple binary encoding, must use instIdCode instead of instId.
125+
/** Category of instrument's base currency. "1" = Crypto, "3" = Stocks */
126+
instCategory?: string;
123127
posLmtAmt?: string; // Maximum position value (USD) for this instrument at the user level. Applicable to SWAP/FUTURES.
124128
posLmtPct?: string; // Maximum position ratio (e.g., 30 for 30%) a user may hold relative to platform's current total position value. Applicable to SWAP/FUTURES.
125129
maxPlatOILmt?: string; // Platform-wide maximum position value (USD) for this instrument. Applicable to SWAP/FUTURES.
@@ -203,6 +207,15 @@ export interface Announcement {
203207
url: string;
204208
}
205209

210+
/** Public borrow history record (GET /api/v5/finance/savings/lending-rate-history) */
211+
export interface PublicBorrowHistoryRecord {
212+
ccy: string; // Currency, e.g. BTC
213+
amt: string; // Lending amount (deprecated)
214+
rate: string; // Annual borrowing interest rate
215+
lendingRate: string; // Annual lending interest rate
216+
ts: string; // Unix timestamp format in milliseconds
217+
}
218+
206219
export interface BasicInterestRate {
207220
ccy: string; // Currency
208221
rate: string; // Daily borrowing rate

src/types/websockets/ws-api-request.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import {
77
} from '../rest/shared.js';
88

99
export interface WSAPIPlaceOrderRequestV5 {
10-
instId: string;
10+
/** Instrument ID. Deprecated March 2026; use instIdCode for lower latency. */
11+
instId?: string;
12+
/** Instrument ID code. Takes precedence over instId if both provided. Use Get instruments to map. */
13+
instIdCode?: number;
1114
tdMode: TradeMode;
1215
ccy?: string;
1316
clOrdId?: string;
@@ -26,10 +29,15 @@ export interface WSAPIPlaceOrderRequestV5 {
2629
banAmend?: boolean;
2730
tradeQuoteCcy?: string;
2831
stpMode?: 'cancel_maker' | 'cancel_taker' | 'cancel_both';
32+
/** ELP taker access. true = can trade with ELP orders (speed bump applied). Default false. Only applicable to ioc orders */
33+
isElpTakerAccess?: boolean;
2934
}
3035

3136
export interface WSAPIAmendOrderRequestV5 {
32-
instId: string;
37+
/** Instrument ID. Deprecated March 2026; use instIdCode for lower latency. */
38+
instId?: string;
39+
/** Instrument ID code. Takes precedence over instId if both provided. Use Get instruments to map. */
40+
instIdCode?: number;
3341
cxlOnFail?: boolean;
3442
ordId?: string;
3543
clOrdId?: string;

0 commit comments

Comments
 (0)