← back

Creating API out of whatsapp

dogs-communicating

What can you do with WhatsApp API? πŸ˜•

Usage Scenarios for the API

Let’s Begin 🌟

Note: Install Node.js v16+ if you haven’t already.

We are going to use whatsapp-api-nodejs that converts users WhatsApp account into an API.

In addition, whatsapp-api-nodejs can 🀯:

To get started clone the repository from Github:

git clone https://github.com/salman0ansari/whatsapp-api-nodejs.git

Change directory into the project and run

npm install

It will take some time to install the dependencies.

If you going to use webhook make sure to create a .env file in the project root. Inside the file add:

WEBHOOK_URL=https://your webhook url

Finally, run npm run start in the project root to start the server. Our applications will be accessed at

http://localhost:3333

Init Instance 🌌

To initialise a server make a GET request Note: Don’t forgot to save KEY value.

ENDPOINT: /init

init

Scanning QR Code πŸ“±

To scan QR code make a GET request

ENDPOINT: /qrcode?key=KEY
QUERY -> KEY = Instance Key

Note: make sure to scan QR ASAP after you init a Instance.

qrcode

Sending a Message πŸ“¨

To send a Text message make a POST request

ENDPOINT: /sendText?key=KEY
QUERY -> KEY = Instance Key
REQUEST BODY:
{
  "msg_data": {
    "id": "919999999999",
    "message": "Hello World"
  }
}

sendText

API-Docs πŸ“‘

To check more enpoint make a GET request

ENDPOINT: /api-docs

api-docs