pywa


Namepywa JSON
Version 2.7.0 PyPI version JSON
download
home_pageNone
SummaryPython wrapper for the WhatsApp Cloud API
upload_time2025-01-18 19:42:01
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT
keywords whatsapp whatsapp-api whatsapp-cloud-api whatsapp-cloud whatsapp-api-python whatsapp-cloud-api-python pywa wapy wa wa-api wa-cloud-api wa-cloud wa-api-python wa-cloud-api-python whatsapp-webhook whatsapp-webhook-python whatsapp-webhook-api whatsapp-flows whatsapp-cloud-api-flows
VCS
bugtrack_url
requirements httpx
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <img alt="PyWa Logo" height="250" src="https://pywa.readthedocs.io/en/latest/_static/pywa-logo.png" width="250"/>

________________________

# [PyWa](https://github.com/david-lev/pywa) • Python wrapper for the WhatsApp Cloud API

[![PyPi Downloads](https://img.shields.io/pypi/dm/pywa)](https://pypi.org/project/pywa/)
[![PyPI Version](https://badge.fury.io/py/pywa.svg)](https://pypi.org/project/pywa/)
[![Tests](https://img.shields.io/github/actions/workflow/status/david-lev/pywa/tests.yml?label=Tests)](https://github.com/david-lev/pywa/actions/workflows/tests.yml)
[![Coverage](https://img.shields.io/codecov/c/github/david-lev/pywa)](https://codecov.io/gh/david-lev/pywa)
[![Docs](https://readthedocs.org/projects/pywa/badge/?version=latest&)](https://pywa.readthedocs.io)
[![License](https://img.shields.io/github/license/david-lev/pywa)](https://github.com/david-lev/pywa/blob/master/LICENSE)
[![CodeFactor](https://www.codefactor.io/repository/github/david-lev/pywa/badge/master)](https://www.codefactor.io/repository/github/david-lev/pywa/overview/master)
[![Telegram](https://badges.aleen42.com/src/telegram.svg)](https://t.me/py_wa)

________________________

**PyWa is a Fast, Simple, Modern and easy-to-use asynchronous Python framework for building WhatsApp bots using the WhatsApp Cloud API.**

📄 **Quick Documentation Index**
--------------------------------

> [Get Started](https://pywa.readthedocs.io/en/latest/content/getting-started.html)
• [WhatsApp Client](https://pywa.readthedocs.io/en/latest/content/client/overview.html)
• [Handlers](https://pywa.readthedocs.io/en/latest/content/handlers/overview.html)
• [Listeners](https://pywa.readthedocs.io/en/latest/content/listeners/overview.html)
• [Filters](https://pywa.readthedocs.io/en/latest/content/filters/overview.html)
• [Updates](https://pywa.readthedocs.io/en/latest/content/updates/overview.html)
• [Flows](https://pywa.readthedocs.io/en/latest/content/flows/overview.html)
• [Examples](https://pywa.readthedocs.io/en/latest/content/examples/overview.html)

------------------------

⚡ **Features**
---------------
- 🚀 Fast and simple to use. No need to worry about the low-level details.
- 💬 Send text messages with interactive keyboards, images, videos, documents, audio, locations, contacts, etc.
- 📩 Receive messages, callbacks, message status updates, etc.
- ♻️ Create, send and listen to Flows (NEW!)
- 🔄 Built-in support for webhooks (Flask, FastAPI, etc.)
- 🔬 Filters for handling incoming updates
- 📄 Send and create templates
- ✅ Fully typed, documented and tested

------------------------

👨‍💻 **Usage**
----------------

- Create a WhatsApp client and send a message
> See [Getting Started](https://pywa.readthedocs.io/en/latest/content/getting-started.html) for more information.

```python
from pywa import WhatsApp

wa = WhatsApp(
    phone_id="100458559237541",
    token="EAAEZC6hUxkTIB"
)

wa.send_message(
    to="9876543210",
    text="Hello from PyWa!"
)
```

- To listen to updates, create a `WhatsApp` client, pass a web server app ([FastAPI](https://fastapi.tiangolo.com/) in this example) and register callbacks:

> See [Handlers](https://pywa.readthedocs.io/en/latest/content/handlers/overview.html) for more information.

```python
# wa.py
from pywa import WhatsApp, filters, types
from fastapi import FastAPI

fastapi_app = FastAPI()
wa = WhatsApp(
    phone_id="1234567890",
    token="xxxxxxx",
    server=fastapi_app,
    callback_url="https://yourdomain.com/",
    verify_token="xyz123",
    app_id=123456,
    app_secret="yyyyyy"
)

@wa.on_message(filters.matches("Hello", "Hi"))
def hello(client: WhatsApp, msg: types.Message):
    msg.react("👋")
    msg.reply_text(
        text=f"Hello {msg.from_user.name}!",
        buttons=[
            types.Button(
                title="Click me!",
                callback_data="id:123"
            )
        ]
    )

@wa.on_callback_button(filters.startswith("id"))
def click_me(client: WhatsApp, clb: types.CallbackButton):
    clb.reply_text("You clicked me!")
```

- To run the server, use [fastapi-cli](https://fastapi.tiangolo.com/#run-it) (`pip install "fastapi[standard]"`):

```bash
fastapi dev wa.py  # see uvicorn docs for more options (port, host, reload, etc.)
```

💫 **Async Usage**

- PyWa has async support! To use the async version, replace **all** the imports from `pywa` to `pywa_async` and use `async`/`await`:

```python
# wa.py
import fastapi
from pywa_async import WhatsApp, types

fastapi_app = fastapi.FastAPI()
wa = WhatsApp(..., server=fastapi_app)

async def main():
    await wa.send_message(...)

@wa.on_message()
async def hello(_: WhatsApp, msg: types.Message):
    await msg.react("👋")
    await msg.reply(...)
```

```bash
fastapi dev wa.py
```

🎛 **Installation**
--------------------

- **Install using pip3:**

```bash
pip3 install -U pywa
```

- **Install from source (the bleeding edge):**

```bash
pip3 install -U git+https://github.com/david-lev/pywa.git
```

- **If you going to use the webhook features, here is shortcut to install the required dependencies:**

```bash
pip3 install -U "pywa[fastapi]"
pip3 install -U "pywa[flask]"
```

- **If you going to use the Flow features and want to use the default FlowRequestDecryptor and the default FlowResponseEncryptor, here is shortcut to install the required dependencies:**

```bash
pip3 install -U "pywa[cryptography]"
```

💾 **Requirements**
--------------------

- Python 3.10 or higher - https://www.python.org

📖 **Setup and Usage**
-----------------------

See the [Documentation](https://pywa.readthedocs.io/) for detailed instructions

☑️ **TODO**
------------

- ~~Add support for async~~
- ~~Add support for more web frameworks (Django, aiohttp, etc.)~~
- ~~Add support for flows~~
- Add support for more types of updates (``account_alerts``, ``phone_number_quality_updates``, ``template_category_updates``, etc.)
- Add more examples and guides

Feel free to open an issue if you have any suggestions. or even better - submit a PR!

⚖️ **License**
---------------

This project is licensed under the MIT License - see the
[LICENSE](https://github.com/david-lev/pywa/blob/master/LICENSE) file for details


🔱 **Contributing**
--------------------

Contributions are welcome! Please see the [Contributing Guide](https://github.com/david-lev/pywa/blob/master/CONTRIBUTING.md) for more information.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pywa",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "whatsapp, whatsapp-api, whatsapp-cloud-api, whatsapp-cloud, whatsapp-api-python, whatsapp-cloud-api-python, pywa, wapy, wa, wa-api, wa-cloud-api, wa-cloud, wa-api-python, wa-cloud-api-python, whatsapp-webhook, whatsapp-webhook-python, whatsapp-webhook-api, whatsapp-flows, whatsapp-cloud-api-flows",
    "author": null,
    "author_email": "David Lev <david@davidlev.dev>",
    "download_url": "https://files.pythonhosted.org/packages/48/a4/8a02043af8442804e8a4b43f08182e8530621a513659d5b4329597845190/pywa-2.7.0.tar.gz",
    "platform": null,
    "description": "<img alt=\"PyWa Logo\" height=\"250\" src=\"https://pywa.readthedocs.io/en/latest/_static/pywa-logo.png\" width=\"250\"/>\n\n________________________\n\n# [PyWa](https://github.com/david-lev/pywa) \u2022 Python wrapper for the WhatsApp Cloud API\n\n[![PyPi Downloads](https://img.shields.io/pypi/dm/pywa)](https://pypi.org/project/pywa/)\n[![PyPI Version](https://badge.fury.io/py/pywa.svg)](https://pypi.org/project/pywa/)\n[![Tests](https://img.shields.io/github/actions/workflow/status/david-lev/pywa/tests.yml?label=Tests)](https://github.com/david-lev/pywa/actions/workflows/tests.yml)\n[![Coverage](https://img.shields.io/codecov/c/github/david-lev/pywa)](https://codecov.io/gh/david-lev/pywa)\n[![Docs](https://readthedocs.org/projects/pywa/badge/?version=latest&)](https://pywa.readthedocs.io)\n[![License](https://img.shields.io/github/license/david-lev/pywa)](https://github.com/david-lev/pywa/blob/master/LICENSE)\n[![CodeFactor](https://www.codefactor.io/repository/github/david-lev/pywa/badge/master)](https://www.codefactor.io/repository/github/david-lev/pywa/overview/master)\n[![Telegram](https://badges.aleen42.com/src/telegram.svg)](https://t.me/py_wa)\n\n________________________\n\n**PyWa is a Fast, Simple, Modern and easy-to-use asynchronous Python framework for building WhatsApp bots using the WhatsApp Cloud API.**\n\n\ud83d\udcc4 **Quick Documentation Index**\n--------------------------------\n\n> [Get Started](https://pywa.readthedocs.io/en/latest/content/getting-started.html)\n\u2022 [WhatsApp Client](https://pywa.readthedocs.io/en/latest/content/client/overview.html)\n\u2022 [Handlers](https://pywa.readthedocs.io/en/latest/content/handlers/overview.html)\n\u2022 [Listeners](https://pywa.readthedocs.io/en/latest/content/listeners/overview.html)\n\u2022 [Filters](https://pywa.readthedocs.io/en/latest/content/filters/overview.html)\n\u2022 [Updates](https://pywa.readthedocs.io/en/latest/content/updates/overview.html)\n\u2022 [Flows](https://pywa.readthedocs.io/en/latest/content/flows/overview.html)\n\u2022 [Examples](https://pywa.readthedocs.io/en/latest/content/examples/overview.html)\n\n------------------------\n\n\u26a1 **Features**\n---------------\n- \ud83d\ude80 Fast and simple to use. No need to worry about the low-level details.\n- \ud83d\udcac Send text messages with interactive keyboards, images, videos, documents, audio, locations, contacts, etc.\n- \ud83d\udce9 Receive messages, callbacks, message status updates, etc.\n- \u267b\ufe0f Create, send and listen to Flows (NEW!)\n- \ud83d\udd04 Built-in support for webhooks (Flask, FastAPI, etc.)\n- \ud83d\udd2c Filters for handling incoming updates\n- \ud83d\udcc4 Send and create templates\n- \u2705 Fully typed, documented and tested\n\n------------------------\n\n\ud83d\udc68\u200d\ud83d\udcbb **Usage**\n----------------\n\n- Create a WhatsApp client and send a message\n> See [Getting Started](https://pywa.readthedocs.io/en/latest/content/getting-started.html) for more information.\n\n```python\nfrom pywa import WhatsApp\n\nwa = WhatsApp(\n    phone_id=\"100458559237541\",\n    token=\"EAAEZC6hUxkTIB\"\n)\n\nwa.send_message(\n    to=\"9876543210\",\n    text=\"Hello from PyWa!\"\n)\n```\n\n- To listen to updates, create a `WhatsApp` client, pass a web server app ([FastAPI](https://fastapi.tiangolo.com/) in this example) and register callbacks:\n\n> See [Handlers](https://pywa.readthedocs.io/en/latest/content/handlers/overview.html) for more information.\n\n```python\n# wa.py\nfrom pywa import WhatsApp, filters, types\nfrom fastapi import FastAPI\n\nfastapi_app = FastAPI()\nwa = WhatsApp(\n    phone_id=\"1234567890\",\n    token=\"xxxxxxx\",\n    server=fastapi_app,\n    callback_url=\"https://yourdomain.com/\",\n    verify_token=\"xyz123\",\n    app_id=123456,\n    app_secret=\"yyyyyy\"\n)\n\n@wa.on_message(filters.matches(\"Hello\", \"Hi\"))\ndef hello(client: WhatsApp, msg: types.Message):\n    msg.react(\"\ud83d\udc4b\")\n    msg.reply_text(\n        text=f\"Hello {msg.from_user.name}!\",\n        buttons=[\n            types.Button(\n                title=\"Click me!\",\n                callback_data=\"id:123\"\n            )\n        ]\n    )\n\n@wa.on_callback_button(filters.startswith(\"id\"))\ndef click_me(client: WhatsApp, clb: types.CallbackButton):\n    clb.reply_text(\"You clicked me!\")\n```\n\n- To run the server, use [fastapi-cli](https://fastapi.tiangolo.com/#run-it) (`pip install \"fastapi[standard]\"`):\n\n```bash\nfastapi dev wa.py  # see uvicorn docs for more options (port, host, reload, etc.)\n```\n\n\ud83d\udcab **Async Usage**\n\n- PyWa has async support! To use the async version, replace **all** the imports from `pywa` to `pywa_async` and use `async`/`await`:\n\n```python\n# wa.py\nimport fastapi\nfrom pywa_async import WhatsApp, types\n\nfastapi_app = fastapi.FastAPI()\nwa = WhatsApp(..., server=fastapi_app)\n\nasync def main():\n    await wa.send_message(...)\n\n@wa.on_message()\nasync def hello(_: WhatsApp, msg: types.Message):\n    await msg.react(\"\ud83d\udc4b\")\n    await msg.reply(...)\n```\n\n```bash\nfastapi dev wa.py\n```\n\n\ud83c\udf9b **Installation**\n--------------------\n\n- **Install using pip3:**\n\n```bash\npip3 install -U pywa\n```\n\n- **Install from source (the bleeding edge):**\n\n```bash\npip3 install -U git+https://github.com/david-lev/pywa.git\n```\n\n- **If you going to use the webhook features, here is shortcut to install the required dependencies:**\n\n```bash\npip3 install -U \"pywa[fastapi]\"\npip3 install -U \"pywa[flask]\"\n```\n\n- **If you going to use the Flow features and want to use the default FlowRequestDecryptor and the default FlowResponseEncryptor, here is shortcut to install the required dependencies:**\n\n```bash\npip3 install -U \"pywa[cryptography]\"\n```\n\n\ud83d\udcbe **Requirements**\n--------------------\n\n- Python 3.10 or higher - https://www.python.org\n\n\ud83d\udcd6 **Setup and Usage**\n-----------------------\n\nSee the [Documentation](https://pywa.readthedocs.io/) for detailed instructions\n\n\u2611\ufe0f **TODO**\n------------\n\n- ~~Add support for async~~\n- ~~Add support for more web frameworks (Django, aiohttp, etc.)~~\n- ~~Add support for flows~~\n- Add support for more types of updates (``account_alerts``, ``phone_number_quality_updates``, ``template_category_updates``, etc.)\n- Add more examples and guides\n\nFeel free to open an issue if you have any suggestions. or even better - submit a PR!\n\n\u2696\ufe0f **License**\n---------------\n\nThis project is licensed under the MIT License - see the\n[LICENSE](https://github.com/david-lev/pywa/blob/master/LICENSE) file for details\n\n\n\ud83d\udd31 **Contributing**\n--------------------\n\nContributions are welcome! Please see the [Contributing Guide](https://github.com/david-lev/pywa/blob/master/CONTRIBUTING.md) for more information.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python wrapper for the WhatsApp Cloud API",
    "version": "2.7.0",
    "project_urls": {
        "Changelog": "https://github.com/david-lev/pywa/blob/master/CHANGELOG.md",
        "Documentation": "https://pywa.readthedocs.io/",
        "Funding": "https://github.com/sponsors/david-lev",
        "Issue Tracker": "https://github.com/david-lev/pywa/issues",
        "Source Code": "https://github.com/david-lev/pywa"
    },
    "split_keywords": [
        "whatsapp",
        " whatsapp-api",
        " whatsapp-cloud-api",
        " whatsapp-cloud",
        " whatsapp-api-python",
        " whatsapp-cloud-api-python",
        " pywa",
        " wapy",
        " wa",
        " wa-api",
        " wa-cloud-api",
        " wa-cloud",
        " wa-api-python",
        " wa-cloud-api-python",
        " whatsapp-webhook",
        " whatsapp-webhook-python",
        " whatsapp-webhook-api",
        " whatsapp-flows",
        " whatsapp-cloud-api-flows"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3bd6b0cfdc16186b735cd1b72f094722a9ca01618bab61d5c07e76b4e93fc5a2",
                "md5": "6cb2b292465818e6f70d89fb9fc5556c",
                "sha256": "cb58512d862909380da4b9f9ffa60622c94046aca9f4d734aabd6e03acbda57e"
            },
            "downloads": -1,
            "filename": "pywa-2.7.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6cb2b292465818e6f70d89fb9fc5556c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 180038,
            "upload_time": "2025-01-18T19:41:58",
            "upload_time_iso_8601": "2025-01-18T19:41:58.429530Z",
            "url": "https://files.pythonhosted.org/packages/3b/d6/b0cfdc16186b735cd1b72f094722a9ca01618bab61d5c07e76b4e93fc5a2/pywa-2.7.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "48a48a02043af8442804e8a4b43f08182e8530621a513659d5b4329597845190",
                "md5": "71182cb88ac304de1d1da6b7288bec53",
                "sha256": "890bfebda10ef12ab38f5e64a9e420db7fad5d8ccc07dda16f20121e8966e2f6"
            },
            "downloads": -1,
            "filename": "pywa-2.7.0.tar.gz",
            "has_sig": false,
            "md5_digest": "71182cb88ac304de1d1da6b7288bec53",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 184781,
            "upload_time": "2025-01-18T19:42:01",
            "upload_time_iso_8601": "2025-01-18T19:42:01.073740Z",
            "url": "https://files.pythonhosted.org/packages/48/a4/8a02043af8442804e8a4b43f08182e8530621a513659d5b4329597845190/pywa-2.7.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-18 19:42:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "david-lev",
    "github_project": "pywa",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "httpx",
            "specs": [
                [
                    ">=",
                    "0.27.0"
                ]
            ]
        }
    ],
    "lcname": "pywa"
}
        
Elapsed time: 0.41877s