@binance/common 1.0.0

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.
@@ -0,0 +1,974 @@
1
+ import { Agent } from 'https';
2
+ import { RawAxiosRequestConfig, AxiosError, RawAxiosResponseHeaders, AxiosResponseHeaders } from 'axios';
3
+ import WebSocketClient from 'ws';
4
+
5
+ declare const TimeUnit: {
6
+ readonly MILLISECOND: "MILLISECOND";
7
+ readonly millisecond: "millisecond";
8
+ readonly MICROSECOND: "MICROSECOND";
9
+ readonly microsecond: "microsecond";
10
+ };
11
+ type TimeUnit = (typeof TimeUnit)[keyof typeof TimeUnit];
12
+ declare const SPOT_REST_API_PROD_URL = "https://api.binance.com";
13
+ declare const SPOT_REST_API_TESTNET_URL = "https://testnet.binance.vision";
14
+ declare const SPOT_WS_API_PROD_URL = "wss://ws-api.binance.com:443/ws-api/v3";
15
+ declare const SPOT_WS_API_TESTNET_URL = "wss://ws-api.testnet.binance.vision/ws-api/v3";
16
+ declare const SPOT_WS_STREAMS_PROD_URL = "wss://stream.binance.com:9443";
17
+ declare const SPOT_WS_STREAMS_TESTNET_URL = "wss://stream.testnet.binance.vision";
18
+ declare const SPOT_REST_API_MARKET_URL = "https://data-api.binance.vision";
19
+ declare const SPOT_WS_STREAMS_MARKET_URL = "wss://data-stream.binance.vision";
20
+ declare const ALGO_REST_API_PROD_URL = "https://api.binance.com";
21
+ declare const ALGO_REST_API_TESTNET_URL = "https://testnet.binance.vision";
22
+ declare const AUTO_INVEST_REST_API_PROD_URL = "https://api.binance.com";
23
+ declare const AUTO_INVEST_REST_API_TESTNET_URL = "https://testnet.binance.vision";
24
+ declare const C2C_REST_API_PROD_URL = "https://api.binance.com";
25
+ declare const C2C_REST_API_TESTNET_URL = "https://testnet.binance.vision";
26
+ declare const CONVERT_REST_API_PROD_URL = "https://api.binance.com";
27
+ declare const CONVERT_REST_API_TESTNET_URL = "https://testnet.binance.vision";
28
+ declare const COPY_TRADING_REST_API_PROD_URL = "https://api.binance.com";
29
+ declare const COPY_TRADING_REST_API_TESTNET_URL = "https://testnet.binance.vision";
30
+ declare const CRYPTO_LOAN_REST_API_PROD_URL = "https://api.binance.com";
31
+ declare const CRYPTO_LOAN_REST_API_TESTNET_URL = "https://testnet.binance.vision";
32
+ declare const DERIVATIVES_TRADING_COIN_FUTURES_REST_API_PROD_URL = "https://dapi.binance.com";
33
+ declare const DERIVATIVES_TRADING_COIN_FUTURES_REST_API_TESTNET_URL = "https://testnet.binancefuture.com";
34
+ declare const DERIVATIVES_TRADING_COIN_FUTURES_WS_API_PROD_URL = "wss://ws-dapi.binance.com/ws-dapi/v1";
35
+ declare const DERIVATIVES_TRADING_COIN_FUTURES_WS_API_TESTNET_URL = "wss://testnet.binancefuture.com/ws-dapi/v1";
36
+ declare const DERIVATIVES_TRADING_COIN_FUTURES_WS_STREAMS_PROD_URL = "wss://dstream.binance.com";
37
+ declare const DERIVATIVES_TRADING_COIN_FUTURES_WS_STREAMS_TESTNET_URL = "wss://dstream.binancefuture.com";
38
+ declare const DERIVATIVES_TRADING_USDS_FUTURES_REST_API_PROD_URL = "https://fapi.binance.com";
39
+ declare const DERIVATIVES_TRADING_USDS_FUTURES_REST_API_TESTNET_URL = "https://testnet.binancefuture.com";
40
+ declare const DERIVATIVES_TRADING_USDS_FUTURES_WS_API_PROD_URL = "wss://ws-fapi.binance.com/ws-fapi/v1";
41
+ declare const DERIVATIVES_TRADING_USDS_FUTURES_WS_API_TESTNET_URL = "wss://testnet.binancefuture.com/ws-fapi/v1";
42
+ declare const DERIVATIVES_TRADING_USDS_FUTURES_WS_STREAMS_PROD_URL = "wss://fstream.binance.com";
43
+ declare const DERIVATIVES_TRADING_USDS_FUTURES_WS_STREAMS_TESTNET_URL = "wss://stream.binancefuture.com";
44
+ declare const DERIVATIVES_TRADING_OPTIONS_REST_API_PROD_URL = "https://eapi.binance.com";
45
+ declare const DERIVATIVES_TRADING_OPTIONS_WS_STREAMS_PROD_URL = "wss://nbstream.binance.com/eoptions";
46
+ declare const DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_PROD_URL = "https://papi.binance.com";
47
+ declare const DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_TESTNET_URL = "https://testnet.binancefuture.com";
48
+ declare const DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_REST_API_PROD_URL = "https://fapi.binance.com";
49
+ declare const DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_REST_API_TESTNET_URL = "https://testnet.binancefuture.com";
50
+ declare const DUAL_INVESTMENT_REST_API_PROD_URL = "https://api.binance.com";
51
+ declare const DUAL_INVESTMENT_REST_API_TESTNET_URL = "https://testnet.binance.vision";
52
+ declare const FIAT_REST_API_PROD_URL = "https://api.binance.com";
53
+ declare const FIAT_REST_API_TESTNET_URL = "https://testnet.binance.vision";
54
+ declare const GIFT_CARD_REST_API_PROD_URL = "https://api.binance.com";
55
+ declare const GIFT_CARD_REST_API_TESTNET_URL = "https://testnet.binance.vision";
56
+ declare const MARGIN_TRADING_REST_API_PROD_URL = "https://api.binance.com";
57
+ declare const MARGIN_TRADING_REST_API_TESTNET_URL = "https://testnet.binance.vision";
58
+ declare const MINING_REST_API_PROD_URL = "https://api.binance.com";
59
+ declare const MINING_REST_API_TESTNET_URL = "https://testnet.binance.vision";
60
+ declare const NFT_REST_API_PROD_URL = "https://api.binance.com";
61
+ declare const NFT_REST_API_TESTNET_URL = "https://testnet.binance.vision";
62
+ declare const PAY_REST_API_PROD_URL = "https://api.binance.com";
63
+ declare const PAY_REST_API_TESTNET_URL = "https://testnet.binance.vision";
64
+ declare const REBATE_REST_API_PROD_URL = "https://api.binance.com";
65
+ declare const REBATE_REST_API_TESTNET_URL = "https://testnet.binance.vision";
66
+ declare const SIMPLE_EARN_REST_API_PROD_URL = "https://api.binance.com";
67
+ declare const SIMPLE_EARN_REST_API_TESTNET_URL = "https://testnet.binance.vision";
68
+ declare const STAKING_REST_API_PROD_URL = "https://api.binance.com";
69
+ declare const STAKING_REST_API_TESTNET_URL = "https://testnet.binance.vision";
70
+ declare const SUB_ACCOUNT_REST_API_PROD_URL = "https://api.binance.com";
71
+ declare const SUB_ACCOUNT_REST_API_TESTNET_URL = "https://testnet.binance.vision";
72
+ declare const VIP_LOAN_REST_API_PROD_URL = "https://api.binance.com";
73
+ declare const VIP_LOAN_REST_API_TESTNET_URL = "https://testnet.binance.vision";
74
+ declare const WALLET_REST_API_PROD_URL = "https://api.binance.com";
75
+ declare const WALLET_REST_API_TESTNET_URL = "https://testnet.binance.vision";
76
+
77
+ declare class ConfigurationRestAPI {
78
+ /**
79
+ * The API key used for authentication.
80
+ * @memberof ConfigurationRestAPI
81
+ */
82
+ apiKey: string;
83
+ /**
84
+ * The API secret used for authentication.
85
+ * @memberof ConfigurationRestAPI
86
+ */
87
+ apiSecret?: string;
88
+ /**
89
+ * override base path
90
+ * @type {string}
91
+ * @memberof ConfigurationRestAPI
92
+ */
93
+ basePath?: string;
94
+ /**
95
+ * set a timeout (in milliseconds) for the request
96
+ * @default 1000
97
+ * @type {number}
98
+ * @memberof ConfigurationRestAPI
99
+ */
100
+ timeout?: number;
101
+ /**
102
+ * HTTP/HTTPS proxy configuration
103
+ * @default false
104
+ * @type {object}
105
+ * @property {string} host - Proxy server hostname
106
+ * @property {number} port - Proxy server port number
107
+ * @property {string} protocol - Proxy server protocol
108
+ * @property {object} [auth] - Proxy authentication credentials
109
+ * @property {string} auth.username - Proxy authentication username
110
+ * @property {string} auth.password - Proxy authentication password
111
+ * @memberof ConfigurationRestAPI
112
+ */
113
+ proxy?: {
114
+ host: string;
115
+ port: number;
116
+ protocol?: string;
117
+ auth?: {
118
+ username: string;
119
+ password: string;
120
+ };
121
+ };
122
+ /**
123
+ * enables keep-alive functionality for the connection
124
+ * @default true
125
+ * @type {boolean}
126
+ * @memberof ConfigurationRestAPI
127
+ */
128
+ keepAlive?: boolean;
129
+ /**
130
+ * enables response compression
131
+ * @default true
132
+ * @type {boolean}
133
+ * @memberof ConfigurationRestAPI
134
+ */
135
+ compression?: boolean;
136
+ /**
137
+ * number of retry attempts for failed requests
138
+ * @default 3
139
+ * @type {number}
140
+ * @memberof ConfigurationRestAPI
141
+ */
142
+ retries?: number;
143
+ /**
144
+ * delay between retry attempts in milliseconds
145
+ * @default 1000
146
+ * @type {number}
147
+ * @memberof ConfigurationRestAPI
148
+ */
149
+ backoff?: number;
150
+ /**
151
+ * https agent
152
+ * @default false
153
+ * @type {boolean | Agent}
154
+ * @memberof ConfigurationRestAPI
155
+ */
156
+ httpsAgent?: boolean | Agent;
157
+ /**
158
+ * private key
159
+ * @type {Buffer}
160
+ * @memberof ConfigurationRestAPI
161
+ */
162
+ privateKey?: Buffer;
163
+ /**
164
+ * private key passphrase
165
+ * @type {string}
166
+ * @memberof ConfigurationRestAPI
167
+ */
168
+ privateKeyPassphrase?: string;
169
+ /**
170
+ * timeUnit (used only on SPOT API)
171
+ * @type {TimeUnit}
172
+ * @memberof ConfigurationRestAPI
173
+ */
174
+ timeUnit?: TimeUnit;
175
+ /**
176
+ * base options for axios calls
177
+ * @type {Record<string, unknown>}
178
+ * @memberof ConfigurationRestAPI
179
+ */
180
+ baseOptions?: Record<string, unknown>;
181
+ constructor(param?: ConfigurationRestAPI);
182
+ }
183
+ declare class ConfigurationWebsocketAPI {
184
+ /**
185
+ * The API key used for authentication.
186
+ * @memberof ConfigurationWebsocketAPI
187
+ */
188
+ apiKey: string;
189
+ /**
190
+ * The API secret used for authentication.
191
+ * @memberof ConfigurationWebsocketAPI
192
+ */
193
+ apiSecret?: string;
194
+ /**
195
+ * override websocket url
196
+ * @type {string}
197
+ * @memberof ConfigurationWebsocketAPI
198
+ */
199
+ wsURL?: string;
200
+ /**
201
+ * set a timeout (in milliseconds) for the request
202
+ * @default 5000
203
+ * @type {number}
204
+ * @memberof ConfigurationWebsocketAPI
205
+ */
206
+ timeout?: number;
207
+ /**
208
+ * reconnction delay
209
+ * @default 5000
210
+ * @type {number}
211
+ * @memberof ConfigurationWebsocketAPI
212
+ */
213
+ reconnectDelay?: number;
214
+ /**
215
+ * use compression for websocket messages
216
+ * @default true
217
+ * @type {boolean}
218
+ * @memberof ConfigurationWebsocketAPI
219
+ */
220
+ compression?: boolean;
221
+ /**
222
+ * websocket agent
223
+ * @default false
224
+ * @type {boolean | Agent}
225
+ * @memberof ConfigurationWebsocketAPI
226
+ */
227
+ agent?: boolean | Agent;
228
+ /**
229
+ * the mode of the connection, either 'single' or 'pool'.
230
+ * @default 'single'
231
+ * @type {'single' | 'pool'}
232
+ * @memberof ConfigurationWebsocketAPI
233
+ */
234
+ mode?: 'single' | 'pool';
235
+ /**
236
+ * the size of the connection pool, if the mode is set to 'pool'.
237
+ * @default 1
238
+ * @type {number}
239
+ * @memberof ConfigurationWebsocketAPI
240
+ */
241
+ poolSize?: number;
242
+ /**
243
+ * private key
244
+ * @type {Buffer}
245
+ * @memberof ConfigurationWebsocketAPI
246
+ */
247
+ privateKey?: Buffer;
248
+ /**
249
+ * private key passphrase
250
+ * @type {string}
251
+ * @memberof ConfigurationWebsocketAPI
252
+ */
253
+ privateKeyPassphrase?: string;
254
+ /**
255
+ * timeUnit (used only on SPOT API)
256
+ * @type {TimeUnit}
257
+ * @memberof ConfigurationWebsocketAPI
258
+ */
259
+ timeUnit?: TimeUnit;
260
+ constructor(param?: ConfigurationWebsocketAPI);
261
+ }
262
+ declare class ConfigurationWebsocketStreams {
263
+ /**
264
+ * override websocket url
265
+ * @type {string}
266
+ * @memberof ConfigurationWebsocketStreams
267
+ */
268
+ wsURL?: string;
269
+ /**
270
+ * reconnction delay
271
+ * @default 5000
272
+ * @type {number}
273
+ * @memberof ConfigurationWebsocketStreams
274
+ */
275
+ reconnectDelay?: number;
276
+ /**
277
+ * use compression for websocket messages
278
+ * @default true
279
+ * @type {boolean}
280
+ * @memberof ConfigurationWebsocketAPI
281
+ */
282
+ compression?: boolean;
283
+ /**
284
+ * websocket agent
285
+ * @default false
286
+ * @type {boolean | Agent}
287
+ * @memberof ConfigurationWebsocketStreams
288
+ */
289
+ agent?: boolean | Agent;
290
+ /**
291
+ * the mode of the connection, either 'single' or 'pool'.
292
+ * @default single
293
+ * @type {'single' | 'pool'}
294
+ * @memberof ConfigurationWebsocketStreams
295
+ */
296
+ mode?: 'single' | 'pool';
297
+ /**
298
+ * the size of the connection pool, if the mode is set to 'pool'.
299
+ * @default 1
300
+ * @type {number}
301
+ * @memberof ConfigurationWebsocketStreams
302
+ */
303
+ poolSize?: number;
304
+ /**
305
+ * timeUnit (used only on SPOT API)
306
+ * @type {TimeUnit}
307
+ * @memberof ConfigurationWebsocketStreams
308
+ */
309
+ timeUnit?: TimeUnit;
310
+ constructor(param?: ConfigurationWebsocketStreams);
311
+ }
312
+
313
+ /**
314
+ * Represents an error that occurred in the Connector client.
315
+ * @param msg - An optional error message.
316
+ */
317
+ declare class ConnectorClientError extends Error {
318
+ constructor(msg?: string);
319
+ }
320
+ /**
321
+ * Represents an error that occurs when a required parameter is missing or undefined.
322
+ * @param field - The name of the missing parameter.
323
+ * @param msg - An optional error message.
324
+ */
325
+ declare class RequiredError extends Error {
326
+ field: string;
327
+ constructor(field: string, msg?: string);
328
+ }
329
+ /**
330
+ * Represents an error that occurs when a client is unauthorized to access a resource.
331
+ * @param msg - An optional error message.
332
+ */
333
+ declare class UnauthorizedError extends Error {
334
+ constructor(msg?: string);
335
+ }
336
+ /**
337
+ * Represents an error that occurs when a resource is forbidden to the client.
338
+ * @param msg - An optional error message.
339
+ */
340
+ declare class ForbiddenError extends Error {
341
+ constructor(msg?: string);
342
+ }
343
+ /**
344
+ * Represents an error that occurs when client is doing too many requests.
345
+ * @param msg - An optional error message.
346
+ */
347
+ declare class TooManyRequestsError extends Error {
348
+ constructor(msg?: string);
349
+ }
350
+ /**
351
+ * Represents an error that occurs when client's IP has been banned.
352
+ * @param msg - An optional error message.
353
+ */
354
+ declare class RateLimitBanError extends Error {
355
+ constructor(msg?: string);
356
+ }
357
+ /**
358
+ * Represents an error that occurs when there is an internal server error.
359
+ * @param msg - An optional error message.
360
+ * @param statusCode - An optional HTTP status code associated with the error.
361
+ */
362
+ declare class ServerError extends Error {
363
+ statusCode?: number | undefined;
364
+ constructor(msg?: string, statusCode?: number | undefined);
365
+ }
366
+ /**
367
+ * Represents an error that occurs when a network error occurs.
368
+ * @param msg - An optional error message.
369
+ */
370
+ declare class NetworkError extends Error {
371
+ constructor(msg?: string);
372
+ }
373
+ /**
374
+ * Represents an error that occurs when the requested resource was not found.
375
+ * @param msg - An optional error message.
376
+ */
377
+ declare class NotFoundError extends Error {
378
+ constructor(msg?: string);
379
+ }
380
+ /**
381
+ * Represents an error that occurs when a request is invalid or cannot be otherwise served.
382
+ * @param msg - An optional error message.
383
+ */
384
+ declare class BadRequestError extends Error {
385
+ constructor(msg?: string);
386
+ }
387
+
388
+ declare enum LogLevel {
389
+ NONE = "",
390
+ DEBUG = "debug",
391
+ INFO = "info",
392
+ WARN = "warn",
393
+ ERROR = "error"
394
+ }
395
+ declare class Logger {
396
+ private static instance;
397
+ private minLogLevel;
398
+ private readonly levelsOrder;
399
+ constructor();
400
+ static getInstance(): Logger;
401
+ setMinLogLevel(level: LogLevel): void;
402
+ private isValidLogLevel;
403
+ private log;
404
+ private allowLevelLog;
405
+ debug(...message: unknown[]): void;
406
+ info(...message: unknown[]): void;
407
+ warn(...message: unknown[]): void;
408
+ error(...message: unknown[]): void;
409
+ }
410
+
411
+ /**
412
+ * Represents the rate limit information for a REST API response.
413
+ * @property {string} rateLimitType - The type of rate limit, either 'REQUEST_WEIGHT' or 'ORDERS'.
414
+ * @property {string} interval - The time interval for the rate limit, one of 'SECOND', 'MINUTE', 'HOUR', or 'DAY'.
415
+ * @property {number} intervalNum - The number of intervals for the rate limit.
416
+ * @property {number} count - The current count of requests or orders for the rate limit.
417
+ * @property {number} [retryAfter] - The number of seconds to wait before retrying the request.
418
+ */
419
+ interface RestApiRateLimit {
420
+ rateLimitType: 'REQUEST_WEIGHT' | 'ORDERS';
421
+ interval: 'SECOND' | 'MINUTE' | 'HOUR' | 'DAY';
422
+ intervalNum: number;
423
+ count: number;
424
+ retryAfter?: number;
425
+ }
426
+ /**
427
+ * Represents the response from a REST API request.
428
+ * @template T - The type of the data returned in the response.
429
+ * @property {() => Promise<T>} data - A function that returns a Promise resolving to the data from the API response.
430
+ * @property {number} status - The HTTP status code of the response.
431
+ * @property {Record<string, string>} headers - The headers of the response.
432
+ * @property {RestApiRateLimit[]} [rateLimits] - An optional array of rate limit information for the response.
433
+ */
434
+ type RestApiResponse<T> = {
435
+ data: () => Promise<T>;
436
+ status: number;
437
+ headers: Record<string, string>;
438
+ rateLimits?: RestApiRateLimit[];
439
+ };
440
+ /**
441
+ * Represents the rate limit information for a WebSocket API response.
442
+ * @property {string} rateLimitType - The type of rate limit, either 'REQUEST_WEIGHT' or 'ORDERS'.
443
+ * @property {string} interval - The time interval for the rate limit, one of 'SECOND', 'MINUTE', 'HOUR', or 'DAY'.
444
+ * @property {number} intervalNum - The number of intervals for the rate limit.
445
+ * @property {number} limit - The maximum number of requests or orders allowed within the specified interval.
446
+ * @property {number} count - The current count of requests or orders for the rate limit.
447
+ */
448
+ interface WebsocketApiRateLimit {
449
+ rateLimitType: 'REQUEST_WEIGHT' | 'ORDERS';
450
+ interval: 'SECOND' | 'MINUTE' | 'HOUR' | 'DAY';
451
+ intervalNum: number;
452
+ limit: number;
453
+ count: number;
454
+ }
455
+ /**
456
+ * Represents the response from a WebSocket API request.
457
+ * @template T - The type of the data returned in the response.
458
+ * @property {T} data - The data from the API response.
459
+ * @property {WebsocketApiRateLimit[]} [rateLimits] - An optional array of rate limit information for the response.
460
+ */
461
+ type WebsocketApiResponse<T> = {
462
+ data: T;
463
+ rateLimits?: WebsocketApiRateLimit[];
464
+ };
465
+ /**
466
+ * Represents the options for sending a message.
467
+ * The object can have any number of properties, where the keys are strings and the values can be strings, numbers, booleans, objects, or undefined.
468
+ */
469
+ interface SendMessageOptions {
470
+ [key: string]: string | number | boolean | object | undefined;
471
+ }
472
+ /**
473
+ * Represents an object type where the keys are strings and the values can be strings, numbers, booleans, or objects.
474
+ */
475
+ interface ObjectType {
476
+ [key: string]: string | number | boolean | object;
477
+ }
478
+ /**
479
+ * Represents the arguments for an Axios request.
480
+ * @property {string} url - The URL for the request.
481
+ * @property {RawAxiosRequestConfig} options - The options for the Axios request.
482
+ */
483
+ interface AxiosRequestArgs {
484
+ url: string;
485
+ options: RawAxiosRequestConfig;
486
+ }
487
+ /**
488
+ * Represents the arguments for a request.
489
+ * @property {string} endpoint - The endpoint for the request.
490
+ * @property {'GET' | 'POST' | 'DELETE' | 'PUT' | 'PATCH'} method - The HTTP method for the request.
491
+ * @property {Record<string, unknown>} params - The parameters for the request.
492
+ * @property {TimeUnit} [timeUnit] - The optional time unit for the request.
493
+ */
494
+ interface RequestArgs {
495
+ endpoint: string;
496
+ method: 'GET' | 'POST' | 'DELETE' | 'PUT' | 'PATCH';
497
+ params: Record<string, unknown>;
498
+ timeUnit?: TimeUnit;
499
+ }
500
+
501
+ /**
502
+ * Generates a query string from an object of parameters.
503
+ *
504
+ * @param params - An object containing the query parameters.
505
+ * @returns The generated query string.
506
+ */
507
+ declare function buildQueryString(params: object): string;
508
+ /**
509
+ * Generates a random string of 16 hexadecimal characters.
510
+ *
511
+ * @returns A random string of 16 hexadecimal characters.
512
+ */
513
+ declare function randomString(): string;
514
+ /**
515
+ * Validates the provided time unit string and returns it if it is either 'MILLISECOND' or 'MICROSECOND'.
516
+ *
517
+ * @param timeUnit - The time unit string to be validated.
518
+ * @returns The validated time unit string, or `undefined` if the input is falsy.
519
+ * @throws {Error} If the time unit is not 'MILLISECOND' or 'MICROSECOND'.
520
+ */
521
+ declare function validateTimeUnit(timeUnit: string): string | undefined;
522
+ /**
523
+ * Delays the execution of the current function for the specified number of milliseconds.
524
+ *
525
+ * @param ms - The number of milliseconds to delay the function.
526
+ * @returns A Promise that resolves after the specified delay.
527
+ */
528
+ declare function delay(ms: number): Promise<void>;
529
+ /**
530
+ * Generates the current timestamp in milliseconds.
531
+ *
532
+ * @returns The current timestamp in milliseconds.
533
+ */
534
+ declare function getTimestamp(): number;
535
+ /**
536
+ * Generates a signature for a signed request based on the provided configuration.
537
+ *
538
+ * @param configuration - The configuration object containing the API secret or private key information.
539
+ * @param queryParams - The object containing the query parameters to be signed.
540
+ * @returns The generated signature as a string.
541
+ */
542
+ declare const getSignature: (configuration: {
543
+ apiSecret?: string;
544
+ privateKey?: string | Buffer;
545
+ privateKeyPassphrase?: string;
546
+ }, queryParams: object) => string;
547
+ /**
548
+ * Asserts that a function parameter exists and is not null or undefined.
549
+ *
550
+ * @param functionName - The name of the function that the parameter belongs to.
551
+ * @param paramName - The name of the parameter to check.
552
+ * @param paramValue - The value of the parameter to check.
553
+ * @throws {RequiredError} If the parameter is null or undefined.
554
+ */
555
+ declare const assertParamExists: (functionName: string, paramName: string, paramValue: unknown) => void;
556
+ /**
557
+ * Sets the search parameters of the provided URL by flattening the given objects into the URL's search parameters.
558
+ *
559
+ * This function takes a URL and one or more objects, and updates the URL's search parameters by flattening the objects into key-value pairs. It uses the `setFlattenedQueryParams` function to recursively flatten the objects.
560
+ *
561
+ * @param url - The URL to update the search parameters for.
562
+ * @param objects - One or more objects to flatten into the URL's search parameters.
563
+ */
564
+ declare const setSearchParams: (url: URL, ...objects: Record<string, unknown>[]) => void;
565
+ declare const toPathString: (url: URL) => string;
566
+ /**
567
+ * Determines whether a request should be retried based on the provided error.
568
+ *
569
+ * This function checks the HTTP method, response status, and number of retries left to determine if a request should be retried.
570
+ *
571
+ * @param error The error object to check.
572
+ * @param method The HTTP method of the request (optional).
573
+ * @param retriesLeft The number of retries left (optional).
574
+ * @returns `true` if the request should be retried, `false` otherwise.
575
+ */
576
+ declare const shouldRetryRequest: (error: AxiosError | object, method?: string, retriesLeft?: number) => boolean;
577
+ /**
578
+ * Performs an HTTP request using the provided Axios instance and configuration.
579
+ *
580
+ * This function handles retries, rate limit handling, and error handling for the HTTP request.
581
+ *
582
+ * @param axiosArgs The request arguments to be passed to Axios.
583
+ * @param axios The Axios instance to use for the request.
584
+ * @param configuration The configuration options for the request.
585
+ * @returns A Promise that resolves to the API response, including the data and rate limit headers.
586
+ */
587
+ declare const httpRequestFunction: <T>(axiosArgs: AxiosRequestArgs, configuration?: ConfigurationRestAPI) => Promise<RestApiResponse<T>>;
588
+ /**
589
+ * Parses the rate limit headers from the Axios response headers and returns an array of `RestApiRateLimit` objects.
590
+ *
591
+ * @param headers - The Axios response headers.
592
+ * @returns An array of `RestApiRateLimit` objects containing the parsed rate limit information.
593
+ */
594
+ declare const parseRateLimitHeaders: (headers: RawAxiosResponseHeaders | AxiosResponseHeaders) => RestApiRateLimit[];
595
+ /**
596
+ * Generic function to send a request with optional API key and signature.
597
+ * @param endpoint - The API endpoint to call.
598
+ * @param method - HTTP method to use (GET, POST, DELETE, etc.).
599
+ * @param params - Query parameters for the request.
600
+ * @param timeUnit - The time unit for the request.
601
+ * @param options - Additional request options (isSigned).
602
+ * @returns A promise resolving to the response data object.
603
+ */
604
+ declare const sendRequest: <T>(configuration: ConfigurationRestAPI, endpoint: string, method: "GET" | "POST" | "DELETE" | "PUT" | "PATCH", params?: Record<string, unknown>, timeUnit?: TimeUnit, options?: {
605
+ isSigned?: boolean;
606
+ }) => Promise<RestApiResponse<T>>;
607
+ /**
608
+ * Removes any null, undefined, or empty string values from the provided object.
609
+ *
610
+ * @param obj - The object to remove empty values from.
611
+ * @returns A new object with empty values removed.
612
+ */
613
+ declare function removeEmptyValue(obj: object): SendMessageOptions;
614
+ /**
615
+ * Sorts the properties of the provided object in alphabetical order and returns a new object with the sorted properties.
616
+ *
617
+ * @param obj - The object to be sorted.
618
+ * @returns A new object with the properties sorted in alphabetical order.
619
+ */
620
+ declare function sortObject(obj: ObjectType): ObjectType;
621
+ /**
622
+ * Replaces placeholders in the format <field> with corresponding values from the provided variables object.
623
+ *
624
+ * @param {string} str - The input string containing placeholders.
625
+ * @param {Object} variables - An object where keys correspond to placeholder names and values are the replacements.
626
+ * @returns {string} - The resulting string with placeholders replaced by their corresponding values.
627
+ */
628
+ declare function replaceWebsocketStreamsPlaceholders(str: string, variables: Record<string, unknown>): string;
629
+ /**
630
+ * Creates a WebsocketStream instance that subscribes to the specified stream and provides a callback for handling incoming messages.
631
+ *
632
+ * @param websocketBase - The WebsocketStreamsBase instance to use for subscribing and unsubscribing from the stream.
633
+ * @param stream - The name of the stream to subscribe to.
634
+ * @param id - An optional identifier for the stream.
635
+ * @returns A WebsocketStream instance that can be used to handle incoming messages and unsubscribe from the stream.
636
+ */
637
+ declare function createStreamHandler<T>(websocketBase: WebsocketStreamsBase, stream: string, id?: string): WebsocketStream<T>;
638
+
639
+ declare class WebsocketEventEmitter {
640
+ private eventEmitter;
641
+ constructor();
642
+ on(event: 'open' | 'message' | 'error' | 'close' | 'ping' | 'pong', listener: (...args: any[]) => void): void;
643
+ off(event: 'open' | 'message' | 'error' | 'close' | 'ping' | 'pong', listener: (...args: any[]) => void): void;
644
+ protected emit(event: 'open' | 'message' | 'error' | 'close' | 'ping' | 'pong', ...args: any[]): void;
645
+ }
646
+ interface WebsocketConnection {
647
+ id: string;
648
+ reconnectionPending: boolean;
649
+ renewalPending: boolean;
650
+ closeInitiated: boolean;
651
+ pendingRequests: Map<string, {
652
+ resolve: (value: any) => void;
653
+ reject: (reason?: unknown) => void;
654
+ }>;
655
+ pendingSubscriptions?: string[];
656
+ ws?: WebSocketClient;
657
+ }
658
+ declare class WebsocketCommon extends WebsocketEventEmitter {
659
+ protected configuration: ConfigurationWebsocketAPI | ConfigurationWebsocketStreams;
660
+ private static readonly MAX_CONNECTION_DURATION;
661
+ private readonly connectionQueue;
662
+ private queueProcessing;
663
+ private connectionTimers;
664
+ private mode;
665
+ private poolSize;
666
+ private roundRobinIndex;
667
+ connectionPool: WebsocketConnection[];
668
+ logger: Logger;
669
+ constructor(configuration: ConfigurationWebsocketAPI | ConfigurationWebsocketStreams, connectionPool?: WebsocketConnection[]);
670
+ /**
671
+ * Initializes the WebSocket connection pool by creating a specified number of connection objects
672
+ * and adding them to the `connectionPool` array. Each connection object has the following properties:
673
+ * - `closeInitiated`: a boolean indicating whether the connection has been closed
674
+ * - `reconnectionPending`: a boolean indicating whether a reconnection is pending
675
+ * - `pendingRequests`: a Map that tracks pending requests for the connection
676
+ * @param size - The number of connection objects to create and add to the pool.
677
+ * @returns void
678
+ */
679
+ private initializePool;
680
+ /**
681
+ * Gets a WebSocket connection from the pool or single connection.
682
+ * If the connection mode is 'single', it returns the first connection in the pool.
683
+ * If the connection mode is 'pool', it returns an available connection from the pool,
684
+ * using a round-robin selection strategy. If no available connections are found, it throws an error.
685
+ * @param allowNonEstablishedWebsockets - A boolean indicating whether to allow connections that are not established.
686
+ * @returns {WebsocketConnection} The selected WebSocket connection.
687
+ */
688
+ protected getConnection(allowNonEstablishedWebsockets?: boolean): WebsocketConnection;
689
+ /**
690
+ * Checks if the provided WebSocket connection is ready for use.
691
+ * A connection is considered ready if it is open, has no pending reconnection, and has not been closed.
692
+ * @param connection - The WebSocket connection to check.
693
+ * @param allowNonEstablishedWebsockets - An optional flag to allow non-established WebSocket connections.
694
+ * @returns `true` if the connection is ready, `false` otherwise.
695
+ */
696
+ protected isConnectionReady(connection: WebsocketConnection, allowNonEstablishedWebsockets?: boolean): boolean;
697
+ /**
698
+ * Schedules a timer for a WebSocket connection and tracks it
699
+ * @param connection WebSocket client instance
700
+ * @param callback Function to execute when timer triggers
701
+ * @param delay Time in milliseconds before callback execution
702
+ * @param type Timer type ('timeout' or 'interval')
703
+ * @returns Timer handle
704
+ */
705
+ private scheduleTimer;
706
+ /**
707
+ * Clears all timers associated with a WebSocket connection.
708
+ * @param connection - The WebSocket client instance to clear timers for.
709
+ * @returns void
710
+ */
711
+ private clearTimers;
712
+ /**
713
+ * Processes the connection queue, reconnecting or renewing connections as needed.
714
+ * This method is responsible for iterating through the connection queue and initiating
715
+ * the reconnection or renewal process for each connection in the queue. It throttles
716
+ * the queue processing to avoid overwhelming the server with too many connection
717
+ * requests at once.
718
+ * @param throttleRate - The time in milliseconds to wait between processing each
719
+ * connection in the queue.
720
+ * @returns A Promise that resolves when the queue has been fully processed.
721
+ */
722
+ private processQueue;
723
+ /**
724
+ * Enqueues a reconnection or renewal for a WebSocket connection.
725
+ * This method adds the connection, URL, and renewal flag to the connection queue,
726
+ * and then calls the `processQueue` method to initiate the reconnection or renewal
727
+ * process.
728
+ * @param connection - The WebSocket connection to reconnect or renew.
729
+ * @param url - The URL to use for the reconnection or renewal.
730
+ * @param isRenewal - A flag indicating whether this is a renewal (true) or a reconnection (false).
731
+ */
732
+ private enqueueReconnection;
733
+ /**
734
+ * Gracefully closes a WebSocket connection after pending requests complete.
735
+ * This method waits for any pending requests to complete before closing the connection.
736
+ * It sets up a timeout to force-close the connection after 30 seconds if the pending requests
737
+ * do not complete. Once all pending requests are completed, the connection is closed.
738
+ * @param connectionToClose - The WebSocket client instance to close.
739
+ * @param WebsocketConnectionToClose - The WebSocket connection to close.
740
+ * @param connection - The WebSocket connection to close.
741
+ * @returns Promise that resolves when the connection is closed.
742
+ */
743
+ private closeConnectionGracefully;
744
+ /**
745
+ * Cleans up WebSocket connection resources.
746
+ * Removes all listeners and clears any associated timers for the provided WebSocket client.
747
+ * @param ws - The WebSocket client to clean up.
748
+ * @returns void
749
+ */
750
+ protected cleanup(ws: WebSocketClient): void;
751
+ /**
752
+ * Handles incoming WebSocket messages
753
+ * @param data Raw message data received
754
+ * @param connection Websocket connection
755
+ */
756
+ protected onMessage(data: string, connection: WebsocketConnection): void;
757
+ /**
758
+ * Handles the opening of a WebSocket connection.
759
+ * @param url - The URL of the WebSocket server.
760
+ * @param targetConnection - The WebSocket connection being opened.
761
+ * @param oldConnection - The previous WebSocket connection, if this is a renewal.
762
+ * @param isRenewal - Indicates whether this is a connection renewal.
763
+ * @param oldWSConnection - The WebSocket client instance associated with the old connection.
764
+ */
765
+ protected onOpen(url: string, targetConnection: WebsocketConnection, oldWSConnection: WebSocketClient): void;
766
+ /**
767
+ * Returns the URL to use when reconnecting.
768
+ * Derived classes should override this to provide dynamic URLs.
769
+ * @param defaultURL The URL originally passed during the first connection.
770
+ * @param targetConnection The WebSocket connection being connected.
771
+ * @returns The URL to reconnect to.
772
+ */
773
+ protected getReconnectURL(defaultURL: string, targetConnection: WebsocketConnection): string;
774
+ /**
775
+ * Connects all WebSocket connections in the pool
776
+ * @param url - The Websocket server URL.
777
+ * @returns A promise that resolves when all connections are established.
778
+ */
779
+ protected connectPool(url: string): Promise<void>;
780
+ /**
781
+ * Creates a new WebSocket client instance.
782
+ * @param url - The URL to connect to.
783
+ * @returns A new WebSocket client instance.
784
+ */
785
+ protected createWebSocket(url: string): WebSocketClient;
786
+ /**
787
+ * Initializes a WebSocket connection.
788
+ * @param url - The Websocket server URL.
789
+ * @param isRenewal - Whether this is a connection renewal.
790
+ * @param connection - An optional WebSocket connection to use.
791
+ * @returns The WebSocket connection.
792
+ */
793
+ protected initConnect(url: string, isRenewal?: boolean, connection?: WebsocketConnection): WebsocketConnection | undefined;
794
+ /**
795
+ * Checks if the WebSocket connection is currently open.
796
+ * @param connection - An optional WebSocket connection to check. If not provided, the entire connection pool is checked.
797
+ * @returns `true` if the connection is open, `false` otherwise.
798
+ */
799
+ isConnected(connection?: WebsocketConnection): boolean;
800
+ /**
801
+ * Disconnects from the WebSocket server.
802
+ * If there is no active connection, a warning is logged.
803
+ * Otherwise, all connections in the connection pool are closed gracefully,
804
+ * and a message is logged indicating that the connection has been disconnected.
805
+ * @returns A Promise that resolves when all connections have been closed.
806
+ * @throws Error if the WebSocket client is not set.
807
+ */
808
+ disconnect(): Promise<void>;
809
+ /**
810
+ * Sends a ping message to all connected Websocket servers in the pool.
811
+ * If no connections are ready, a warning is logged.
812
+ * For each active connection, the ping message is sent, and debug logs provide details.
813
+ * @throws Error if a Websocket client is not set for a connection.
814
+ */
815
+ pingServer(): void;
816
+ /**
817
+ * Sends a payload through the WebSocket connection.
818
+ * @param payload - Message to send.
819
+ * @param id - Optional request identifier.
820
+ * @param promiseBased - Whether to return a promise.
821
+ * @param timeout - Timeout duration in milliseconds.
822
+ * @param connection - The WebSocket connection to use.
823
+ * @returns A promise if `promiseBased` is true, void otherwise.
824
+ * @throws Error if not connected or WebSocket client is not set.
825
+ */
826
+ protected send<T = unknown>(payload: string, id?: string, promiseBased?: boolean, timeout?: number, connection?: WebsocketConnection): Promise<WebsocketApiResponse<T>> | void;
827
+ }
828
+ interface WebsocketSendMsgOptions {
829
+ id?: string;
830
+ [key: string]: string | number | boolean | object | undefined;
831
+ }
832
+ declare class WebsocketAPIBase extends WebsocketCommon {
833
+ private isConnecting;
834
+ configuration: ConfigurationWebsocketAPI;
835
+ logger: Logger;
836
+ constructor(configuration: ConfigurationWebsocketAPI, connectionPool?: WebsocketConnection[]);
837
+ /**
838
+ * Prepares the WebSocket URL by adding optional timeUnit parameter
839
+ * @param wsUrl The base WebSocket URL
840
+ * @returns The formatted WebSocket URL with parameters
841
+ */
842
+ private prepareURL;
843
+ /**
844
+ * Processes incoming WebSocket messages
845
+ * @param data The raw message data received
846
+ */
847
+ protected onMessage(data: string, connection: WebsocketConnection): void;
848
+ /**
849
+ * Establishes a WebSocket connection to Binance
850
+ * @returns Promise that resolves when connection is established
851
+ * @throws Error if connection times out
852
+ */
853
+ connect(): Promise<void>;
854
+ /**
855
+ * Sends a message to the WebSocket API Server.
856
+ * Supports both signed and unsigned messages.
857
+ * @param method The API method to call
858
+ * @param payload Message parameters and options
859
+ * @param options Additional requests options (withApiKey, isSigned)
860
+ * @returns Promise that resolves with the server response
861
+ * @throws Error if not connected
862
+ */
863
+ sendMessage<T = unknown>(method: string, payload?: WebsocketSendMsgOptions, options?: {
864
+ withApiKey?: boolean;
865
+ isSigned?: boolean;
866
+ }): Promise<WebsocketApiResponse<T>>;
867
+ }
868
+ interface WebsocketStream<T> {
869
+ /**
870
+ * Attach a listener for the stream.
871
+ * @param event - Event name (currently supports "message").
872
+ * @param callback - Callback function to handle incoming data.
873
+ */
874
+ on(event: 'message', callback: (data: T) => void): void;
875
+ /**
876
+ * Unsubscribe from the stream and clean up resources.
877
+ */
878
+ unsubscribe(): void;
879
+ }
880
+ declare class WebsocketStreamsBase extends WebsocketCommon {
881
+ private streamConnectionMap;
882
+ protected configuration: ConfigurationWebsocketStreams;
883
+ protected wsURL: string;
884
+ streamCallbackMap: Map<string, Set<(data: unknown) => void>>;
885
+ logger: Logger;
886
+ constructor(configuration: ConfigurationWebsocketStreams, connectionPool?: WebsocketConnection[]);
887
+ /**
888
+ * Formats the WebSocket URL for a given stream or streams.
889
+ * @param streams - Array of stream names to include in the URL.
890
+ * @returns The formatted WebSocket URL with the provided streams.
891
+ */
892
+ private prepareURL;
893
+ /**
894
+ * Formats the WebSocket URL with stream and configuration parameters to be used for reconnection.
895
+ * @param url - The base WebSocket URL.
896
+ * @param targetConnection - The target WebSocket connection.
897
+ * @returns The formatted WebSocket URL with streams and optional parameters.
898
+ */
899
+ protected getReconnectURL(url: string, targetConnection: WebsocketConnection): string;
900
+ /**
901
+ * Handles subscription to streams and assigns them to specific connections
902
+ * @param streams Array of stream names to subscribe to
903
+ * @returns Map of connections to streams
904
+ */
905
+ private handleStreamAssignment;
906
+ /**
907
+ * Sends a subscription payload for specified streams on a given connection.
908
+ * @param connection The WebSocket connection to use for sending the subscription.
909
+ * @param streams The streams to subscribe to.
910
+ * @param id Optional ID for the subscription.
911
+ */
912
+ private sendSubscriptionPayload;
913
+ /**
914
+ * Processes pending subscriptions for a given connection.
915
+ * Sends all queued subscriptions in a single payload.
916
+ * @param connection The WebSocket connection to process.
917
+ */
918
+ private processPendingSubscriptions;
919
+ /**
920
+ * Handles incoming WebSocket messages, parsing the data and invoking the appropriate callback function.
921
+ * If the message contains a stream name that is registered in the `streamCallbackMap`, the corresponding
922
+ * callback function is called with the message data.
923
+ * If the message cannot be parsed, an error is logged.
924
+ * @param data The raw WebSocket message data.
925
+ * @param connection The WebSocket connection that received the message.
926
+ */
927
+ protected onMessage(data: string, connection: WebsocketConnection): void;
928
+ /**
929
+ * Called when the WebSocket connection is opened.
930
+ * Processes any pending subscriptions for the target connection.
931
+ * @param url The URL of the WebSocket connection.
932
+ * @param targetConnection The WebSocket connection that was opened.
933
+ * @param oldConnection The previous WebSocket connection, if any.
934
+ * @param isRenewal Whether the connection is a renewal of an existing connection.
935
+ */
936
+ protected onOpen(url: string, targetConnection: WebsocketConnection, oldWSConnection: WebSocketClient): void;
937
+ /**
938
+ * Connects to the WebSocket server and subscribes to the specified streams.
939
+ * This method returns a Promise that resolves when the connection is established,
940
+ * or rejects with an error if the connection fails to be established within 10 seconds.
941
+ * @param stream - A single stream name or an array of stream names to subscribe to.
942
+ * @returns A Promise that resolves when the connection is established.
943
+ */
944
+ connect(stream?: string | string[]): Promise<void>;
945
+ /**
946
+ * Disconnects the WebSocket connection and clears the stream callback map.
947
+ * This method is called to clean up the connection and associated resources.
948
+ */
949
+ disconnect(): Promise<void>;
950
+ /**
951
+ * Subscribes to one or multiple WebSocket streams
952
+ * Handles both single and pool modes
953
+ * @param stream Single stream name or array of stream names to subscribe to
954
+ * @param id Optional subscription ID
955
+ * @returns void
956
+ */
957
+ subscribe(stream: string | string[], id?: string): void;
958
+ /**
959
+ * Unsubscribes from one or multiple WebSocket streams
960
+ * Handles both single and pool modes
961
+ * @param stream Single stream name or array of stream names to unsubscribe from
962
+ * @param id Optional unsubscription ID
963
+ * @returns void
964
+ */
965
+ unsubscribe(stream: string | string[], id?: string): void;
966
+ /**
967
+ * Checks if the specified stream is currently subscribed.
968
+ * @param stream - The name of the stream to check.
969
+ * @returns `true` if the stream is currently subscribed, `false` otherwise.
970
+ */
971
+ isSubscribed(stream: string): boolean;
972
+ }
973
+
974
+ export { ALGO_REST_API_PROD_URL, ALGO_REST_API_TESTNET_URL, AUTO_INVEST_REST_API_PROD_URL, AUTO_INVEST_REST_API_TESTNET_URL, AxiosRequestArgs, BadRequestError, C2C_REST_API_PROD_URL, C2C_REST_API_TESTNET_URL, CONVERT_REST_API_PROD_URL, CONVERT_REST_API_TESTNET_URL, COPY_TRADING_REST_API_PROD_URL, COPY_TRADING_REST_API_TESTNET_URL, CRYPTO_LOAN_REST_API_PROD_URL, CRYPTO_LOAN_REST_API_TESTNET_URL, ConfigurationRestAPI, ConfigurationWebsocketAPI, ConfigurationWebsocketStreams, ConnectorClientError, DERIVATIVES_TRADING_COIN_FUTURES_REST_API_PROD_URL, DERIVATIVES_TRADING_COIN_FUTURES_REST_API_TESTNET_URL, DERIVATIVES_TRADING_COIN_FUTURES_WS_API_PROD_URL, DERIVATIVES_TRADING_COIN_FUTURES_WS_API_TESTNET_URL, DERIVATIVES_TRADING_COIN_FUTURES_WS_STREAMS_PROD_URL, DERIVATIVES_TRADING_COIN_FUTURES_WS_STREAMS_TESTNET_URL, DERIVATIVES_TRADING_OPTIONS_REST_API_PROD_URL, DERIVATIVES_TRADING_OPTIONS_WS_STREAMS_PROD_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_REST_API_PROD_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_REST_API_TESTNET_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_PROD_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_TESTNET_URL, DERIVATIVES_TRADING_USDS_FUTURES_REST_API_PROD_URL, DERIVATIVES_TRADING_USDS_FUTURES_REST_API_TESTNET_URL, DERIVATIVES_TRADING_USDS_FUTURES_WS_API_PROD_URL, DERIVATIVES_TRADING_USDS_FUTURES_WS_API_TESTNET_URL, DERIVATIVES_TRADING_USDS_FUTURES_WS_STREAMS_PROD_URL, DERIVATIVES_TRADING_USDS_FUTURES_WS_STREAMS_TESTNET_URL, DUAL_INVESTMENT_REST_API_PROD_URL, DUAL_INVESTMENT_REST_API_TESTNET_URL, FIAT_REST_API_PROD_URL, FIAT_REST_API_TESTNET_URL, ForbiddenError, GIFT_CARD_REST_API_PROD_URL, GIFT_CARD_REST_API_TESTNET_URL, LogLevel, Logger, MARGIN_TRADING_REST_API_PROD_URL, MARGIN_TRADING_REST_API_TESTNET_URL, MINING_REST_API_PROD_URL, MINING_REST_API_TESTNET_URL, NFT_REST_API_PROD_URL, NFT_REST_API_TESTNET_URL, NetworkError, NotFoundError, ObjectType, PAY_REST_API_PROD_URL, PAY_REST_API_TESTNET_URL, REBATE_REST_API_PROD_URL, REBATE_REST_API_TESTNET_URL, RateLimitBanError, RequestArgs, RequiredError, RestApiRateLimit, RestApiResponse, SIMPLE_EARN_REST_API_PROD_URL, SIMPLE_EARN_REST_API_TESTNET_URL, SPOT_REST_API_MARKET_URL, SPOT_REST_API_PROD_URL, SPOT_REST_API_TESTNET_URL, SPOT_WS_API_PROD_URL, SPOT_WS_API_TESTNET_URL, SPOT_WS_STREAMS_MARKET_URL, SPOT_WS_STREAMS_PROD_URL, SPOT_WS_STREAMS_TESTNET_URL, STAKING_REST_API_PROD_URL, STAKING_REST_API_TESTNET_URL, SUB_ACCOUNT_REST_API_PROD_URL, SUB_ACCOUNT_REST_API_TESTNET_URL, SendMessageOptions, ServerError, TimeUnit, TooManyRequestsError, UnauthorizedError, VIP_LOAN_REST_API_PROD_URL, VIP_LOAN_REST_API_TESTNET_URL, WALLET_REST_API_PROD_URL, WALLET_REST_API_TESTNET_URL, WebsocketAPIBase, WebsocketApiRateLimit, WebsocketApiResponse, WebsocketCommon, WebsocketConnection, WebsocketEventEmitter, WebsocketSendMsgOptions, WebsocketStream, WebsocketStreamsBase, assertParamExists, buildQueryString, createStreamHandler, delay, getSignature, getTimestamp, httpRequestFunction, parseRateLimitHeaders, randomString, removeEmptyValue, replaceWebsocketStreamsPlaceholders, sendRequest, setSearchParams, shouldRetryRequest, sortObject, toPathString, validateTimeUnit };