Binance Connector JS
    Preparing search index...
    Index

    Constructors

    Methods

    • Disconnects from the WebSocket server. If there is no active connection, a warning is logged. Otherwise, all connections in the connection pool are closed gracefully, and a message is logged indicating that the connection has been disconnected.

      Returns Promise<void>

      A Promise that resolves when all connections have been closed.

      Error if the WebSocket client is not set.

    • The Kline/Candlestick Stream push updates to the current klines/candlestick every second in UTC+8 timezone

      Kline/Candlestick chart intervals:*

      Supported intervals: See Kline/Candlestick chart intervals

      UTC+8 timezone offset:*

      • Kline intervals open and close in the UTC+8 timezone. For example the 1d klines will open at the beginning of the UTC+8 day, and close at the end of the UTC+8 day.
      • Note that E (event time), t (start time) and T (close time) in the payload are Unix timestamps, which are always interpreted in UTC.

      Update Speed: 1000ms for 1s, 2000ms for the other intervals

      Parameters

      Returns WebsocketStream<KlineOffsetResponse>

    • Removes an event listener for the specified WebSocket event.

      Parameters

      • event: "open" | "message" | "error" | "close" | "ping" | "pong"

        The WebSocket event to stop listening for, such as 'open', 'message', 'error', 'close', 'ping', or 'pong'.

      • listener: (...args: any[]) => void

        The callback function that was previously added as the event listener.

      Returns void

    • Adds an event listener for the specified WebSocket event.

      Parameters

      • event: "open" | "message" | "error" | "close" | "ping" | "pong"

        The WebSocket event to listen for, such as 'open', 'message', 'error', 'close', 'ping', or 'pong'.

      • listener: (...args: any[]) => void

        The callback function to be executed when the event is triggered. The function can accept any number of arguments.

      Returns void

    • Sends a ping message to all connected Websocket servers in the pool. If no connections are ready, a warning is logged. For each active connection, the ping message is sent, and debug logs provide details.

      Returns void

      Error if a Websocket client is not set for a connection.

    • Subscribes to one or multiple WebSocket streams Handles both single and pool modes

      Parameters

      • stream: string | string[]

        Single stream name or array of stream names to subscribe to

      • Optionalid: string

        Optional subscription ID

      Returns void

      void

    • Unsubscribes from one or multiple WebSocket streams Handles both single and pool modes

      Parameters

      • stream: string | string[]

        Single stream name or array of stream names to unsubscribe from

      • Optionalid: string

        Optional unsubscription ID

      Returns void

      void