kucoin-api 2.1.17 → 2.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/llms.txt CHANGED
@@ -3991,176 +3991,6 @@ File: .eslintrc.cjs
3991
3991
  ================
3992
3992
  // 'no-unused-vars': ['warn'],
3993
3993
 
3994
- ================
3995
- File: src/lib/BaseRestClient.ts
3996
- ================
3997
- import axios, { AxiosRequestConfig, AxiosResponse, Method } from 'axios';
3998
- import https from 'https';
3999
- ⋮----
4000
- import { neverGuard } from './misc-util.js';
4001
- import {
4002
- APIIDFutures,
4003
- APIIDFuturesSign,
4004
- APIIDMain,
4005
- APIIDMainSign,
4006
- getRestBaseUrl,
4007
- REST_CLIENT_TYPE_ENUM,
4008
- RestClientOptions,
4009
- RestClientType,
4010
- serializeParams,
4011
- } from './requestUtils.js';
4012
- import { signMessage } from './webCryptoAPI.js';
4013
- ⋮----
4014
- interface SignedRequest<T extends object | undefined = {}> {
4015
- originalParams: T;
4016
- paramsWithSign?: T & { sign: string };
4017
- serializedParams: string;
4018
- sign: string;
4019
- queryParamsWithSign: string;
4020
- timestamp: number;
4021
- recvWindow: number;
4022
- }
4023
- ⋮----
4024
- interface UnsignedRequest<T extends object | undefined = {}> {
4025
- originalParams: T;
4026
- paramsWithSign: T;
4027
- }
4028
- ⋮----
4029
- type SignMethod = 'kucoin';
4030
- ⋮----
4031
- // request: {
4032
- // url: response.config.url,
4033
- // method: response.config.method,
4034
- // data: response.config.data,
4035
- // headers: response.config.headers,
4036
- // },
4037
- ⋮----
4038
- export abstract class BaseRestClient
4039
- ⋮----
4040
- /** Defines the client type (affecting how requests & signatures behave) */
4041
- abstract getClientType(): RestClientType;
4042
- ⋮----
4043
- /**
4044
- * Create an instance of the REST client. Pass API credentials in the object in the first parameter.
4045
- * @param {RestClientOptions} [restClientOptions={}] options to configure REST API connectivity
4046
- * @param {AxiosRequestConfig} [networkOptions={}] HTTP networking options for axios
4047
- */
4048
- constructor(
4049
- restClientOptions: RestClientOptions = {},
4050
- networkOptions: AxiosRequestConfig = {},
4051
- )
4052
- ⋮----
4053
- /** Throw errors if any request params are empty */
4054
- ⋮----
4055
- /** in ms == 5 minutes by default */
4056
- ⋮----
4057
- /** inject custom rquest options based on axios specs - see axios docs for more guidance on AxiosRequestConfig: https://github.com/axios/axios#request-config */
4058
- ⋮----
4059
- // If enabled, configure a https agent with keepAlive enabled
4060
- ⋮----
4061
- // Extract existing https agent parameters, if provided, to prevent the keepAlive flag from overwriting an existing https agent completely
4062
- ⋮----
4063
- // For more advanced configuration, raise an issue on GitHub or use the "networkOptions"
4064
- // parameter to define a custom httpsAgent with the desired properties
4065
- ⋮----
4066
- // Throw if one of the 3 values is missing, but at least one of them is set
4067
- ⋮----
4068
- /**
4069
- * Generates a timestamp for signing API requests.
4070
- *
4071
- * This method can be overridden or customized using `customTimestampFn`
4072
- * to implement a custom timestamp synchronization mechanism.
4073
- * If no custom function is provided, it defaults to the current system time.
4074
- */
4075
- private getSignTimestampMs(): number
4076
- ⋮----
4077
- get(endpoint: string, params?: any)
4078
- ⋮----
4079
- post(endpoint: string, params?: any)
4080
- ⋮----
4081
- getPrivate(endpoint: string, params?: any)
4082
- ⋮----
4083
- postPrivate(endpoint: string, params?: any)
4084
- ⋮----
4085
- deletePrivate(endpoint: string, params?: any)
4086
- ⋮----
4087
- /**
4088
- * @private Make a HTTP request to a specific endpoint. Private endpoint API calls are automatically signed.
4089
- */
4090
- private async _call(
4091
- method: Method,
4092
- endpoint: string,
4093
- params?: any,
4094
- isPublicApi?: boolean,
4095
- ): Promise<any>
4096
- ⋮----
4097
- // Sanity check to make sure it's only ever prefixed by one forward slash
4098
- ⋮----
4099
- // Build a request and handle signature process
4100
- ⋮----
4101
- // Dispatch request
4102
- ⋮----
4103
- // Throw if API returns an error (e.g. insufficient balance)
4104
- ⋮----
4105
- /**
4106
- * @private generic handler to parse request exceptions
4107
- */
4108
- parseException(e: any, requestParams: any): unknown
4109
- ⋮----
4110
- // Something happened in setting up the request that triggered an error
4111
- ⋮----
4112
- // request made but no response received
4113
- ⋮----
4114
- // The request was made and the server responded with a status code
4115
- // that falls out of the range of 2xx
4116
- ⋮----
4117
- // console.error('err: ', response?.data);
4118
- ⋮----
4119
- // Prevent credentials from leaking into error messages
4120
- ⋮----
4121
- /**
4122
- * @private sign request and set recv window
4123
- */
4124
- private async signRequest<T extends object | undefined = {}>(
4125
- data: T,
4126
- endpoint: string,
4127
- method: Method,
4128
- signMethod: SignMethod,
4129
- ): Promise<SignedRequest<T>>
4130
- ⋮----
4131
- private async prepareSignParams<TParams extends object | undefined>(
4132
- method: Method,
4133
- endpoint: string,
4134
- signMethod: SignMethod,
4135
- params?: TParams,
4136
- isPublicApi?: true,
4137
- ): Promise<UnsignedRequest<TParams>>;
4138
- ⋮----
4139
- private async prepareSignParams<TParams extends object | undefined>(
4140
- method: Method,
4141
- endpoint: string,
4142
- signMethod: SignMethod,
4143
- params?: TParams,
4144
- isPublicApi?: false | undefined,
4145
- ): Promise<SignedRequest<TParams>>;
4146
- ⋮----
4147
- private async prepareSignParams<TParams extends object | undefined>(
4148
- method: Method,
4149
- endpoint: string,
4150
- signMethod: SignMethod,
4151
- params?: TParams,
4152
- isPublicApi?: boolean,
4153
- )
4154
- ⋮----
4155
- /** Returns an axios request object. Handles signing process automatically if this is a private API call */
4156
- private async buildRequest(
4157
- method: Method,
4158
- endpoint: string,
4159
- url: string,
4160
- params?: any,
4161
- isPublicApi?: boolean,
4162
- ): Promise<AxiosRequestConfig>
4163
-
4164
3994
  ================
4165
3995
  File: src/lib/BaseWSClient.ts
4166
3996
  ================
@@ -5542,371 +5372,174 @@ export interface LendingRedemption {
5542
5372
  }
5543
5373
 
5544
5374
  ================
5545
- File: README.md
5375
+ File: src/lib/BaseRestClient.ts
5546
5376
  ================
