@binance/common 2.3.4 → 2.3.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.
package/dist/index.d.mts CHANGED
@@ -24,10 +24,11 @@ declare const DERIVATIVES_TRADING_COIN_FUTURES_WS_STREAMS_PROD_URL = "wss://dstr
24
24
  declare const DERIVATIVES_TRADING_COIN_FUTURES_WS_STREAMS_TESTNET_URL = "wss://dstream.binancefuture.com";
25
25
  declare const DERIVATIVES_TRADING_USDS_FUTURES_REST_API_PROD_URL = "https://fapi.binance.com";
26
26
  declare const DERIVATIVES_TRADING_USDS_FUTURES_REST_API_TESTNET_URL = "https://testnet.binancefuture.com";
27
+ declare const DERIVATIVES_TRADING_USDS_FUTURES_REST_API_DEMO_URL = "https://demo-fapi.binance.com";
27
28
  declare const DERIVATIVES_TRADING_USDS_FUTURES_WS_API_PROD_URL = "wss://ws-fapi.binance.com/ws-fapi/v1";
28
29
  declare const DERIVATIVES_TRADING_USDS_FUTURES_WS_API_TESTNET_URL = "wss://testnet.binancefuture.com/ws-fapi/v1";
29
30
  declare const DERIVATIVES_TRADING_USDS_FUTURES_WS_STREAMS_PROD_URL = "wss://fstream.binance.com";
30
- declare const DERIVATIVES_TRADING_USDS_FUTURES_WS_STREAMS_TESTNET_URL = "wss://stream.binancefuture.com";
31
+ declare const DERIVATIVES_TRADING_USDS_FUTURES_WS_STREAMS_TESTNET_URL = "wss://fstream.binancefuture.com";
31
32
  declare const DERIVATIVES_TRADING_OPTIONS_REST_API_PROD_URL = "https://eapi.binance.com";
32
33
  declare const DERIVATIVES_TRADING_OPTIONS_REST_API_TESTNET_URL = "https://testnet.binancefuture.com";
33
34
  declare const DERIVATIVES_TRADING_OPTIONS_WS_STREAMS_PROD_URL = "wss://fstream.binance.com";
@@ -51,10 +52,13 @@ declare const REBATE_REST_API_PROD_URL = "https://api.binance.com";
51
52
  declare const SIMPLE_EARN_REST_API_PROD_URL = "https://api.binance.com";
52
53
  declare const SPOT_REST_API_PROD_URL = "https://api.binance.com";
53
54
  declare const SPOT_REST_API_TESTNET_URL = "https://testnet.binance.vision";
55
+ declare const SPOT_REST_API_DEMO_URL = "https://demo-api.binance.com";
54
56
  declare const SPOT_WS_API_PROD_URL = "wss://ws-api.binance.com:443/ws-api/v3";
55
57
  declare const SPOT_WS_API_TESTNET_URL = "wss://ws-api.testnet.binance.vision/ws-api/v3";
58
+ declare const SPOT_WS_API_DEMO_URL = "wss://demo-ws-api.binance.com/ws-api/v3";
56
59
  declare const SPOT_WS_STREAMS_PROD_URL = "wss://stream.binance.com:9443";
57
60
  declare const SPOT_WS_STREAMS_TESTNET_URL = "wss://stream.testnet.binance.vision";
61
+ declare const SPOT_WS_STREAMS_DEMO_URL = "wss://demo-stream.binance.com:9443";
58
62
  declare const SPOT_REST_API_MARKET_URL = "https://data-api.binance.vision";
59
63
  declare const SPOT_WS_STREAMS_MARKET_URL = "wss://data-stream.binance.vision";
60
64
  declare const STAKING_REST_API_PROD_URL = "https://api.binance.com";
