{"id":16415412,"url":"https://github.com/green-api/whatsapp-api-webhook-server-python","last_synced_at":"2025-03-21T03:32:06.328Z","repository":{"id":62593115,"uuid":"550921138","full_name":"green-api/whatsapp-api-webhook-server-python","owner":"green-api","description":"This library helps you easily create a Python server endpoint to receive WhatsApp message webhooks.","archived":false,"fork":false,"pushed_at":"2024-05-01T08:20:02.000Z","size":153,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-01T02:21:39.902Z","etag":null,"topics":["whatsapp","whatsapp-api","whatsapp-api-python","whatsapp-python","whatsapp-webhook","whatsapp-webhook-server"],"latest_commit_sha":null,"homepage":"https://green-api.com/en","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/green-api.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2022-10-13T14:41:50.000Z","updated_at":"2024-06-04T05:37:11.000Z","dependencies_parsed_at":"2024-10-28T09:17:16.721Z","dependency_job_id":null,"html_url":"https://github.com/green-api/whatsapp-api-webhook-server-python","commit_stats":{"total_commits":67,"total_committers":4,"mean_commits":16.75,"dds":"0.34328358208955223","last_synced_commit":"a59cce69e681a84d8355d80504f9be2ef8de00de"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-api%2Fwhatsapp-api-webhook-server-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-api%2Fwhatsapp-api-webhook-server-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-api%2Fwhatsapp-api-webhook-server-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-api%2Fwhatsapp-api-webhook-server-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/green-api","download_url":"https://codeload.github.com/green-api/whatsapp-api-webhook-server-python/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244102772,"owners_count":20398386,"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":["whatsapp","whatsapp-api","whatsapp-api-python","whatsapp-python","whatsapp-webhook","whatsapp-webhook-server"],"created_at":"2024-10-11T07:05:36.977Z","updated_at":"2025-03-21T03:32:05.888Z","avatar_url":"https://github.com/green-api.png","language":"Python","readme":"# whatsapp-api-webhook-server-python\n\n![](https://img.shields.io/badge/license-CC%20BY--ND%204.0-green)\n![](https://img.shields.io/pypi/status/whatsapp-api-webhook-server-python)\n![](https://img.shields.io/pypi/pyversions/whatsapp-api-webhook-server-python)\n![](https://img.shields.io/github/actions/workflow/status/green-api/whatsapp-api-webhook-server-python/python-package.yml)\n![](https://img.shields.io/pypi/dm/whatsapp-api-webhook-server-python)\n\n## Support links\n\n[![Support](https://img.shields.io/badge/support@green--api.com-D14836?style=for-the-badge\u0026logo=gmail\u0026logoColor=white)](mailto:support@greenapi.com)\n[![Support](https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge\u0026logo=telegram\u0026logoColor=white)](https://t.me/greenapi_support_eng_bot)\n[![Support](https://img.shields.io/badge/WhatsApp-25D366?style=for-the-badge\u0026logo=whatsapp\u0026logoColor=white)](https://wa.me/77273122366)\n\n## Guides \u0026 News\n\n[![Guides](https://img.shields.io/badge/YouTube-%23FF0000.svg?style=for-the-badge\u0026logo=YouTube\u0026logoColor=white)](https://www.youtube.com/@greenapi-en)\n[![News](https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge\u0026logo=telegram\u0026logoColor=white)](https://t.me/green_api)\n[![News](https://img.shields.io/badge/WhatsApp-25D366?style=for-the-badge\u0026logo=whatsapp\u0026logoColor=white)](https://whatsapp.com/channel/0029VaLj6J4LNSa2B5Jx6s3h)\n\n- [Документация на русском языке](https://github.com/green-api/whatsapp-api-webhook-server-python/blob/master/docs/README_RU.md).\n\nwhatsapp-api-webhook-server-python is a library for integration with WhatsApp messenger using the API\nservice [green-api.com](https://green-api.com/en/). You should get a registration token and an account ID in\nyour [personal cabinet](https://console.green-api.com/) to use the library. There is a free developer account tariff.\n\n## API\n\nThe documentation for the REST API can be found at the [link](https://green-api.com/en/docs/). The library is a wrapper\nfor the REST API, so the documentation at the link above also applies.\n\n## Authorization\n\nTo send a message or perform other Green API methods, the WhatsApp account in the phone app must be authorized. To\nauthorize the account, go to your [cabinet](https://console.green-api.com/) and scan the QR code using the WhatsApp app.\n\n## Examples of preparing the environment\n\n### Example of preparing the environment for Ubuntu Server\n\n#### Updating the system\n\nUpdate the system:\n\n```shell\nsudo apt update\nsudo apt upgrade -y\n```\n\n#### Firewall\n\nSet up the firewall:\n\nAllow the SSH connection:\n\n```shell\nsudo ufw allow ssh\n```\n\nBase rules:\n\n```shell\nsudo ufw default deny incoming\nsudo ufw default allow outgoing\n```\n\nAllow HTTP and HTTPS connections:\n\n```shell\nsudo ufw allow http\nsudo ufw allow https\n```\n\nEnable the firewall:\n\n```shell\nsudo ufw enable\n```\n\n#### Installation\n\nA package management system must be installed:\n\n```shell\nsudo apt install python3-pip\n```\n\nLibrary installation:\n\n```shell\npython3 -m pip install whatsapp-api-webhook-server-python\n```\n\nAs an example you can download and run [our script](\nhttps://github.com/green-api/whatsapp-api-webhook-server-python/blob/master/examples/echo.py\n). The script sends all incoming notifications.\n\n```shell\nwget https://raw.githubusercontent.com/green-api/whatsapp-api-webhook-server-python/master/examples/echo.py\n```\n\n```shell\npython3 -m echo.py\n```\n\n### Example of preparing the environment for Windows Server\n\n#### Python installation\n\nPython must be installed on the server. [Python installation instructions](https://www.python.org/downloads/).\n\n#### Как настроить конфигурацию веб-сервера\n\nTo use IIS (Internet Information Services) as a web server, you need to configure the configuration file `web.config` so\nthat the IIS service can properly execute Python code. This file is located in the publication folder of your web\nserver.\n\nAfter installing the interpreter, you should define the HttpPlatform handler in the `web.config` file. This handler will\ntransfer connections to the standalone Python process.\n\nExample configuration file:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cconfiguration\u003e\n    \u003csystem.webServer\u003e\n        \u003chandlers\u003e\n            \u003cadd name=\"PythonHandler\" path=\"*\" verb=\"*\" modules=\"httpPlatformHandler\" resourceType=\"Unspecified\"/\u003e\n        \u003c/handlers\u003e\n        \u003chttpPlatform arguments=\"\u003cPath-to-server-file\u003e\\echo.py\"\n                      processesPerApplication=\"16\"\n                      processPath=\"\u003cPath-to-python\u003e\\python.exe\"\n                      startupTimeLimit=\"60\"\n                      stdoutLogEnabled=\"true\"\n                      stdoutLogFile=\"\u003cPath-to-log-file\u003e\\python.log\"\u003e\n            \u003cenvironmentVariables\u003e\n                \u003cenvironmentVariable name=\"SOME_VARIABLE\" value=\"%SOME_VAR%\"/\u003e\n            \u003c/environmentVariables\u003e\n        \u003c/httpPlatform\u003e\n    \u003c/system.webServer\u003e\n\u003c/configuration\u003e\n```\n\n- `\u003cPath-to-python\u003e` - the path to the executable file of the Python interpreter;\n- `\u003cPath-to-server-file\u003e` - the path to the server executable file (e.g. echo.py from the example);\n- `\u003cPath-to-log-file\u003e` - the path to the log file.\n\nYou will also need to open the corresponding port to the external network by setting the firewall settings (Advanced\nOptions -\u003e Rules for incoming connections -\u003e Create Rule -\u003e Rule Type = Port Protocols, Port -\u003e TCP, specify the\nfirewall settings. options -\u003e Rules for incoming connections -\u003e Create Rule -\u003e Rule Type = Port, Protocols and Port -\u003e\nTCP, specify port, Action -\u003e Allow connection).\n\n### An example of deploying a server environment using Docker\n\nThe machine should have Docker installed.\n\nTo get an image from the Docker Hub, you need to write a command:\n\n```\nsudo docker pull greenapi/whatsapp-api-webhook-server-python\n```\n\nRun the image in a container with the port and the console displayed:\n\n```\nsudo docker run --publish 8080:80 -it greenapi/whatsapp-api-webhook-server-python\n```\n\nYou can specify any free machine port instead of port 8080. In [personal cabinet](https://console.green-api.com/) you\nwill need to specify the IP (or external machine name) with this port.\n\nAfter starting the container, the container console should receive incoming notifications.\n\n## Running the server\n\nTo use in your solutions, simply import the webhooksHandler class.\n\n```\nimport whatsapp_api_webhook_server_python.webhooksHandler as webhooksHandler\n```\n\nStart of the server:\n\n```\nwebhooksHandler.startServer('127.0.0.1', 80, onEvent)\n```\n\nThe `onEvent` parameter is a handler function that should be created by the developer.\n\nMethod parameters:\n\n| Parameter       | Description                   |\n|-----------------|-------------------------------|\n| webhooksHandler | library class instance        |\n| typeWebhook     | type of incoming notification |\n| body            | notification body             |\n\nExample: [echo.py](https://github.com/green-api/whatsapp-api-webhook-server-python/blob/master/examples/echo.py).\n\n## How to reroute incoming notifications to a web server\n\nTo reroute incoming notifications, you need to set the notification sending address (URL)\nin [personal cabinet](https://console.green-api.com/).\n\n## Service methods documentation\n\n[Service methods documentation](https://green-api.com/en/docs/api/)\n\n## License\n\nLicensed under [\nCreative Commons Attribution-NoDerivatives 4.0 International (CC BY-ND 4.0)\n](https://creativecommons.org/licenses/by-nd/4.0/) terms.\nPlease see file [LICENSE](https://github.com/green-api/whatsapp-api-webhook-server-python/blob/master/LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreen-api%2Fwhatsapp-api-webhook-server-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgreen-api%2Fwhatsapp-api-webhook-server-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreen-api%2Fwhatsapp-api-webhook-server-python/lists"}