kucoin-api 2.1.15 → 2.1.17
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/README.md +87 -8
- package/llms.txt +11332 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -20,18 +20,53 @@
|
|
|
20
20
|
|
|
21
21
|
Updated & performant JavaScript & Node.js SDK for the Kucoin REST APIs and WebSockets:
|
|
22
22
|
|
|
23
|
+
- Professional, robust & performant Kucoin SDK with extensive production use in live trading environments.
|
|
23
24
|
- Complete integration with all Kucoin REST APIs and WebSockets.
|
|
24
|
-
-
|
|
25
|
+
- Dedicated REST clients for Spot, Futures, and Broker operations
|
|
26
|
+
- Unified WebSocket client for all markets
|
|
27
|
+
- Complete TypeScript support (with type declarations for most API requests & responses).
|
|
28
|
+
- Strongly typed requests and responses.
|
|
29
|
+
- Automated end-to-end tests ensuring reliability.
|
|
30
|
+
- Actively maintained with a modern, promise-driven interface.
|
|
25
31
|
- Robust WebSocket integration with configurable connection heartbeats & automatic reconnect then resubscribe workflows.
|
|
32
|
+
- Event driven messaging.
|
|
33
|
+
- Smart WebSocket persistence with automatic reconnection handling.
|
|
34
|
+
- Emit `reconnected` event when dropped connection is restored.
|
|
35
|
+
- Support for both public and private WebSocket streams.
|
|
26
36
|
- Browser-friendly HMAC signature mechanism.
|
|
27
37
|
- Automatically supports both ESM and CJS projects.
|
|
38
|
+
- Heavy automated end-to-end testing with real API calls.
|
|
28
39
|
- Proxy support via axios integration.
|
|
29
40
|
- Active community support & collaboration in telegram: [Node.js Algo Traders](https://t.me/nodetraders).
|
|
30
41
|
|
|
42
|
+
## Table of Contents
|
|
43
|
+
|
|
44
|
+
- [Installation](#installation)
|
|
45
|
+
- [Examples](#examples)
|
|
46
|
+
- [Issues & Discussion](#issues--discussion)
|
|
47
|
+
- [Related Projects](#related-projects)
|
|
48
|
+
- [Documentation](#documentation)
|
|
49
|
+
- [Structure](#structure)
|
|
50
|
+
- [Usage](#usage)
|
|
51
|
+
- [REST API Clients](#rest-api)
|
|
52
|
+
- [Spot & Margin Trading](#spot--margin-trading)
|
|
53
|
+
- [Futures Trading](#futures-trading)
|
|
54
|
+
- [Broker Operations](#broker-operations)
|
|
55
|
+
- [WebSocket Client](#websockets)
|
|
56
|
+
- [Public WebSocket Streams](#public-websocket-streams)
|
|
57
|
+
- [Private WebSocket Streams](#private-websocket-streams)
|
|
58
|
+
- [Customise Logging](#customise-logging)
|
|
59
|
+
- [LLMs & AI](#use-with-llms--ai)
|
|
60
|
+
- [Contributions & Thanks](#contributions--thanks)
|
|
61
|
+
|
|
31
62
|
## Installation
|
|
32
63
|
|
|
33
64
|
`npm install --save kucoin-api`
|
|
34
65
|
|
|
66
|
+
## Examples
|
|
67
|
+
|
|
68
|
+
Refer to the [examples](./examples) folder for implementation demos.
|
|
69
|
+
|
|
35
70
|
## Issues & Discussion
|
|
36
71
|
|
|
37
72
|
- Issues? Check the [issues tab](https://github.com/tiagosiebler/kucoin-api/issues).
|
|
@@ -62,16 +97,19 @@ Check out my related JavaScript/TypeScript/Node.js projects:
|
|
|
62
97
|
|
|
63
98
|
## Documentation
|
|
64
99
|
|
|
65
|
-
Most methods accept JS objects. These can be populated using parameters specified by Kucoin's API documentation.
|
|
100
|
+
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.
|
|
101
|
+
|
|
102
|
+
### API Documentation Links
|
|
66
103
|
|
|
67
104
|
- [Kucoin API Documentation](https://www.kucoin.com/docs-new/introduction)
|
|
105
|
+
|
|
106
|
+
### SDK Documentation & Guides
|
|
107
|
+
|
|
68
108
|
- Node.js Quick Start Guides
|
|
69
109
|
- [Spot Node.js Kucoin Quick Start Guide](./examples/kucoin-SPOT-examples-nodejs.md)
|
|
70
110
|
- [Futures Node.js Kucoin Quick Start Guide](./examples/kucoin-FUTURES-examples-nodejs.md)
|
|
71
111
|
- [Futures Node.js Kucoin Order Placement Guide](./examples/rest-futures-orders-guide.ts)
|
|
72
|
-
|
|
73
112
|
- [REST Endpoint Function List](./docs/endpointFunctionList.md)
|
|
74
|
-
<!-- - [TSDoc Documentation (autogenerated using typedoc)](https://tsdocs.dev/docs/kucoin-api) -->
|
|
75
113
|
|
|
76
114
|
## Structure
|
|
77
115
|
|
|
@@ -84,13 +122,21 @@ This project uses typescript. Resources are stored in 2 key structures:
|
|
|
84
122
|
|
|
85
123
|
# Usage
|
|
86
124
|
|
|
87
|
-
Create API credentials
|
|
125
|
+
Create API credentials on Kucoin's website:
|
|
88
126
|
|
|
89
127
|
- [Kucoin API Key Management](https://www.kucoin.com/account/api)
|
|
90
128
|
|
|
91
|
-
|
|
129
|
+
## REST API
|
|
130
|
+
|
|
131
|
+
The SDK provides dedicated REST clients for different trading products:
|
|
132
|
+
|
|
133
|
+
- **SpotClient** - for spot trading and margin operations
|
|
134
|
+
- **FuturesClient** - for futures trading operations
|
|
135
|
+
- **BrokerClient** - for broker and sub-account management
|
|
92
136
|
|
|
93
|
-
|
|
137
|
+
### Spot & Margin Trading
|
|
138
|
+
|
|
139
|
+
To use Kucoin's Spot and Margin APIs, import (or require) the `SpotClient`:
|
|
94
140
|
|
|
95
141
|
```javascript
|
|
96
142
|
const { SpotClient, FuturesClient } = require('kucoin-api');
|
|
@@ -124,10 +170,33 @@ try {
|
|
|
124
170
|
}
|
|
125
171
|
```
|
|
126
172
|
|
|
127
|
-
See [SpotClient](./src/SpotClient.ts)
|
|
173
|
+
See [SpotClient](./src/SpotClient.ts) for further information, or the [examples](./examples/) for lots of usage examples.
|
|
174
|
+
|
|
175
|
+
### Futures Trading
|
|
176
|
+
|
|
177
|
+
Use the `FuturesClient` for futures trading operations. See [FuturesClient](./src/FuturesClient.ts) for complete API coverage.
|
|
178
|
+
|
|
179
|
+
### Broker Operations
|
|
180
|
+
|
|
181
|
+
Use the `BrokerClient` for broker and sub-account management operations. See [BrokerClient](./src/BrokerClient.ts) for complete API coverage.
|
|
128
182
|
|
|
129
183
|
## WebSockets
|
|
130
184
|
|
|
185
|
+
All WebSocket functionality is supported via the unified `WebsocketClient`. This client handles both spot and futures WebSocket streams with automatic connection management and reconnection.
|
|
186
|
+
|
|
187
|
+
Key WebSocket features:
|
|
188
|
+
|
|
189
|
+
- Event driven messaging
|
|
190
|
+
- Smart WebSocket persistence with automatic reconnection
|
|
191
|
+
- Heartbeat mechanisms to detect disconnections
|
|
192
|
+
- Automatic resubscription after reconnection
|
|
193
|
+
- Support for both public and private WebSocket streams
|
|
194
|
+
- Unified client for spot and futures markets
|
|
195
|
+
|
|
196
|
+
### Public WebSocket Streams
|
|
197
|
+
|
|
198
|
+
For public market data, API credentials are not required:
|
|
199
|
+
|
|
131
200
|
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).
|
|
132
201
|
|
|
133
202
|
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.
|
|
@@ -208,6 +277,10 @@ try {
|
|
|
208
277
|
}
|
|
209
278
|
```
|
|
210
279
|
|
|
280
|
+
### Private WebSocket Streams
|
|
281
|
+
|
|
282
|
+
For private account data streams, API credentials are required. The WebsocketClient will automatically handle authentication when you provide API credentials.
|
|
283
|
+
|
|
211
284
|
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.
|
|
212
285
|
|
|
213
286
|
---
|
|
@@ -248,6 +321,12 @@ const ws = new WebsocketClient(
|
|
|
248
321
|
);
|
|
249
322
|
```
|
|
250
323
|
|
|
324
|
+
## Use with LLMs & AI
|
|
325
|
+
|
|
326
|
+
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.
|
|
327
|
+
|
|
328
|
+
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.
|
|
329
|
+
|
|
251
330
|
---
|
|
252
331
|
|
|
253
332
|
<!-- template_contributions -->
|