-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathUnifiedAPIClient.ts
More file actions
1009 lines (928 loc) · 31.2 KB
/
Copy pathUnifiedAPIClient.ts
File metadata and controls
1009 lines (928 loc) · 31.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { BaseRestClient } from './lib/BaseRestClient.js';
import type {
InternalRequestContext,
RestClientType,
} from './lib/requestUtils.js';
import {
isUTAMainClientType,
REST_CLIENT_TYPE_ENUM,
} from './lib/requestUtils.js';
import type {
AddSubAccountApiRequestUTA,
AddSubAccountRequestUTA,
AmendOrderRequestUTA,
BatchCancelOrdersBySymbolRequestUTA,
BatchCancelOrdersRequestUTA,
BatchModifyMarginModeRequestUTA,
BatchPlaceOrderRequestUTA,
CancelOrderRequestUTA,
FlexTransferRequestUTA,
GetAccountLedgerRequestUTA,
GetAccountPositionTiersRequestUTA,
GetAnnouncementsRequestUTA,
GetBorrowingRatesAndLimitsRequestUTA,
GetCallAuctionInfoRequestUTA,
GetClassicAccountRequestUTA,
GetCurrenciesRequestUTA,
GetCurrencyRequestUTA,
GetCurrentFundingRateRequestUTA,
GetDCPRequestUTA,
GetDepositAddressRequestUTA,
GetDepositHistoryRequestUTA,
GetFeeRateRequestUTA,
GetFiatPriceRequestUTA,
GetHistoryFundingRateRequestUTA,
GetIndexPriceRequestUTA,
GetInterestHistoryRequestUTA,
GetInterestRateIndexRequestUTA,
GetKlinesRequestUTA,
GetLeverageRequestUTA,
GetOpenOrderListRequestUTA,
GetOrderBookRequestUTA,
GetOrderDetailsRequestUTA,
GetOrderHistoryRequestUTA,
GetPositionListRequestUTA,
GetPositionsHistoryRequestUTA,
GetPrivateFundingFeeHistoryRequestUTA,
GetRateLimitRequestUTA,
GetServiceStatusRequestUTA,
GetSubAccountListRequestUTA,
GetSubAccountRequestUTA,
GetSymbolRequestUTA,
GetThirdPartyCustodyCurrenciesRequestUTA,
GetThirdPartyCustodyQuotaRequestUTA,
GetTickerRequestUTA,
GetTradeHistoryRequestUTA,
GetTradesRequestUTA,
GetTransferQuotasRequestUTA,
GetWithdrawalHistoryRequestUTA,
GetWithdrawalQuotasRequestUTA,
ModifyIsolatedFuturesMarginRequestUTA,
ModifyLeverageRequestUTA,
ModifyMarginCrossLeverageRequestUTA,
PlaceOrderRequestUTA,
SetAccountModeRequestUTA,
SetDCPRequestUTA,
SetKcsFeeDeductionRequestUTA,
SetSubAccountsRateLimitRequestUTA,
SetSubAccountTransferPermissionRequestUTA,
SubmitWithdrawRequestUTA,
} from './types/request/uta-types.js';
import type { APISuccessResponse } from './types/response/shared.types.js';
import type {
AddSubAccountApiResponseUTA,
AddSubAccountResponseUTA,
AmendOrderResponseUTA,
ApiKeyInfoUTA,
BatchCancelOrdersBySymbolResponseUTA,
BatchCancelOrdersResponseUTA,
BatchModifyMarginModeResponseUTA,
BatchPlaceOrderResponseUTA,
BorrowableCurrencyUTA,
CancelOrderResponseUTA,
DCPResponseUTA,
DepositAddressUTA,
FlexTransferResponseUTA,
GetAccountLedgerResponseClassicUTA,
GetAccountLedgerResponseUTA,
GetAccountModeResponseUTA,
GetAccountOverviewResponseUTA,
GetAnnouncementsResponseUTA,
GetBorrowingRatesAndLimitsResponseUTA,
GetCallAuctionInfoResponseUTA,
GetClassicAccountResponseUTA,
GetCrossMarginConfigResponseUTA,
GetCurrenciesResponseUTA,
GetCurrencyResponseUTA,
GetCurrentFundingRateResponseUTA,
GetDepositHistoryResponseUTA,
GetFeeRateResponseUTA,
GetFiatPriceResponseUTA,
GetHistoryFundingRateResponseUTA,
GetIndexPriceResponseUTA,
GetInterestHistoryResponseUTA,
GetInterestRateIndexResponseUTA,
GetKlinesResponseUTA,
GetLeverageItemUTA,
GetOpenOrderListResponseUTA,
GetOrderBookResponseUTA,
GetOrderHistoryResponseUTA,
GetPositionsHistoryResponseUTA,
GetPrivateFundingFeeHistoryResponseUTA,
GetRateLimitCapResponseUTA,
GetRateLimitResponseUTA,
GetServiceStatusResponseUTA,
GetSubAccountListResponseUTA,
GetSubAccountResponseUTA,
GetSymbolResponseUTA,
GetTickerResponseUTA,
GetTradeHistoryResponseUTA,
GetTradesResponseUTA,
GetTradeStatisticsResponseUTA,
GetTransferQuotasResponseUTA,
GetWithdrawalHistoryResponseUTA,
KYCRegionUTA,
ModifyIsolatedFuturesMarginResponseUTA,
ModifyMarginCrossLeverageResponseUTA,
OrderDetailsUTA,
PlaceOrderResponseUTA,
PositionTierUTA,
PositionUTA,
SetKcsFeeDeductionResponseUTA,
SetSubAccountsRateLimitResponseUTA,
SubAccountTransferPermissionUTA,
SubmitWithdrawResponseUTA,
ThirdPartyCustodyCurrencyUTA,
ThirdPartyCustodyQuotaUTA,
WithdrawalQuotasUTA,
} from './types/response/uta-types.js';
/**
* Unified Trading Account Client
*
* This client provides access to the Unified Trading Account API endpoints
* that unify market data access across Spot, Futures, and Margin trading.
*/
export class UnifiedAPIClient extends BaseRestClient {
getClientType(): RestClientType {
return REST_CLIENT_TYPE_ENUM.unifiedTradingAccount;
}
/**
*
* REST - Unified Trading Account - Market Data
*
*/
/**
* Get Announcements
* This interface can obtain the latest news announcements, and the default
* page search is for announcements within a month.
*/
getAnnouncements(
params?: GetAnnouncementsRequestUTA,
): Promise<APISuccessResponse<GetAnnouncementsResponseUTA>> {
return this.get('api/ua/v2/market/announcement', params);
}
/**
* Get Currency
* Request the currency details of a specified currency via this endpoint.
*/
getCurrency(
params: GetCurrencyRequestUTA,
): Promise<APISuccessResponse<GetCurrencyResponseUTA>> {
return this.get('api/ua/v2/market/currency', params);
}
/**
* Get Currencies
* Currency and chain-level deposit/withdrawal configuration.
*/
getCurrencies(
params?: GetCurrenciesRequestUTA,
): Promise<APISuccessResponse<GetCurrenciesResponseUTA>> {
return this.get('api/ua/v2/asset/currencies', params);
}
/**
* Get Third-Party Custody Currencies
* Query settlement currencies supported by third-party (OES) custodian institutions.
*/
getThirdPartyCustodyCurrencies(
params?: GetThirdPartyCustodyCurrenciesRequestUTA,
): Promise<APISuccessResponse<ThirdPartyCustodyCurrencyUTA[]>> {
return this.get('api/ua/v2/oes/currency', params);
}
/**
* Get Symbol
* Request a list of available currency pairs for trading via this endpoint.
*/
getSymbols(
params: GetSymbolRequestUTA,
): Promise<APISuccessResponse<GetSymbolResponseUTA>> {
return this.get('api/ua/v2/market/instrument', params);
}
/**
* Get Ticker
* Request market tickers for the trading pairs in the market (including 24h volume).
*/
getTickers(
params: GetTickerRequestUTA,
): Promise<APISuccessResponse<GetTickerResponseUTA>> {
return this.get('api/ua/v2/market/ticker', params);
}
/**
* Get Trades
* Request via this endpoint to get the latest 100 public trades of the specified symbol.
*/
getTrades(
params: GetTradesRequestUTA,
): Promise<APISuccessResponse<GetTradesResponseUTA>> {
return this.get('api/ua/v2/market/trade', params);
}
/**
* Get OrderBook
* Query order book depth information (aggregated by price).
*/
getOrderBook(
params: GetOrderBookRequestUTA,
): Promise<APISuccessResponse<GetOrderBookResponseUTA>> {
return this.get('api/ua/v2/market/orderbook', params);
}
/**
* Get Klines
* Get the Kline of the symbol. Data are returned in grouped buckets based on requested type.
*/
getKlines(
params: GetKlinesRequestUTA,
): Promise<APISuccessResponse<GetKlinesResponseUTA>> {
return this.get('api/ua/v2/market/kline', params);
}
/**
* Get Index Price
* Index price snapshots (updated once per second).
*/
getIndexPrice(
params: GetIndexPriceRequestUTA,
): Promise<APISuccessResponse<GetIndexPriceResponseUTA>> {
return this.get('api/ua/v2/market/index-price', params);
}
/**
* Get Current Funding Rate
* Get current Futures funding fee rate.
*/
getCurrentFundingRate(
params?: GetCurrentFundingRateRequestUTA,
): Promise<
APISuccessResponse<
GetCurrentFundingRateResponseUTA | GetCurrentFundingRateResponseUTA[]
>
> {
return this.get('api/ua/v2/market/funding-rate', params);
}
/**
* Get History Funding Rate
* Query the Futures funding rate at each settlement time point within a certain time range.
*/
getHistoryFundingRate(
params: GetHistoryFundingRateRequestUTA,
): Promise<APISuccessResponse<GetHistoryFundingRateResponseUTA>> {
return this.get('api/ua/v2/market/funding-rate-history', params);
}
/**
* Get Cross Margin Config
* Request the configure info of the 'spot cross margin' via this endpoint.
*/
getCrossMarginConfig(): Promise<
APISuccessResponse<GetCrossMarginConfigResponseUTA>
> {
return this.get('api/ua/v1/market/cross-config');
}
/**
* Get Borrowable Currencies
* List of borrowable currencies (UTA / public).
*/
getBorrowableCurrencies(): Promise<
APISuccessResponse<BorrowableCurrencyUTA[]>
> {
return this.get('api/ua/v2/market/borrowable-currency');
}
/**
* Get Service Status
* Get the service status.
*/
getServiceStatus(
params: GetServiceStatusRequestUTA,
): Promise<APISuccessResponse<GetServiceStatusResponseUTA>> {
return this.get('api/ua/v2/server/status', params);
}
/**
* Get Client IP Address
* Get the client side IP address. Added 2026.07.01.
*/
getClientIPAddress(): Promise<APISuccessResponse<string>> {
return this.get('api/ua/v2/user/my-ip');
}
/**
* Get Fiat Price (UTA)
* Request the fiat price of currencies for available trading pairs. Added 2026.07.01.
*/
getFiatPrice(
params: GetFiatPriceRequestUTA,
): Promise<APISuccessResponse<GetFiatPriceResponseUTA>> {
return this.get('api/ua/v2/market/fiat-price', params);
}
/**
* Get Interest Rate Index (UTA)
* Interest rate index records by symbol. Added 2026.07.17.
*/
getInterestRateIndex(
params: GetInterestRateIndexRequestUTA,
): Promise<APISuccessResponse<GetInterestRateIndexResponseUTA>> {
return this.get('api/ua/v2/market/interest-rate-index', params);
}
/**
* Platform 24h Market Statistics (UTA)
* Spot and futures 24h turnover. Added 2026.07.17.
*/
getTradeStatistics(): Promise<
APISuccessResponse<GetTradeStatisticsResponseUTA>
> {
return this.get('api/ua/v2/trade-statistics');
}
/**
* Get Call Auction Info (UTA)
* Estimated price/size and bid/ask ranges during call auction. Added 2026.07.17.
*/
getCallAuctionInfo(
params: GetCallAuctionInfoRequestUTA,
): Promise<APISuccessResponse<GetCallAuctionInfoResponseUTA>> {
return this.get('api/ua/v2/market/call-auction-info', params);
}
/**
*
* REST - Unified Trading Account - Account
*
*/
/**
* Get Account (Classic)
* Get information for Classic Account (FUNDING, SPOT, FUTURES, CROSS, ISOLATED).
* Note: AccountType enum value changed from TRADING to SPOT as of 2026.01.17.
*/
getClassicAccount(
params: GetClassicAccountRequestUTA,
): Promise<APISuccessResponse<GetClassicAccountResponseUTA>> {
return this.getPrivate('api/ua/v2/account/balance', params);
}
/**
* Get Account (UTA)
* Get information for Unified Trading Account.
*/
getAccount(): Promise<APISuccessResponse<GetClassicAccountResponseUTA>> {
return this.getPrivate('api/ua/v2/unified/account/balance');
}
/**
* Get Account Overview (UTA)
* Get account overview for Unified Trading Account.
*/
getAccountOverview(): Promise<
APISuccessResponse<GetAccountOverviewResponseUTA>
> {
return this.getPrivate('api/ua/v2/unified/account/overview');
}
/**
* Get Sub Account
* Request sub account info via this endpoint.
*/
getSubAccount(
params?: GetSubAccountRequestUTA,
): Promise<APISuccessResponse<GetSubAccountResponseUTA>> {
return this.getPrivate('api/ua/v2/sub-account/balance', params);
}
/**
* Get Sub-account List (UTA)
* Paginated list of sub-accounts. Added 2026.08.03.
*/
getSubAccountList(
params?: GetSubAccountListRequestUTA,
): Promise<APISuccessResponse<GetSubAccountListResponseUTA>> {
return this.getPrivate('api/ua/v2/user/sub-account-list', params);
}
/**
* Get Transfer Quotas
* This endpoint returns the transferable balance of a specified account.
* Note: AccountType enum value changed from TRADING to SPOT as of 2026.01.17.
* Note: UNIFIED accountType supported as of latest UTA update.
*/
getTransferQuotas(
params: GetTransferQuotasRequestUTA,
): Promise<APISuccessResponse<GetTransferQuotasResponseUTA>> {
return this.getPrivate('api/ua/v2/account/transfer-quota', params);
}
/**
* Flex Transfer
* This interface can be used for transfers between master- and sub-accounts and transfers.
* Note: AccountType enum value changed from TRADING to SPOT as of 2026.01.17.
*/
flexTransfer(
params: FlexTransferRequestUTA,
): Promise<APISuccessResponse<FlexTransferResponseUTA>> {
return this.postPrivate('api/ua/v2/account/transfer', params);
}
/**
* Set Sub Account Transfer Permission
* This endpoint supports setting whether the specified sub-account needs to open the SUB_TO_SUB transfer permission.
*/
setSubAccountTransferPermission(
params: SetSubAccountTransferPermissionRequestUTA,
): Promise<APISuccessResponse<SubAccountTransferPermissionUTA[]>> {
return this.postPrivate('api/ua/v2/sub-account/canTransferOut', params);
}
/**
* Get Account Mode
* This interface supports query the list of unified and classic sub-accounts and current account mode.
*/
getAccountMode(): Promise<APISuccessResponse<GetAccountModeResponseUTA>> {
return this.getPrivate('api/ua/v2/account/mode');
}
/**
* Set Account Mode
* This interface supports set account mode to UTA.
*/
setAccountMode(
params: SetAccountModeRequestUTA,
): Promise<APISuccessResponse<null>> {
return this.postPrivate('api/ua/v2/account/mode', params);
}
/**
* Get Fee Rate
* This interface is for the trading pair's actual fee rate.
* You can inquire about fee rates of 10 trading pairs each time at most for Spot.
* Futures only supports 1 symbol at a time.
*/
getFeeRate(
params: GetFeeRateRequestUTA,
): Promise<APISuccessResponse<GetFeeRateResponseUTA>> {
return this.getPrivate('api/ua/v2/user/fee-rate', params);
}
/**
* Get Account Ledger
* This API endpoint returns all transfer (in and out) records and supports multi-coin queries.
* The query results are sorted in descending order by createdAt and ID.
* Note: AccountType enum value changed from TRADING to SPOT as of 2026.01.17.
* Note: direction values unified to uppercase IN/OUT as of 2026.01.17.
* Note: For Futures - id changed from Number to String, balance/amount changed from Number to String as of 2026.01.17.
* Note: ts standardized to nanoseconds as of 2026.01.12.
* Note: amount is always returned as a positive number as of 2026.04.28; use direction (IN/OUT) to determine flow.
*/
getAccountLedger(
params: GetAccountLedgerRequestUTA,
): Promise<
APISuccessResponse<
GetAccountLedgerResponseUTA | GetAccountLedgerResponseClassicUTA
>
> {
return this.getPrivate('api/ua/v2/account/ledger', params);
}
/**
* Get Interest History (UTA)
* Request the interest records via this endpoint.
*/
getInterestHistory(
params: GetInterestHistoryRequestUTA,
): Promise<APISuccessResponse<GetInterestHistoryResponseUTA>> {
return this.getPrivate('api/ua/v2/account/interest-history', params);
}
/**
* Get Borrowing Rates and Limits
* Hourly/daily rates and borrow limits (UTA).
*/
getBorrowingRatesAndLimits(
params: GetBorrowingRatesAndLimitsRequestUTA,
): Promise<APISuccessResponse<GetBorrowingRatesAndLimitsResponseUTA>> {
return this.getPrivate('api/ua/v2/account/interest-limits', params);
}
/**
* Modify Leverage (UTA)
* This interface supports modify leverage of the specified symbol.
*/
modifyLeverage(
params: ModifyLeverageRequestUTA,
): Promise<APISuccessResponse<null>> {
return this.postPrivate(
'api/ua/v2/unified/account/modify-leverage',
params,
);
}
/**
* Modify Leverage Margin Cross (UTA)
* Update leverage for a currency in UTA cross margin.
*/
modifyMarginCrossLeverage(
params: ModifyMarginCrossLeverageRequestUTA,
accountMode: 'classic' | 'unified' = 'unified',
): Promise<APISuccessResponse<ModifyMarginCrossLeverageResponseUTA>> {
return this.postPrivate(
accountMode === 'classic'
? 'api/ua/v1/classic/account/modify-leverage-margin-cross'
: 'api/ua/v2/unified/account/modify-leverage-margin-cross',
params,
);
}
/**
* Get Leverage (UTA)
* Query leverage for MARGIN (currency) or FUTURES (symbol).
*/
getLeverage(
params: GetLeverageRequestUTA,
): Promise<APISuccessResponse<GetLeverageItemUTA[]>> {
return this.getPrivate('api/ua/v2/unified/account/leverage', params);
}
/**
* Get Deposit Address
* Return a deposit address; when both currency and chain are provided,
* the address will be created if it does not exist.
* URL unified to GET /api/ua/v2/asset/deposit/address as of 2026.01.17.
*/
getDepositAddress(
params: GetDepositAddressRequestUTA,
): Promise<APISuccessResponse<DepositAddressUTA[]>> {
return this.getPrivate('api/ua/v2/asset/deposit/address', params);
}
/**
* Get Deposit History (UTA)
* Paginated deposit records. Added 2026.08.03.
*/
getDepositHistory(
params?: GetDepositHistoryRequestUTA,
): Promise<APISuccessResponse<GetDepositHistoryResponseUTA>> {
return this.getPrivate('api/ua/v2/asset/deposit/history', params);
}
/**
* Get Withdrawal History (UTA)
* Paginated withdrawal records. Added 2026.08.03.
*/
getWithdrawalHistory(
params?: GetWithdrawalHistoryRequestUTA,
): Promise<APISuccessResponse<GetWithdrawalHistoryResponseUTA>> {
return this.getPrivate('api/ua/v2/asset/withdrawal/history', params);
}
/**
* KCS Fee Deduction Management (UTA)
* Enable or disable KCS fee deduction. Added 2026.08.03.
*/
setKcsFeeDeduction(
params: SetKcsFeeDeductionRequestUTA,
): Promise<APISuccessResponse<SetKcsFeeDeductionResponseUTA>> {
return this.getPrivate('api/ua/v2/account/fee/kcs-deduct', params);
}
/**
* Get API Key Info (UTA)
* Get the API key information for the key used to call this endpoint.
* Works for both master and sub user API keys. Added 2026.05.15.
*/
getApiKeyInfo(): Promise<APISuccessResponse<ApiKeyInfoUTA>> {
return this.getPrivate('api/ua/v2/user/api-key');
}
/**
* Get KYC Regions (UTA)
* Obtain the list of KYC regions. Added 2026.05.15.
*/
getKYCRegions(): Promise<APISuccessResponse<KYCRegionUTA[]>> {
return this.get('api/ua/v2/user/kyc-region');
}
/**
* Get API Rate Limit (UTA)
* Query UTA API rate limit for specified UIDs. Added 2026.06.05.
*/
getRateLimit(
params: GetRateLimitRequestUTA,
): Promise<APISuccessResponse<GetRateLimitResponseUTA>> {
return this.getPrivate('api/ua/v2/rate-limit/query', params);
}
/**
* Get All API Rate Limit (UTA)
* Query UTA API rate limit for all accounts under the master. Added 2026.06.05.
*/
getAllRateLimit(): Promise<APISuccessResponse<GetRateLimitResponseUTA>> {
return this.getPrivate('api/ua/v2/rate-limit/query-all');
}
/**
* Get API Rate Limit Cap (UTA)
* Query the master account UTA API rate limit cap and allocation. Added 2026.06.05.
*/
getRateLimitCap(): Promise<APISuccessResponse<GetRateLimitCapResponseUTA>> {
return this.getPrivate('api/ua/v2/rate-limit/query-cap');
}
/**
* Set Sub Accounts API Rate Limit (UTA)
* Set UTA API rate limits for sub-accounts. Added 2026.06.05.
*/
setSubAccountsRateLimit(
params: SetSubAccountsRateLimitRequestUTA,
): Promise<APISuccessResponse<SetSubAccountsRateLimitResponseUTA>> {
return this.postPrivate('api/ua/v2/rate-limit/set', params);
}
/**
* Add Sub-Account (UTA)
* Create a sub-account. Added 2026.05.15.
*/
addSubAccount(
params: AddSubAccountRequestUTA,
): Promise<APISuccessResponse<AddSubAccountResponseUTA>> {
return this.postPrivate('api/ua/v2/user/sub/create-sub-account', params);
}
/**
* Add Sub-Account API (UTA)
* Create an API key for a sub-account. Added 2026.05.15.
*/
addSubAccountApi(
params: AddSubAccountApiRequestUTA,
): Promise<APISuccessResponse<AddSubAccountApiResponseUTA>> {
return this.postPrivate('api/ua/v2/user/create-sub-api-key', params);
}
/**
* Get Withdrawal Quotas (UTA)
* Obtain withdrawal quota information for a currency. Added 2026.05.15.
*/
getWithdrawalQuotas(
params: GetWithdrawalQuotasRequestUTA,
): Promise<APISuccessResponse<WithdrawalQuotasUTA>> {
return this.getPrivate('api/ua/v2/withdrawals/quotas', params);
}
/**
* Withdraw (UTA)
* Withdraw the specified currency. Added 2026.05.15.
*/
submitWithdraw(
params: SubmitWithdrawRequestUTA,
): Promise<APISuccessResponse<SubmitWithdrawResponseUTA>> {
return this.postPrivate('api/ua/v2/withdrawal', params);
}
/**
* Cancel Withdrawal (UTA)
* Cancel a withdrawal request in PROCESSING status. Added 2026.05.15.
*/
cancelWithdrawal(params?: {
withdrawalId?: string;
}): Promise<APISuccessResponse<string | null>> {
return this.deletePrivate('api/ua/v2/withdrawal', params);
}
/**
* Get Third-Party Custody Account Currency Limits
* OES remaining custody quota per custodian and settlement currency.
*/
getThirdPartyCustodyQuota(
params?: GetThirdPartyCustodyQuotaRequestUTA,
): Promise<APISuccessResponse<ThirdPartyCustodyQuotaUTA[]>> {
return this.getPrivate('api/ua/v2/oes/custody-quota', params);
}
/**
*
* REST - Unified Trading Account - Orders
*
*/
/**
* Place Order
* This interface can be used to place orders.
* Supports RPI (Retail Price Improvement) orders for Futures as of 2025.01.02.
* Note: timeInForce supports 'RPI' value for Futures only (Phase 1).
* Note: For Classic mode, tradeType is required in query param.
* Note: For Unified mode, tradeType is sent in the request body (incl. MARGIN as of 2026.04.19).
* Note: closeOrder supported for closing futures position by symbol.
*/
placeOrder(
params: PlaceOrderRequestUTA,
accountMode: 'classic' | 'unified' = 'unified',
): Promise<APISuccessResponse<PlaceOrderResponseUTA>> {
const { tradeType, ...bodyParams } = params;
const url =
accountMode === 'classic'
? `api/ua/v1/classic/order/place?tradeType=${tradeType}`
: 'api/ua/v2/unified/order/place';
const internalReqContext: InternalRequestContext = {
derivedClientType: isUTAMainClientType(params)
? REST_CLIENT_TYPE_ENUM.main
: REST_CLIENT_TYPE_ENUM.futures,
};
if (accountMode === 'unified') {
return this.postPrivate(
url,
{ ...bodyParams, tradeType },
internalReqContext,
);
}
return this.postPrivate(url, bodyParams, internalReqContext);
}
/**
* Amend Order
* Modify price, size, or TP/SL trigger prices. Futures only. Provide orderId or clientOid.
*/
amendOrder(
params: AmendOrderRequestUTA,
): Promise<APISuccessResponse<AmendOrderResponseUTA>> {
return this.postPrivate('api/ua/v2/unified/order/amend', params);
}
/**
* Batch Place Order (Classic)
* This interface can be used for placing batch orders.
* URL changed to /api/ua/v2/{accountMode}/order/place-batch as of 2026.01.17.
* Note: timeInForce supports 'RPI' value for Futures as of 2025.01.02.
*/
batchPlaceOrder(
params: BatchPlaceOrderRequestUTA,
accountMode: 'classic' | 'unified' = 'classic',
): Promise<APISuccessResponse<BatchPlaceOrderResponseUTA>> {
const url =
accountMode === 'classic'
? `api/ua/v1/classic/order/place-batch?tradeType=${params.tradeType}`
: 'api/ua/v2/unified/order/place-batch';
const internalReqContext: InternalRequestContext = {
derivedClientType: isUTAMainClientType(params)
? REST_CLIENT_TYPE_ENUM.main
: REST_CLIENT_TYPE_ENUM.futures,
};
return this.postPrivate(url, params, internalReqContext);
}
/**
* Get Order Details
* This interface can be used getting single order details.
* Note: timeInForce returns 'RPI' value for Futures RPI orders as of 2025.01.02.
* Note: status changed from String to Number for UTA as of 2026.01.17.
* Note: orderTime/updatedTime standardized to nanoseconds as of 2026.01.12.
*/
getOrderDetails(
params: GetOrderDetailsRequestUTA,
accountMode: 'classic' | 'unified' = 'unified',
): Promise<APISuccessResponse<OrderDetailsUTA>> {
return this.getPrivate(
accountMode === 'classic'
? 'api/ua/v1/classic/order/detail'
: 'api/ua/v2/unified/order/detail',
params,
);
}
/**
* Get Open Order List
* This interface can be used getting open order list.
* Note: timeInForce returns 'RPI' value for Futures RPI orders as of 2025.01.02.
* Note: status changed from String to Number for UTA as of 2026.01.17.
* Note: orderTime/updatedTime standardized to nanoseconds as of 2026.01.12.
*/
getOpenOrderList(
params: GetOpenOrderListRequestUTA,
accountMode: 'classic' | 'unified' = 'unified',
): Promise<APISuccessResponse<GetOpenOrderListResponseUTA>> {
return this.getPrivate(
accountMode === 'classic'
? 'api/ua/v1/classic/order/open-list'
: 'api/ua/v2/unified/order/open-list',
params,
);
}
/**
* Get Order History
* This interface can be used for getting order history.
* Note: timeInForce returns 'RPI' value for Futures RPI orders as of 2025.01.02.
* Note: status changed from String to Number for UTA as of 2026.01.17.
* Note: orderTime/updatedTime standardized to nanoseconds as of 2026.01.12.
*/
getOrderHistory(
params: GetOrderHistoryRequestUTA,
accountMode: 'classic' | 'unified' = 'unified',
): Promise<APISuccessResponse<GetOrderHistoryResponseUTA>> {
return this.getPrivate(
accountMode === 'classic'
? 'api/ua/v1/classic/order/history'
: 'api/ua/v2/unified/order/history',
params,
);
}
/**
* Get Trade History
* This interface can be used for getting trade execution history.
* Note: executionTime standardized to nanoseconds as of 2026.01.12.
* Note: isRpiTrade added for Futures as of 2025.01.02.
*/
getTradeHistory(
params: GetTradeHistoryRequestUTA,
accountMode: 'classic' | 'unified' = 'unified',
): Promise<APISuccessResponse<GetTradeHistoryResponseUTA>> {
return this.getPrivate(
accountMode === 'classic'
? 'api/ua/v1/classic/order/execution'
: 'api/ua/v2/unified/order/execution',
params,
);
}
/**
* Cancel Order
* This interface can be used to cancel orders.
* Note: ts (timestamp in nanoseconds) only effective for unified account mode.
*/
cancelOrder(
params: CancelOrderRequestUTA,
accountMode: 'classic' | 'unified' = 'unified',
): Promise<APISuccessResponse<CancelOrderResponseUTA>> {
const url =
accountMode === 'classic'
? `api/ua/v1/classic/order/cancel?tradeType=${params.tradeType}`
: 'api/ua/v2/unified/order/cancel';
return this.postPrivate(url, params);
}
/**
* Batch Cancel Orders
* This interface can be used for batch cancel orders (maximum 20 orders).
* Note: tradeType required for Classic accounts only; ignored in UTA (UNIFIED) mode.
* Note: ts (timestamp in nanoseconds) not supported for classic accounts.
*/
batchCancelOrders(
params: BatchCancelOrdersRequestUTA,
accountMode: 'classic' | 'unified' = 'unified',
): Promise<APISuccessResponse<BatchCancelOrdersResponseUTA>> {
const url =
accountMode === 'classic'
? `api/ua/v1/classic/order/cancel-batch?tradeType=${params.tradeType}`
: 'api/ua/v2/unified/order/cancel-batch';
return this.postPrivate(url, params);
}
/**
* Batch Cancel Orders By Symbol
* Cancels orders in batch by symbol. UTA only. Supports SPOT (non-margin), FUTURES, and MARGIN (Spot-Margin as of 2026.05.15).
*/
batchCancelOrdersBySymbol(
params: BatchCancelOrdersBySymbolRequestUTA,
): Promise<APISuccessResponse<BatchCancelOrdersBySymbolResponseUTA>> {
return this.postPrivate('api/ua/v2/unified/order/cancel-all', params);
}
/**
* Set DCP (Disconnection Protect / Deadman Switch) - Classic Only
* Set automatic order cancellation after specified time.
* Call this interface to automatically cancel all orders of the set trading pair after the specified time.
* Note: Order cancellation delay is between 0 and 10 seconds.
* Note: timeout range: -1 (unset) or 5 <= timeout <= 86400 seconds.
*/
setDCP(
params: SetDCPRequestUTA,
): Promise<APISuccessResponse<DCPResponseUTA>> {
return this.postPrivate('api/ua/v1/dcp/set', params);
}
/**
* Get DCP (Disconnection Protect / Deadman Switch) - Classic Only
* Get automatic order cancellation settings.
* If data is empty, it means DCP is not set.
*/
getDCP(
params: GetDCPRequestUTA,
): Promise<APISuccessResponse<DCPResponseUTA>> {
return this.getPrivate('api/ua/v1/dcp/query', params);
}
/**
*
* REST - Unified Trading Account - Positions
*
*/
/**
* Get Position List (UTA)
* Get the position details of all open positions.
* Note: creationTime standardized to nanoseconds as of 2026.01.12.
* Note: pageNumber, pageSize query params and liquidationPrice in each position (as of 2026.04.09).
* Note: adlPercentage added 2026.05.15.
* Note: positionMargin and riskRatio added in latest UTA update.
*/
getPositionList(
params?: GetPositionListRequestUTA,
): Promise<APISuccessResponse<PositionUTA[]>> {
return this.getPrivate('api/ua/v2/unified/position/open-list', params);
}
/**
* Batch Modify Margin Mode (UTA)
* Batch modify the margin mode for futures positions.
*/
batchModifyMarginMode(
params: BatchModifyMarginModeRequestUTA,
): Promise<APISuccessResponse<BatchModifyMarginModeResponseUTA>> {
return this.postPrivate('api/ua/v2/unified/position/margin-mode', params);
}
/**
* Modify Isolated Futures Margin (UTA)
* Extract or add margin for an isolated futures position.
*/
modifyIsolatedFuturesMargin(
params: ModifyIsolatedFuturesMarginRequestUTA,
): Promise<APISuccessResponse<ModifyIsolatedFuturesMarginResponseUTA>> {
return this.postPrivate('api/ua/v2/unified/position/modify-margin', params);
}
/**
* Get Positions History (UTA)
* Query position history information records.
* Note: Data retained for up to 3 months.
* Note: Each query limited to 7 days time range.
* Note: creationTime and closingTime standardized to nanoseconds as of 2026.01.12.
*/
getPositionsHistory(
params?: GetPositionsHistoryRequestUTA,
): Promise<APISuccessResponse<GetPositionsHistoryResponseUTA>> {
return this.getPrivate('api/ua/v2/position/history', params);
}
/**
* Get Private Funding Fee History
* Settled funding fee records for the current account.
*/
getPrivateFundingFeeHistory(
params?: GetPrivateFundingFeeHistoryRequestUTA,
): Promise<APISuccessResponse<GetPrivateFundingFeeHistoryResponseUTA>> {
return this.getPrivate('api/ua/v2/position/funding-history', params);
}
/**
* Get Account Position Tiers
* Request account position tiers (risk limit) info.
* Note: Currently only queries of classic - futures isolated margin are supported.
*/
getAccountPositionTiers(
params: GetAccountPositionTiersRequestUTA,
accountMode: 'classic' | 'unified' = 'classic',