You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+18-14
Original file line number
Diff line number
Diff line change
@@ -19,22 +19,23 @@
19
19
20
20
[1]: https://www.npmjs.com/package/bybit-api
21
21
22
-
Node.js, JavaScript & TypeScript SDK for the Bybit REST APIs and WebSockets:
22
+
Professional Node.js, JavaScript & TypeScript SDK for the Bybit REST APIs and WebSockets:
23
23
24
24
- Complete integration with all Bybit REST APIs & WebSockets, including the WebSocket API.
25
25
- Actively maintained with a modern, promise-driven interface.
26
-
- TypeScript support (with type declarations for most API requests & responses).
27
-
- Thorough end-to-end tests making real API calls & WebSocket connections, validating any changes before they reach npm.
26
+
- TypeScript support (thorough type declarations for most API requests & responses, including WS API).
27
+
- JavaScript support (TypeScript not required but definitely recommended).
28
+
- Thorough & automatic end-to-end tests making real API calls & WebSocket connections, validating any changes before they reach npm.
28
29
- Proxy support via axios integration.
29
-
- Robust WebSocket integration with configurable connection heartbeats & automatic reconnect then resubscribe workflows.
30
-
- Event driven messaging.
30
+
- Robust WebSocket consumer integration with configurable heartbeats & automatic reconnect then resubscribe workflows.
31
+
- Event driven messaging
31
32
- Smart websocket persistence
32
33
- Automatically handle silent websocket disconnections through timed heartbeats, including the scheduled 24hr disconnect.
33
-
- Automatically handle listenKey persistence and expiration/refresh.
34
+
- Automatically handle authentication.
34
35
- Emit `reconnected` event when dropped connection is restored.
35
36
- WebSocket API integration, with two design patterns to choose from:
36
37
- Asynchronous promise-driven responses:
37
-
-This behaves very much like a REST API. No need to subscribe to asynchronous events.
38
+
-Make requests like a REST API, using the WebSocket API. No need to subscribe to asynchronous events.
38
39
- Send commands with the await sendWSAPIRequest(...) method.
39
40
- Await responses to commands directly in the fully typed sendWSAPIRequest() call.
40
41
- The method directly returns a promise. Use a try/catch block for convenient error handling without the complexity of asynchronous WebSockets.
@@ -124,7 +125,7 @@ The SDK is written in TypeScript, but fully compatible with both TypeScript and
124
125
125
126
126
127
-[src](./src) - the complete SDK written in TypeScript.
127
-
-[lib](./lib) - the JavaScript version of the project (built from TypeScript). This should not be edited directly, as it will be overwritten with each release.
128
+
-[lib](./lib) - the JavaScript version of the project (built from TypeScript) that is published to npm. This should not be edited directly, as it will be overwritten with each release.
128
129
-[examples](./examples) - examples & demonstrations. Contributions are welcome!
129
130
-[test](./test) - automated end-to-end tests that run before every release, making real API calls.
130
131
@@ -149,7 +150,7 @@ Here are the available REST clients and the corresponding API groups described i
Bybit supports sending, amending and cancelling orders over a WebSocket connection. The [WebsocketClient](./src/WebsocketClient.ts) fully supports Bybit's WebSocket API.
399
+
Bybit supports sending, amending and cancelling orders over a WebSocket connection. The [WebsocketClient](./src/WebsocketClient.ts) fully supports Bybit's WebSocket API via the `sendWSAPIRequest(...)` method.
396
400
397
401
Links for reference:
398
402
- [Bybit WebSocket API Documentation](https://bybit-exchange.github.io/docs/v5/websocket/trade/guideline)
399
403
- [WebSocket API Example Node.js/TypeScript/JavaScript](./examples/ws-api-promises.ts).
400
404
401
-
Note: as of January 2024, the demo trading environment does not support the WebSocket API.
405
+
Note: as of January 2025, the demo trading environment does not support the WebSocket API.
402
406
403
407
There are two ways to use the WS API, depending on individual preference:
404
408
- event-driven:
405
-
- send requests via `client.sendWSAPIRequest(wsKey, operation, params)`, fire and forget, don't use await
409
+
- send requests via `client.sendWSAPIRequest(wsKey, operation, params)`, fire and forget
406
410
- handle async replies via event handlers on `client.on('exception', cb)` and `client.on('response', cb)`
407
411
- See example for more details: [examples/ws-api-events.ts](./examples/ws-api-events.ts)
0 commit comments