gateio-api 1.2.4 → 1.2.5

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.
Files changed (3) hide show
  1. package/README.md +65 -9
  2. package/llms.txt +149 -86
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -20,32 +20,66 @@
20
20
 
21
21
  Updated & performant JavaScript & Node.js SDK for the Gate.com (gate.io) REST APIs and WebSockets:
22
22
 
23
+ - Professional, robust & performant Gate.com SDK with extensive production use in live trading environments.
23
24
  - Extensive integration with Gate.com (Gate.io) REST APIs and WebSockets.
24
- - TypeScript support (with type declarations for most API requests & responses).
25
+ - Complete TypeScript support (with type declarations for most API requests & responses).
26
+ - Strongly typed requests and responses.
27
+ - Automated end-to-end tests ensuring reliability.
28
+ - Actively maintained with a modern, promise-driven interface.
25
29
  - Gate.com REST APIs for Gate.com Spot, Margin, Perpetual Futures, Delivery Futures, Options & Announcements APIs.
30
+ - Unified RestClient for all Gate.com trading products.
26
31
  - Strongly typed on most requests and responses.
27
- - Extremely robust & performant JavaScript/Node.js Gate.com SDK.
28
- - Actively maintained with a modern, promise-driven interface.
29
32
  - Support for seamless API authentication for private Gate.com REST API and WebSocket calls.
30
- - Gate.com Spot, Margin, Perpetual Futures, Delivery Futures & Options.
33
+ - Robust WebSocket integration with configurable connection heartbeats & automatic reconnect then resubscribe workflows.
31
34
  - Event driven messaging.
32
- - Smart websocket persistence
35
+ - Smart websocket persistence with automatic reconnection handling.
33
36
  - Automatically handle silent websocket disconnections through timed heartbeats, including the scheduled 24hr disconnect.
34
37
  - Automatically handle listenKey persistence and expiration/refresh.
35
38
  - Emit `reconnected` event when dropped connection is restored.
36
- - Websocket API for Gate.com Spot, Margin, Perpetual Futures & Delivery Futures.
39
+ - Support for Gate.com Spot, Margin, Perpetual Futures, Delivery Futures & Options.
40
+ - WebSocket API for Gate.com Spot, Margin, Perpetual Futures & Delivery Futures.
37
41
  - Automatic connectivity via existing WebsocketClient, just call sendWSAPIRequest to trigger a request.
38
42
  - Automatic authentication, just call sendWSAPIRequest with channel & parameters.
39
43
  - Choose between two interfaces for WS API communication:
40
44
  - Event-driven interface, fire & forget via sendWSAPIRequest and receive async replies via wsClient's event emitter.
41
45
  - Promise-driven interface, simply use the WebsocketAPIClient for a REST-like experience. Use the WebSocket API like a REST API! See [examples/ws-api-client.ts](./examples/ws-api-client.ts) for a demonstration.
46
+ - Heavy automated end-to-end testing with real API calls.
42
47
  - Proxy support via axios integration.
