{"id":21942918,"url":"https://github.com/green-api/whatsapp-api-webhook-server-python-v2","last_synced_at":"2026-02-11T18:03:47.394Z","repository":{"id":245229162,"uuid":"808435469","full_name":"green-api/whatsapp-api-webhook-server-python-v2","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-06-06T07:42:11.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-05T21:10:03.405Z","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":"2024-05-31T04:19:01.000Z","updated_at":"2024-06-20T05:10:14.000Z","dependencies_parsed_at":"2024-06-20T18:13:57.641Z","dependency_job_id":null,"html_url":"https://github.com/green-api/whatsapp-api-webhook-server-python-v2","commit_stats":null,"previous_names":["green-api/whatsapp-api-webhook-server-python-v2"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/green-api/whatsapp-api-webhook-server-python-v2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-api%2Fwhatsapp-api-webhook-server-python-v2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-api%2Fwhatsapp-api-webhook-server-python-v2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-api%2Fwhatsapp-api-webhook-server-python-v2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-api%2Fwhatsapp-api-webhook-server-python-v2/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-v2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-api%2Fwhatsapp-api-webhook-server-python-v2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29340395,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-11T16:14:43.024Z","status":"ssl_error","status_checked_at":"2026-02-11T16:14:15.258Z","response_time":97,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-11-29T03:27:16.014Z","updated_at":"2026-02-11T18:03:47.378Z","avatar_url":"https://github.com/green-api.png","language":"Python","readme":"# whatsapp-api-webhook-server-python-v2\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-v2)\n![](https://img.shields.io/pypi/pyversions/whatsapp-api-webhook-server-python-v2)\n![](https://img.shields.io/pypi/dm/whatsapp-api-webhook-server-python-v2)\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-v2/blob/master/README.ru.md).\n\n`whatsapp-api-webhook-server-python-v2` is a library for receiving and processing webhooks from [green-api.com](https://green-api.com/en/), based on `FastAPI` server.\n\nYou should get a registration token and an account ID in your [personal cabinet](https://console.green-api.com/) to use the library. To develop, you can use a free account with the \"Developer\" 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 for 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 authorize 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-v2\n```\n\nAs an example you can download and run [our script](https://github.com/green-api/whatsapp-api-webhook-server-python-v2/blob/master/examples/receive_all_with_counter.py):\n\n\n```shell\nwget https://raw.githubusercontent.com/green-api/whatsapp-api-webhook-server-python-v2/master/examples/receive_all_with_counter.py\n```\n\n\n```shell\npython3 -m receive_all_with_counter.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#### How to configure web server\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\\receive_all_with_counter.py.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. receive_all_with_counter.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### How to run example via 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-v2\n```\n\nRun the image in a container with the port and the console displayed:\n\n```\nsudo docker run -it -e PORT=8000 -p 80:8000 greenapi/whatsapp-api-webhook-server-python-v2\n```\n\nIn this case we run a webhook server on `8000` port inside container and proxy our machine's `80` port to internal `8000` container's port\n\nIn [personal cabinet](https://console.green-api.com/) you\nwill need to specify the IP (or external machine name) with this (`80`) port.\n\nAfter the container is launched, the data on incoming webhooks will be available in the console.\n\nAlso you can run it via `docker compose` (from root repo directory):\n\n```\ndocker compose up --build\n```\n\n## Running the server\n\nTo use in your solutions, simply import the `GreenAPIWebhookServer` class and init server object.\n\n```python\nfrom whatsapp_api_webhook_server_python_v2 import GreenAPIWebhookServer\n\ndef event_handler(webhook_type: str, webhook_data: dict):\n    # Write webhook handling logic here\n    ...\n\nhandler = GreenAPIWebhookServer(\n    event_handler=event_handler,    # Your event handler func (check examples in repo)\n    host=\"0.0.0.0\",                 # Your host\n    port=8080,                      # Your port\n    webhook_auth_header=None,       # Webhook auth header param (check API console)\n)\n\nif __name__ == \"__main__\":\n    handler.start()\n```\n\nThe `event_handler` parameter is a handler function that should be created by the developer.\n\nMethod parameters:\n\n| Parameter           | Description              |\n|---------------------|--------------------------|\n| `webhook_type: str` | type of incoming webhook |\n| `webhook_data: dict`| data of incoming webhook |\n\nExample: [receive_all_with_counter.py](https://github.com/green-api/whatsapp-api-webhook-server-python-v2/blob/master/examples/receive_all_with_counter.py).\n\nAlso, if you need to implement webhooks processing logic inside your project yourself, you can use `Pydantic v2` models, which are located in the `webhook_dto.py` file\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-v2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgreen-api%2Fwhatsapp-api-webhook-server-python-v2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreen-api%2Fwhatsapp-api-webhook-server-python-v2/lists"}