-
Notifications
You must be signed in to change notification settings - Fork 213
Expand file tree
/
Copy pathwebsocket-api.ts
More file actions
50 lines (46 loc) · 2.01 KB
/
Copy pathwebsocket-api.ts
File metadata and controls
50 lines (46 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* Binance Spot WebSocket API
*
* OpenAPI Specifications for the Binance Spot WebSocket API
*
* API documents:
* - [Github web-socket-api documentation file](https://github.com/binance/binance-spot-api-docs/blob/master/web-socket-api.md)
* - [General API information for web-socket-api on website](https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api/general-api-information)
*
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { WebsocketAPIBase, ConfigurationWebsocketAPI } from '@binance/common';
import { WebsocketAPIConnection } from './websocket-api-connection';
export class WebsocketAPI {
private configuration: ConfigurationWebsocketAPI;
constructor(configuration: ConfigurationWebsocketAPI) {
this.configuration = configuration;
}
/**
* Connects to the Binance WebSocket API and returns a `WebsocketAPIConnection` instance.
*
* @param {object} [options] - Optional connection options.
* @param {string} [options.mode='single'] - The connection mode, either 'single' or 'pool'. Overrides the `mode` property in the configuration.
* @param {number} [options.poolSize=1] - The number of connections to use in pool mode. Overrides the `poolSize` property in the configuration.
* @returns {Promise<WebsocketAPIConnection>} - A promise that resolves to a `WebsocketAPIConnection` instance.
*/
async connect({
mode,
poolSize,
}: { mode?: 'single' | 'pool'; poolSize?: number } = {}): Promise<WebsocketAPIConnection> {
const websocketBase = new WebsocketAPIBase({
...this.configuration,
...(mode && { mode }),
...(poolSize && { poolSize }),
});
const websocketAPIConnection = new WebsocketAPIConnection(websocketBase);
await websocketBase.connect();
return websocketAPIConnection;
}
}