
This code is an implementation of WhiskeySockets, as a RestFull Api service, which controls whatsapp functions.
With this one you can create multiservice chats, service bots or any other system that uses whatsapp. With this code you don't need to know javascript for nodejs , just start the server and make the language requests that you feel most comfortable with.
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker ${USER}
PostgreSql [required]
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
# or
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
After finishing, restart the terminal to load the new information.
nvm install 20
npm i -g pm2
Cloning the Repository
git clone https://github.com/code-chat-br/whatsapp-api.git
Go to the project directory and install all dependencies.
Give preference to npm as it has greater compatibility.
cd whatsapp-api-v2
npm install
# or
npm install --force
See additional settings that can be applied through the env file by clicking here.
⚠️Attention⚠️: copy the .env.dev file to .env.
cp .env.dev .env
migrate dev in development to automatically create and apply migrations, making working with the database easier.migrate deploy to apply migrations in a controlled and secure way.npx prisma studioDefine the DATABASE_URL environment variable for the database deployment.
bash deploy_db.sh
Finally, run the command below to start the application:
npm run start:dev
npm run start:prod
# pm2
pm2 start 'npm run start:prod' --name CodeChat_API_v1.3.0
To use the worker with the API it is necessary to define the following environment variables in the API:
PROVIDER_ENABLED=true: This variable enables the use of the provider (worker) in the API.PROVIDER_HOST=127.0.0.1: Defines the host where the worker is listening for requests.PROVIDER_PORT=5656: Defines the port where the worker is listening for requests.PROVIDER_PREFIX=codechat: Set prefix for instance grouping on workerwebsocket compatibility added. Read here.
http://localhost:8084/docsYou can define two authentication types for the routes in the env file. Authentications must be inserted in the request header.
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.
After building the application, in the same directory as the files above, run the following command:
docker-compose up
| Send Text | ✔ |
| Send Buttons | ❌ |
| Send Media: audio - video - image - document - gif |
base64: false | ✔ |
| Send Media File | ✔ |
| Send Audio type WhatsApp | ✔ |
| Send Audio type WhatsApp - File | ✔ |
| Send Location | ✔ |
| Send List | ❌ |
| Send Link Preview | ✔ |
| Send Contact | ✔ |
| Send Reaction - emoji | ✔ |
| Name | Event | TypeData | Description |
|---|---|---|---|
| QRCODE_UPDATED | qrcode.updated |
JSON | Sends the base64 of the QR code for reading |
| CONNECTION_UPDATE | connection.update |
JSON | Informs the status of the connection with WhatsApp |
| MESSAGES_SET | messages.set |
JSON | Sends a list of all your messages uploaded on WhatsApp |
This event occurs only once |
| MESSAGES_UPSERT | messages.upsert | JSON | Notifies you when a message is received |
| MESSAGES_UPDATE | messages.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 a contact is updated |
| PRESENCE_UPDATE | presence.update | JSON | Informs if the user is online, typing, recording, or last seen
unavailable available composing recording paused |
| CHATS_SET | chats.set | JSON | Sends 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 |
| CHATS_DELETE | chats.delete | JSON | Informs when a chat is deleted |
| 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 remove promote demote|
| REFRESH_TOKEN | refresh.token | JSON | Notifies when the JWT token is updated |
| CALL_UPSERT | call.upsert | JSON | Notifies when there is a new call event |
| LABELS_ASSOCIATION | labels.association | JSON | Associates labels to chats or contacts |
| LABELS_EDIT | labels.edit | JSON | Notifies when a label is edited |
To install the SSL certificate, follow the instructions below.
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.
$ claude mcp add whatsapp-api \
-- python -m otcore.mcp_server <graph>