43
48
  - Active community support & collaboration in telegram: [Node.js Algo Traders](https://t.me/nodetraders).
44
49
 
50
+ ## Table of Contents
51
+
52
+ - [Installation](#installation)
53
+ - [Examples](#examples)
54
+ - [Issues & Discussion](#issues--discussion)
55
+ - [Related Projects](#related-projects)
56
+ - [Documentation](#documentation)
57
+ - [Structure](#structure)
58
+ - [Usage](#usage)
59
+ - [REST API Client](#rest-api)
60
+ - [WebSocket Client](#websockets)
61
+ - [WebSocket Data Streams](#websocket-data-streams)
62
+ - [WebSocket API](#websocket-api)
63
+ - [Event Driven API](#event-driven-api)
64
+ - [REST-like API](#rest-like-api)
65
+ - [Customise Logging](#customise-logging)
66
+ - [LLMs & AI](#use-with-llms--ai)
67
+ - [Contributions & Thanks](#contributions--thanks)
68
+
45
69
  ## Installation
46
70
 
47
71
  `npm install --save gateio-api`
48
72
 
73
+ ## Examples
74
+
75
+ Refer to the [examples](./examples) folder for implementation demos, including:
76
+
77
+ - **REST API Examples**: spot trading, futures trading, account management
78
+ - **WebSocket Examples**: public market data streams, private account data, WebSocket API usage
79
+ - **Spot Trading**: comprehensive spot market examples
80
+ - **Futures Trading**: perpetual and delivery futures examples
81
+ - **WebSocket API**: both event-driven and promise-driven approaches
82
+
49
83
  ## Issues & Discussion
50
84
 
51
85
  - Issues? Check the [issues tab](https://github.com/tiagosiebler/gateio-api/issues).
@@ -76,9 +110,16 @@ Check out my related JavaScript/TypeScript/Node.js projects:
76
110
 
77
111
  ## Documentation
78
112
 
79
- Most methods accept JS objects. These can be populated using parameters specified by gateio's API documentation.
113
+ Most methods accept JS objects. These can be populated using parameters specified by Gate.com's API documentation, or check the type definition in each class within this repository.
114
+
115
+ ### API Documentation Links
80
116
 
81
117
  - [Gate.com/gate.io API Documentation](https://www.gate.com/docs/developers/apiv4/en/)
118
+ - [Spot Trading API](https://www.gate.com/docs/developers/apiv4/en/#spot-new)
119
+ - [Margin Trading API](https://www.gate.com/docs/developers/apiv4/en/#margin-new)
120
+ - [Futures Trading API](https://www.gate.com/docs/developers/apiv4/en/#futures-new)
121
+ - [Options Trading API](https://www.gate.com/docs/developers/apiv4/en/#options-new)
122
+ - [WebSocket API](https://www.gate.com/docs/developers/apiv4/en/#websocket-api)
82
123
  - [REST Endpoint Function List](./docs/endpointFunctionList.md)
83
124
  - [TSDoc Documentation (autogenerated using typedoc)](https://tsdocs.dev/docs/gateio-api)
84
125
 
@@ -93,11 +134,13 @@ This project uses typescript. Resources are stored in 2 key structures:
93
134
 
94
135
  # Usage
95
136
 
96
- Create API credentials
137
+ Create API credentials on Gate.com's website:
97
138
 
98
139
  - [Gate.com API Key Management](https://www.gate.com/myaccount/api_key_manage)
99
140
 
100
- ### REST API
141
+ ## REST API
142
+
143
+ The SDK provides a unified `RestClient` for all Gate.com trading products including Spot, Margin, Perpetual Futures, Delivery Futures, and Options. This single client handles all REST API operations across all trading markets.
101
144
 
102
145
  To use any of Gate.com's REST APIs in JavaScript/TypeScript/Node.js, import (or require) the `RestClient`:
103
146
 
@@ -138,6 +181,19 @@ See [RestClient](./src/RestClient.ts) for further information, or the [examples]
138
181
 
139
182
  ## WebSockets
140
183
 
184
+ All WebSocket functionality is supported via the unified `WebsocketClient`. This client handles all Gate.com WebSocket streams with automatic connection management and reconnection.
185
+
186
+ Key WebSocket features:
187
+
188
+ - Event driven messaging
189
+ - Smart WebSocket persistence with automatic reconnection
190
+ - Heartbeat mechanisms to detect disconnections
191
+ - Automatic resubscription after reconnection
192
+ - Support for all Gate.com trading products (Spot, Margin, Futures, Options)
193
+ - WebSocket API support for real-time trading operations
194
+
195
+ ### WebSocket Data Streams
196
+
141
197
  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).
142
198
 
143
199
  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.
package/llms.txt CHANGED
@@ -2356,42 +2356,6 @@ File: tsconfig.esm.json
2356
2356
  "include": ["src/**/*.*"]
2357
2357
  }
2358
2358
 
2359
- ================
2360
- File: tsconfig.json
2361
- ================
2362
- {
2363
- "compilerOptions": {
2364
- "allowSyntheticDefaultImports": true,
2365
- "baseUrl": "src",
2366
- "noEmitOnError": true,
2367
- "declaration": true,
2368
- "esModuleInterop": true,
2369
- "forceConsistentCasingInFileNames": false,
2370
- "inlineSourceMap": false,
2371
- "lib": ["esnext"],
2372
- "listEmittedFiles": false,
2373
- "listFiles": false,
2374
- "moduleResolution": "node",
2375
- "noFallthroughCasesInSwitch": true,
2376
- "noImplicitAny": true,
2377
- "noUnusedParameters": true,
2378
- "pretty": true,
2379
- "removeComments": false,
2380
- "resolveJsonModule": true,
2381
- "skipLibCheck": false,
2382
- "sourceMap": true,
2383
- "strict": true,
2384
- "strictNullChecks": true,
2385
- "types": ["node", "jest"],
2386
- "module": "commonjs",
2387
- "outDir": "dist/cjs",
2388
- "target": "esnext"
2389
- },
2390
- "compileOnSave": true,
2391
- "exclude": ["node_modules", "dist"],
2392
- "include": ["src/**/*.*", "test/**/*.*", ".eslintrc.cjs"]
2393
- }
2394
-
2395
2359
  ================
2396
2360
  File: tsconfig.linting.json
2397
2361
  ================
@@ -3786,49 +3750,45 @@ File: src/index.ts
3786
3750
  // Shared Types
3787
3751
 
3788
3752
  ================
3789
- File: .gitignore
3753
+ File: .nvmrc
3790
3754
  ================
3791
- !.gitkeep
3792
- .DS_STORE
3793
- *.log
3794
- npm-debug.log*
3795
- yarn-debug.log*
3796
- yarn-error.log*
3797
- lerna-debug.log*
3798
- report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
3799
- pids
3800
- *.pid
3801
- *.seed
3802
- *.pid.lock
3803
- node_modules/
3804
- .npm
3805
- .eslintcache
3806
- .node_repl_history
3807
- *.tgz
3808
- .yarn-integrity
3809
- .env
3810
- .env.test
3811
- .cache
3812
- bundleReport.html
3813
- .history/
3814
- dist
3815
- coverage
3816
- localtest.sh
3817
- repomix.sh
3818
-
3819
- ws-private-spot-wsapi-performance.ts
3820
- ws-private-perp-futures-wsapi-readonly.ts
3821
- privatetest.ts
3822
-
3823
- privaterepotracker
3824
- restClientRegex.ts
3825
-
3826
- testfile.ts
3755
+ v22.17.0
3827
3756
 
3828
3757
  ================
3829
- File: .nvmrc
3758
+ File: tsconfig.json
3830
3759
  ================
3831
- v22.17.0
3760
+ {
3761
+ "compilerOptions": {
3762
+ "allowSyntheticDefaultImports": true,
3763
+ "baseUrl": ".",
3764
+ "noEmitOnError": true,
3765
+ "declaration": true,
3766
+ "esModuleInterop": true,
3767
+ "forceConsistentCasingInFileNames": false,
3768
+ "inlineSourceMap": false,
3769
+ "lib": ["esnext"],
3770
+ "listEmittedFiles": false,
3771
+ "listFiles": false,
3772
+ "moduleResolution": "node",
3773
+ "noFallthroughCasesInSwitch": true,
3774
+ "noImplicitAny": true,
3775
+ "noUnusedParameters": true,
3776
+ "pretty": true,
3777
+ "removeComments": false,
3778
+ "resolveJsonModule": true,
3779
+ "skipLibCheck": false,
3780
+ "sourceMap": true,
3781
+ "strict": true,
3782
+ "strictNullChecks": true,
3783
+ "types": ["node", "jest"],
3784
+ "module": "commonjs",
3785
+ "outDir": "dist/cjs",
3786
+ "target": "esnext"
3787
+ },
3788
+ "compileOnSave": true,
3789
+ "exclude": ["node_modules", "dist"],
3790
+ "include": ["src/**/*.*", "test/**/*.*", ".eslintrc.cjs"]
3791
+ }
3832
3792
 
3833
3793
  ================
3834
3794
  File: examples/ws-private-spot-wsapi.ts
@@ -4291,6 +4251,46 @@ File: .eslintrc.cjs
4291
4251
  ================
4292
4252
  // 'no-unused-vars': ['warn'],
4293
4253
 
4254
+ ================
4255
+ File: .gitignore
4256
+ ================
4257
+ !.gitkeep
4258
+ .DS_STORE
4259
+ *.log
4260
+ npm-debug.log*
4261
+ yarn-debug.log*
4262
+ yarn-error.log*
4263
+ lerna-debug.log*
4264
+ report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
4265
+ pids
4266
+ *.pid
4267
+ *.seed
4268
+ *.pid.lock
4269
+ node_modules/
4270
+ .npm
4271
+ .eslintcache
4272
+ .node_repl_history
4273
+ *.tgz
4274
+ .yarn-integrity
4275
+ .env
4276
+ .env.test
4277
+ .cache
4278
+ bundleReport.html
4279
+ .history/
4280
+ dist
4281
+ coverage
4282
+ localtest.sh
4283
+ repomix.sh
4284
+
4285
+ ws-private-spot-wsapi-performance.ts
4286
+ ws-private-perp-futures-wsapi-readonly.ts
4287
+ privatetest.ts
4288
+
4289
+ privaterepotracker
4290
+ restClientRegex.ts
4291
+
4292
+ testfile.ts
4293
+
4294
4294
  ================
4295
4295
  File: src/types/request/futures.ts
4296
4296
  ================
@@ -7073,32 +7073,66 @@ File: README.md
7073
7073
 
7074
7074
  Updated & performant JavaScript & Node.js SDK for the Gate.com (gate.io) REST APIs and WebSockets:
7075
7075
 
7076
+ - Professional, robust & performant Gate.com SDK with extensive production use in live trading environments.
7076
7077
  - Extensive integration with Gate.com (Gate.io) REST APIs and WebSockets.
7077
- - TypeScript support (with type declarations for most API requests & responses).
7078
+ - Complete TypeScript support (with type declarations for most API requests & responses).
7079
+ - Strongly typed requests and responses.
7080
+ - Automated end-to-end tests ensuring reliability.
7081
+ - Actively maintained with a modern, promise-driven interface.
7078
7082
  - Gate.com REST APIs for Gate.com Spot, Margin, Perpetual Futures, Delivery Futures, Options & Announcements APIs.
7083
+ - Unified RestClient for all Gate.com trading products.
7079
7084
  - Strongly typed on most requests and responses.
7080
- - Extremely robust & performant JavaScript/Node.js Gate.com SDK.
7081
- - Actively maintained with a modern, promise-driven interface.
7082
7085
  - Support for seamless API authentication for private Gate.com REST API and WebSocket calls.
7083
- - Gate.com Spot, Margin, Perpetual Futures, Delivery Futures & Options.
7086
+ - Robust WebSocket integration with configurable connection heartbeats & automatic reconnect then resubscribe workflows.
7084
7087
  - Event driven messaging.
7085
- - Smart websocket persistence
7088
+ - Smart websocket persistence with automatic reconnection handling.
7086
7089
  - Automatically handle silent websocket disconnections through timed heartbeats, including the scheduled 24hr disconnect.
7087
7090
  - Automatically handle listenKey persistence and expiration/refresh.
7088
7091
  - Emit `reconnected` event when dropped connection is restored.
7089
- - Websocket API for Gate.com Spot, Margin, Perpetual Futures & Delivery Futures.
7092
+ - Support for Gate.com Spot, Margin, Perpetual Futures, Delivery Futures & Options.
7093
+ - WebSocket API for Gate.com Spot, Margin, Perpetual Futures & Delivery Futures.
7090
7094
  - Automatic connectivity via existing WebsocketClient, just call sendWSAPIRequest to trigger a request.
7091
7095
  - Automatic authentication, just call sendWSAPIRequest with channel & parameters.
7092
7096
  - Choose between two interfaces for WS API communication:
7093
7097
  - Event-driven interface, fire & forget via sendWSAPIRequest and receive async replies via wsClient's event emitter.
7094
7098
  - Promise-driven interface, simply use the WebsocketAPIClient for a REST-like experience. Use the WebSocket API like a REST API! See [examples/ws-api-client.ts](./examples/ws-api-client.ts) for a demonstration.
7099
+ - Heavy automated end-to-end testing with real API calls.
7095
7100
  - Proxy support via axios integration.
7096
7101
  - Active community support & collaboration in telegram: [Node.js Algo Traders](https://t.me/nodetraders).
7097
7102
 
7103
+ ## Table of Contents
7104
+
7105
+ - [Installation](#installation)
7106
+ - [Examples](#examples)
7107
+ - [Issues & Discussion](#issues--discussion)
7108
+ - [Related Projects](#related-projects)
7109
+ - [Documentation](#documentation)
7110
+ - [Structure](#structure)
7111
+ - [Usage](#usage)
7112
+ - [REST API Client](#rest-api)
7113
+ - [WebSocket Client](#websockets)
7114
+ - [WebSocket Data Streams](#websocket-data-streams)
7115
+ - [WebSocket API](#websocket-api)
7116
+ - [Event Driven API](#event-driven-api)
7117
+ - [REST-like API](#rest-like-api)
7118
+ - [Customise Logging](#customise-logging)
7119
+ - [LLMs & AI](#use-with-llms--ai)
7120
+ - [Contributions & Thanks](#contributions--thanks)
7121
+
7098
7122
  ## Installation
7099
7123
 
7100
7124
  `npm install --save gateio-api`
7101
7125
 
7126
+ ## Examples
7127
+
7128
+ Refer to the [examples](./examples) folder for implementation demos, including:
7129
+
7130
+ - **REST API Examples**: spot trading, futures trading, account management
7131
+ - **WebSocket Examples**: public market data streams, private account data, WebSocket API usage
7132
+ - **Spot Trading**: comprehensive spot market examples
7133
+ - **Futures Trading**: perpetual and delivery futures examples
7134
+ - **WebSocket API**: both event-driven and promise-driven approaches
7135
+
7102
7136
  ## Issues & Discussion
7103
7137
 
7104
7138
  - Issues? Check the [issues tab](https://github.com/tiagosiebler/gateio-api/issues).
@@ -7129,9 +7163,16 @@ Check out my related JavaScript/TypeScript/Node.js projects:
7129
7163
 
7130
7164
  ## Documentation
7131
7165
 
7132
- Most methods accept JS objects. These can be populated using parameters specified by gateio's API documentation.
7166
+ Most methods accept JS objects. These can be populated using parameters specified by Gate.com's API documentation, or check the type definition in each class within this repository.
7167
+
7168
+ ### API Documentation Links
7133
7169
 
7134
7170
  - [Gate.com/gate.io API Documentation](https://www.gate.com/docs/developers/apiv4/en/)
7171
+ - [Spot Trading API](https://www.gate.com/docs/developers/apiv4/en/#spot-new)
7172
+ - [Margin Trading API](https://www.gate.com/docs/developers/apiv4/en/#margin-new)
7173
+ - [Futures Trading API](https://www.gate.com/docs/developers/apiv4/en/#futures-new)
7174
+ - [Options Trading API](https://www.gate.com/docs/developers/apiv4/en/#options-new)
7175
+ - [WebSocket API](https://www.gate.com/docs/developers/apiv4/en/#websocket-api)
7135
7176
  - [REST Endpoint Function List](./docs/endpointFunctionList.md)
7136
7177
  - [TSDoc Documentation (autogenerated using typedoc)](https://tsdocs.dev/docs/gateio-api)
7137
7178
 
@@ -7146,11 +7187,13 @@ This project uses typescript. Resources are stored in 2 key structures:
7146
7187
 
7147
7188
  # Usage
7148
7189
 
7149
- Create API credentials
7190
+ Create API credentials on Gate.com's website:
7150
7191
 
7151
7192
  - [Gate.com API Key Management](https://www.gate.com/myaccount/api_key_manage)
7152
7193
 
7153
- ### REST API
7194
+ ## REST API
7195
+
7196
+ The SDK provides a unified `RestClient` for all Gate.com trading products including Spot, Margin, Perpetual Futures, Delivery Futures, and Options. This single client handles all REST API operations across all trading markets.
7154
7197
 
7155
7198
  To use any of Gate.com's REST APIs in JavaScript/TypeScript/Node.js, import (or require) the `RestClient`:
7156
7199
 
@@ -7191,6 +7234,19 @@ See [RestClient](./src/RestClient.ts) for further information, or the [examples]
7191
7234
 
7192
7235
  ## WebSockets
7193
7236
 
7237
+ All WebSocket functionality is supported via the unified `WebsocketClient`. This client handles all Gate.com WebSocket streams with automatic connection management and reconnection.
7238
+
7239
+ Key WebSocket features:
7240
+
7241
+ - Event driven messaging
7242
+ - Smart WebSocket persistence with automatic reconnection
7243
+ - Heartbeat mechanisms to detect disconnections
7244
+ - Automatic resubscription after reconnection
7245
+ - Support for all Gate.com trading products (Spot, Margin, Futures, Options)
7246
+ - WebSocket API support for real-time trading operations
7247
+
7248
+ ### WebSocket Data Streams
7249
+
7194
7250
  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).
7195
7251
 
7196
7252
  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.
@@ -7428,6 +7484,12 @@ DefaultLogger.silly = () => {};
7428
7484
  const ws = new WebsocketClient({ key: 'xxx', secret: 'yyy' }, DefaultLogger);
7429
7485
  ```
7430
7486
 
7487
+ ## Use with LLMs & AI
7488
+
7489
+ 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.
7490
+
7491
+ 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.
7492
+
7431
7493
  ---
7432
7494
 
7433
7495
  <!-- template_contributions -->
@@ -11412,7 +11474,7 @@ File: package.json
11412
11474
  ================
11413
11475
  {
11414
11476
  "name": "gateio-api",
11415
- "version": "1.2.3",
11477
+ "version": "1.2.4",
11416
11478
  "description": "Complete & Robust Node.js SDK for Gate.com's REST APIs, WebSockets & WebSocket APIs, with TypeScript declarations.",
11417
11479
  "scripts": {
11418
11480
  "clean": "rm -rf dist/*",
@@ -11432,7 +11494,8 @@ File: package.json
11432
11494
  },
11433
11495
  "type": "module",
11434
11496
  "files": [
11435
- "dist/*"
11497
+ "dist/*",
11498
+ "llms.txt"
11436
11499
  ],
11437
11500
  "author": "Tiago Siebler (https://github.com/tiagosiebler)",
11438
11501
  "contributors": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gateio-api",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "description": "Complete & Robust Node.js SDK for Gate.com's REST APIs, WebSockets & WebSocket APIs, with TypeScript declarations.",
5
5
  "scripts": {
6
6
  "clean": "rm -rf dist/*",