5547
- # Node.js & JavaScript SDK for Kucoin REST APIs & Websockets
5548
-
5549
- <p align="center">
5550
- <a href="https://www.npmjs.com/package/kucoin-api">
5551
- <picture>
5552
- <source media="(prefers-color-scheme: dark)" srcset="https://github.com/tiagosiebler/kucoin-api/blob/master/docs/images/logoDarkMode2.svg?raw=true#gh-dark-mode-only">
5553
- <img alt="SDK Logo" src="https://github.com/tiagosiebler/kucoin-api/blob/master/docs/images/logoBrightMode2.svg?raw=true#gh-light-mode-only">
5554
- </picture>
5555
- </a>
5556
- </p>
5557
-
5558
- [![npm version](https://img.shields.io/npm/v/kucoin-api)][1]
5559
- [![npm size](https://img.shields.io/bundlephobia/min/kucoin-api/latest)][1]
5560
- [![npm downloads](https://img.shields.io/npm/dt/kucoin-api)][1]
5561
- [![Build & Test](https://github.com/tiagosiebler/kucoin-api/actions/workflows/e2etest.yml/badge.svg?branch=master)](https://github.com/tiagosiebler/kucoin-api/actions/workflows/e2etest.yml)
5562
- [![last commit](https://img.shields.io/github/last-commit/tiagosiebler/kucoin-api)][1]
5563
- [![Telegram](https://img.shields.io/badge/chat-on%20telegram-blue.svg)](https://t.me/nodetraders)
5564
-
5565
- [1]: https://www.npmjs.com/package/kucoin-api
5566
-
5567
- Updated & performant JavaScript & Node.js SDK for the Kucoin REST APIs and WebSockets:
5568
-
5569
- - Professional, robust & performant Kucoin SDK with extensive production use in live trading environments.
5570
- - Complete integration with all Kucoin REST APIs and WebSockets.
5571
- - Dedicated clients for Spot, Futures, and Broker operations
5572
- - Unified WebSocket client for all markets
5573
- - Complete TypeScript support (with type declarations for most API requests & responses).
5574
- - Strongly typed requests and responses.
5575
- - Automated end-to-end tests ensuring reliability.
5576
- - Actively maintained with a modern, promise-driven interface.
5577
- - Robust WebSocket integration with configurable connection heartbeats & automatic reconnect then resubscribe workflows.
5578
- - Event driven messaging.
5579
- - Smart WebSocket persistence with automatic reconnection handling.
5580
- - Emit `reconnected` event when dropped connection is restored.
5581
- - Support for both public and private WebSocket streams.
5582
- - Browser-friendly HMAC signature mechanism.
5583
- - Automatically supports both ESM and CJS projects.
5584
- - Heavy automated end-to-end testing with real API calls.
5585
- - Proxy support via axios integration.
5586
- - Active community support & collaboration in telegram: [Node.js Algo Traders](https://t.me/nodetraders).
5587
-
5588
- ## Table of Contents
5589
-
5590
- - [Installation](#installation)
5591
- - [Examples](#examples)
5592
- - [Issues & Discussion](#issues--discussion)
5593
- - [Related Projects](#related-projects)
5594
- - [Documentation](#documentation)
5595
- - [Structure](#structure)
5596
- - [Usage](#usage)
5597
- - [REST API Clients](#rest-api)
5598
- - [Spot & Margin Trading](#spot--margin-trading)
5599
- - [Futures Trading](#futures-trading)
5600
- - [Broker Operations](#broker-operations)
5601
- - [WebSocket Client](#websockets)
5602
- - [Public WebSocket Streams](#public-websocket-streams)
5603
- - [Private WebSocket Streams](#private-websocket-streams)
5604
- - [Customise Logging](#customise-logging)
5605
- - [LLMs & AI](#use-with-llms--ai)
5606
- - [Contributions & Thanks](#contributions--thanks)
5607
-
5608
- ## Installation
5609
-
5610
- `npm install --save kucoin-api`
5611
-
5612
- ## Examples
5613
-
5614
- Refer to the [examples](./examples) folder for implementation demos.
5615
-
5616
- ## Issues & Discussion
5617
-
5618
- - Issues? Check the [issues tab](https://github.com/tiagosiebler/kucoin-api/issues).
5619
- - Discuss & collaborate with other node devs? Join our [Node.js Algo Traders](https://t.me/nodetraders) engineering community on telegram.
5620
- - Follow our announcement channel for real-time updates on [X/Twitter](https://x.com/sieblyio)
5621
-
5622
- <!-- template_related_projects -->
5623
-
5624
- ## Related projects
5625
-
5626
- Check out my related JavaScript/TypeScript/Node.js projects:
5627
-
5628
- - Try my REST API & WebSocket SDKs:
5629
- - [Bybit-api Node.js SDK](https://www.npmjs.com/package/bybit-api)
5630
- - [Okx-api Node.js SDK](https://www.npmjs.com/package/okx-api)
5631
- - [Binance Node.js SDK](https://www.npmjs.com/package/binance)
5632
- - [Gateio-api Node.js SDK](https://www.npmjs.com/package/gateio-api)
5633
- - [Bitget-api Node.js SDK](https://www.npmjs.com/package/bitget-api)
5634
- - [Kucoin-api Node.js SDK](https://www.npmjs.com/package/kucoin-api)
5635
- - [Coinbase-api Node.js SDK](https://www.npmjs.com/package/coinbase-api)
5636
- - [Bitmart-api Node.js SDK](https://www.npmjs.com/package/bitmart-api)
5637
- - Try my misc utilities:
5638
- - [OrderBooks Node.js](https://www.npmjs.com/package/orderbooks)
5639
- - [Crypto Exchange Account State Cache](https://www.npmjs.com/package/accountstate)
5640
- - Check out my examples:
5641
- - [awesome-crypto-examples Node.js](https://github.com/tiagosiebler/awesome-crypto-examples)
5642
- <!-- template_related_projects_end -->
5643
-
5644
- ## Documentation
5645
-
5646
- Most methods accept JS objects. These can be populated using parameters specified by Kucoin's API documentation, or check the type definition in each class within this repository.
5647
-
5648
- ### API Documentation Links
5649
-
5650
- - [Kucoin API Documentation](https://www.kucoin.com/docs-new/introduction)
5651
-
5652
- ### SDK Documentation & Guides
5653
-
5654
- - Node.js Quick Start Guides
5655
- - [Spot Node.js Kucoin Quick Start Guide](./examples/kucoin-SPOT-examples-nodejs.md)
5656
- - [Futures Node.js Kucoin Quick Start Guide](./examples/kucoin-FUTURES-examples-nodejs.md)
5657
- - [Futures Node.js Kucoin Order Placement Guide](./examples/rest-futures-orders-guide.ts)
5658
- - [REST Endpoint Function List](./docs/endpointFunctionList.md)
5659
-
5660
- ## Structure
5661
-
5662
- This project uses typescript. Resources are stored in 2 key structures:
5663
-
5664
- - [src](./src) - the whole connector written in typescript
5665
- - [examples](./examples) - some implementation examples & demonstrations. Contributions are welcome!
5666
-
5667
- ---
5668
-
5669
- # Usage
5670
-
5671
- Create API credentials on Kucoin's website:
5672
-
5673
- - [Kucoin API Key Management](https://www.kucoin.com/account/api)
5674
-
5675
- ## REST API
5676
-
5677
- The SDK provides dedicated REST clients for different trading products:
5678
-
5679
- - **SpotClient** - for spot trading and margin operations
5680
- - **FuturesClient** - for futures trading operations
5681
- - **BrokerClient** - for broker and sub-account management
5682
-
5683
- ### Spot & Margin Trading
5684
-
5685
- To use Kucoin's Spot and Margin APIs, import (or require) the `SpotClient`:
5686
-
5687
- ```javascript
5688
- const { SpotClient, FuturesClient } = require('kucoin-api');
5689
-
5690
- const client = new SpotClient({
5691
- apiKey: 'apiKeyHere',
5692
- apiSecret: 'apiSecretHere',
5693
- apiPassphrase: 'apiPassPhraseHere',
5694
- });
5695
-
5696
- try {
5697
- const spotBuyResult = await client.submitHFOrder({
5698
- clientOid: client.generateNewOrderID(),
5699
- side: 'buy',
5700
- type: 'market',
5701
- symbol: 'BTC-USDT',
5702
- size: '0.00001',
5703
- });
5704
- console.log('spotBuy ', JSON.stringify(spotBuyResult, null, 2));
5705
-
5706
- const spotSellResult = await client.submitHFOrder({
5707
- clientOid: client.generateNewOrderID(),
5708
- side: 'sell',
5709
- type: 'market',
5710
- symbol: 'BTC-USDT',
5711
- size: '0.00001',
5712
- });
5713
- console.log('spotSellResult ', JSON.stringify(spotSellResult, null, 2));
5714
- } catch (e) {
5715
- console.error(`Req error: `, e);
5377
+ import axios, { AxiosRequestConfig, AxiosResponse, Method } from 'axios';
5378
+ import https from 'https';
5379
+ ⋮----
5380
+ import { neverGuard } from './misc-util.js';
5381
+ import {
5382
+ APIIDFutures,
5383
+ APIIDFuturesSign,
5384
+ APIIDMain,
5385
+ APIIDMainSign,
5386
+ getRestBaseUrl,
5387
+ REST_CLIENT_TYPE_ENUM,
5388
+ RestClientOptions,
5389
+ RestClientType,
5390
+ serializeParams,
5391
+ } from './requestUtils.js';
5392
+ import { signMessage } from './webCryptoAPI.js';
5393
+ ⋮----
5394
+ interface SignedRequest<T extends object | undefined = {}> {
5395
+ originalParams: T;
5396
+ paramsWithSign?: T & { sign: string };
5397
+ serializedParams: string;
5398
+ sign: string;
5399
+ queryParamsWithSign: string;
5400
+ timestamp: number;
5401
+ recvWindow: number;
5716
5402
  }
5717
- ```
5718
-
5719
- See [SpotClient](./src/SpotClient.ts) for further information, or the [examples](./examples/) for lots of usage examples.
5720
-
5721
- ### Futures Trading
5722
-
5723
- Use the `FuturesClient` for futures trading operations. See [FuturesClient](./src/FuturesClient.ts) for complete API coverage.
5724
-
5725
- ### Broker Operations
5726
-
5727
- Use the `BrokerClient` for broker and sub-account management operations. See [BrokerClient](./src/BrokerClient.ts) for complete API coverage.
5728
-
5729
- ## WebSockets
5730
-
5731
- All WebSocket functionality is supported via the unified `WebsocketClient`. This client handles both spot and futures WebSocket streams with automatic connection management and reconnection.
5732
-
5733
- Key WebSocket features:
5734
-
5735
- - Event driven messaging
5736
- - Smart WebSocket persistence with automatic reconnection
5737
- - Heartbeat mechanisms to detect disconnections
5738
- - Automatic resubscription after reconnection
5739
- - Support for both public and private WebSocket streams
5740
- - Unified client for spot and futures markets
5741
-
5742
- ### Public WebSocket Streams
5743
-
5744
- For public market data, API credentials are not required:
5745
-
5746
- All available WebSockets can be used via a shared `WebsocketClient`. The WebSocket client will automatically open/track/manage connections as needed. Each unique connection (one per server URL) is tracked using a WsKey (each WsKey is a string - see [WS_KEY_MAP](src/lib/websocket/websocket-util.ts) for a list of supported values).
5747
-
5748
- Any subscribe/unsubscribe events will need to include a WsKey, so the WebSocket client understands which connection the event should be routed to. See examples below or in the [examples](./examples/) folder on GitHub.
5749
-
5750
- Data events are emitted from the WebsocketClient via the `update` event, see example below:
5751
-
5752
- ```javascript
5753
- const { WebsocketClient } = require('kucoin-api');
5754
-
5755
- const client = new WebsocketClient();
5756
-
5757
- client.on('open', (data) => {
5758
- console.log('open: ', data?.wsKey);
5759
- });
5760
-
5761
- // Data received
5762
- client.on('update', (data) => {
5763
- console.info('data received: ', JSON.stringify(data));
5764
- });
5765
-
5766
- // Something happened, attempting to reconenct
5767
- client.on('reconnect', (data) => {
5768
- console.log('reconnect: ', data);
5769
- });
5770
-
5771
- // Reconnect successful
5772
- client.on('reconnected', (data) => {
5773
- console.log('reconnected: ', data);
5774
- });
5775
-
5776
- // Connection closed. If unexpected, expect reconnect -> reconnected.
5777
- client.on('close', (data) => {
5778
- console.error('close: ', data);
5779
- });
5780
-
5781
- // Reply to a request, e.g. "subscribe"/"unsubscribe"/"authenticate"
5782
- client.on('response', (data) => {
5783
- console.info('response: ', data);
5784
- // throw new Error('res?');
5785
- });
5786
-
5787
- client.on('exception', (data) => {
5788
- console.error('exception: ', {
5789
- msg: data.msg,
5790
- errno: data.errno,
5791
- code: data.code,
5792
- syscall: data.syscall,
5793
- hostname: data.hostname,
5794
- });
5795
- });
5796
-
5797
- try {
5798
- // Optional: await a connection to be ready before subscribing (this is not necessary)
5799
- // await client.connect('futuresPublicV1');
5800
-
5801
- /**
5802
- * Examples for public futures websocket topics (that don't require authentication).
5403
+ ⋮----
5404
+ interface UnsignedRequest<T extends object | undefined = {}> {
5405
+ originalParams: T;
5406
+ paramsWithSign: T;
5407
+ }
5408
+ ⋮----
5409
+ type SignMethod = 'kucoin';
5410
+ ⋮----
5411
+ // request: {
5412
+ // url: response.config.url,
5413
+ // method: response.config.method,
5414
+ // data: response.config.data,
5415
+ // headers: response.config.headers,
5416
+ // },
5417
+ ⋮----
5418
+ export abstract class BaseRestClient
5419
+ ⋮----
5420
+ /** Defines the client type (affecting how requests & signatures behave) */
5421
+ abstract getClientType(): RestClientType;
5422
+ ⋮----
5423
+ /**
5424
+ * Create an instance of the REST client. Pass API credentials in the object in the first parameter.
5425
+ * @param {RestClientOptions} [restClientOptions={}] options to configure REST API connectivity
5426
+ * @param {AxiosRequestConfig} [networkOptions={}] HTTP networking options for axios
5427
+ */
5428
+ constructor(
5429
+ restClientOptions: RestClientOptions = {},
5430
+ networkOptions: AxiosRequestConfig = {},
5431
+ )
5432
+ ⋮----
5433
+ /** Throw errors if any request params are empty */
5434
+ ⋮----
5435
+ /** in ms == 5 minutes by default */
5436
+ ⋮----
5437
+ /** inject custom rquest options based on axios specs - see axios docs for more guidance on AxiosRequestConfig: https://github.com/axios/axios#request-config */
5438
+ ⋮----
5439
+ // If enabled, configure a https agent with keepAlive enabled
5440
+ ⋮----
5441
+ // Extract existing https agent parameters, if provided, to prevent the keepAlive flag from overwriting an existing https agent completely
5442
+ ⋮----
5443
+ // For more advanced configuration, raise an issue on GitHub or use the "networkOptions"
5444
+ // parameter to define a custom httpsAgent with the desired properties
5445
+ ⋮----
5446
+ // Throw if one of the 3 values is missing, but at least one of them is set
5447
+ ⋮----
5448
+ /**
5449
+ * Generates a timestamp for signing API requests.
5803
5450
  *
5804
- * These should all subscribe via the "futuresPublicV1" wsKey. For detailed usage, refer to the ws-spot-public.ts example.
5451
+ * This method can be overridden or customized using `customTimestampFn`
5452
+ * to implement a custom timestamp synchronization mechanism.
5453
+ * If no custom function is provided, it defaults to the current system time.
5805
5454
  */
5806
- client.subscribe(
5807
- [
5808
- '/contractMarket/tickerV2:XBTUSDM',
5809
- '/contractMarket/ticker:XBTUSDM',
5810
- '/contractMarket/level2:XBTUSDM',
5811
- '/contractMarket/execution:XBTUSDM',
5812
- '/contractMarket/level2Depth5:XBTUSDM',
5813
- '/contractMarket/level2Depth50:XBTUSDM',
5814
- '/contractMarket/limitCandle:XBTUSDTM_1hour',
5815
- '/contract/instrument:XBTUSDM',
5816
- '/contract/announcement',
5817
- '/contractMarket/snapshot:XBTUSDM',
5818
- ],
5819
- 'futuresPublicV1',
5820
- );
5821
- } catch (e) {
5822
- console.error(`Subscribe exception: `, e);
5823
- }
5824
- ```
5825
-
5826
- ### Private WebSocket Streams
5827
-
5828
- For private account data streams, API credentials are required. The WebsocketClient will automatically handle authentication when you provide API credentials.
5829
-
5830
- See [WebsocketClient](./src/WebsocketClient.ts) for further information and make sure to check the [examples](./examples/) folder for much more detail, especially [ws-spot-public.ts](./examples/ws-spot-public.ts), which explains a lot of detail.
5831
-
5832
- ---
5833
-
5834
- ## Customise Logging
5835
-
5836
- Pass a custom logger which supports the log methods `trace`, `info` and `error`, or override methods from the default logger as desired.
5837
-
5838
- ```javascript
5839
- const { WebsocketClient, DefaultLogger } = require('kucoin-api');
5840
-
5841
- // E.g. customise logging for only the trace level:
5842
- const logger = {
5843
- // Inherit existing logger methods, using an object spread
5844
- ...DefaultLogger,
5845
- // Define a custom trace function to override only that function
5846
- trace: (...params) => {
5847
- if (
5848
- [
5849
- 'Sending ping',
5850
- // 'Sending upstream ws message: ',
5851
- 'Received pong',
5852
- ].includes(params[0])
5853
- ) {
5854
- return;
5855
- }
5856
- console.log('trace', JSON.stringify(params, null, 2));
5857
- },
5858
- };
5859
-
5860
- const ws = new WebsocketClient(
5861
- {
5862
- apiKey: 'apiKeyHere',
5863
- apiSecret: 'apiSecretHere',
5864
- apiPassphrase: 'apiPassPhraseHere',
5865
- },
5866
- logger,
5867
- );
5868
- ```
5869
-
5870
- ## Use with LLMs & AI
5871
-
5872
- This SDK includes a bundled `llms.txt` file in the root of the repository. If you're developing with LLMs, use the included `llms.txt` with your LLM - it will significantly improve the LLMs understanding of how to correctly use this SDK.
5873
-
5874
- This file contains AI optimised structure of all the functions in this package, and their parameters for easier use with any learning models or artificial intelligence.
5875
-
5876
- ---
5877
-
5878
- <!-- template_contributions -->
5879
-
5880
- ### Contributions & Thanks
5881
-
5882
- Have my projects helped you? Share the love, there are many ways you can show your thanks:
5883
-
5884
- - Star & share my projects.
5885
- - Are my projects useful? Sponsor me on Github and support my effort to maintain & improve them: https://github.com/sponsors/tiagosiebler
5886
- - Have an interesting project? Get in touch & invite me to it.
5887
- - Or buy me all the coffee:
5888
- - ETH(ERC20): `0xA3Bda8BecaB4DCdA539Dc16F9C54a592553Be06C` <!-- metamask -->
5889
-
5890
- <!---
5891
- old ones:
5892
- - BTC: `1C6GWZL1XW3jrjpPTS863XtZiXL1aTK7Jk`
5893
- - BTC(SegWit): `bc1ql64wr9z3khp2gy7dqlmqw7cp6h0lcusz0zjtls`
5894
- - ETH(ERC20): `0xe0bbbc805e0e83341fadc210d6202f4022e50992`
5895
- - USDT(TRC20): `TA18VUywcNEM9ahh3TTWF3sFpt9rkLnnQa
5896
- -->
5897
- <!-- template_contributions_end -->
5898
-
5899
- ### Contributions & Pull Requests
5900
-
5901
- Contributions are encouraged, I will review any incoming pull requests. See the issues tab for todo items.
5902
-
5903
- <!-- template_star_history -->
5904
-
5905
- ## Star History
5906
-
5907
- [![Star History Chart](https://api.star-history.com/svg?repos=tiagosiebler/bybit-api,tiagosiebler/okx-api,tiagosiebler/binance,tiagosiebler/bitget-api,tiagosiebler/bitmart-api,tiagosiebler/gateio-api,tiagosiebler/kucoin-api,tiagosiebler/coinbase-api,tiagosiebler/orderbooks,tiagosiebler/accountstate,tiagosiebler/awesome-crypto-examples&type=Date)](https://star-history.com/#tiagosiebler/bybit-api&tiagosiebler/okx-api&tiagosiebler/binance&tiagosiebler/bitget-api&tiagosiebler/bitmart-api&tiagosiebler/gateio-api&tiagosiebler/kucoin-api&tiagosiebler/coinbase-api&tiagosiebler/orderbooks&tiagosiebler/accountstate&tiagosiebler/awesome-crypto-examples&Date)
5908
-
5909
- <!-- template_star_history_end -->
5455
+ private getSignTimestampMs(): number
5456
+ ⋮----
5457
+ get(endpoint: string, params?: any)
5458
+ ⋮----
5459
+ post(endpoint: string, params?: any)
5460
+ ⋮----
5461
+ getPrivate(endpoint: string, params?: any)
5462
+ ⋮----
5463
+ postPrivate(endpoint: string, params?: any)
5464
+ ⋮----
5465
+ deletePrivate(endpoint: string, params?: any)
5466
+ ⋮----
5467
+ /**
5468
+ * @private Make a HTTP request to a specific endpoint. Private endpoint API calls are automatically signed.
5469
+ */
5470
+ private async _call(
5471
+ method: Method,
5472
+ endpoint: string,
5473
+ params?: any,
5474
+ isPublicApi?: boolean,
5475
+ ): Promise<any>
5476
+ ⋮----
5477
+ // Sanity check to make sure it's only ever prefixed by one forward slash
5478
+ ⋮----
5479
+ // Build a request and handle signature process
5480
+ ⋮----
5481
+ // Dispatch request
5482
+ ⋮----
5483
+ // Throw if API returns an error (e.g. insufficient balance)
5484
+ ⋮----
5485
+ /**
5486
+ * @private generic handler to parse request exceptions
5487
+ */
5488
+ parseException(e: any, requestParams: any): unknown
5489
+ ⋮----
5490
+ // Something happened in setting up the request that triggered an error
5491
+ ⋮----
5492
+ // request made but no response received
5493
+ ⋮----
5494
+ // The request was made and the server responded with a status code
5495
+ // that falls out of the range of 2xx
5496
+ ⋮----
5497
+ // console.error('err: ', response?.data);
5498
+ ⋮----
5499
+ // Prevent credentials from leaking into error messages
5500
+ ⋮----
5501
+ /**
5502
+ * @private sign request and set recv window
5503
+ */
5504
+ private async signRequest<T extends object | undefined = {}>(
5505
+ data: T,
5506
+ endpoint: string,
5507
+ method: Method,
5508
+ signMethod: SignMethod,
5509
+ ): Promise<SignedRequest<T>>
5510
+ ⋮----
5511
+ private async prepareSignParams<TParams extends object | undefined>(
5512
+ method: Method,
5513
+ endpoint: string,
5514
+ signMethod: SignMethod,
5515
+ params?: TParams,
5516
+ isPublicApi?: true,
5517
+ ): Promise<UnsignedRequest<TParams>>;
5518
+ ⋮----
5519
+ private async prepareSignParams<TParams extends object | undefined>(
5520
+ method: Method,
5521
+ endpoint: string,
5522
+ signMethod: SignMethod,
5523
+ params?: TParams,
5524
+ isPublicApi?: false | undefined,
5525
+ ): Promise<SignedRequest<TParams>>;
5526
+ ⋮----
5527
+ private async prepareSignParams<TParams extends object | undefined>(
5528
+ method: Method,
5529
+ endpoint: string,
5530
+ signMethod: SignMethod,
5531
+ params?: TParams,
5532
+ isPublicApi?: boolean,
5533
+ )
5534
+ ⋮----
5535
+ /** Returns an axios request object. Handles signing process automatically if this is a private API call */
5536
+ private async buildRequest(
5537
+ method: Method,
5538
+ endpoint: string,
5539
+ url: string,
5540
+ params?: any,
5541
+ isPublicApi?: boolean,
5542
+ ): Promise<AxiosRequestConfig>
5910
5543
 
5911
5544
  ================
5912
5545
  File: src/types/response/spot-trading.ts
@@ -6742,272 +6375,24 @@ protected getPrivateWSKeys(): WsKey[]
6742
6375
  /** Force subscription requests to be sent in smaller batches, if a number is returned */
6743
6376
  protected getMaxTopicsPerSubscribeEvent(wsKey: WsKey): number | null
6744
6377
  ⋮----
6745
- // Return a number if there's a limit on the number of sub topics per rq
6746
- // Always 1 at a time for this exchange
6747
- ⋮----
6748
- /**
6749
- * Map one or more topics into fully prepared "subscribe request" events (already stringified and ready to send)
6750
- */
6751
- protected async getWsOperationEventsForTopics(
6752
- topicRequests: WsTopicRequest<string>[],
6753
- wsKey: WsKey,
6754
- operation: WsOperation,
6755
- ): Promise<string[]>
6756
- ⋮----
6757
- // Operations structured in a way that this exchange understands
6758
- ⋮----
6759
- // Events that are ready to send (usually stringified JSON)
6760
- ⋮----
6761
- // Not used for kucoin - auth is part of the WS URL
6762
- protected async getWsAuthRequestEvent(wsKey: WsKey): Promise<object>
6763
-
6764
- ================
6765
- File: src/types/response/spot-funding.ts
6766
- ================
6767
- /**
6768
- *
6769
- ***********
6770
- * Funding
6771
- ***********
6772
- *
6773
- */
6774
- ⋮----
6775
- export interface MarginAccountBalance {
6776
- currency: string;
6777
- totalBalance: string;
6778
- availableBalance: string;
6779
- holdBalance: string;
6780
- liability: string;
6781
- maxBorrowSize: string;
6782
- }
6783
- ⋮----
6784
- export interface MarginAccountDetail {
6785
- currency: string;
6786
- total: string;
6787
- available: string;
6788
- hold: string;
6789
- liability: string;
6790
- liabilityPrincipal: string;
6791
- liabilityInterest: string;
6792
- maxBorrowSize: string;
6793
- borrowEnabled: boolean;
6794
- transferInEnabled: boolean;
6795
- }
6796
- ⋮----
6797
- export interface MarginBalance {
6798
- totalAssetOfQuoteCurrency: string;
6799
- totalLiabilityOfQuoteCurrency: string;
6800
- debtRatio: string;
6801
- status: 'EFFECTIVE' | 'BANKRUPTCY' | 'LIQUIDATION' | 'REPAY' | 'BORROW';
6802
- accounts: MarginAccountDetail[];
6803
- }
6804
- export interface IsolatedMarginAssetDetail {
6805
- symbol: string;
6806
- debtRatio: string;
6807
- status: 'EFFECTIVE' | 'BANKRUPTCY' | 'LIQUIDATION' | 'REPAY' | 'BORROW';
6808
- baseAsset: MarginAccountDetail;
6809
- quoteAsset: MarginAccountDetail;
6810
- }
6811
- ⋮----
6812
- export interface IsolatedMarginBalance {
6813
- totalAssetOfQuoteCurrency: string;
6814
- totalLiabilityOfQuoteCurrency: string;
6815
- timestamp: number;
6816
- assets: IsolatedMarginAssetDetail[];
6817
- }
6818
- ⋮----
6819
- /**
6820
- *
6821
- * Deposit
6822
- *
6823
- */
6824
- ⋮----
6825
- export interface DepositAddress {
6826
- address: string;
6827
- memo: string;
6828
- chain: string;
6829
- }
6830
- ⋮----
6831
- export type DepositAddressV2 = DepositAddress & {
6832
- contractAddress: string;
6833
- };
6834
- ⋮----
6835
- export interface DepositAddressV3 {
6836
- address: string;
6837
- memo: string;
6838
- chainId: string;
6839
- to: 'MAIN' | 'TRADE'; // main (funding account), trade (spot trading account)
6840
- expirationDate: number;
6841
- currency: string;
6842
- contractAddress: string;
6843
- chainName: string;
6844
- }
6845
- ⋮----
6846
- to: 'MAIN' | 'TRADE'; // main (funding account), trade (spot trading account)
6847
- ⋮----
6848
- export interface HistoricalDepositItem {
6849
- currency: string;
6850
- createAt: number;
6851
- amount: string;
6852
- walletTxId: string;
6853
- isInner: boolean;
6854
- status: 'PROCESSING' | 'SUCCESS' | 'FAILURE';
6855
- }
6856
- export interface DepositItem {
6857
- currency?: string;
6858
- chain?: string;
6859
- status?: 'PROCESSING' | 'SUCCESS' | 'FAILURE';
6860
- address?: string;
6861
- memo?: string;
6862
- isInner?: boolean;
6863
- amount?: string;
6864
- fee?: string;
6865
- walletTxId?: string | null;
6866
- createdAt?: number;
6867
- updatedAt?: number;
6868
- remark?: string;
6869
- arrears?: boolean;
6870
- }
6871
- ⋮----
6872
- export interface Deposits {
6873
- currentPage: number;
6874
- pageSize: number;
6875
- totalNum: number;
6876
- totalPage: number;
6877
- items: DepositItem[];
6878
- }
6879
- ⋮----
6880
- export interface V1HistoricalDeposits {
6881
- currentPage: number;
6882
- pageSize: number;
6883
- totalNum: number;
6884
- totalPage: number;
6885
- items: HistoricalDepositItem[];
6886
- }
6887
- ⋮----
6888
- export interface CreateDepositAddressV3Response {
6889
- address: string;
6890
- memo: string | null;
6891
- chainName: string;
6892
- chainId: string;
6893
- to: string;
6894
- currency: string;
6895
- expirationDate?: string;
6896
- }
6897
- ⋮----
6898
- /**
6899
- *
6900
- * Withdrawals
6901
- *
6902
- */
6903
- ⋮----
6904
- interface DetailedWithdrawal {
6905
- id: string;
6906
- address: string;
6907
- memo: string;
6908
- currency: string;
6909
- chain: string;
6910
- amount: string;
6911
- fee: string;
6912
- walletTxId: string;
6913
- isInner: boolean;
6914
- status: 'PROCESSING' | 'WALLET_PROCESSING' | 'SUCCESS' | 'FAILURE';
6915
- remark: string;
6916
- createdAt: number;
6917
- updatedAt: number;
6918
- }
6919
- ⋮----
6920
- interface HistoricalWithdrawal {
6921
- currency: string;
6922
- createAt: number;
6923
- amount: string;
6924
- address: string;
6925
- walletTxId: string;
6926
- isInner: boolean;
6927
- status: 'PROCESSING' | 'SUCCESS' | 'FAILURE';
6928
- }
6929
- ⋮----
6930
- export interface Withdrawals {
6931
- currentPage: number;
6932
- pageSize: number;
6933
- totalNum: number;
6934
- totalPage: number;
6935
- items: DetailedWithdrawal[];
6936
- }
6937
- ⋮----
6938
- export interface HistoricalWithdrawalsV1 {
6939
- currentPage: number;
6940
- pageSize: number;
6941
- totalNum: number;
6942
- totalPage: number;
6943
- items: HistoricalWithdrawal[];
6944
- }
6945
- ⋮----
6946
- export interface WithdrawalQuotas {
6947
- currency: string;
6948
- limitBTCAmount: string;
6949
- usedBTCAmount: string;
6950
- quotaCurrency: string;
6951
- limitQuotaCurrencyAmount: string;
6952
- usedQuotaCurrencyAmount: string;
6953
- remainAmount: string;
6954
- availableAmount: string;
6955
- withdrawMinFee: string;
6956
- innerWithdrawMinFee: string;
6957
- withdrawMinSize: string;
6958
- isWithdrawEnabled: boolean;
6959
- precision: number;
6960
- chain: string;
6961
- reason: string | null;
6962
- lockedAmount: string;
6963
- }
6964
- ⋮----
6965
- export interface WithdrawalById {
6966
- id: string;
6967
- uid: number;
6968
- currency: string;
6969
- chainId: string;
6970
- chainName: string;
6971
- currencyName: string;
6972
- status: string;
6973
- failureReason: string;
6974
- failureReasonMsg: string | null;
6975
- address: string;
6976
- memo: string;
6977
- isInner: boolean;
6978
- amount: string;
6979
- fee: string;
6980
- walletTxId: string | null;
6981
- addressRemark: string | null;
6982
- remark: string;
6983
- createdAt: number;
6984
- cancelType: string;
6985
- taxes: string | null;
6986
- taxDescription: string | null;
6987
- returnStatus: string;
6988
- returnAmount: string | null;
6989
- returnCurrency: string;
6990
- }
6991
- ⋮----
6378
+ // Return a number if there's a limit on the number of sub topics per rq
6379
+ // Always 1 at a time for this exchange
6380
+ ⋮----
6992
6381
  /**
6993
- *
6994
- * Transfer
6995
- *
6996
- */
6382
+ * Map one or more topics into fully prepared "subscribe request" events (already stringified and ready to send)
6383
+ */
6384
+ protected async getWsOperationEventsForTopics(
6385
+ topicRequests: WsTopicRequest<string>[],
6386
+ wsKey: WsKey,
6387
+ operation: WsOperation,
6388
+ ): Promise<string[]>
6997
6389
  ⋮----
6998
- export interface TransferableFunds {
6999
- currency: string; // Currency
7000
- balance: string; // Total funds in an account.
7001
- available: string; // Funds available to withdraw or trade.
7002
- holds: string; // Funds on hold (not available for use).
7003
- transferable: string; // Funds available to transfer.
7004
- }
6390
+ // Operations structured in a way that this exchange understands
7005
6391
  ⋮----
7006
- currency: string; // Currency
7007
- balance: string; // Total funds in an account.
7008
- available: string; // Funds available to withdraw or trade.
7009
- holds: string; // Funds on hold (not available for use).
7010
- transferable: string; // Funds available to transfer.
6392
+ // Events that are ready to send (usually stringified JSON)
6393
+ ⋮----
6394
+ // Not used for kucoin - auth is part of the WS URL
6395
+ protected async getWsAuthRequestEvent(wsKey: WsKey): Promise<object>
7011
6396
 
7012
6397
  ================
7013
6398
  File: src/types/request/futures.types.ts
@@ -7232,77 +6617,692 @@ export interface AccountFillsRequest {
7232
6617
  *
7233
6618
  */
7234
6619
  ⋮----
7235
- export interface MaxOpenSizeRequest {
7236
- symbol: string;
7237
- price: string;
7238
- leverage: number;
6620
+ export interface MaxOpenSizeRequest {
6621
+ symbol: string;
6622
+ price: string;
6623
+ leverage: number;
6624
+ }
6625
+ ⋮----
6626
+ /**
6627
+ *
6628
+ * Futures risk limit
6629
+ *
6630
+ */
6631
+ ⋮----
6632
+ /**
6633
+ *
6634
+ * Futures funding fees
6635
+ *
6636
+ */
6637
+ ⋮----
6638
+ export interface GetFundingRatesRequest {
6639
+ symbol: string;
6640
+ from: number;
6641
+ to: number;
6642
+ }
6643
+ ⋮----
6644
+ export interface GetFundingHistoryRequest {
6645
+ symbol: string;
6646
+ from?: number;
6647
+ to?: number;
6648
+ reverse?: boolean;
6649
+ offset?: number;
6650
+ forward?: boolean;
6651
+ maxCount?: number;
6652
+ }
6653
+ ⋮----
6654
+ /**
6655
+ *
6656
+ * Futures Copy Trading
6657
+ *
6658
+ */
6659
+ ⋮----
6660
+ export interface CopyTradeOrderRequest {
6661
+ clientOid: string;
6662
+ side: 'buy' | 'sell';
6663
+ symbol: string;
6664
+ type: 'limit' | 'market';
6665
+ leverage?: number;
6666
+ remark?: string;
6667
+ stop?: 'up' | 'down';
6668
+ stopPriceType?: 'TP' | 'MP' | 'IP';
6669
+ stopPrice?: string;
6670
+ reduceOnly?: boolean;
6671
+ closeOrder?: boolean;
6672
+ forceHold?: boolean;
6673
+ marginMode?: 'ISOLATED' | 'CROSS';
6674
+ price?: string;
6675
+ size: number;
6676
+ timeInForce?: 'GTC' | 'IOC';
6677
+ postOnly?: boolean;
6678
+ hidden?: boolean;
6679
+ iceberg?: boolean;
6680
+ visibleSize?: string;
6681
+ }
6682
+ ⋮----
6683
+ export interface CopyTradeSLTPOrderRequest extends CopyTradeOrderRequest {
6684
+ triggerStopUpPrice?: string; // Take profit price
6685
+ triggerStopDownPrice?: string; // Stop loss price
6686
+ stopPriceType?: 'TP' | 'MP' | 'IP';
6687
+ }
6688
+ ⋮----
6689
+ triggerStopUpPrice?: string; // Take profit price
6690
+ triggerStopDownPrice?: string; // Stop loss price
6691
+
6692
+ ================
6693
+ File: src/types/response/spot-funding.ts
6694
+ ================
6695
+ /**
6696
+ *
6697
+ ***********
6698
+ * Funding
6699
+ ***********
6700
+ *
6701
+ */
6702
+ ⋮----
6703
+ export interface MarginAccountBalance {
6704
+ currency: string;
6705
+ totalBalance: string;
6706
+ availableBalance: string;
6707
+ holdBalance: string;
6708
+ liability: string;
6709
+ maxBorrowSize: string;
6710
+ }
6711
+ ⋮----
6712
+ export interface MarginAccountDetail {
6713
+ currency: string;
6714
+ total: string;
6715
+ available: string;
6716
+ hold: string;
6717
+ liability: string;
6718
+ liabilityPrincipal: string;
6719
+ liabilityInterest: string;
6720
+ maxBorrowSize: string;
6721
+ borrowEnabled: boolean;
6722
+ transferInEnabled: boolean;
6723
+ }
6724
+ ⋮----
6725
+ export interface MarginBalance {
6726
+ totalAssetOfQuoteCurrency: string;
6727
+ totalLiabilityOfQuoteCurrency: string;
6728
+ debtRatio: string;
6729
+ status: 'EFFECTIVE' | 'BANKRUPTCY' | 'LIQUIDATION' | 'REPAY' | 'BORROW';
6730
+ accounts: MarginAccountDetail[];
6731
+ }
6732
+ export interface IsolatedMarginAssetDetail {
6733
+ symbol: string;
6734
+ debtRatio: string;
6735
+ status: 'EFFECTIVE' | 'BANKRUPTCY' | 'LIQUIDATION' | 'REPAY' | 'BORROW';
6736
+ baseAsset: MarginAccountDetail;
6737
+ quoteAsset: MarginAccountDetail;
6738
+ }
6739
+ ⋮----
6740
+ export interface IsolatedMarginBalance {
6741
+ totalAssetOfQuoteCurrency: string;
6742
+ totalLiabilityOfQuoteCurrency: string;
6743
+ timestamp: number;
6744
+ assets: IsolatedMarginAssetDetail[];
6745
+ }
6746
+ ⋮----
6747
+ /**
6748
+ *
6749
+ * Deposit
6750
+ *
6751
+ */
6752
+ ⋮----
6753
+ export interface DepositAddress {
6754
+ address: string;
6755
+ memo: string;
6756
+ chain: string;
6757
+ }
6758
+ ⋮----
6759
+ export type DepositAddressV2 = DepositAddress & {
6760
+ contractAddress: string;
6761
+ };
6762
+ ⋮----
6763
+ export interface DepositAddressV3 {
6764
+ address: string;
6765
+ memo: string;
6766
+ chainId: string;
6767
+ to: 'MAIN' | 'TRADE'; // main (funding account), trade (spot trading account)
6768
+ expirationDate: number;
6769
+ currency: string;
6770
+ contractAddress: string;
6771
+ chainName: string;
6772
+ }
6773
+ ⋮----
6774
+ to: 'MAIN' | 'TRADE'; // main (funding account), trade (spot trading account)
6775
+ ⋮----
6776
+ export interface HistoricalDepositItem {
6777
+ currency: string;
6778
+ createAt: number;
6779
+ amount: string;
6780
+ walletTxId: string;
6781
+ isInner: boolean;
6782
+ status: 'PROCESSING' | 'SUCCESS' | 'FAILURE';
6783
+ }
6784
+ export interface DepositItem {
6785
+ currency?: string;
6786
+ chain?: string;
6787
+ status?: 'PROCESSING' | 'SUCCESS' | 'FAILURE';
6788
+ address?: string;
6789
+ memo?: string;
6790
+ isInner?: boolean;
6791
+ amount?: string;
6792
+ fee?: string;
6793
+ walletTxId?: string | null;
6794
+ createdAt?: number;
6795
+ updatedAt?: number;
6796
+ remark?: string;
6797
+ arrears?: boolean;
6798
+ }
6799
+ ⋮----
6800
+ export interface Deposits {
6801
+ currentPage: number;
6802
+ pageSize: number;
6803
+ totalNum: number;
6804
+ totalPage: number;
6805
+ items: DepositItem[];
6806
+ }
6807
+ ⋮----
6808
+ export interface V1HistoricalDeposits {
6809
+ currentPage: number;
6810
+ pageSize: number;
6811
+ totalNum: number;
6812
+ totalPage: number;
6813
+ items: HistoricalDepositItem[];
6814
+ }
6815
+ ⋮----
6816
+ export interface CreateDepositAddressV3Response {
6817
+ address: string;
6818
+ memo: string | null;
6819
+ chainName: string;
6820
+ chainId: string;
6821
+ to: string;
6822
+ currency: string;
6823
+ expirationDate?: string;
6824
+ }
6825
+ ⋮----
6826
+ /**
6827
+ *
6828
+ * Withdrawals
6829
+ *
6830
+ */
6831
+ ⋮----
6832
+ interface DetailedWithdrawal {
6833
+ id: string;
6834
+ address: string;
6835
+ memo: string;
6836
+ currency: string;
6837
+ chain: string;
6838
+ amount: string;
6839
+ fee: string;
6840
+ walletTxId: string;
6841
+ isInner: boolean;
6842
+ status: 'PROCESSING' | 'WALLET_PROCESSING' | 'SUCCESS' | 'FAILURE';
6843
+ remark: string;
6844
+ createdAt: number;
6845
+ updatedAt: number;
6846
+ }
6847
+ ⋮----
6848
+ interface HistoricalWithdrawal {
6849
+ currency: string;
6850
+ createAt: number;
6851
+ amount: string;
6852
+ address: string;
6853
+ walletTxId: string;
6854
+ isInner: boolean;
6855
+ status: 'PROCESSING' | 'SUCCESS' | 'FAILURE';
7239
6856
  }
7240
6857
  ⋮----
7241
- /**
7242
- *
7243
- * Futures risk limit
7244
- *
7245
- */
6858
+ export interface Withdrawals {
6859
+ currentPage: number;
6860
+ pageSize: number;
6861
+ totalNum: number;
6862
+ totalPage: number;
6863
+ items: DetailedWithdrawal[];
6864
+ }
7246
6865
  ⋮----
7247
- /**
7248
- *
7249
- * Futures funding fees
7250
- *
7251
- */
6866
+ export interface HistoricalWithdrawalsV1 {
6867
+ currentPage: number;
6868
+ pageSize: number;
6869
+ totalNum: number;
6870
+ totalPage: number;
6871
+ items: HistoricalWithdrawal[];
6872
+ }
7252
6873
  ⋮----
7253
- export interface GetFundingRatesRequest {
7254
- symbol: string;
7255
- from: number;
7256
- to: number;
6874
+ export interface WithdrawalQuotas {
6875
+ currency: string;
6876
+ limitBTCAmount: string;
6877
+ usedBTCAmount: string;
6878
+ quotaCurrency: string;
6879
+ limitQuotaCurrencyAmount: string;
6880
+ usedQuotaCurrencyAmount: string;
6881
+ remainAmount: string;
6882
+ availableAmount: string;
6883
+ withdrawMinFee: string;
6884
+ innerWithdrawMinFee: string;
6885
+ withdrawMinSize: string;
6886
+ isWithdrawEnabled: boolean;
6887
+ precision: number;
6888
+ chain: string;
6889
+ reason: string | null;
6890
+ lockedAmount: string;
7257
6891
  }
7258
6892
  ⋮----
7259
- export interface GetFundingHistoryRequest {
7260
- symbol: string;
7261
- from?: number;
7262
- to?: number;
7263
- reverse?: boolean;
7264
- offset?: number;
7265
- forward?: boolean;
7266
- maxCount?: number;
6893
+ export interface WithdrawalById {
6894
+ id: string;
6895
+ uid: number;
6896
+ currency: string;
6897
+ chainId: string;
6898
+ chainName: string;
6899
+ currencyName: string;
6900
+ status: string;
6901
+ failureReason: string;
6902
+ failureReasonMsg: string | null;
6903
+ address: string;
6904
+ memo: string;
6905
+ isInner: boolean;
6906
+ amount: string;
6907
+ fee: string;
6908
+ walletTxId: string | null;
6909
+ addressRemark: string | null;
6910
+ remark: string;
6911
+ createdAt: number;
6912
+ cancelType: string;
6913
+ taxes: string | null;
6914
+ taxDescription: string | null;
6915
+ returnStatus: string;
6916
+ returnAmount: string | null;
6917
+ returnCurrency: string;
7267
6918
  }
7268
6919
  ⋮----
7269
6920
  /**
7270
6921
  *
7271
- * Futures Copy Trading
6922
+ * Transfer
7272
6923
  *
7273
6924
  */
7274
6925
  ⋮----
7275
- export interface CopyTradeOrderRequest {
7276
- clientOid: string;
7277
- side: 'buy' | 'sell';
7278
- symbol: string;
7279
- type: 'limit' | 'market';
7280
- leverage?: number;
7281
- remark?: string;
7282
- stop?: 'up' | 'down';
7283
- stopPriceType?: 'TP' | 'MP' | 'IP';
7284
- stopPrice?: string;
7285
- reduceOnly?: boolean;
7286
- closeOrder?: boolean;
7287
- forceHold?: boolean;
7288
- marginMode?: 'ISOLATED' | 'CROSS';
7289
- price?: string;
7290
- size: number;
7291
- timeInForce?: 'GTC' | 'IOC';
7292
- postOnly?: boolean;
7293
- hidden?: boolean;
7294
- iceberg?: boolean;
7295
- visibleSize?: string;
6926
+ export interface TransferableFunds {
6927
+ currency: string; // Currency
6928
+ balance: string; // Total funds in an account.
6929
+ available: string; // Funds available to withdraw or trade.
6930
+ holds: string; // Funds on hold (not available for use).
6931
+ transferable: string; // Funds available to transfer.
6932
+ }
6933
+ ⋮----
6934
+ currency: string; // Currency
6935
+ balance: string; // Total funds in an account.
6936
+ available: string; // Funds available to withdraw or trade.
6937
+ holds: string; // Funds on hold (not available for use).
6938
+ transferable: string; // Funds available to transfer.
6939
+
6940
+ ================
6941
+ File: README.md
6942
+ ================
6943
+ # Node.js & JavaScript SDK for Kucoin REST APIs & Websockets
6944
+
6945
+ <p align="center">
6946
+ <a href="https://www.npmjs.com/package/kucoin-api">
6947
+ <picture>
6948
+ <source media="(prefers-color-scheme: dark)" srcset="https://github.com/tiagosiebler/kucoin-api/blob/master/docs/images/logoDarkMode2.svg?raw=true#gh-dark-mode-only">
6949
+ <img alt="SDK Logo" src="https://github.com/tiagosiebler/kucoin-api/blob/master/docs/images/logoBrightMode2.svg?raw=true#gh-light-mode-only">
6950
+ </picture>
6951
+ </a>
6952
+ </p>
6953
+
6954
+ [![npm version](https://img.shields.io/npm/v/kucoin-api)][1]
6955
+ [![npm size](https://img.shields.io/bundlephobia/min/kucoin-api/latest)][1]
6956
+ [![npm downloads](https://img.shields.io/npm/dt/kucoin-api)][1]
6957
+ [![Build & Test](https://github.com/tiagosiebler/kucoin-api/actions/workflows/e2etest.yml/badge.svg?branch=master)](https://github.com/tiagosiebler/kucoin-api/actions/workflows/e2etest.yml)
6958
+ [![last commit](https://img.shields.io/github/last-commit/tiagosiebler/kucoin-api)][1]
6959
+ [![Telegram](https://img.shields.io/badge/chat-on%20telegram-blue.svg)](https://t.me/nodetraders)
6960
+
6961
+ [1]: https://www.npmjs.com/package/kucoin-api
6962
+
6963
+ Updated & performant JavaScript & Node.js SDK for the Kucoin REST APIs and WebSockets:
6964
+
6965
+ - Professional, robust & performant Kucoin SDK with extensive production use in live trading environments.
6966
+ - Complete integration with all Kucoin REST APIs and WebSockets.
6967
+ - Dedicated REST clients for Spot, Futures, and Broker operations
6968
+ - Unified WebSocket client for all markets
6969
+ - Complete TypeScript support (with type declarations for most API requests & responses).
6970
+ - Strongly typed requests and responses.
6971
+ - Automated end-to-end tests ensuring reliability.
6972
+ - Actively maintained with a modern, promise-driven interface.
6973
+ - Robust WebSocket integration with configurable connection heartbeats & automatic reconnect then resubscribe workflows.
6974
+ - Event driven messaging.
6975
+ - Smart WebSocket persistence with automatic reconnection handling.
6976
+ - Emit `reconnected` event when dropped connection is restored.
6977
+ - Support for both public and private WebSocket streams.
6978
+ - Browser-friendly HMAC signature mechanism.
6979
+ - Automatically supports both ESM and CJS projects.
6980
+ - Heavy automated end-to-end testing with real API calls.
6981
+ - Proxy support via axios integration.
6982
+ - Active community support & collaboration in telegram: [Node.js Algo Traders](https://t.me/nodetraders).
6983
+
6984
+ ## Table of Contents
6985
+
6986
+ - [Installation](#installation)
6987
+ - [Examples](#examples)
6988
+ - [Issues & Discussion](#issues--discussion)
6989
+ - [Related Projects](#related-projects)
6990
+ - [Documentation](#documentation)
6991
+ - [Structure](#structure)
6992
+ - [Usage](#usage)
6993
+ - [REST API Clients](#rest-api)
6994
+ - [Spot & Margin Trading](#spot--margin-trading)
6995
+ - [Futures Trading](#futures-trading)
6996
+ - [Broker Operations](#broker-operations)
6997
+ - [WebSocket Client](#websockets)
6998
+ - [Public WebSocket Streams](#public-websocket-streams)
6999
+ - [Private WebSocket Streams](#private-websocket-streams)
7000
+ - [Customise Logging](#customise-logging)
7001
+ - [LLMs & AI](#use-with-llms--ai)
7002
+ - [Contributions & Thanks](#contributions--thanks)
7003
+
7004
+ ## Installation
7005
+
7006
+ `npm install --save kucoin-api`
7007
+
7008
+ ## Examples
7009
+
7010
+ Refer to the [examples](./examples) folder for implementation demos.
7011
+
7012
+ ## Issues & Discussion
7013
+
7014
+ - Issues? Check the [issues tab](https://github.com/tiagosiebler/kucoin-api/issues).
7015
+ - Discuss & collaborate with other node devs? Join our [Node.js Algo Traders](https://t.me/nodetraders) engineering community on telegram.
7016
+ - Follow our announcement channel for real-time updates on [X/Twitter](https://x.com/sieblyio)
7017
+
7018
+ <!-- template_related_projects -->
7019
+
7020
+ ## Related projects
7021
+
7022
+ Check out my related JavaScript/TypeScript/Node.js projects:
7023
+
7024
+ - Try my REST API & WebSocket SDKs:
7025
+ - [Bybit-api Node.js SDK](https://www.npmjs.com/package/bybit-api)
7026
+ - [Okx-api Node.js SDK](https://www.npmjs.com/package/okx-api)
7027
+ - [Binance Node.js SDK](https://www.npmjs.com/package/binance)
7028
+ - [Gateio-api Node.js SDK](https://www.npmjs.com/package/gateio-api)
7029
+ - [Bitget-api Node.js SDK](https://www.npmjs.com/package/bitget-api)
7030
+ - [Kucoin-api Node.js SDK](https://www.npmjs.com/package/kucoin-api)
7031
+ - [Coinbase-api Node.js SDK](https://www.npmjs.com/package/coinbase-api)
7032
+ - [Bitmart-api Node.js SDK](https://www.npmjs.com/package/bitmart-api)
7033
+ - Try my misc utilities:
7034
+ - [OrderBooks Node.js](https://www.npmjs.com/package/orderbooks)
7035
+ - [Crypto Exchange Account State Cache](https://www.npmjs.com/package/accountstate)
7036
+ - Check out my examples:
7037
+ - [awesome-crypto-examples Node.js](https://github.com/tiagosiebler/awesome-crypto-examples)
7038
+ <!-- template_related_projects_end -->
7039
+
7040
+ ## Documentation
7041
+
7042
+ Most methods accept JS objects. These can be populated using parameters specified by Kucoin's API documentation, or check the type definition in each class within this repository.
7043
+
7044
+ ### API Documentation Links
7045
+
7046
+ - [Kucoin API Documentation](https://www.kucoin.com/docs-new/introduction)
7047
+
7048
+ ### SDK Documentation & Guides
7049
+
7050
+ - Node.js Quick Start Guides
7051
+ - [Spot Node.js Kucoin Quick Start Guide](./examples/kucoin-SPOT-examples-nodejs.md)
7052
+ - [Futures Node.js Kucoin Quick Start Guide](./examples/kucoin-FUTURES-examples-nodejs.md)
7053
+ - [Futures Node.js Kucoin Order Placement Guide](./examples/rest-futures-orders-guide.ts)
7054
+ - [REST Endpoint Function List](./docs/endpointFunctionList.md)
7055
+
7056
+ ## Structure
7057
+
7058
+ This project uses typescript. Resources are stored in 2 key structures:
7059
+
7060
+ - [src](./src) - the whole connector written in typescript
7061
+ - [examples](./examples) - some implementation examples & demonstrations. Contributions are welcome!
7062
+
7063
+ ---
7064
+
7065
+ # Usage
7066
+
7067
+ Create API credentials on Kucoin's website:
7068
+
7069
+ - [Kucoin API Key Management](https://www.kucoin.com/account/api)
7070
+
7071
+ ## REST API
7072
+
7073
+ The SDK provides dedicated REST clients for different trading products:
7074
+
7075
+ - **SpotClient** - for spot trading and margin operations
7076
+ - **FuturesClient** - for futures trading operations
7077
+ - **BrokerClient** - for broker and sub-account management
7078
+
7079
+ ### Spot & Margin Trading
7080
+
7081
+ To use Kucoin's Spot and Margin APIs, import (or require) the `SpotClient`:
7082
+
7083
+ ```javascript
7084
+ const { SpotClient, FuturesClient } = require('kucoin-api');
7085
+
7086
+ const client = new SpotClient({
7087
+ apiKey: 'apiKeyHere',
7088
+ apiSecret: 'apiSecretHere',
7089
+ apiPassphrase: 'apiPassPhraseHere',
7090
+ });
7091
+
7092
+ try {
7093
+ const spotBuyResult = await client.submitHFOrder({
7094
+ clientOid: client.generateNewOrderID(),
7095
+ side: 'buy',
7096
+ type: 'market',
7097
+ symbol: 'BTC-USDT',
7098
+ size: '0.00001',
7099
+ });
7100
+ console.log('spotBuy ', JSON.stringify(spotBuyResult, null, 2));
7101
+
7102
+ const spotSellResult = await client.submitHFOrder({
7103
+ clientOid: client.generateNewOrderID(),
7104
+ side: 'sell',
7105
+ type: 'market',
7106
+ symbol: 'BTC-USDT',
7107
+ size: '0.00001',
7108
+ });
7109
+ console.log('spotSellResult ', JSON.stringify(spotSellResult, null, 2));
7110
+ } catch (e) {
7111
+ console.error(`Req error: `, e);
7296
7112
  }
7297
- ⋮----
7298
- export interface CopyTradeSLTPOrderRequest extends CopyTradeOrderRequest {
7299
- triggerStopUpPrice?: string; // Take profit price
7300
- triggerStopDownPrice?: string; // Stop loss price
7301
- stopPriceType?: 'TP' | 'MP' | 'IP';
7113
+ ```
7114
+
7115
+ See [SpotClient](./src/SpotClient.ts) for further information, or the [examples](./examples/) for lots of usage examples.
7116
+
7117
+ ### Futures Trading
7118
+
7119
+ Use the `FuturesClient` for futures trading operations. See [FuturesClient](./src/FuturesClient.ts) for complete API coverage.
7120
+
7121
+ ### Broker Operations
7122
+
7123
+ Use the `BrokerClient` for broker and sub-account management operations. See [BrokerClient](./src/BrokerClient.ts) for complete API coverage.
7124
+
7125
+ ## WebSockets
7126
+
7127
+ All WebSocket functionality is supported via the unified `WebsocketClient`. This client handles both spot and futures WebSocket streams with automatic connection management and reconnection.
7128
+
7129
+ Key WebSocket features:
7130
+
7131
+ - Event driven messaging
7132
+ - Smart WebSocket persistence with automatic reconnection
7133
+ - Heartbeat mechanisms to detect disconnections
7134
+ - Automatic resubscription after reconnection
7135
+ - Support for both public and private WebSocket streams
7136
+ - Unified client for spot and futures markets
7137
+
7138
+ ### Public WebSocket Streams
7139
+
7140
+ For public market data, API credentials are not required:
7141
+
7142
+ All available WebSockets can be used via a shared `WebsocketClient`. The WebSocket client will automatically open/track/manage connections as needed. Each unique connection (one per server URL) is tracked using a WsKey (each WsKey is a string - see [WS_KEY_MAP](src/lib/websocket/websocket-util.ts) for a list of supported values).
7143
+
7144
+ Any subscribe/unsubscribe events will need to include a WsKey, so the WebSocket client understands which connection the event should be routed to. See examples below or in the [examples](./examples/) folder on GitHub.
7145
+
7146
+ Data events are emitted from the WebsocketClient via the `update` event, see example below:
7147
+
7148
+ ```javascript
7149
+ const { WebsocketClient } = require('kucoin-api');
7150
+
7151
+ const client = new WebsocketClient();
7152
+
7153
+ client.on('open', (data) => {
7154
+ console.log('open: ', data?.wsKey);
7155
+ });
7156
+
7157
+ // Data received
7158
+ client.on('update', (data) => {
7159
+ console.info('data received: ', JSON.stringify(data));
7160
+ });
7161
+
7162
+ // Something happened, attempting to reconenct
7163
+ client.on('reconnect', (data) => {
7164
+ console.log('reconnect: ', data);
7165
+ });
7166
+
7167
+ // Reconnect successful
7168
+ client.on('reconnected', (data) => {
7169
+ console.log('reconnected: ', data);
7170
+ });
7171
+
7172
+ // Connection closed. If unexpected, expect reconnect -> reconnected.
7173
+ client.on('close', (data) => {
7174
+ console.error('close: ', data);
7175
+ });
7176
+
7177
+ // Reply to a request, e.g. "subscribe"/"unsubscribe"/"authenticate"
7178
+ client.on('response', (data) => {
7179
+ console.info('response: ', data);
7180
+ // throw new Error('res?');
7181
+ });
7182
+
7183
+ client.on('exception', (data) => {
7184
+ console.error('exception: ', {
7185
+ msg: data.msg,
7186
+ errno: data.errno,
7187
+ code: data.code,
7188
+ syscall: data.syscall,
7189
+ hostname: data.hostname,
7190
+ });
7191
+ });
7192
+
7193
+ try {
7194
+ // Optional: await a connection to be ready before subscribing (this is not necessary)
7195
+ // await client.connect('futuresPublicV1');
7196
+
7197
+ /**
7198
+ * Examples for public futures websocket topics (that don't require authentication).
7199
+ *
7200
+ * These should all subscribe via the "futuresPublicV1" wsKey. For detailed usage, refer to the ws-spot-public.ts example.
7201
+ */
7202
+ client.subscribe(
7203
+ [
7204
+ '/contractMarket/tickerV2:XBTUSDM',
7205
+ '/contractMarket/ticker:XBTUSDM',
7206
+ '/contractMarket/level2:XBTUSDM',
7207
+ '/contractMarket/execution:XBTUSDM',
7208
+ '/contractMarket/level2Depth5:XBTUSDM',
7209
+ '/contractMarket/level2Depth50:XBTUSDM',
7210
+ '/contractMarket/limitCandle:XBTUSDTM_1hour',
7211
+ '/contract/instrument:XBTUSDM',
7212
+ '/contract/announcement',
7213
+ '/contractMarket/snapshot:XBTUSDM',
7214
+ ],
7215
+ 'futuresPublicV1',
7216
+ );
7217
+ } catch (e) {
7218
+ console.error(`Subscribe exception: `, e);
7302
7219
  }
7303
- ⋮----
7304
- triggerStopUpPrice?: string; // Take profit price
7305
- triggerStopDownPrice?: string; // Stop loss price
7220
+ ```
7221
+
7222
+ ### Private WebSocket Streams
7223
+
7224
+ For private account data streams, API credentials are required. The WebsocketClient will automatically handle authentication when you provide API credentials.
7225
+
7226
+ See [WebsocketClient](./src/WebsocketClient.ts) for further information and make sure to check the [examples](./examples/) folder for much more detail, especially [ws-spot-public.ts](./examples/ws-spot-public.ts), which explains a lot of detail.
7227
+
7228
+ ---
7229
+
7230
+ ## Customise Logging
7231
+
7232
+ Pass a custom logger which supports the log methods `trace`, `info` and `error`, or override methods from the default logger as desired.
7233
+
7234
+ ```javascript
7235
+ const { WebsocketClient, DefaultLogger } = require('kucoin-api');
7236
+
7237
+ // E.g. customise logging for only the trace level:
7238
+ const logger = {
7239
+ // Inherit existing logger methods, using an object spread
7240
+ ...DefaultLogger,
7241
+ // Define a custom trace function to override only that function
7242
+ trace: (...params) => {
7243
+ if (
7244
+ [
7245
+ 'Sending ping',
7246
+ // 'Sending upstream ws message: ',
7247
+ 'Received pong',
7248
+ ].includes(params[0])
7249
+ ) {
7250
+ return;
7251
+ }
7252
+ console.log('trace', JSON.stringify(params, null, 2));
7253
+ },
7254
+ };
7255
+
7256
+ const ws = new WebsocketClient(
7257
+ {
7258
+ apiKey: 'apiKeyHere',
7259
+ apiSecret: 'apiSecretHere',
7260
+ apiPassphrase: 'apiPassPhraseHere',
7261
+ },
7262
+ logger,
7263
+ );
7264
+ ```
7265
+
7266
+ ## Use with LLMs & AI
7267
+
7268
+ This SDK includes a bundled `llms.txt` file in the root of the repository. If you're developing with LLMs, use the included `llms.txt` with your LLM - it will significantly improve the LLMs understanding of how to correctly use this SDK.
7269
+
7270
+ This file contains AI optimised structure of all the functions in this package, and their parameters for easier use with any learning models or artificial intelligence.
7271
+
7272
+ ---
7273
+
7274
+ <!-- template_contributions -->
7275
+
7276
+ ### Contributions & Thanks
7277
+
7278
+ Have my projects helped you? Share the love, there are many ways you can show your thanks:
7279
+
7280
+ - Star & share my projects.
7281
+ - Are my projects useful? Sponsor me on Github and support my effort to maintain & improve them: https://github.com/sponsors/tiagosiebler
7282
+ - Have an interesting project? Get in touch & invite me to it.
7283
+ - Or buy me all the coffee:
7284
+ - ETH(ERC20): `0xA3Bda8BecaB4DCdA539Dc16F9C54a592553Be06C` <!-- metamask -->
7285
+
7286
+ <!---
7287
+ old ones:
7288
+ - BTC: `1C6GWZL1XW3jrjpPTS863XtZiXL1aTK7Jk`
7289
+ - BTC(SegWit): `bc1ql64wr9z3khp2gy7dqlmqw7cp6h0lcusz0zjtls`
7290
+ - ETH(ERC20): `0xe0bbbc805e0e83341fadc210d6202f4022e50992`
7291
+ - USDT(TRC20): `TA18VUywcNEM9ahh3TTWF3sFpt9rkLnnQa
7292
+ -->
7293
+ <!-- template_contributions_end -->
7294
+
7295
+ ### Contributions & Pull Requests
7296
+
7297
+ Contributions are encouraged, I will review any incoming pull requests. See the issues tab for todo items.
7298
+
7299
+ <!-- template_star_history -->
7300
+
7301
+ ## Star History
7302
+
7303
+ [![Star History Chart](https://api.star-history.com/svg?repos=tiagosiebler/bybit-api,tiagosiebler/okx-api,tiagosiebler/binance,tiagosiebler/bitget-api,tiagosiebler/bitmart-api,tiagosiebler/gateio-api,tiagosiebler/kucoin-api,tiagosiebler/coinbase-api,tiagosiebler/orderbooks,tiagosiebler/accountstate,tiagosiebler/awesome-crypto-examples&type=Date)](https://star-history.com/#tiagosiebler/bybit-api&tiagosiebler/okx-api&tiagosiebler/binance&tiagosiebler/bitget-api&tiagosiebler/bitmart-api&tiagosiebler/gateio-api&tiagosiebler/kucoin-api&tiagosiebler/coinbase-api&tiagosiebler/orderbooks&tiagosiebler/accountstate&tiagosiebler/awesome-crypto-examples&Date)
7304
+
7305
+ <!-- template_star_history_end -->
7306
7306
 
7307
7307
  ================
7308
7308
  File: src/types/response/futures.types.ts
@@ -8023,6 +8023,15 @@ export interface CrossMarginRiskLimit {
8023
8023
  currency: string;
8024
8024
  }
8025
8025
  ⋮----
8026
+ export interface CrossMarginRequirement {
8027
+ symbol: string;
8028
+ imr: string;
8029
+ mmr: string;
8030
+ size: number;
8031
+ positionValue: string;
8032
+ price: string;
8033
+ }
8034
+ ⋮----
8026
8035
  /**
8027
8036
  *
8028
8037
  * Futures risk limit
@@ -8211,6 +8220,7 @@ import {
8211
8220
  BatchCancelOrderResult,
8212
8221
  BatchMarginModeUpdateResponse,
8213
8222
  CopyTradePosition,
8223
+ CrossMarginRequirement,
8214
8224
  CrossMarginRiskLimit,
8215
8225
  FullOrderBookDetail,
8216
8226
  FuturesAccountFundingRateHistory,
@@ -8769,6 +8779,16 @@ withdrawMargin(params: {
8769
8779
  withdrawAmount: string;
8770
8780
  }): Promise<APISuccessResponse<string>>
8771
8781
  ⋮----
8782
+ /**
8783
+ * Get Cross Margin Requirement
8784
+ * This endpoint supports querying the cross margin requirements of a symbol by position value.
8785
+ */
8786
+ getCrossMarginRequirement(params: {
8787
+ symbol: string;
8788
+ positionValue: string;
8789
+ leverage?: string;
8790
+ }): Promise<APISuccessResponse<CrossMarginRequirement>>
8791
+ ⋮----
8772
8792
  /**
8773
8793
  * Get Isolated Margin Risk Limit
8774
8794
  * This endpoint can be used to obtain information about risk limit level of a specific contract(Only valid for isolated Margin).
@@ -11239,7 +11259,7 @@ File: package.json
11239
11259
  ================
11240
11260
  {
11241
11261
  "name": "kucoin-api",
11242
- "version": "2.1.16",
11262
+ "version": "2.1.19",
11243
11263
  "description": "Complete & robust Node.js SDK for Kucoin's REST APIs and WebSockets, with TypeScript & strong end to end tests.",
11244
11264
  "scripts": {
11245
11265
  "clean": "rm -rf dist",