{"id":18075610,"url":"https://github.com/blakepro/whatsapp-web-api-rest","last_synced_at":"2025-04-05T19:41:28.492Z","repository":{"id":260383931,"uuid":"861112954","full_name":"BlakePro/whatsapp-web-api-rest","owner":"BlakePro","description":"Interact with WhatsApp via an API to send messages, simulate actions, retrieve contacts, and more.","archived":false,"fork":false,"pushed_at":"2025-01-07T18:32:32.000Z","size":230,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-11T17:56:56.661Z","etag":null,"topics":["docker","nestjs","node","webhook","whatsapp","whatsapp-api"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BlakePro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-09-22T03:16:14.000Z","updated_at":"2025-02-03T18:13:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"f09de1f3-49ba-4f4f-ae1a-ccda562e7d67","html_url":"https://github.com/BlakePro/whatsapp-web-api-rest","commit_stats":null,"previous_names":["blakepro/whatsapp-web-api-rest"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlakePro%2Fwhatsapp-web-api-rest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlakePro%2Fwhatsapp-web-api-rest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlakePro%2Fwhatsapp-web-api-rest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlakePro%2Fwhatsapp-web-api-rest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BlakePro","download_url":"https://codeload.github.com/BlakePro/whatsapp-web-api-rest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247393542,"owners_count":20931809,"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":["docker","nestjs","node","webhook","whatsapp","whatsapp-api"],"created_at":"2024-10-31T11:06:29.105Z","updated_at":"2025-04-05T19:41:28.474Z","avatar_url":"https://github.com/BlakePro.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"public/api_whatsapp.png\" alt=\"Lightweight API for WhatsApp\" width=\"120\" height=\"120\"\u003e\n\u003c/p\u003e\n\n# 📱 WhatsApp API REST\n\n`whatsapp-web-api-rest` is an easy-to-use Docker REST API  wrapper for [Baileys - Lightweight full-featured TypeScript/JavaScript WhatsApp Web API](https://github.com/WhiskeySockets/Baileys) built with [NestJS](https://nestjs.com/). It allows you to interact with WhatsApp using endpoints to enable message sending, simulate actions, fetch contacts, and more.\n\n## ✨ Features\n\n- 🚀 Send WhatsApp messages via API\n- 🤖 Simulate user actions (e.g. composing, recording audio)\n- 📲 Fetch chats, contacts, labels, and WhatsApp states\n- 🔔 Manage webhooks for real-time updates\n- 🔄 Server-Sent Events (SSE) for live message updates\n- ⚡️ RESTful design based on NestJS\n\n\u003cbr/\u003e\n\n## 🐳 Docker\n\n\u003e https://hub.docker.com/r/blakegt/whatsapp-web-api-rest\n\n```bash\ndocker run --restart unless-stopped -dp 8085:8085 --name whatsapp-web-api-rest blakegt/whatsapp-web-api-rest:latest\n```\n\n\u003cbr/\u003e\n\n## 👨🏻‍💻 Dev mode\n\nClone the repository:\n\n```bash\ngit clone https://github.com/BlakePro/whatsapp-web-api-rest.git\n```\n\nInstall dependencies:\n\n```bash\ncd whatsapp-web-api-rest\nnpm install or pnpm i\n```\n\nStart the server:\n\n```bash\nnpm run dev or pnpm dev\n```\n\n\u003cbr/\u003e\n\n## 🛠️ API Endpoints\n\n- `GET` /\n\n    **Start whatsApp session**\n\n    Returns an HTML page displaying QR code for authentication `curl -i http://localhost:8085` or open in your browser [http://localhost:8085](http://localhost:8085)\n\n\n- `POST`  /message\n \n    **Send message text, media, location, poll, contact**\n\n    Request Body: `application/json`\n\n    `curl -X POST http://localhost:8085/message \\\n    -H \"Content-Type: application/json\" -d {...body}`\n\n    *Body examples*:\n\n    - Text:\n    \n      ```json\n      {\n        \"chatId\": \"5215512345678@c.us\",\n        \"text\": \"Hello!\",\n      }\n      ```\n    \n    - Media (document):\n    \n      ```json\n      {\n        \"chatId\": \"5215512345678@c.us\",\n        \"media\": {\n            \"type\": \"document\",\n            \"filename\": \"My name of the file\",\n            \"caption\": \"Hey! This is a pdf doc\",\n            \"mimetype\": \"application/pdf\",\n            \"data\": \"JVBERi0xLjMKJbrfrO...\" // base64\n        }\n      }\n      ```\n    \n    - Media (video):\n    \n      ```json\n      {\n        \"chatId\": \"5215512345678@c.us\",\n        \"media\": {\n            \"type\": \"video\",\n            \"caption\": \"Hey! This is a video\",\n            \"data\": \"JVBERi0xLjMKJbrfrO...\" // base64\n        }\n      }\n      ```\n    \n    - Media (audio):\n      ```json\n      {\n        \"chatId\": \"5215512345678@c.us\",\n        \"media\": {\n            \"type\": \"audio\",\n            \"caption\": \"Hey! This is an audio\",\n            \"ptt\": false, // Set to true if you want it to appear as a voice note\n            \"data\": \"JVBERi0xLjMKJbrfrO...\" // base64\n        }\n      }\n    - Media (sticker):\n      ```json\n      {\n        \"chatId\": \"5215512345678@c.us\",\n        \"media\": {\n            \"type\": \"sticker\",\n            \"mimetype\": \"image/webp\",\n            \"data\": \"JVBERi0xLjMKJbrfrO...\" // base64\n        }\n      }\n      ```\n    \n    - Location:\n    \n      ```json\n      {\n          \"chatId\": \"5215512345678@c.us\",\n          \"location\": {\n            \"name\": \"Googleplex\",\n            \"address\": \"1600 Amphitheatre Pkwy\",\n            \"url\": \"https: //google.com\",\n            \"latitude\": 37.422,\n            \"longitude\": -122.084\n          }\n      }\n      ```\n    \n    - Contact:\n    \n      ```json\n      {\n          \"chatId\": \"5215512345678@c.us\",\n          \"contact\": {\n              \"firstname\": \"Blake\",\n              \"lastname\": \"Pro\",\n              \"email\": \"blakegt@gmail.com\",\n              \"phone\": \"5215512345678\"\n          }\n      }\n      ```\n    \n    - Poll:\n    \n      ```json\n      {\n          \"chatId\": \"5215512345678@c.us\",\n          \"poll\": {\n              \"name\": \"Do you like Apple?\",\n              \"options\": [\n                  \"Yes\",\n                  \"No\",\n                  \"Maybe\"\n              ],\n              \"allowMultipleAnswers\": false\n          }\n      }\n      ```\n\n\u003cbr/\u003e\n\n- `POST` /simulate\n\n    **Simulate an action (presence)**\n  - **chatId**: The chat number ID\n  - **action**: The action to simulate: unavailable | available | composing | recording | paused\n    ```json\n    {\n        \"chatId\": \"5215512345678@c.us\",\n        \"action\": \"composing\",\n    }\n    ```\n    `curl http://localhost:8085/simulate`\n\n\u003cbr/\u003e\n\n- `GET` /profile/status/:chatId\n    \n    **Get the status of a person/group**\n     - **chatId**: The chat number ID\n      \n    `curl http://localhost:8085/profile/status/:chatId`\n\n\u003cbr/\u003e\n\n- `GET` /profile/picture/:chatId\n\n    **Get profile url picture of a person/group**\n     - **chatId**: The chat number ID\n     \n     `curl http://localhost:8085/picture/status/:chatId`\n\n\u003cbr/\u003e\n\n- `GET` /chats\n\n    **Fetches all available chats**\n    \n    `curl http://localhost:8085/chats`\n\n\u003cbr/\u003e\n\n- `GET` /contacts  \n\n    **Fetches all available contacts**  \n\n    `curl http://localhost:8085/contacts`\n\n\u003cbr/\u003e\n\n- `GET` /number/:numberId  \n\n    **Check if a given ID is on WhatsApp**\n  - **number**: The phone number\n  \n  `curl http://localhost:8085/number/:number`\n\n\u003cbr/\u003e\n\n- `GET` /logout\n\n    **Logs out from the current WhatsApp session**\n    \n    `curl http://localhost:8085/logout`\n\n\u003cbr/\u003e\n\n## 🛠️ Manage webhooks\n\n- `GET`  /webhooks\n\n    **Fetches the list of registered webhook URLs**\n    \n    `curl http://localhost:8085/webhooks`\n\n\u003cbr/\u003e\n\n- `POST` /webhooks\n\n    **Create a new webhook URL**\n    Request Body: `application/json`\n    \n    \n    ```bash\n    curl -X POST http://localhost:8085/webhooks \\\n    -H \"Content-Type: application/json\" \\\n    -d { \"url\": \"https://your-webhook-url.com\" }\n    ```\n    \n\u003cbr/\u003e\n\n- `DELETE` /webhooks/:indexId\n\n    **Remove the webhook by the index in the list**\n    \n    `curl -X DELETE http://localhost:8085/webhooks/:indexId`\n\n\u003cbr/\u003e\n\n## 🌐 Example of a webhook in an Express.js (Node.js) application\n\n1. Create a folder in your computer and enter\n\n2. Init the project\n`npm init` or `pnpm i`\n\n3. Install express.js\n`npm i express.js` or `pnpm i express.js`\n\n4. Create a file index.js\n\n5. Copy and paste in index.js and run in terminal `node index.js`\n\n    ```js\n    const express = require('express');\n    \n    const app = express();\n    const port = 3005;\n    const limit = '50mb';\n    \n    // Use express.json() middleware to parse JSON bodies\n    app.use(express.json({ limit }));\n    app.use(express.urlencoded({ extended: true, limit }));\n    \n    // Define a POST endpoint\n    app.post('/', async (req, res) =\u003e {\n      const url = `${req.protocol}://${req.get('host')}${req.url}`;\n      const bodyPayload = req.body;\n    \n      const message = bodyPayload?.message;\n      const media = bodyPayload?.media;\n      const from = message?.from;\n      console.log(from)\n\n      // Body payload data \n      const payload = {\n        chatId: from,\n        text: 'Response from webhook'\n      }\n    \n      // Send message to endpoint\n      await fetch(`${url}/message`,\n        {\n          method: 'POST',\n          body: JSON.stringify(payload),\n          headers: {\n            \"Content-Type\": \"application/json\",\n          },\n        })\n    \n      res.send({});\n    });\n    \n    // Start the server\n    app.listen(port, () =\u003e {\n      console.log(`Server running at http://localhost:${port}`);\n    });\n    ```\n\n## 🤝 Contributing\n\nFeel free to contribute by creating issues or submitting pull requests. All contributions are welcome!\n\n## 🤝 Disclaimer\n\nThis project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with WhatsApp or any of its subsidiaries or its affiliates. The official WhatsApp website can be found at whatsapp.com. \"WhatsApp\" as well as related names, marks, emblems and images are registered trademarks of their respective owners. Also it is not guaranteed you will not be blocked by using this method. WhatsApp does not allow bots or unofficial clients on their platform, so this shouldn't be considered totally safe.\n\n## 📜 License\n\nThis project is licensed under the MIT License.\n\n## 👨🏻‍💻 Author\n\n[Cristian Yosafat Hernández Ruiz - BlakePro](https://github.com/blakepro)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblakepro%2Fwhatsapp-web-api-rest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblakepro%2Fwhatsapp-web-api-rest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblakepro%2Fwhatsapp-web-api-rest/lists"}