{"id":14986960,"url":"https://github.com/code-chat-br/whatsapp-api","last_synced_at":"2025-05-14T22:08:15.493Z","repository":{"id":64152327,"uuid":"571362538","full_name":"code-chat-br/whatsapp-api","owner":"code-chat-br","description":"CodeChat - WhatsApp Api","archived":false,"fork":false,"pushed_at":"2025-04-12T21:15:15.000Z","size":2389,"stargazers_count":796,"open_issues_count":0,"forks_count":304,"subscribers_count":55,"default_branch":"main","last_synced_at":"2025-04-13T18:44:40.739Z","etag":null,"topics":["api","api-rest","automotion","chat","communication","nodejs","whatsapp","whatsapp-api","whatsapp-bot"],"latest_commit_sha":null,"homepage":"https://docs.codechat.dev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/code-chat-br.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-11-28T00:23:09.000Z","updated_at":"2025-04-12T21:14:38.000Z","dependencies_parsed_at":"2023-12-09T22:24:28.952Z","dependency_job_id":"f85bb114-7d91-48b3-a816-45fae5cee5bf","html_url":"https://github.com/code-chat-br/whatsapp-api","commit_stats":{"total_commits":446,"total_committers":13,"mean_commits":34.30769230769231,"dds":"0.10538116591928248","last_synced_commit":"a8749f792b0a6f38a435e55aba25a127dd058215"},"previous_names":[],"tags_count":124,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-chat-br%2Fwhatsapp-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-chat-br%2Fwhatsapp-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-chat-br%2Fwhatsapp-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-chat-br%2Fwhatsapp-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/code-chat-br","download_url":"https://codeload.github.com/code-chat-br/whatsapp-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254235698,"owners_count":22036963,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","api-rest","automotion","chat","communication","nodejs","whatsapp","whatsapp-api","whatsapp-bot"],"created_at":"2024-09-24T14:13:52.694Z","updated_at":"2025-05-14T22:08:10.477Z","avatar_url":"https://github.com/code-chat-br.png","language":"TypeScript","readme":"\u003c/br\u003e\n\u003chr style=\"height: 5px;background: #007500;margin: 20px 0;box-shadow: 0px 3px 5px 0px rgb(204 204 204);\"\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![Telegram Group](https://img.shields.io/badge/Group-Telegram-%2333C1FF)](https://t.me/codechatBR)\n[![Whatsapp Group](https://img.shields.io/badge/Group-WhatsApp-%2322BC18)](https://chat.whatsapp.com/HyO8X8K0bAo0bfaeW8bhY5)\n[![License](https://img.shields.io/badge/license-GPL--3.0-orange)](./LICENSE)\n[![Support](https://img.shields.io/badge/Buy%20me-coffe-orange)](https://app.picpay.com/user/cleber.wilson.oliveira)\n[![Support](https://img.shields.io/badge/Buy%20me%20coffe-pix-blue)](#pix-2b526ada-4ef4-4db4-bbeb-f60da2421fce)\n\n\u003c/div\u003e\n  \n\u003cdiv align=\"center\"\u003e\u003cimg src=\"./public/images/cover.png\"\u003e\u003c/div\u003e\n\n## Project Structure\n\n* [Look here](./PROJECT_STRUCTURE.md)\n\n## WhatsApp-Api-NodeJs\n\nThis code is an implementation of [WhiskeySockets](https://github.com/WhiskeySockets/Baileys), as a RestFull Api service, which controls whatsapp functions.\u003c/br\u003e\nWith 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.\n\n## Infrastructure\n\n### 1. Docker installation\n\n* First, let's install Docker. Docker is a platform that allows us to quickly create, test and deploy applications in isolated environments called containers.\n\n```sh\ncurl -fsSL https://get.docker.com -o get-docker.sh\nsudo sh get-docker.sh\nsudo usermod -aG docker ${USER}\n```\n\n### 2. Installing the database\n\n\u003e PostgreSql [required]\n\n* Now, we have configured our PostgreSQL database using Docker Compose.\n* Access your postgre manager and create a database.\n\n[compose from postgres](./postgres/docker-compose.yaml)\n\n### 3. Nvm installation\n\n```sh\ncurl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash\n# or\nwget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash\n```\n\u003e\n\u003e After finishing, restart the terminal to load the new information.\n\u003e\n\n#### 3.1 Nodejs installation\n\n* Installing Node.js using NVM, a version manager that allows us to switch between different versions of Node.js easily.\n\n```sh\nnvm install 20\n```\n\n### 4. pm2 installation\n```sh\nnpm i -g pm2\n```\n\n### 5. Application startup\n\nCloning the Repository\n```\ngit clone https://github.com/code-chat-br/whatsapp-api.git\n```\n\nGo to the project directory and install all dependencies.\n\n\u003e\n\u003e Give preference to **npm** as it has greater compatibility.\n\u003e\n\n```sh\ncd whatsapp-api-v2\n\nnpm install\n# or\nnpm install --force\n```\n\n### 6. Environment variables\nSee additional settings that can be applied through the **env** file by clicking **[here](./.env.dev)**.\n\n\u003e **⚠️Attention⚠️:** copy the **.env.dev** file to **.env**.\n```sh\ncp .env.dev .env\n```\n\n### 7. Prism ORM\n\n* We're going to use Prisma ORM to manage our database. Prisma simplifies database access and ensures operations are secure and easy to maintain.\n* **Commands and Explanations:**\n  * **In development environment: npx prisma migrate dev**\n    * We use `migrate dev` in development to automatically create and apply migrations, making working with the database easier.\n  * **In production environment: npx prisma migrate deploy**\n    * In production, we use `migrate deploy` to apply migrations in a controlled and secure way.\n  * **Data visualization:** `npx prisma studio`\n    * Prisma Studio is a visual tool that helps us manage and visualize bank data in an intuitive way.\n\nDefine the [DATABASE_URL](https://github.com/code-chat-br/whatsapp-api/blob/6d0ab3e27932c5d1a6d8275dc3c6cb5097ff099e/.env.dev#L48) environment variable for the database deployment.\n\n* Performing the database [deployment](https://www.prisma.io/docs/orm/reference/prisma-cli-reference#migrate-deploy).\n```sh\nbash deploy_db.sh\n```\n\nFinally, run the command below to start the application:\n```sh\nnpm run start:dev\n\nnpm run start:prod\n\n# pm2\npm2 start 'npm run start:prod' --name CodeChat_API_v1.3.0\n```\n---\n\n## Worker\n\n### Worker options for session management\n\n- **[session-manager:files-v0.0.1](https://github.com/code-chat-br/session-manager)**\n- **[session-manager:sqlite-v0.0.1](https://github.com/code-chat-br/session-manager/tree/sqlite)**\n\nTo use the worker with the API it is necessary to define the following environment variables in the API:\n\n- `PROVIDER_ENABLED=true`: This variable enables the use of the provider (worker) in the API.\n- `PROVIDER_HOST=127.0.0.1`: Defines the host where the worker is listening for requests.\n- `PROVIDER_PORT=5656`: Defines the port where the worker is listening for requests.\n- `PROVIDER_PREFIX=codechat`: Set prefix for instance grouping on worker\n\n---\n\n## WebSocket\nwebsocket compatibility added.\n[Read here.](./src/websocket/Readme.md)\n\n## Swagger - OpenAPI 3.0.0\n\n* Route: `http://localhost:8084/docs`\n* YAML file: [swagger.yaml](./src/docs/swagger.yaml)\n\n## Authentication\n\nYou can define two authentication **types** for the routes in the **[env file](./env.dev)**.\nAuthentications must be inserted in the request header.\n\n1. **jwt:** A JWT is a standard for authentication and information exchange defined with a signature.\n\n\u003e Authentications are generated at instance creation time.\n\n**Note:** There is also the possibility to define a global api key, which can access and control all instances.\n\n### App in Docker\n  - [docker-compose](./docker-compose.yml)\n  - [DockerHub-codechat/api:develop](https://hub.docker.com/r/codechat/api/tags)\n  \n\nAfter building the application, in the same directory as the files above, run the following command:\n```sh\ndocker-compose up\n```\n## Send Messages\n|     |   |\n|-----|---|\n| Send Text | ✔ |\n| Send Buttons | ✔ only \\[ios,android\\] |\n| Send Media: audio - video - image - document - gif \u003cbr\u003e\u003c/br\u003ebase64: ```false``` | ✔ |\n| Send Media File | ✔ |\n| Send Audio type WhatsApp | ✔ |\n| Send Audio type WhatsApp - File | ✔ |\n| Send Location | ✔ |\n| Send List | ✔ only \\[ios,android\\] |\n| Send Link Preview | ❌ |\n| Send Contact | ✔ |\n| Send Reaction - emoji | ✔ |\n\n## Postman collections\n  - [![Run in Postman](https://run.pstmn.io/button.svg)](https://www.postman.com/codechat/codechat-api/overview)\n\n## Webhook Events\n\n| Name | Event | TypeData | Description |\n|------|-------|-----------|------------|\n| QRCODE_UPDATED | qrcode.updated | json | Sends the base64 of the qrcode for reading |\n| CONNECTION_UPDATE | connection.update | json | Informs the status of the connection with whatsapp |\n| MESSAGES_SET | message.set | json | Sends a list of all your messages uploaded on whatsapp\u003c/br\u003eThis event occurs only once |\n| MESSAGES_UPSERT | message.upsert | json |  Notifies you when a message is received |\n| MESSAGES_UPDATE | message.update | json | Tells you when a message is updated |\n| SEND_MESSAGE | send.message | json | Notifies when a message is sent |\n| CONTACTS_SET | contacts.set | json | Performs initial loading of all contacts\u003c/br\u003eThis event occurs only once |\n| CONTACTS_UPSERT | contacts.upsert | json | Reloads all contacts with additional information\u003c/br\u003eThis event occurs only once |\n| CONTACTS_UPDATE | contacts.update | json | Informs you when the chat is updated |\n| 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\u003c/br\u003e'unavailable' | 'available' | 'composing' | 'recording' | 'paused' |\n| CHATS_SET | chats.set | json | Send a list of all loaded chats |\n| CHATS_UPDATE | chats.update | json | Informs you when the chat is updated |\n| CHATS_UPSERT | chats.upsert | json | Sends any new chat information |\n| GROUPS_UPSERT | groups.upsert | JSON | Notifies when a group is created |\n| GROUPS_UPDATE | groups.update | JSON | Notifies when a group has its information updated |\n| GROUP_PARTICIPANTS_UPDATE | group-participants.update | JSON | Notifies when an action occurs involving a participant\u003c/br\u003e'add' | 'remove' | 'promote' | 'demote' |\n| NEW_TOKEN | new.jwt | JSON | Notifies when the token (jwt) is updated\n\n\n## SSL\n\nTo install the SSL certificate, follow the **[instructions](https://certbot.eff.org/instructions?ws=other\u0026os=ubuntufocal)** below.\n\n# Note\n\nThis code is in no way affiliated with WhatsApp. Use at your own discretion. Don't spam this.\n\nThis code was produced based on the baileys library and it is still under development.\n\n# Donate to the project.\n\n#### Pix: 2b526ada-4ef4-4db4-bbeb-f60da2421fce\n\n#### PicPay\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://app.picpay.com/user/cleber.wilson.oliveira\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\n    \u003cimg src=\"./public/images/picpay-image.png\" style=\"width: 50% !important;\"\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003c/br\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-chat-br%2Fwhatsapp-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcode-chat-br%2Fwhatsapp-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-chat-br%2Fwhatsapp-api/lists"}