Evolution API Evolution API began as a WhatsApp controller API based on CodeChat, which in turn implemented the Baileys library. While originally focused on WhatsApp, Evolution API has grown into a comprehensive platform supporting multiple messaging services and integrations. We continue to acknowledge CodeChat for laying the groundwork. Today, Evolution API is not limited to WhatsApp. It integrates with various platforms such as Typebot, Chatwoot, Dify, and OpenAI, offering a broad array of functionalities beyond messaging. Evolution API supports both the Baileys-based WhatsApp API and the official WhatsApp Business API, with upcoming support for Instagram and Messenger.
Go to file
2023-06-13 13:11:24 -03:00
.vscode init project evolution api 2023-06-09 07:48:59 -03:00
Docker feat: expose api key in fetch instances 2023-06-12 16:07:38 -03:00
instances init project evolution api 2023-06-09 07:48:59 -03:00
mongodb init project evolution api 2023-06-09 07:48:59 -03:00
public/images fix: readme 2023-06-12 13:35:47 -03:00
src fixed docker files and quoted message option 2023-06-13 13:11:24 -03:00
store init project evolution api 2023-06-09 07:48:59 -03:00
temp fix sending narrated audio on whatsapp android and ios 2023-06-13 11:41:17 -03:00
views init project evolution api 2023-06-09 07:48:59 -03:00
.dockerignore init project evolution api 2023-06-09 07:48:59 -03:00
.eslintignore init project evolution api 2023-06-09 07:48:59 -03:00
.eslintrc.js init project evolution api 2023-06-09 07:48:59 -03:00
.gitignore fix: adjust in docker-compose file and added all variables in dockerfile 2023-06-10 18:11:28 -03:00
.prettierrc.js init project evolution api 2023-06-09 07:48:59 -03:00
CHANGELOG.md fixed the problem of not disabling the global webhook by the variable and apikey only appears if it is enabled to be exposed 2023-06-13 11:52:30 -03:00
docker-compose.yaml fixed docker files and quoted message option 2023-06-13 13:11:24 -03:00
docker.sh fixed docker files and quoted message option 2023-06-13 13:11:24 -03:00
Dockerfile fixed docker files and quoted message option 2023-06-13 13:11:24 -03:00
LICENSE init project evolution api 2023-06-09 07:48:59 -03:00
package.json feat: Added conversion of audios for sending recorded audio 2023-06-11 10:29:49 -03:00
postman.json init project evolution api 2023-06-09 07:48:59 -03:00
README.md fix: readme 2023-06-12 13:45:51 -03:00
start.sh fix error after logout and try to get status or to connect again 2023-06-12 10:32:47 -03:00
tsconfig.json init project evolution api 2023-06-09 07:48:59 -03:00

Evolution Api

License Support

WhatsApp-Api-NodeJs

This project is based on the CodeChat. The original project is an implementation of Baileys, serving as a Restful API service that controls WhatsApp functions.
The code allows the creation of multiservice chats, service bots, or any other system that utilizes WhatsApp. The documentation provides instructions on how to set up and use the project, as well as additional information about its features and configuration options.

Infrastructure

Nvm installation

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
# or
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash

After finishing, restart the terminal to load the new information.

Docker installation [optional]

curl -fsSL https://get.docker.com -o get-docker.sh

sudo sh get-docker.sh

sudo usermod -aG docker ${USER}

Nodejs installation

nvm install 16.18.1

pm2 installation

npm i -g pm2
docker --version

node --version

MongoDb [optional]

After installing docker and docker-compose, up the container.

In the same directory where the file is located, run the following command:

bash docker.sh

Using the database is optional.

Application startup

Cloning the Repository

git clone https://github.com/EvolutionAPI/evolution-api.git

Go to the project directory and install all dependencies.

cd whatsapp-api

npm i

Finally, run the command below to start the application:

# Under development
npm run start

# In production
npm run start:prod

# pm2
pm2 start 'npm run start:prod' --name ApiEvolution

Authentication

You can define two authentication types for the routes in the env file. Authentications must be inserted in the request header.

  1. apikey

  2. jwt: A JWT is a standard for authentication and information exchange defined with a signature.

Authentications are generated at instance creation time.

Note: There is also the possibility to define a global api key, which can access and control all instances.

Connection

Create an instance

HTTP

NOTE: This key must be inserted in the request header to create an instance.

POST /instance/create HTTP/1.1
Host: localhost:8080
Content-Type: application/json
apikey: t8OOEeISKzpmc3jjcMqBWYSaJH2PIxns

{
  "instanceName": "evolution"
}
cURL
curl --location --request POST 'http://localhost:8080/instance/create' \
--header 'Content-Type: application/json' \
--header 'apikey: t8OOEeISKzpmc3jjcMqBWYSaJH2PIxns' \
--data-raw '{
  "instanceName": "evolution"
}'

Response

{
  "instance": {
    "instanceName": "evolution",
    "status": "created"
  },
  "hash": {
    "jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9. [...]"

    // or
    // "apikey": "88513847-1B0E-4188-8D76-4A2750C9B6C3"
  }
}

Connection with qrcode

HTTP
GET /instance/connect/evolution HTTP/1.1
Host: localhost:8080
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9. [...]
GET /instance/connect/evolution HTTP/1.1
Host: localhost:8080
apikey: 88513847-1B0E-4188-8D76-4A2750C9B6C3
cURL
curl --location --request GET 'http://localhost:8080/instance/connect/evolution' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9. [...]'
curl --location --request GET 'http://localhost:8080/instance/connect/evolution' \
--header 'apikey: 88513847-1B0E-4188-8D76-4A2750C9B6C3'

Response

{
  "code": "2@nXSUgRJSBY6T0XJmiFKZ0 [...] ,XsgJhJHYa+0MPpXANdPHHt6Ke/I7O2QyXT/Lsge0uSg=",
  "base64": "data:image/png;base64,iVBORw0KGgoAAAANSUhE [...] LkMtqAAAAABJRU5ErkJggg=="
}

App in Docker

After building the application, in the same directory as the files above, run the following command:

docker-compose up

Send Messages

Send Text
Send Template
Send Media: audio - video - image - document - gif

base64: true
Send Media File
Send Audio type WhatsApp
Send Location
Send Link Preview
Send Contact
Send Reaction - emoji
Send Poll Message
Send Buttons (Deprecated)
Send List (Deprecated)

Postman collections

Webhook Events

Name Event TypeData Description
APPLICATION_STARTUP application.startup json Notifies you when a application startup
QRCODE_UPDATED qrcode.updated json Sends the base64 of the qrcode for reading
CONNECTION_UPDATE connection.update json Informs the status of the connection with whatsapp
MESSAGES_SET message.set json Sends a list of all your messages uploaded on whatsapp
This event occurs only once
MESSAGES_UPSERT message.upsert json Notifies you when a message is received
MESSAGES_UPDATE message.update json Tells you when a message is updated
SEND_MESSAGE send.message json Notifies when a message is sent
CONTACTS_SET contacts.set json Performs initial loading of all contacts
This event occurs only once
CONTACTS_UPSERT contacts.upsert json Reloads all contacts with additional information
This event occurs only once
CONTACTS_UPDATE contacts.update json Informs you when the chat is updated
PRESENCE_UPDATE presence.update json Informs if the user is online, if he is performing some action like writing or recording and his last seen
'unavailable'
CHATS_SET chats.set json Send a list of all loaded chats
CHATS_UPDATE chats.update json Informs you when the chat is updated
CHATS_UPSERT chats.upsert json Sends any new chat information
GROUPS_UPSERT groups.upsert JSON Notifies when a group is created
GROUPS_UPDATE groups.update JSON Notifies when a group has its information updated
GROUP_PARTICIPANTS_UPDATE group-participants.update JSON Notifies when an action occurs involving a participant
'add'
NEW_TOKEN new.jwt JSON Notifies when the token (jwt) is updated

Webhook Routes

When enabling the WEBHOOK_BY_EVENTS options in the global and local webhooks, the following paths will be added at the end of the webhook.

Example:

https://sub.domain.com/webhook-test/exclusive-webhook-code/qrcode-updated

Name Path
APPLICATION_STARTUP /application-startup
QRCODE_UPDATED /qrcode-updated
CONNECTION_UPDATE /connection-update
MESSAGES_SET /messages-set
MESSAGES_UPSERT /messages-upsert
MESSAGES_UPDATE /messages-update
SEND_MESSAGE /send-message
CONTACTS_SET /contacts-set
CONTACTS_UPSERT /contacts-upsert
CONTACTS_UPDATE /contacts-update
PRESENCE_UPDATE /presence-update
CHATS_SET /chats-set
CHATS_UPDATE /chats-update
CHATS_UPSERT /chats-upsert
GROUPS_UPSERT /groups-upsert
GROUPS_UPDATE /groups-update
GROUP_PARTICIPANTS_UPDATE /groups-participants-update
NEW_TOKEN /new-token

Env File

See additional settings that can be applied through the env file by clicking here.

⚠️Attention⚠️: rename the dev-env.yml file to env.yml.

SSL

To install the SSL certificate, follow the instructions below.

Note

This code is in no way affiliated with WhatsApp. Use at your own discretion. Don't spam this.

This code was produced based on the baileys library and it is still under development.

Donate to the project.

PicPay