Realtime API
    • Dark
      Light
    • PDF

    Realtime API

    • Dark
      Light
    • PDF

    Article summary

    The Rocket.Chat real-time API allows developers to integrate Rocket.Chat’s real-time messaging and collaboration features in their applications. It utilizes WebSockets, a technology that enables real-time communication between a client (your application) and the Rocket.Chat server. By leveraging this API, you can create dynamic, interactive experiences within your application, enabling users to send and receive messages, participate in live chats, and access various collaboration features.

    To get started with the Rocket.Chat real-time API, point your client to the WebSocket of the server you want to connect to:

    wss://[ABC.DOMAIN.COM]/websocket

    For localhost, use ws://localhost:3000/websocket.

    The API encompasses two integral components: Method Calls and Subscriptions, seamlessly supported within the WebSocket connection.

    To ensure streamlined functionality within a single connection, we leverage RPC (Remote Procedure Call) using the following format:

    {
        "msg": "type-of-communication",
        "id": "unique-id",
        ... // per call defined data
    }

    The type-of-communication is defined based on its purpose:

    Connect to the WebSocket

    Before requesting any method calls and subscriptions, you must send a connect message. This connect message is an initial step to establish the connection and prepare for subsequent requests.

    {
        "msg": "connect",
        "version": "1",
        "support": ["1"]
    }

    The server periodically sends a ping message, and it's essential to respond with a pong message to maintain the connection. Failure to respond appropriately will result in the server closing the connection.

    {
        "msg": "pong"
    }

    Resources


    Was this article helpful?

    What's Next
    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.
    ESC

    Eddy AI, facilitating knowledge discovery through conversational intelligence