This project provides a REST API for interacting with WhatsApp using the whatsapp-web.js library.
The API is used to share links to cyber security related news and incidents through WhatsApp channel at https://whatsapp.com/channel/0029VbBxBJfBA1f0xn4Rwd1g
- Authentication: QR Code generated in terminal and available via webhook.
- Messaging: Send text (with automatic link previews), media, and react to messages.
- Channels: Full support for WhatsApp Channels (Newsletters) - create, subscribe, search, and send messages.
- Groups: Create groups, add/remove participants.
- Chat Management: Archive, Pin, Mute, Delete messages.
- Webhooks: Notifies an external URL of events with
X-API-KEYverification. - Security: Protected by an API Key (
X-API-KEYheader). - Reliability: Built-in retry mechanism for browser-related transient errors.
Tested with chromium-browser in Linux for arm64.
- Install dependencies:
npm install
- Configure environment variables:
Copy
.env.exampleto.envand fill in your values.cp .env.example .env
- Start the server:
node index.js
All requests require the X-API-KEY header. See USER_GUIDE.md for full documentation.
POST /send-message:{ "number": "1234567890", "message": "Hello" }POST /send-media:{ "number": "1234567890", "url": "...", "caption": "...", "filename": "..." }POST /messages/:chatId/:messageId/react:{ "reaction": "👍" }
GET /channels: List subscribed channels.POST /channels/create:{ "title": "...", "description": "..." }POST /channels/:id/send-message:{ "message": "..." }POST /channels/:id/send-media:{ "url": "...", "caption": "..." }
POST /groups/create:{ "title": "My Group", "participants": ["..."] }POST /groups/add-participants:{ "groupId": "...", "participants": ["..."] }
POST /chats/:id/archivePOST /chats/:id/pinPOST /chats/:id/mute:{ "durationInSeconds": 3600 }
GET /chats: List all chats.GET /contacts: List all contacts.GET /info: Get client info and version.POST /check-number/:number: Check if a number is registered on WhatsApp.
If WEBHOOK_URL is configured, the server will send POST requests (including X-API-KEY header) for:
qr,ready,message,message_create,status_change,contact_update,disconnected.