Skip to content

Commit 4cb7db2

Browse files
committed
feat(v3.1.5): update version to 3.1.5, add affiliate and stable rewards API support
- Bumped version in package.json and package-lock.json to 3.1.5. - Introduced new API endpoints for affiliate and stable rewards functionalities. - Added request and response types for affiliate and stable rewards in the respective files. - Updated RestClient to include methods for the new endpoints.
1 parent bfb8068 commit 4cb7db2

15 files changed

Lines changed: 782 additions & 341 deletions

package-lock.json

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

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "okx-api",
3-
"version": "3.1.4",
3+
"version": "3.1.5",
44
"description": "Complete Node.js SDK for OKX's REST APIs and WebSockets, with TypeScript & end-to-end tests",
55
"scripts": {
66
"test": "jest",
@@ -52,15 +52,13 @@
5252
"jest": "^29.7.0",
5353
"ts-jest": "^29.1.2",
5454
"ts-node": "^10.9.2",
55-
"typescript": "^5.7.3"
56-
},
57-
"optionalDependencies": {
55+
"typescript": "^5.7.3",
5856
"source-map-loader": "^4.0.0",
5957
"ts-loader": "^9.5.4",
6058
"webpack": "^5.74.0",
6159
"webpack-bundle-analyzer": "^4.6.1",
6260
"webpack-cli": "^4.10.0"
63-
},
61+
},
6462
"keywords": [
6563
"okx",
6664
"okx api",

src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export * from './types/rest/client.js';
55
export * from './types/rest/shared.js';
66
// REST/request
77
export * from './types/rest/request/account.js';
8+
export * from './types/rest/request/affiliate.js';
89
export * from './types/rest/request/block-trading.js';
910
export * from './types/rest/request/convert.js';
1011
export * from './types/rest/request/copy-trading.js';
@@ -17,10 +18,12 @@ export * from './types/rest/request/shared.js';
1718
export * from './types/rest/request/signal-bot.js';
1819
export * from './types/rest/request/simple-earn.js';
1920
export * from './types/rest/request/spread-trading.js';
21+
export * from './types/rest/request/stable-rewards.js';
2022
export * from './types/rest/request/subaccount.js';
2123
export * from './types/rest/request/trade.js';
2224
// REST/response
2325
export * from './types/rest/response/private-account.js';
26+
export * from './types/rest/response/private-affiliate.js';
2427
export * from './types/rest/response/private-block-trading.js';
2528
export * from './types/rest/response/private-copy-trading.js';
2629
export * from './types/rest/response/private-dual-investment.js';
@@ -29,6 +32,7 @@ export * from './types/rest/response/private-funding.js';
2932
export * from './types/rest/response/private-recurring-buy.js';
3033
export * from './types/rest/response/private-signal-bot.js';
3134
export * from './types/rest/response/private-spread-trading.js';
35+
export * from './types/rest/response/private-stable-rewards.js';
3236
export * from './types/rest/response/private-subaccount.js';
3337
export * from './types/rest/response/private-trade.js';
3438
export * from './types/rest/response/public-data.js';

src/rest-client.ts

Lines changed: 115 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ import {
2525
UpdateFixedLoanBorrowingOrderRequest,
2626
WithdrawalHistoryRequest,
2727
} from './types/rest/request/account.js';
28+
import {
29+
GetAffiliateCoInviterLinkListRequest,
30+
GetAffiliateInviteeListRequest,
31+
GetAffiliateLinkListRequest,
32+
GetAffiliatePerformanceSummaryRequest,
33+
GetAffiliateSubAffiliateListRequest,
34+
GetInviteeDetailRequest,
35+
} from './types/rest/request/affiliate.js';
2836
import {
2937
CancelBlockQuoteRequest,
3038
CancelBlockRFQRequest,
@@ -133,6 +141,14 @@ import {
133141
PlaceSpreadOrderRequest,
134142
UpdateSpreadOrderRequest,
135143
} from './types/rest/request/spread-trading.js';
144+
import {
145+
GetStableRewardsApyHistoryRequest,
146+
GetStableRewardsBalanceRequest,
147+
GetStableRewardsProductInfoRequest,
148+
GetStableRewardsSubscribeRedeemHistoryRequest,
149+
RequestStableRewardsQuoteRequest,
150+
SubmitStableRewardsTradeRequest,
151+
} from './types/rest/request/stable-rewards.js';
136152
import {
137153
GetManagedSubAccountTransferHistoryRequest,
138154
GetSubAccountMaxWithdrawalsRequest,
@@ -196,6 +212,14 @@ import {
196212
VIPLoanOrder,
197213
VIPLoanOrderDetail,
198214
} from './types/rest/response/private-account.js';
215+
import {
216+
AffiliateCoInviterLinkListItem,
217+
AffiliateInviteeListItem,
218+
AffiliateLinkListItem,
219+
AffiliatePerformanceSummary,
220+
AffiliateSubAffiliateListItem,
221+
InviteeDetail,
222+
} from './types/rest/response/private-affiliate.js';
199223
import {
200224
BlockCounterParty,
201225
BlockMakerInstrumentSettings,
@@ -291,6 +315,14 @@ import {
291315
SpreadTrade,
292316
UpdateSpreadOrderResponse,
293317
} from './types/rest/response/private-spread-trading.js';
318+
import {
319+
StableRewardsApyHistoryItem,
320+
StableRewardsBalance,
321+
StableRewardsProductInfo,
322+
StableRewardsQuote,
323+
StableRewardsSubscribeRedeemHistoryItem,
324+
StableRewardsTradeResult,
325+
} from './types/rest/response/private-stable-rewards.js';
294326
import {
295327
ManagedSubAccountTransfer,
296328
SubAccount,
@@ -2490,6 +2522,8 @@ export class RestClient extends BaseRestClient {
24902522
ccy?: string;
24912523
type?: `${ASSET_BILL_TYPE}`;
24922524
clientId?: string;
2525+
/** Third-party custody type. Defaults to 1 (Copper) if not specified. */
2526+
thirdPartyType?: '1' | '2' | '5' | '6';
24932527
after?: numberInString;
24942528
before?: numberInString;
24952529
limit?: numberInString;
@@ -3014,16 +3048,96 @@ export class RestClient extends BaseRestClient {
30143048
return this.getPrivate('/api/v5/finance/sfp/dcd/order-history', params);
30153049
}
30163050

3051+
/**
3052+
*
3053+
* Financial product — stable rewards endpoints
3054+
* @see https://www.okx.com/docs-v5/en/ (2026-04-24 release)
3055+
*
3056+
*/
3057+
3058+
getStableRewardsProductInfo(
3059+
params: GetStableRewardsProductInfoRequest,
3060+
): Promise<StableRewardsProductInfo[]> {
3061+
return this.getPrivate(
3062+
'/api/v5/finance/stable-rewards/product-info',
3063+
params,
3064+
);
3065+
}
3066+
3067+
requestStableRewardsQuote(
3068+
params: RequestStableRewardsQuoteRequest,
3069+
): Promise<StableRewardsQuote[]> {
3070+
return this.postPrivate('/api/v5/finance/stable-rewards/quote', params);
3071+
}
3072+
3073+
submitStableRewardsTrade(
3074+
params: SubmitStableRewardsTradeRequest,
3075+
): Promise<StableRewardsTradeResult[]> {
3076+
return this.postPrivate('/api/v5/finance/stable-rewards/trade', params);
3077+
}
3078+
3079+
getStableRewardsBalance(
3080+
params?: GetStableRewardsBalanceRequest,
3081+
): Promise<StableRewardsBalance[]> {
3082+
return this.getPrivate('/api/v5/finance/stable-rewards/balance', params);
3083+
}
3084+
3085+
getStableRewardsApyHistory(
3086+
params: GetStableRewardsApyHistoryRequest,
3087+
): Promise<StableRewardsApyHistoryItem[]> {
3088+
return this.get('/api/v5/finance/stable-rewards/apy-history', params);
3089+
}
3090+
3091+
getStableRewardsSubscribeRedeemHistory(
3092+
params: GetStableRewardsSubscribeRedeemHistoryRequest,
3093+
): Promise<StableRewardsSubscribeRedeemHistoryItem[]> {
3094+
return this.getPrivate(
3095+
'/api/v5/finance/stable-rewards/subscribe-redeem-history',
3096+
params,
3097+
);
3098+
}
3099+
30173100
/**
30183101
*
30193102
* Affiliate endpoints
3103+
* @see https://www.okx.com/docs-v5/en/ (2026-05-08 release)
30203104
*
30213105
*/
30223106

3023-
getInviteeDetail(params: { uid: string }): Promise<any[]> {
3107+
getAffiliatePerformanceSummary(
3108+
params?: GetAffiliatePerformanceSummaryRequest,
3109+
): Promise<AffiliatePerformanceSummary[]> {
3110+
return this.getPrivate('/api/v5/affiliate/performance/summary', params);
3111+
}
3112+
3113+
getInviteeDetail(params: GetInviteeDetailRequest): Promise<InviteeDetail[]> {
30243114
return this.getPrivate('/api/v5/affiliate/invitee/detail', params);
30253115
}
30263116

3117+
getAffiliateInviteeList(
3118+
params?: GetAffiliateInviteeListRequest,
3119+
): Promise<AffiliateInviteeListItem[]> {
3120+
return this.getPrivate('/api/v5/affiliate/invitee/list', params);
3121+
}
3122+
3123+
getAffiliateLinkList(
3124+
params?: GetAffiliateLinkListRequest,
3125+
): Promise<AffiliateLinkListItem[]> {
3126+
return this.getPrivate('/api/v5/affiliate/link/list', params);
3127+
}
3128+
3129+
getAffiliateCoInviterLinkList(
3130+
params?: GetAffiliateCoInviterLinkListRequest,
3131+
): Promise<AffiliateCoInviterLinkListItem[]> {
3132+
return this.getPrivate('/api/v5/affiliate/co-inviter/list', params);
3133+
}
3134+
3135+
getAffiliateSubAffiliateList(
3136+
params?: GetAffiliateSubAffiliateListRequest,
3137+
): Promise<AffiliateSubAffiliateListItem[]> {
3138+
return this.getPrivate('/api/v5/affiliate/sub-affiliate/list', params);
3139+
}
3140+
30273141
getAffiliateRebateInfo(params: { apiKey: string }): Promise<any[]> {
30283142
return this.getPrivate('/api/v5/users/partner/if-rebate', params);
30293143
}

src/types/rest/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export interface RestClientOptions {
77

88
/**
99
* The API group this client should connect to:
10-
* - market: 'prod' (default: connects to OKX global) https://www.okx.com/docs-v5/en/#overview-production-trading-services
10+
* - market: 'prod' (default: OKX Global REST at https://openapi.okx.com)
1111
* - market: 'EEA' // also known as "my.okx.com" https://my.okx.com/docs-v5/en/#overview-production-trading-services
1212
* - market: 'US' // also known as "app.okx.com" https://app.okx.com/docs-v5/en/#overview-production-trading-services
1313
*/
@@ -21,7 +21,7 @@ export interface RestClientOptions {
2121
// Default: false. If true, we'll throw errors if any params are undefined
2222
strict_param_validation?: boolean;
2323

24-
// Optionally override API protocol + domain.
24+
// Optionally override REST API base URL (e.g. 'https://www.okx.com' or 'https://openapi.okx.com').
2525
// Note: to use my.okx or app.okx or eea.okx or us.okx, use the "market" parameter
2626
// e.g 'https://eea.okx.com'
2727
baseUrl?: string;
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
export type AffiliatePeriodType =
2+
| 'last_7d'
3+
| 'last_30d'
4+
| 'this_month'
5+
| 'last_month'
6+
| 'total'
7+
| 'today'
8+
| 'this_week'
9+
| 'custom';
10+
11+
export type AffiliateCommissionCategory = 'SPOT' | 'DERIVATIVE' | 'BSC';
12+
13+
export type AffiliateKycStatus = 'unverified' | 'verified';
14+
15+
export type AffiliateLinkType = 'standard' | 'co_inviter';
16+
17+
export type AffiliateLinkStatus = 'normal' | 'abnormal';
18+
19+
export type AffiliateInviteeListOrderBy =
20+
| 'cTime'
21+
| 'depAmt'
22+
| 'vol'
23+
| 'fee'
24+
| 'rebate';
25+
26+
export type AffiliateSubAffiliateListOrderBy =
27+
| 'cTime'
28+
| 'depAmt'
29+
| 'vol'
30+
| 'fee'
31+
| 'rebate';
32+
33+
export type AffiliateOrderDir = 'asc' | 'desc';
34+
35+
export interface GetAffiliatePerformanceSummaryRequest {
36+
periodType?: AffiliatePeriodType;
37+
/** Required when periodType=custom, together with end. Inclusive. */
38+
begin?: string;
39+
/** Required when periodType=custom, together with begin. Inclusive. */
40+
end?: string;
41+
}
42+
43+
export interface GetInviteeDetailRequest {
44+
uid: string;
45+
}
46+
47+
export interface GetAffiliateInviteeListRequest {
48+
page?: string;
49+
limit?: string;
50+
periodType?: AffiliatePeriodType;
51+
/** Required when periodType=custom, together with end. Inclusive. */
52+
begin?: string;
53+
/** Required when periodType=custom, together with begin. Inclusive. */
54+
end?: string;
55+
keyword?: string;
56+
commissionCategory?: AffiliateCommissionCategory;
57+
orderBy?: AffiliateInviteeListOrderBy;
58+
orderDir?: AffiliateOrderDir;
59+
kycStatus?: AffiliateKycStatus;
60+
subAffiliateUid?: string;
61+
}
62+
63+
export interface GetAffiliateLinkListRequest {
64+
page?: string;
65+
limit?: string;
66+
linkType?: AffiliateLinkType;
67+
linkStatus?: AffiliateLinkStatus;
68+
}
69+
70+
export interface GetAffiliateCoInviterLinkListRequest {
71+
page?: string;
72+
limit?: string;
73+
linkStatus?: AffiliateLinkStatus;
74+
}
75+
76+
export interface GetAffiliateSubAffiliateListRequest {
77+
page?: string;
78+
limit?: string;
79+
keyword?: string;
80+
commissionCategory?: AffiliateCommissionCategory;
81+
orderBy?: AffiliateSubAffiliateListOrderBy;
82+
orderDir?: AffiliateOrderDir;
83+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
export interface GetStableRewardsProductInfoRequest {
2+
ccy: string;
3+
}
4+
5+
export interface RequestStableRewardsQuoteRequest {
6+
ccy: string;
7+
settleCcy: string;
8+
action: 'subscribe' | 'redeem';
9+
amt: string;
10+
}
11+
12+
export interface SubmitStableRewardsTradeRequest {
13+
quoteId: string;
14+
}
15+
16+
export interface GetStableRewardsBalanceRequest {
17+
ccy?: string;
18+
}
19+
20+
export interface GetStableRewardsApyHistoryRequest {
21+
ccy: string;
22+
days?: string;
23+
}
24+
25+
export interface GetStableRewardsSubscribeRedeemHistoryRequest {
26+
ccy: string;
27+
type?: 'subscribe' | 'redeem';
28+
status?: 'pending' | 'success' | 'failed';
29+
after?: string;
30+
before?: string;
31+
limit?: string;
32+
}

src/types/rest/request/trade.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,12 @@ export interface OrderRequest {
242242
reduceOnly?: boolean;
243243
/** A spot buy on BTC-USDT with "base_ccy" would mean the QTY (sz) is in USDT */
244244
tgtCcy?: 'base_ccy' | 'quote_ccy';
245+
/**
246+
* Maximum acceptable slippage for spot and spot margin market-side orders, where tgtCcy is the received currency (base_ccy for buy, quote_ccy for sell).
247+
* Range: 0 to 0.05 (0% to 5%, inclusive). Up to 2 decimal places, e.g. 0.01 (1%) and 0.0123 (1.23%). Defaults to 0.00% if not specified.
248+
* Only applicable to SPOT and SPOT margin market orders. Cannot be amended on an existing order.
249+
*/
250+
slippagePct?: string;
245251
banAmend?: boolean;
246252
/** Price amendment type: "0" = do not allow amendment, "1" = allow amendment within price limit. Default is "0" */
247253
pxAmendType?: '0' | '1';

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ export interface AccountInstrument {
400400
seriesId?: string;
401401
uly?: string;
402402
/**
403-
* FUTURES label (deprecated prefer `expTime`; may include this_five_years, next_five_years, ).
403+
* FUTURES label (deprecated prefer `expTime`; may include this_five_years, next_five_years, ).
404404
*/
405405
alias?: string;
406406
/** Deprecated; see `instCategory` on public `Instrument` where used. */
@@ -424,7 +424,7 @@ export interface AccountInstrument {
424424
quoteCcy: string;
425425
tradeQuoteCcyList: string[]; // List of quote currencies available for trading, e.g. ["USD", "USDC"]
426426
settleCcy: string;
427-
/** Instrument status: live, suspend, rebase (SWAP only), preopen, test */
427+
/** Instrument status: live, suspend, rebase (SWAP only), post_only (SWAP only), preopen, test */
428428
state: string;
429429
stk: string;
430430
tickSz: string;
@@ -579,7 +579,7 @@ export interface SetTradingConfigResult {
579579
}
580580

581581
export interface UnmatchedInfo {
582-
type: string; // Unmatched information type: spot_mode, futures_mode, isolated_margin, isolated_contract, positions_options, isolated_pending_orders, pending_orders_options, trading_bot, repay_borrowings, loan, delta_risk, collateral_all
582+
type: string; // Unmatched information type: spot_mode, futures_mode, isolated_margin, isolated_contract, positions_options, isolated_pending_orders, pending_orders_options, trading_bot, repay_borrowings, loan, delta_risk, collateral_all, risk_unit_type
583583
deltaLever?: string; // Delta leverage. Applicable when type is delta_risk
584584
ordList?: string[]; // Unmatched order list, order ID. Applicable when type is isolated_pending_orders/pending_orders_options
585585
posList?: string[]; // Unmatched position list, position ID. Applicable when type is isolated_margin/isolated_contract/positions_options

0 commit comments

Comments
 (0)