Skip to content

foxyscat/nodemsg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📱 WhatsApp Messaging API (with Baileys)

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.


🔧 Features

  • ✅ QR code-based login using your WhatsApp account
  • ✅ Auto-reconnect on disconnection
  • ✅ Send messages via HTTP REST API
  • ✅ User credentials stored in auth_info folder
  • ✅ Easy to set up and configure

📦 Requirements

  • Node.js v14 or higher
  • npm (Node package manager)
  • An active WhatsApp account
  • Terminal access (to scan QR code)

🚀 Setup

1. Clone the repository

git clone https://github.com/foxyscat/nodemsg
cd nodemsg

2. Install dependencies

npm install

3. Start the server

node main.js

4. Scan the QR Code

When 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!"

📨 Sending Messages

Endpoint

POST /send-message

Content Type

Content-Type: application/json

Request Body

{
  "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

Responses

  • 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."
}

📁 Project Structure

.
├── 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

🔄 Session Management

  • 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.

⚠️ Warnings and Limitations

  • 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.

🔒 Security

  • 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).

🛠 Development Tips

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

📄 License

Published under the MIT License. See the LICENSE file for more details.


🤝 Contributing

Pull requests are welcome. Feel free to open issues or suggest features!


✉️ Contact

Feel free to reach out with any questions or feedback:

About

Node.js Whatsapp MSG API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors