pywa


Namepywa JSON
Version 1.18.0 PyPI version JSON
download
home_pageNone
SummaryPython wrapper for the WhatsApp Cloud API
upload_time2024-05-02 13:18:18
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 requests requests-toolbelt
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/python-app.yml?label=Tests)
[![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 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)
• [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 ([Flask](https://flask.palletsprojects.com/) in this example) and register callbacks:
> See [Handlers](https://pywa.readthedocs.io/en/latest/content/handlers/overview.html) for more information.

```python
from pywa import WhatsApp, filters
from pywa.types import Message, CallbackButton, Button
from flask import Flask

flask_app = Flask(__name__)
wa = WhatsApp(
    phone_id="1234567890",
    token="xxxxxxx",
    server=flask_app,
    callback_url="https://xyz.ngrok-free.app",
    verify_token="xyz123",
    app_id=123456,
    app_secret="yyyyyy"
)

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

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

flask_app.run()  # Run the flask app to start the server
```

🎛 **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[flask]"
pip3 install -U "pywa[fastapi]"
```

- **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``, ``Starlette``, etc.)
- 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 feel free to submit a Pull Request.

            

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/87/1e/790c29eb4f9770fa790efce9f9b31b314e82f817c010a15ea6060f7530c3/pywa-1.18.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/python-app.yml?label=Tests)\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 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 [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```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 ([Flask](https://flask.palletsprojects.com/) in this example) and register callbacks:\n> See [Handlers](https://pywa.readthedocs.io/en/latest/content/handlers/overview.html) for more information.\n\n```python\nfrom pywa import WhatsApp, filters\nfrom pywa.types import Message, CallbackButton, Button\nfrom flask import Flask\n\nflask_app = Flask(__name__)\nwa = WhatsApp(\n    phone_id=\"1234567890\",\n    token=\"xxxxxxx\",\n    server=flask_app,\n    callback_url=\"https://xyz.ngrok-free.app\",\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: Message):\n    msg.react(\"\ud83d\udc4b\")\n    msg.reply_text(\n        text=f\"Hello {msg.from_user.name}!\",\n        buttons=[\n            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: CallbackButton):\n    clb.reply_text(\"You clicked me!\")\n\nflask_app.run()  # Run the flask app to start the server\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[flask]\"\npip3 install -U \"pywa[fastapi]\"\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``, ``Starlette``, etc.)\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\ud83d\udcdd **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 feel free to submit a Pull Request.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python wrapper for the WhatsApp Cloud API",
    "version": "1.18.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": "1b2faad6ee42f413f65170599d710a81519b275c40538fa95a52826376e1aa59",
                "md5": "0548c10687371a34076001a3f85784b0",
                "sha256": "3d3ad7e3e1548cf417b42688cbae3a58dd89137df3a18dc9439d67671c082e72"
            },
            "downloads": -1,
            "filename": "pywa-1.18.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0548c10687371a34076001a3f85784b0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 102285,
            "upload_time": "2024-05-02T13:18:16",
            "upload_time_iso_8601": "2024-05-02T13:18:16.330264Z",
            "url": "https://files.pythonhosted.org/packages/1b/2f/aad6ee42f413f65170599d710a81519b275c40538fa95a52826376e1aa59/pywa-1.18.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "871e790c29eb4f9770fa790efce9f9b31b314e82f817c010a15ea6060f7530c3",
                "md5": "ee890702a82f35f7c98185b02d37a247",
                "sha256": "96ca964c896bdd5080d9afefeabd77ca19a9426c1d6015620da5d632ad19ca88"
            },
            "downloads": -1,
            "filename": "pywa-1.18.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ee890702a82f35f7c98185b02d37a247",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 108165,
            "upload_time": "2024-05-02T13:18:18",
            "upload_time_iso_8601": "2024-05-02T13:18:18.639974Z",
            "url": "https://files.pythonhosted.org/packages/87/1e/790c29eb4f9770fa790efce9f9b31b314e82f817c010a15ea6060f7530c3/pywa-1.18.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-02 13:18:18",
    "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": "requests",
            "specs": [
                [
                    ">=",
                    "2.31.0"
                ]
            ]
        },
        {
            "name": "requests-toolbelt",
            "specs": [
                [
                    ">=",
                    "1.0.0"
                ]
            ]
        }
    ],
    "lcname": "pywa"
}
        
Elapsed time: 0.24780s