Skip to content

monobilisim/whatsapp-ws

Repository files navigation

Contributors Forks Stargazers Issues GPL License

Readme in English Readme in Turkish

whatsapp-ws

whatsapp-ws utilizes the whatsmeow library to create WebSocket interfaces for integrating WhatsApp messaging capabilities and performing actions programmatically

Table of Contents


Introduction

whatsapp-ws is a project built upon the whatsmeow library, providing a WebSocket interface and endpoints to send daily messages to a database and serve as a WhatsApp bridge. It allows users to connect via WebSocket to interact with WhatsApp through programmatically sent commands.

The main objective of whatsapp-ws is to streamline the integration of WhatsApp messaging capabilities into various applications and systems. By utilizing the WebSocket interface, users can establish real-time connections and send commands to interact with WhatsApp in an automated fashion.


API Usage

/ws Endpoint

The /ws endpoint provides a WebSocket interface for real-time interaction with the WhatsApp messaging capabilities offered by whatsapp-ws. Users can connect to this endpoint and send commands in the form of JSON objects.

{
  "cmd": "string",
  "args": ["string"],
  "user_id": int
}
  • cmd: The command to be executed.
  • args: An array of string arguments required for the command.
  • user_id: An integer representing the user ID for context.

/status Endpoint

The /status endpoint allows users to check if they are logged in. It returns an HTTP 200 response if the user is logged in and authenticated.

/qr Endpoint

The /qr endpoint serves the login QR code for WhatsApp. Users can access this endpoint to view the QR code required for logging in to WhatsApp.

/upload Endpoint

The /upload endpoint enables users to upload files to WhatsApp. It can be used with tools like curl. Here's an example command to upload a file:

curl -X POST -F file=@filepath -F jid=PHONE_NUMBER@s.whatsapp.net -F user_id=1 http://localhost:6023/upload

Build

To build whatsapp-ws, use the following command:

go build -ldflags '-extldflags "-static"'

Endpoints

  • /ws - websocket endpoint
  • /status - status endpoint
  • /qr - qr endpoint
  • /upload - upload endpoint

License

whatsapp-ws is GPL-3.0 licensed. See LICENSE file for details.