THIS IS A WORKING PROJECT.
Whatsapp REST API for wa-automate-nodejs
This is a basic example how to create a REST API for Whatsapp. Not for production use (yet).
- Set ambient variables inside .env file (see .env.example for more information). MYGROUP and MYNUMBER is only for development purpose.
yarn install
ornpm install
yarn start-server
Command | Endpoint |
---|---|
Send (POST): | http://localhost:3000/SESSION_TOKEN/send |
Info (GET): | http://localhost:3000/SESSION_TOKEN/status |
Stop (GET): | http://localhost:3000/SESSION_TOKEN/stop |
Start (GET): | http://localhost:3000/SESSION_TOKEN/start |
// Text message (for groups use @g.us)
{
"cmd": "chat",
"to": "number@c.us",
"msg": "some message"
}
// Audios (audio/ogg, audio/mpeg)
{
"cmd": "media",
"to": "number@c.us",
"url": "https://domain.tld/audio.mp3"
}
// Images (image/jpeg, image/png, image/gif)
{
"cmd": "media",
"to": "number@c.us",
"url": "https://domain.tld/image.jpg",
"msg": "some caption (optional)"
}
// Link or Youtube videos
{
"cmd": "link",
"to": "number@c.us",
"url": "https://github.com",
"msg": "some message (optional)"
}
Set webhook url on .env file. The api will send a post with every message or ack events