- Notifications
You must be signed in to change notification settings - Fork564
This project is a REST API wrapper for the whatsapp-web.js library, providing an easy-to-use interface to interact with the WhatsApp Web platform.
License
chrishubert/whatsapp-api
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Warning
This project is deprecated and no longer maintained.Please use the actively maintained fork:avoylenko/wwebjs-api
REST API wrapper for thewhatsapp-web.js library, providing an easy-to-use interface to interact with the WhatsApp Web platform.It is designed to be used as a docker container, scalable, secure, and easy to integrate with other non-NodeJs projects.
This project is a work in progress: star it, create issues, features or pull requests ❣️
NOTE: I can't guarantee you will not be blocked by using this method, although it has worked for me. WhatsApp does not allow bots or unofficial clients on their platform, so this shouldn't be considered totally safe.
- Clone the repository:
git clone https://github.com/chrishubert/whatsapp-api.gitcd whatsapp-api- Run the Docker Compose:
docker-compose pull&& docker-compose upScan the QR on your console using WhatsApp mobile app -> Linked Device -> Link a Device (it may take time to setup the session)
EXTRA: Look at all the callbacks data in
./session/message_log.txt
- API and Callbacks
| Actions | Status | Sessions | Status | Callbacks | Status |
|---|---|---|---|---|---|
| Send Image Message | ✅ | Initiate session | ✅ | Callback QR code | ✅ |
| Send Video Message | ✅ | Terminate session | ✅ | Callback new message | ✅ |
| Send Audio Message | ✅ | Terminate inactive sessions | ✅ | Callback status change | ✅ |
| Send Document Message | ✅ | Terminate all sessions | ✅ | Callback message media attachment | ✅ |
| Send File URL | ✅ | Healthcheck | ✅ | ||
| Send Button Message | ✅ | Local test callback | |||
| Send Contact Message | ✅ | ||||
| Send List Message | ✅ | ||||
| Set Status | ✅ | ||||
| Send Button With Media | ✅ | ||||
| Is On Whatsapp? | ✅ | ||||
| Download Profile Pic | ✅ | ||||
| User Status | ✅ | ||||
| Block/Unblock User | ✅ | ||||
| Update Profile Picture | ✅ | ||||
| Create Group | ✅ | ||||
| Leave Group | ✅ | ||||
| All Groups | ✅ | ||||
| Invite User | ✅ | ||||
| Make Admin | ✅ | ||||
| Demote Admin | ✅ | ||||
| Group Invite Code | ✅ | ||||
| Update Group Participants | ✅ | ||||
| Update Group Setting | ✅ | ||||
| Update Group Subject | ✅ | ||||
| Update Group Description | ✅ |
Handle multiple client sessions (session data saved locally), identified by unique id
All endpoints may be secured by a global API key
On server start, all existing sessions are restored
Set messages automatically as read
Disable any of the callbacks
- Clone the repository:
git clone https://github.com/chrishubert/whatsapp-api.gitcd whatsapp-api- Install the dependencies:
npm install
- Copy the
.env.examplefile to.envand update the required environment variables:
cp .env.example .env
- Run the application:
npm run start
- Access the API at
http://localhost:3000
Run the test suite with the following command:
npm runtestAPI documentation can be found in theswagger.json file. See this file directly intoSwagger Editor or any other OpenAPI-compatible tool to view and interact with the API documentation.
This documentation is straightforward if you are familiar with whatsapp-web.js library (https://docs.wwebjs.dev/)If you are still confused - open an issue and I'll improve it.
Also, there is an option to run the documentation endpoint locally by setting theENABLE_SWAGGER_ENDPOINT environment variable. Restart the service and go to/api-docs endpoint to see it.
By default, all callback events are delivered to the webhook defined with theBASE_WEBHOOK_URL environment variable.This can be overridden by setting the*_WEBHOOK_URL environment variable, where* is your sessionId.For example, if you have the sessionId defined asDEMO, the environment variable must beDEMO_WEBHOOK_URL.
By setting theDISABLED_CALLBACKS environment variable you can specify what events you arenot willing to receive on your webhook.
In order to validate a new WhatsApp Web instance you need to scan the QR code using your mobile phone. Official documentation can be found at (https://faq.whatsapp.com/1079327266110265/?cms_platform=android) page. The service itself delivers the QR code content as a webhook event or you can use the REST endpoints (/session/qr/:sessionId or/session/qr/:sessionId/image to get the QR code as a png image).
- Load the docker image in docker-compose, or your Kubernetes environment
- Disable the
ENABLE_LOCAL_CALLBACK_EXAMPLEenvironment variable - Set the
API_KEYenvironment variable to protect the REST endpoints - Run periodically the
/api/terminateInactiveSessionsendpoint to prevent useless sessions to take up space and resources(only in case you are not in control of the sessions)
Please readCONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with WhatsApp or any of its subsidiaries or its affiliates. The official WhatsApp website can be found athttps://whatsapp.com. "WhatsApp" as well as related names, marks, emblems and images are registered trademarks of their respective owners.
This project is licensed under the MIT License - see theLICENSE.md file for details.
About
This project is a REST API wrapper for the whatsapp-web.js library, providing an easy-to-use interface to interact with the WhatsApp Web platform.
Topics
Resources
License
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors10
Uh oh!
There was an error while loading.Please reload this page.