@@ -818,6 +822,14 @@ declare class WebsocketCommon extends WebsocketEventEmitter {
818
822
  * @returns {WebsocketConnection} The selected WebSocket connection.
819
823
  */
820
824
  protected getConnection(allowNonEstablishedWebsockets?: boolean, urlPath?: string): WebsocketConnection;
825
+ /**
826
+ * Checks if the message is `serverShutdown`.
827
+ * This is used to identify server shutdown events in incoming WebSocket messages.
828
+ *
829
+ * @param message - The message to check for a server shutdown event.
830
+ * @returns `true` if the message indicates a server shutdown event, `false` otherwise.
831
+ */
832
+ protected isServerShutdownEvent(message: any): boolean;
821
833
  /**
822
834
  * Checks if the provided WebSocket connection is ready for use.
823
835
  * A connection is considered ready if it is open, has no pending reconnection, and has not been closed.
@@ -861,7 +873,7 @@ declare class WebsocketCommon extends WebsocketEventEmitter {
861
873
  * @param url - The URL to use for the reconnection or renewal.
862
874
  * @param isRenewal - A flag indicating whether this is a renewal (true) or a reconnection (false).
863
875
  */
864
- private enqueueReconnection;
876
+ protected enqueueReconnection(connection: WebsocketConnection, url: string, isRenewal: boolean): void;
865
877
  /**
866
878
  * Gracefully closes a WebSocket connection after pending requests complete.
867
879
  * This method waits for any pending requests to complete before closing the connection.
@@ -1148,5 +1160,5 @@ interface WebsocketStream<T> {
1148
1160
  */
1149
1161
  declare function createStreamHandler<T>(websocketBase: WebsocketAPIBase | WebsocketStreamsBase, streamOrId: string, id?: number | string, urlPath?: string): WebsocketStream<T>;
1150
1162
  //#endregion
1151
- export { ALGO_REST_API_PROD_URL, ALPHA_REST_API_PROD_URL, AxiosRequestArgs, BadRequestError, C2C_REST_API_PROD_URL, CONVERT_REST_API_PROD_URL, COPY_TRADING_REST_API_PROD_URL, CRYPTO_LOAN_REST_API_PROD_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_REST_API_TESTNET_URL, DERIVATIVES_TRADING_OPTIONS_WS_STREAMS_PROD_URL, DERIVATIVES_TRADING_OPTIONS_WS_STREAMS_TESTNET_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_REST_API_PROD_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_WS_STREAMS_PROD_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_PROD_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_TESTNET_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_WS_STREAMS_PROD_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_WS_STREAMS_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, FIAT_REST_API_PROD_URL, ForbiddenError, GIFT_CARD_REST_API_PROD_URL, LogLevel, Logger, MARGIN_TRADING_REST_API_PROD_URL, MARGIN_TRADING_RISK_WS_STREAMS_PROD_URL, MARGIN_TRADING_WS_STREAMS_PROD_URL, MINING_REST_API_PROD_URL, NFT_REST_API_PROD_URL, NetworkError, NotFoundError, ObjectType, PAY_REST_API_PROD_URL, REBATE_REST_API_PROD_URL, RateLimitBanError, RequestArgs, RequiredError, RestApiRateLimit, RestApiResponse, SIMPLE_EARN_REST_API_PROD_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, SUB_ACCOUNT_REST_API_PROD_URL, SendMessageOptions, ServerError, TimeUnit, TimerRecord, TooManyRequestsError, UnauthorizedError, VIP_LOAN_REST_API_PROD_URL, WALLET_REST_API_PROD_URL, WebsocketAPIBase, WebsocketApiRateLimit, WebsocketApiResponse, WebsocketCommon, WebsocketConnection, WebsocketEventEmitter, WebsocketSendMsgConfig, WebsocketSendMsgOptions, WebsocketStream, WebsocketStreamsBase, assertParamExists, buildQueryString, buildUserAgent, buildWebsocketAPIMessage, clearSignerCache, createStreamHandler, delay, getSignature, getTimestamp, httpRequestFunction, normalizeScientificNumbers, normalizeStreamId, parseCustomHeaders, parseRateLimitHeaders, randomInteger, randomString, removeEmptyValue, replaceWebsocketStreamsPlaceholders, sanitizeHeaderValue, sendRequest, setSearchParams, shouldRetryRequest, sortObject, toPathString, validateTimeUnit };
1163
+ export { ALGO_REST_API_PROD_URL, ALPHA_REST_API_PROD_URL, AxiosRequestArgs, BadRequestError, C2C_REST_API_PROD_URL, CONVERT_REST_API_PROD_URL, COPY_TRADING_REST_API_PROD_URL, CRYPTO_LOAN_REST_API_PROD_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_REST_API_TESTNET_URL, DERIVATIVES_TRADING_OPTIONS_WS_STREAMS_PROD_URL, DERIVATIVES_TRADING_OPTIONS_WS_STREAMS_TESTNET_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_REST_API_PROD_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_WS_STREAMS_PROD_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_PROD_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_TESTNET_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_WS_STREAMS_PROD_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_WS_STREAMS_TESTNET_URL, DERIVATIVES_TRADING_USDS_FUTURES_REST_API_DEMO_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, FIAT_REST_API_PROD_URL, ForbiddenError, GIFT_CARD_REST_API_PROD_URL, LogLevel, Logger, MARGIN_TRADING_REST_API_PROD_URL, MARGIN_TRADING_RISK_WS_STREAMS_PROD_URL, MARGIN_TRADING_WS_STREAMS_PROD_URL, MINING_REST_API_PROD_URL, NFT_REST_API_PROD_URL, NetworkError, NotFoundError, ObjectType, PAY_REST_API_PROD_URL, REBATE_REST_API_PROD_URL, RateLimitBanError, RequestArgs, RequiredError, RestApiRateLimit, RestApiResponse, SIMPLE_EARN_REST_API_PROD_URL, SPOT_REST_API_DEMO_URL, SPOT_REST_API_MARKET_URL, SPOT_REST_API_PROD_URL, SPOT_REST_API_TESTNET_URL, SPOT_WS_API_DEMO_URL, SPOT_WS_API_PROD_URL, SPOT_WS_API_TESTNET_URL, SPOT_WS_STREAMS_DEMO_URL, SPOT_WS_STREAMS_MARKET_URL, SPOT_WS_STREAMS_PROD_URL, SPOT_WS_STREAMS_TESTNET_URL, STAKING_REST_API_PROD_URL, SUB_ACCOUNT_REST_API_PROD_URL, SendMessageOptions, ServerError, TimeUnit, TimerRecord, TooManyRequestsError, UnauthorizedError, VIP_LOAN_REST_API_PROD_URL, WALLET_REST_API_PROD_URL, WebsocketAPIBase, WebsocketApiRateLimit, WebsocketApiResponse, WebsocketCommon, WebsocketConnection, WebsocketEventEmitter, WebsocketSendMsgConfig, WebsocketSendMsgOptions, WebsocketStream, WebsocketStreamsBase, assertParamExists, buildQueryString, buildUserAgent, buildWebsocketAPIMessage, clearSignerCache, createStreamHandler, delay, getSignature, getTimestamp, httpRequestFunction, normalizeScientificNumbers, normalizeStreamId, parseCustomHeaders, parseRateLimitHeaders, randomInteger, randomString, removeEmptyValue, replaceWebsocketStreamsPlaceholders, sanitizeHeaderValue, sendRequest, setSearchParams, shouldRetryRequest, sortObject, toPathString, validateTimeUnit };
1152
1164
  //# sourceMappingURL=index.d.mts.map
package/dist/index.d.ts CHANGED
@@ -24,10 +24,11 @@ declare const DERIVATIVES_TRADING_COIN_FUTURES_WS_STREAMS_PROD_URL = "wss://dstr
24
24
  declare const DERIVATIVES_TRADING_COIN_FUTURES_WS_STREAMS_TESTNET_URL = "wss://dstream.binancefuture.com";
25
25
  declare const DERIVATIVES_TRADING_USDS_FUTURES_REST_API_PROD_URL = "https://fapi.binance.com";
26
26
  declare const DERIVATIVES_TRADING_USDS_FUTURES_REST_API_TESTNET_URL = "https://testnet.binancefuture.com";
27
+ declare const DERIVATIVES_TRADING_USDS_FUTURES_REST_API_DEMO_URL = "https://demo-fapi.binance.com";
27
28
  declare const DERIVATIVES_TRADING_USDS_FUTURES_WS_API_PROD_URL = "wss://ws-fapi.binance.com/ws-fapi/v1";
28
29
  declare const DERIVATIVES_TRADING_USDS_FUTURES_WS_API_TESTNET_URL = "wss://testnet.binancefuture.com/ws-fapi/v1";
29
30
  declare const DERIVATIVES_TRADING_USDS_FUTURES_WS_STREAMS_PROD_URL = "wss://fstream.binance.com";
30
- declare const DERIVATIVES_TRADING_USDS_FUTURES_WS_STREAMS_TESTNET_URL = "wss://stream.binancefuture.com";
31
+ declare const DERIVATIVES_TRADING_USDS_FUTURES_WS_STREAMS_TESTNET_URL = "wss://fstream.binancefuture.com";
31
32
  declare const DERIVATIVES_TRADING_OPTIONS_REST_API_PROD_URL = "https://eapi.binance.com";
32
33
  declare const DERIVATIVES_TRADING_OPTIONS_REST_API_TESTNET_URL = "https://testnet.binancefuture.com";
33
34
  declare const DERIVATIVES_TRADING_OPTIONS_WS_STREAMS_PROD_URL = "wss://fstream.binance.com";
@@ -51,10 +52,13 @@ declare const REBATE_REST_API_PROD_URL = "https://api.binance.com";
51
52
  declare const SIMPLE_EARN_REST_API_PROD_URL = "https://api.binance.com";
52
53
  declare const SPOT_REST_API_PROD_URL = "https://api.binance.com";
53
54
  declare const SPOT_REST_API_TESTNET_URL = "https://testnet.binance.vision";
55
+ declare const SPOT_REST_API_DEMO_URL = "https://demo-api.binance.com";
54
56
  declare const SPOT_WS_API_PROD_URL = "wss://ws-api.binance.com:443/ws-api/v3";
55
57
  declare const SPOT_WS_API_TESTNET_URL = "wss://ws-api.testnet.binance.vision/ws-api/v3";
58
+ declare const SPOT_WS_API_DEMO_URL = "wss://demo-ws-api.binance.com/ws-api/v3";
56
59
  declare const SPOT_WS_STREAMS_PROD_URL = "wss://stream.binance.com:9443";
57
60
  declare const SPOT_WS_STREAMS_TESTNET_URL = "wss://stream.testnet.binance.vision";
61
+ declare const SPOT_WS_STREAMS_DEMO_URL = "wss://demo-stream.binance.com:9443";
58
62
  declare const SPOT_REST_API_MARKET_URL = "https://data-api.binance.vision";
59
63
  declare const SPOT_WS_STREAMS_MARKET_URL = "wss://data-stream.binance.vision";
60
64
  declare const STAKING_REST_API_PROD_URL = "https://api.binance.com";
@@ -818,6 +822,14 @@ declare class WebsocketCommon extends WebsocketEventEmitter {
818
822
  * @returns {WebsocketConnection} The selected WebSocket connection.
819
823
  */
820
824
  protected getConnection(allowNonEstablishedWebsockets?: boolean, urlPath?: string): WebsocketConnection;
825
+ /**
826
+ * Checks if the message is `serverShutdown`.
827
+ * This is used to identify server shutdown events in incoming WebSocket messages.
828
+ *
829
+ * @param message - The message to check for a server shutdown event.
830
+ * @returns `true` if the message indicates a server shutdown event, `false` otherwise.
831
+ */
832
+ protected isServerShutdownEvent(message: any): boolean;
821
833
  /**
822
834
  * Checks if the provided WebSocket connection is ready for use.
823
835
  * A connection is considered ready if it is open, has no pending reconnection, and has not been closed.
@@ -861,7 +873,7 @@ declare class WebsocketCommon extends WebsocketEventEmitter {
861
873
  * @param url - The URL to use for the reconnection or renewal.
862
874
  * @param isRenewal - A flag indicating whether this is a renewal (true) or a reconnection (false).
863
875
  */
864
- private enqueueReconnection;
876
+ protected enqueueReconnection(connection: WebsocketConnection, url: string, isRenewal: boolean): void;
865
877
  /**
866
878
  * Gracefully closes a WebSocket connection after pending requests complete.
867
879
  * This method waits for any pending requests to complete before closing the connection.
@@ -1148,5 +1160,5 @@ interface WebsocketStream<T> {
1148
1160
  */
1149
1161
  declare function createStreamHandler<T>(websocketBase: WebsocketAPIBase | WebsocketStreamsBase, streamOrId: string, id?: number | string, urlPath?: string): WebsocketStream<T>;
1150
1162
  //#endregion
1151
- export { ALGO_REST_API_PROD_URL, ALPHA_REST_API_PROD_URL, AxiosRequestArgs, BadRequestError, C2C_REST_API_PROD_URL, CONVERT_REST_API_PROD_URL, COPY_TRADING_REST_API_PROD_URL, CRYPTO_LOAN_REST_API_PROD_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_REST_API_TESTNET_URL, DERIVATIVES_TRADING_OPTIONS_WS_STREAMS_PROD_URL, DERIVATIVES_TRADING_OPTIONS_WS_STREAMS_TESTNET_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_REST_API_PROD_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_WS_STREAMS_PROD_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_PROD_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_TESTNET_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_WS_STREAMS_PROD_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_WS_STREAMS_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, FIAT_REST_API_PROD_URL, ForbiddenError, GIFT_CARD_REST_API_PROD_URL, LogLevel, Logger, MARGIN_TRADING_REST_API_PROD_URL, MARGIN_TRADING_RISK_WS_STREAMS_PROD_URL, MARGIN_TRADING_WS_STREAMS_PROD_URL, MINING_REST_API_PROD_URL, NFT_REST_API_PROD_URL, NetworkError, NotFoundError, ObjectType, PAY_REST_API_PROD_URL, REBATE_REST_API_PROD_URL, RateLimitBanError, RequestArgs, RequiredError, RestApiRateLimit, RestApiResponse, SIMPLE_EARN_REST_API_PROD_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, SUB_ACCOUNT_REST_API_PROD_URL, SendMessageOptions, ServerError, TimeUnit, TimerRecord, TooManyRequestsError, UnauthorizedError, VIP_LOAN_REST_API_PROD_URL, WALLET_REST_API_PROD_URL, WebsocketAPIBase, WebsocketApiRateLimit, WebsocketApiResponse, WebsocketCommon, WebsocketConnection, WebsocketEventEmitter, WebsocketSendMsgConfig, WebsocketSendMsgOptions, WebsocketStream, WebsocketStreamsBase, assertParamExists, buildQueryString, buildUserAgent, buildWebsocketAPIMessage, clearSignerCache, createStreamHandler, delay, getSignature, getTimestamp, httpRequestFunction, normalizeScientificNumbers, normalizeStreamId, parseCustomHeaders, parseRateLimitHeaders, randomInteger, randomString, removeEmptyValue, replaceWebsocketStreamsPlaceholders, sanitizeHeaderValue, sendRequest, setSearchParams, shouldRetryRequest, sortObject, toPathString, validateTimeUnit };
1163
+ export { ALGO_REST_API_PROD_URL, ALPHA_REST_API_PROD_URL, AxiosRequestArgs, BadRequestError, C2C_REST_API_PROD_URL, CONVERT_REST_API_PROD_URL, COPY_TRADING_REST_API_PROD_URL, CRYPTO_LOAN_REST_API_PROD_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_REST_API_TESTNET_URL, DERIVATIVES_TRADING_OPTIONS_WS_STREAMS_PROD_URL, DERIVATIVES_TRADING_OPTIONS_WS_STREAMS_TESTNET_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_REST_API_PROD_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_WS_STREAMS_PROD_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_PROD_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_TESTNET_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_WS_STREAMS_PROD_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_WS_STREAMS_TESTNET_URL, DERIVATIVES_TRADING_USDS_FUTURES_REST_API_DEMO_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, FIAT_REST_API_PROD_URL, ForbiddenError, GIFT_CARD_REST_API_PROD_URL, LogLevel, Logger, MARGIN_TRADING_REST_API_PROD_URL, MARGIN_TRADING_RISK_WS_STREAMS_PROD_URL, MARGIN_TRADING_WS_STREAMS_PROD_URL, MINING_REST_API_PROD_URL, NFT_REST_API_PROD_URL, NetworkError, NotFoundError, ObjectType, PAY_REST_API_PROD_URL, REBATE_REST_API_PROD_URL, RateLimitBanError, RequestArgs, RequiredError, RestApiRateLimit, RestApiResponse, SIMPLE_EARN_REST_API_PROD_URL, SPOT_REST_API_DEMO_URL, SPOT_REST_API_MARKET_URL, SPOT_REST_API_PROD_URL, SPOT_REST_API_TESTNET_URL, SPOT_WS_API_DEMO_URL, SPOT_WS_API_PROD_URL, SPOT_WS_API_TESTNET_URL, SPOT_WS_STREAMS_DEMO_URL, SPOT_WS_STREAMS_MARKET_URL, SPOT_WS_STREAMS_PROD_URL, SPOT_WS_STREAMS_TESTNET_URL, STAKING_REST_API_PROD_URL, SUB_ACCOUNT_REST_API_PROD_URL, SendMessageOptions, ServerError, TimeUnit, TimerRecord, TooManyRequestsError, UnauthorizedError, VIP_LOAN_REST_API_PROD_URL, WALLET_REST_API_PROD_URL, WebsocketAPIBase, WebsocketApiRateLimit, WebsocketApiResponse, WebsocketCommon, WebsocketConnection, WebsocketEventEmitter, WebsocketSendMsgConfig, WebsocketSendMsgOptions, WebsocketStream, WebsocketStreamsBase, assertParamExists, buildQueryString, buildUserAgent, buildWebsocketAPIMessage, clearSignerCache, createStreamHandler, delay, getSignature, getTimestamp, httpRequestFunction, normalizeScientificNumbers, normalizeStreamId, parseCustomHeaders, parseRateLimitHeaders, randomInteger, randomString, removeEmptyValue, replaceWebsocketStreamsPlaceholders, sanitizeHeaderValue, sendRequest, setSearchParams, shouldRetryRequest, sortObject, toPathString, validateTimeUnit };
1152
1164
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -715,10 +715,11 @@ const DERIVATIVES_TRADING_COIN_FUTURES_WS_STREAMS_PROD_URL = "wss://dstream.bina
715
715
  const DERIVATIVES_TRADING_COIN_FUTURES_WS_STREAMS_TESTNET_URL = "wss://dstream.binancefuture.com";
716
716
  const DERIVATIVES_TRADING_USDS_FUTURES_REST_API_PROD_URL = "https://fapi.binance.com";
717
717
  const DERIVATIVES_TRADING_USDS_FUTURES_REST_API_TESTNET_URL = "https://testnet.binancefuture.com";
718
+ const DERIVATIVES_TRADING_USDS_FUTURES_REST_API_DEMO_URL = "https://demo-fapi.binance.com";
718
719
  const DERIVATIVES_TRADING_USDS_FUTURES_WS_API_PROD_URL = "wss://ws-fapi.binance.com/ws-fapi/v1";
719
720
  const DERIVATIVES_TRADING_USDS_FUTURES_WS_API_TESTNET_URL = "wss://testnet.binancefuture.com/ws-fapi/v1";
720
721
  const DERIVATIVES_TRADING_USDS_FUTURES_WS_STREAMS_PROD_URL = "wss://fstream.binance.com";
721
- const DERIVATIVES_TRADING_USDS_FUTURES_WS_STREAMS_TESTNET_URL = "wss://stream.binancefuture.com";
722
+ const DERIVATIVES_TRADING_USDS_FUTURES_WS_STREAMS_TESTNET_URL = "wss://fstream.binancefuture.com";
722
723
  const DERIVATIVES_TRADING_OPTIONS_REST_API_PROD_URL = "https://eapi.binance.com";
723
724
  const DERIVATIVES_TRADING_OPTIONS_REST_API_TESTNET_URL = "https://testnet.binancefuture.com";
724
725
  const DERIVATIVES_TRADING_OPTIONS_WS_STREAMS_PROD_URL = "wss://fstream.binance.com";
@@ -742,10 +743,13 @@ const REBATE_REST_API_PROD_URL = "https://api.binance.com";
742
743
  const SIMPLE_EARN_REST_API_PROD_URL = "https://api.binance.com";
743
744
  const SPOT_REST_API_PROD_URL = "https://api.binance.com";
744
745
  const SPOT_REST_API_TESTNET_URL = "https://testnet.binance.vision";
746
+ const SPOT_REST_API_DEMO_URL = "https://demo-api.binance.com";
745
747
  const SPOT_WS_API_PROD_URL = "wss://ws-api.binance.com:443/ws-api/v3";
746
748
  const SPOT_WS_API_TESTNET_URL = "wss://ws-api.testnet.binance.vision/ws-api/v3";
749
+ const SPOT_WS_API_DEMO_URL = "wss://demo-ws-api.binance.com/ws-api/v3";
747
750
  const SPOT_WS_STREAMS_PROD_URL = "wss://stream.binance.com:9443";
748
751
  const SPOT_WS_STREAMS_TESTNET_URL = "wss://stream.testnet.binance.vision";
752
+ const SPOT_WS_STREAMS_DEMO_URL = "wss://demo-stream.binance.com:9443";
749
753
  const SPOT_REST_API_MARKET_URL = "https://data-api.binance.vision";
750
754
  const SPOT_WS_STREAMS_MARKET_URL = "wss://data-stream.binance.vision";
751
755
  const STAKING_REST_API_PROD_URL = "https://api.binance.com";
@@ -1018,6 +1022,17 @@ var WebsocketCommon = class WebsocketCommon extends WebsocketEventEmitter {
1018
1022
  return selectedConnection;
1019
1023
  }
1020
1024
  /**
1025
+ * Checks if the message is `serverShutdown`.
1026
+ * This is used to identify server shutdown events in incoming WebSocket messages.
1027
+ *
1028
+ * @param message - The message to check for a server shutdown event.
1029
+ * @returns `true` if the message indicates a server shutdown event, `false` otherwise.
1030
+ */
1031
+ isServerShutdownEvent(message) {
1032
+ if (!message || typeof message !== "object") return false;
1033
+ return "event" in message && "e" in message["event"] && message?.event?.e === "serverShutdown";
1034
+ }
1035
+ /**
1021
1036
  * Checks if the provided WebSocket connection is ready for use.
1022
1037
  * A connection is considered ready if it is open, has no pending reconnection, and has not been closed.
1023
1038
  * @param connection - The WebSocket connection to check.
@@ -1269,11 +1284,11 @@ var WebsocketCommon = class WebsocketCommon extends WebsocketEventEmitter {
1269
1284
  ws$1.on("message", (data) => {
1270
1285
  this.onMessage(data.toString(), targetConnection);
1271
1286
  });
1272
- ws$1.on("ping", () => {
1287
+ ws$1.on("ping", (data) => {
1273
1288
  this.logger.debug("Received PING from server");
1274
- this.emit("ping");
1275
- ws$1.pong();
1276
- this.logger.debug("Responded PONG to server's PING message");
1289
+ this.emit("ping", data);
1290
+ ws$1.pong(data);
1291
+ this.logger.debug(`Responded PONG to server's PING message with: ${data}`);
1277
1292
  });
1278
1293
  ws$1.on("pong", () => {
1279
1294
  this.logger.debug("Received PONG from server");
@@ -1343,7 +1358,7 @@ var WebsocketCommon = class WebsocketCommon extends WebsocketEventEmitter {
1343
1358
  this.logger.debug("Sending PING to all connected Websocket servers.");
1344
1359
  connectedConnections.forEach((connection) => {
1345
1360
  if (connection.ws) {
1346
- connection.ws.ping();
1361
+ connection.ws.ping(Buffer.alloc(0));
1347
1362
  this.logger.debug(`PING sent to connection with id ${connection.id}`);
1348
1363
  } else this.logger.error("WebSocket Client not set for a connection.");
1349
1364
  });
@@ -1424,11 +1439,13 @@ var WebsocketAPIBase = class extends WebsocketCommon {
1424
1439
  onMessage(data, connection) {
1425
1440
  try {
1426
1441
  const message = (0, json_with_bigint.JSONParse)(data);
1427
- const { id, status } = message;
1428
- if (id && connection.pendingRequests.has(id)) {
1429
- const request = connection.pendingRequests.get(id);
1430
- connection.pendingRequests.delete(id);
1431
- if (status && status >= 400) request?.reject(message.error);
1442
+ if (this.isServerShutdownEvent(message)) {
1443
+ this.logger.warn(`Received serverShutdown event on connection ${connection.id}.`);
1444
+ if (!connection.renewalPending && !connection.closeInitiated) this.enqueueReconnection(connection, this.prepareURL(this.configuration.wsURL), true);
1445
+ } else if (message.id && connection.pendingRequests.has(message.id)) {
1446
+ const request = connection.pendingRequests.get(message.id);
1447
+ connection.pendingRequests.delete(message.id);
1448
+ if (message.status && message.status >= 400) request?.reject(message.error);
1432
1449
  else {
1433
1450
  const response = {
1434
1451
  data: message.result ?? message.response,
@@ -1804,6 +1821,7 @@ exports.DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_PROD_URL = DERIVATIVES_TRA
1804
1821
  exports.DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_TESTNET_URL = DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_TESTNET_URL;
1805
1822
  exports.DERIVATIVES_TRADING_PORTFOLIO_MARGIN_WS_STREAMS_PROD_URL = DERIVATIVES_TRADING_PORTFOLIO_MARGIN_WS_STREAMS_PROD_URL;
1806
1823
  exports.DERIVATIVES_TRADING_PORTFOLIO_MARGIN_WS_STREAMS_TESTNET_URL = DERIVATIVES_TRADING_PORTFOLIO_MARGIN_WS_STREAMS_TESTNET_URL;
1824
+ exports.DERIVATIVES_TRADING_USDS_FUTURES_REST_API_DEMO_URL = DERIVATIVES_TRADING_USDS_FUTURES_REST_API_DEMO_URL;
1807
1825
  exports.DERIVATIVES_TRADING_USDS_FUTURES_REST_API_PROD_URL = DERIVATIVES_TRADING_USDS_FUTURES_REST_API_PROD_URL;
1808
1826
  exports.DERIVATIVES_TRADING_USDS_FUTURES_REST_API_TESTNET_URL = DERIVATIVES_TRADING_USDS_FUTURES_REST_API_TESTNET_URL;
1809
1827
  exports.DERIVATIVES_TRADING_USDS_FUTURES_WS_API_PROD_URL = DERIVATIVES_TRADING_USDS_FUTURES_WS_API_PROD_URL;
@@ -1828,11 +1846,14 @@ exports.REBATE_REST_API_PROD_URL = REBATE_REST_API_PROD_URL;
1828
1846
  exports.RateLimitBanError = RateLimitBanError;
1829
1847
  exports.RequiredError = RequiredError;
1830
1848
  exports.SIMPLE_EARN_REST_API_PROD_URL = SIMPLE_EARN_REST_API_PROD_URL;
1849
+ exports.SPOT_REST_API_DEMO_URL = SPOT_REST_API_DEMO_URL;
1831
1850
  exports.SPOT_REST_API_MARKET_URL = SPOT_REST_API_MARKET_URL;
1832
1851
  exports.SPOT_REST_API_PROD_URL = SPOT_REST_API_PROD_URL;
1833
1852
  exports.SPOT_REST_API_TESTNET_URL = SPOT_REST_API_TESTNET_URL;
1853
+ exports.SPOT_WS_API_DEMO_URL = SPOT_WS_API_DEMO_URL;
1834
1854
  exports.SPOT_WS_API_PROD_URL = SPOT_WS_API_PROD_URL;
1835
1855
  exports.SPOT_WS_API_TESTNET_URL = SPOT_WS_API_TESTNET_URL;
1856
+ exports.SPOT_WS_STREAMS_DEMO_URL = SPOT_WS_STREAMS_DEMO_URL;
1836
1857
  exports.SPOT_WS_STREAMS_MARKET_URL = SPOT_WS_STREAMS_MARKET_URL;
1837
1858
  exports.SPOT_WS_STREAMS_PROD_URL = SPOT_WS_STREAMS_PROD_URL;
1838
1859
  exports.SPOT_WS_STREAMS_TESTNET_URL = SPOT_WS_STREAMS_TESTNET_URL;