Binance Connector JS
    Preparing search index...
    Index
    • 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.

    • 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

    • Real-time push of the user's order updates. Option orders are pushed on orderReportV2, not on orderReport.

      orderReportV2 carries both US stock and US stock option orders; tell them apart with the ac field. To process option orders only, subscribe to orderReportV2 and handle events where ac = us_option.

      A push is sent once when an open order changes (x = ORDER_UPDATE) and once when it reaches a terminal state (x = ORDER_TERMINAL). Pushes are best-effort: a failed push is not retried, events while the listenKey is invalid are not replayed, and an order never pushed in an open state (e.g. rejected immediately) may not get a terminal push. After reconnecting, call Current Open Option Orders for a full snapshot first. Fill-level details are not pushed; use Option Order Detail or Option Trade History.

      For expiration-day auto-liquidation orders by the broker (o = market), p, b, q, tc, u, ct, sp and ed may be null; get contract details from Option Exchange Info by os.

      Prerequisite: obtain a listenKey via the Listen Key endpoint first.

      Parameters

      Returns WebsocketStream<OrderReportV2StreamResponse>

    • 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.

    • 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