robinhodemorais / whatsapp-api-nodejs

RESTful WhatsApp API with Multiple Device Support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

whatsapp-api-nodejs Multi Device


An implementation of Baileys as a simple RESTful API service with multi device support just download, install, and start using, simple as that.

Libraries Used

Installation

  1. Download or clone this repo.
  2. Enter to the project directory.
  3. Execute yarn install or npm install to install the dependencies.

Configuration

Edit this constant in src/config/config.js

// Port number
const PORT = '3333'
// URL of Mongo DB
const MONGODB_URL = 'mongodb://127.0.0.1:27017/WhatsAppInstance'
// Webhook URL
const WEBHOOK_URL = 'https://webhook.site/d0122a66-18a3-432d-b63f-4772b190dd72'

Usage

  1. You can start the server by executing npm run start or yarn start

Generate Key

To generate an Instance Key
Using the route:

curl --location --request GET 'localhost:3333/instance/init' \
--data-raw ''

Response:

{
    "error": false,
    "message": "Initializing successfull",
    "key": "d7e2abff-3ac8-44a9-a738-1b28e0fca8a5"
}

Using Key

Save the value of the key from response. Then use this value to call all the routes.

Examples

#Get qrcode
# /instance/qr?key=KEY

curl --location --request GET 'localhost:3333/instance/qr?key=123'
#Send Message
# /message/text?key=KEY&id=ID&message=MESSAGE

curl --location --request POST 'localhost:3333/message/text?key=123' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'id=919999999999' \
--data-urlencode 'message=Hello World'

See all routes here src/api/routes

Postman Docs

Legal

  • This code is in no way affiliated, authorized, maintained, sponsored or endorsed by WA(WhatsApp) or any of its affiliates or subsidiaries.
  • The official WhatsApp website can be found at https://whatsapp.com. "WhatsApp" as well as related names, marks, emblems and images are registered trademarks of their respective owners.
  • This is an independent and unofficial software Use at your own risk.
  • Do not spam people with this.

About

RESTful WhatsApp API with Multiple Device Support


Languages

Language:JavaScript 97.8%Language:EJS 2.1%Language:Procfile 0.1%