This project is a WhatsApp messaging API built with Node.js using the Baileys library. Users can scan a QR code in the terminal to log in and send messages programmatically via HTTP.
Note: This project is not the official WhatsApp Business API. It simulates the WhatsApp Web protocol and sends messages using your own device.
- ✅ QR code-based login using your WhatsApp account
- ✅ Auto-reconnect on disconnection
- ✅ Send messages via HTTP REST API
- ✅ User credentials stored in
auth_infofolder - ✅ Easy to set up and configure
- Node.js v14 or higher
- npm (Node package manager)
- An active WhatsApp account
- Terminal access (to scan QR code)
git clone https://github.com/foxyscat/nodemsg
cd nodemsgnpm installnode main.jsWhen the server starts, a QR code will appear in the terminal. In your WhatsApp app:
- Go to Settings → Linked Devices → Link a Device
- Scan the QR code
- Once logged in, the terminal will show "WhatsApp client is ready!"
POST /send-message
Content-Type: application/json
{
"number": "905XXXXXXXXX",
"message": "Hello, this is a test message from the API."
}Note: The number must include the country code and contain digits only. Example:
905321234567
- 200 OK – Message sent successfully
{
"success": "Message sent."
}- 400 Bad Request – Missing fields
{
"error": "Number and message are required."
}- 500 Internal Server Error – Sending or connection issue
{
"error": "An error occurred while sending the message."
}.
├── auth_info/ # Stores Baileys credentials (created after first login)
├── main.js # Main application file
├── package.json # Dependency list and scripts
└── README.md # Documentation
└── LICENSE # LICENSE
- QR code is only required during the initial login.
- Credentials are saved in the
auth_info/folder. If this folder is deleted, you'll need to scan the QR code again. - If the connection drops (e.g., due to network issues), the client attempts to reconnect automatically.
- If you log out from WhatsApp Web or another client, this application will also disconnect.
- This application is intended for single-user use. Multi-device support is not included.
- WhatsApp may restrict the use of unofficial clients. Commercial use is not recommended.
- Spamming or overusing the API may lead to your WhatsApp account being temporarily banned.
- Keep the
auth_info/folder secure. If compromised, others can access your WhatsApp session. - If you deploy this API publicly, it is highly recommended to implement authentication (e.g., an API key).
You can extend this project with:
- Media support (images, documents)
- Bot-like functionality to respond to incoming messages
- A web-based dashboard for managing conversations
Published under the MIT License. See the LICENSE file for more details.
Pull requests are welcome. Feel free to open issues or suggest features!
Feel free to reach out with any questions or feedback:
- 📧 Email: bahadirizgi@outlook.com
- 🧑💻 GitHub: @foxyscat
- 🔗 LinkedIn: Bahadır İzgi