open-wa v5 is alpha. Use v4.76.0 for mature production systems unless you are validating v5.
The Client APIAPI ExplorerLicensing

@open-wa/socket-client

Easily connect to remote instances of the EASY API

Package Socket Client Wally

Generated from packages/socket-client/README.md by apps/docs/scripts/gen-workspace-readme-docs.js. Do not edit this page directly.

Remote Socket Client

How to:

  1. Run the EASY API
> npx @open-wa/wa-automate -p 8002 -k api_key

The compatibility client now talks to the EASY API over the active v5 transport: HTTP RPC for command execution and Server-Sent Events (SSE) for runtime events.

  1. Typescript code:
import {
    Client,
    SocketClient,
} from "@open-wa/socket-client";

const NUMBER = 'TEST_PHONE_NUMBER@c.us'

const start = async () => {
    const client = await SocketClient.connect(
        "http://localhost:8002",
        "api_key"
    ) as SocketClient & Client;

    // Commands are sent over HTTP and event subscriptions are delivered over SSE.

    client.onAnyMessage((message) => {
        console.log("onAnyMessage", message.id, message.body);
    });

    const socketId = client.socket.id;
    console.log("🚀 ~ file: client.ts ~ line 144 ~ start ~ socketId", socketId);

    console.log(
        "Connected!",
        await client.sendText(NUMBER, "this is a text")
    );
    client
        .sendAudio(
            NUMBER,
            "https://file-examples-com.github.io/uploads/2017/11/file_example_MP3_700KB.mp3"
        )
        .then((audoMessageId) => console.log(audoMessageId));

    console.log(
        await client.sendFile(
            NUMBER,
            "https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_480_1_5MG.mp4",
            "test.mp4",
            "hellow"
        )
    );
};

start();
Wally the Walrus typing

Was this helpful?

Wally and his cute companion coffee mug are coding day and night to keep this up-to-date!

On this page