wa-me


Namewa-me JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/leandcesar/wa_me
SummaryA modern, easy to use, feature-rich ready API wrapper for WhatsApp Business Cloud written in Python
upload_time2022-12-26 00:21:46
maintainer
docs_urlNone
authorLeandro César Cassimiro
requires_python>=3.6
licenseMIT license
keywords whatsapp
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            =====
wa_me
=====

A modern, easy to use, feature-rich ready API wrapper for `WhatsApp Business Cloud`_ written in Python.


* Documentation: https://leandcesar.github.io/wa_me/
* GitHub: https://github.com/leandcesar/wa_me/
* PyPI: https://pypi.org/project/wa_me/
* Free and open source software: MIT license


Features
--------

* Full `Send Messages`_ Support (text, audio, contacts, documents, images, interactive, location, sticker, and videos)
* Full `Webhook Notification`_ Parsing Support

Installing
----------

Stable release
~~~~~~~~~~~~~~

To install wa_me, run this command in your terminal:

.. code-block:: console

    $ pip install wa_me

This is the preferred method to install wa_me, as it will always install the most recent stable release.

If you don't have `pip`_ installed, this `Python installation guide`_ can guide
you through the process.

From sources
~~~~~~~~~~~~

The sources for wa_me can be downloaded from the `Github repo`_.

You can either clone the public repository:

.. code-block:: console

    $ git clone git://github.com/leandcesar/wa_me

Or download the `tarball`_:

.. code-block:: console

    $ curl -OJL https://github.com/leandcesar/wa_me/tarball/master

Once you have a copy of the source, you can install it with:

.. code-block:: console

    $ python setup.py install

Quick Example
-------------

Mirror Bot
~~~~~~~~~~

.. code:: py

    from wa_me import Bot, Ctx

    class MirrorBot(Bot):
        def before_event_message(self, ctx: Ctx):
            ctx.read()

        def on_event_message_audio(self, ctx: Ctx):
            ctx.send_audio(ctx.message.audio.id)

        def on_event_message_document(self, ctx: Ctx):
            ctx.send_document(
                ctx.message.document.id,
                caption=ctx.message.document.caption,
            )

        def on_event_message_image(self, ctx: Ctx):
            ctx.send_image(
                ctx.message.image.id,
                caption=ctx.message.image.caption,
            )

        def on_event_message_location(self, ctx: Ctx):
            ctx.send_location(
                latitude=ctx.message.location.latitude,
                longitude=ctx.message.location.longitude,
                address=ctx.message.location.address,
                name=ctx.message.location.name,
            )

        def on_event_message_sticker(self, ctx: Ctx):
            ctx.send_sticker(ctx.message.sticker.id)

        def on_event_message_text(self, ctx: Ctx):
            ctx.send_text(ctx.message.text.body)

        def on_event_message_video(self, ctx: Ctx):
            ctx.send_video(
                ctx.message.video.id,
                caption=ctx.message.video.caption,
            )

Run using Flask
~~~~~~~~~~~~~~~

.. code:: py

    from flask import Flask, request
    from wa_me import Bot

    app = Flask(__name__)
    bot = Bot()
    bot.start(phone_id="PHONE_ID", token="ACCESS_TOKEN")

    @app.get("/")
    async def ping():
        if request.args.get("hub.verify_token") == "VERIFY_TOKEN":
            return request.args.get("hub.challenge")
        return "Invalid verify token"

    @app.post("/")
    def root():
        data = request.get_json()
        bot.handle(data)
        return "Success"

Run using Fast API
~~~~~~~~~~~~~~~~~~

.. code:: py

    from fastapi import FastAPI, Request
    from wa_me import Bot

    app = FastAPI()
    bot = Bot()
    bot.start(phone_id="PHONE_ID", token="ACCESS_TOKEN")

    @app.get("/")
    async def ping(
        token: str = Query(alias="hub.verify_token"),
        challenge: str = Query(alias="hub.challenge"),
    ):
        if token == VERIFY_TOKEN:
            return challenge
        return "Invalid verify token"

    @app.post("/")
    async def root(request: Request):
        data = await request.json()
        bot.handle(data)
        return "Success"

Useful Links
------------

* `Get Started with the WhatsApp Business Cloud API`_

Credits
-------

This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.


.. _`WhatsApp Business Cloud`: https://developers.facebook.com/docs/whatsapp/cloud-api
.. _`Send Messages`: https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages
.. _`Webhook Notification`: https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components
.. _`pip`: https://pip.pypa.io
.. _`Python installation guide`: http://docs.python-guide.org/en/latest/starting/installation/
.. _`Github repo`: https://github.com/leandcesar/wa_me
.. _`tarball`: https://github.com/leandcesar/wa_me/tarball/master
.. _`Get Started with the WhatsApp Business Cloud API`: https://developers.facebook.com/docs/whatsapp/cloud-api/get-started
.. _`Cookiecutter`: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage


=======
History
=======

0.1.0 (2022-12-25)
------------------

* First release on PyPI.
* Implement data classes and converters with dacite.
* Implement HTTP and Client.
* Implement Bot and Ctx.
* Implement TTLDict.
* Implement Routine.
* Add docs.
* Add examples.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/leandcesar/wa_me",
    "name": "wa-me",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "whatsapp",
    "author": "Leandro C\u00e9sar Cassimiro",
    "author_email": "ccleandroc@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e0/c3/81709ce6e68f93fec4f90d5c0d1988658a2e3b0880e859753a965a4a7ee8/wa_me-0.1.0.tar.gz",
    "platform": null,
    "description": "=====\nwa_me\n=====\n\nA modern, easy to use, feature-rich ready API wrapper for `WhatsApp Business Cloud`_ written in Python.\n\n\n* Documentation: https://leandcesar.github.io/wa_me/\n* GitHub: https://github.com/leandcesar/wa_me/\n* PyPI: https://pypi.org/project/wa_me/\n* Free and open source software: MIT license\n\n\nFeatures\n--------\n\n* Full `Send Messages`_ Support (text, audio, contacts, documents, images, interactive, location, sticker, and videos)\n* Full `Webhook Notification`_ Parsing Support\n\nInstalling\n----------\n\nStable release\n~~~~~~~~~~~~~~\n\nTo install wa_me, run this command in your terminal:\n\n.. code-block:: console\n\n    $ pip install wa_me\n\nThis is the preferred method to install wa_me, as it will always install the most recent stable release.\n\nIf you don't have `pip`_ installed, this `Python installation guide`_ can guide\nyou through the process.\n\nFrom sources\n~~~~~~~~~~~~\n\nThe sources for wa_me can be downloaded from the `Github repo`_.\n\nYou can either clone the public repository:\n\n.. code-block:: console\n\n    $ git clone git://github.com/leandcesar/wa_me\n\nOr download the `tarball`_:\n\n.. code-block:: console\n\n    $ curl -OJL https://github.com/leandcesar/wa_me/tarball/master\n\nOnce you have a copy of the source, you can install it with:\n\n.. code-block:: console\n\n    $ python setup.py install\n\nQuick Example\n-------------\n\nMirror Bot\n~~~~~~~~~~\n\n.. code:: py\n\n    from wa_me import Bot, Ctx\n\n    class MirrorBot(Bot):\n        def before_event_message(self, ctx: Ctx):\n            ctx.read()\n\n        def on_event_message_audio(self, ctx: Ctx):\n            ctx.send_audio(ctx.message.audio.id)\n\n        def on_event_message_document(self, ctx: Ctx):\n            ctx.send_document(\n                ctx.message.document.id,\n                caption=ctx.message.document.caption,\n            )\n\n        def on_event_message_image(self, ctx: Ctx):\n            ctx.send_image(\n                ctx.message.image.id,\n                caption=ctx.message.image.caption,\n            )\n\n        def on_event_message_location(self, ctx: Ctx):\n            ctx.send_location(\n                latitude=ctx.message.location.latitude,\n                longitude=ctx.message.location.longitude,\n                address=ctx.message.location.address,\n                name=ctx.message.location.name,\n            )\n\n        def on_event_message_sticker(self, ctx: Ctx):\n            ctx.send_sticker(ctx.message.sticker.id)\n\n        def on_event_message_text(self, ctx: Ctx):\n            ctx.send_text(ctx.message.text.body)\n\n        def on_event_message_video(self, ctx: Ctx):\n            ctx.send_video(\n                ctx.message.video.id,\n                caption=ctx.message.video.caption,\n            )\n\nRun using Flask\n~~~~~~~~~~~~~~~\n\n.. code:: py\n\n    from flask import Flask, request\n    from wa_me import Bot\n\n    app = Flask(__name__)\n    bot = Bot()\n    bot.start(phone_id=\"PHONE_ID\", token=\"ACCESS_TOKEN\")\n\n    @app.get(\"/\")\n    async def ping():\n        if request.args.get(\"hub.verify_token\") == \"VERIFY_TOKEN\":\n            return request.args.get(\"hub.challenge\")\n        return \"Invalid verify token\"\n\n    @app.post(\"/\")\n    def root():\n        data = request.get_json()\n        bot.handle(data)\n        return \"Success\"\n\nRun using Fast API\n~~~~~~~~~~~~~~~~~~\n\n.. code:: py\n\n    from fastapi import FastAPI, Request\n    from wa_me import Bot\n\n    app = FastAPI()\n    bot = Bot()\n    bot.start(phone_id=\"PHONE_ID\", token=\"ACCESS_TOKEN\")\n\n    @app.get(\"/\")\n    async def ping(\n        token: str = Query(alias=\"hub.verify_token\"),\n        challenge: str = Query(alias=\"hub.challenge\"),\n    ):\n        if token == VERIFY_TOKEN:\n            return challenge\n        return \"Invalid verify token\"\n\n    @app.post(\"/\")\n    async def root(request: Request):\n        data = await request.json()\n        bot.handle(data)\n        return \"Success\"\n\nUseful Links\n------------\n\n* `Get Started with the WhatsApp Business Cloud API`_\n\nCredits\n-------\n\nThis package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.\n\n\n.. _`WhatsApp Business Cloud`: https://developers.facebook.com/docs/whatsapp/cloud-api\n.. _`Send Messages`: https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages\n.. _`Webhook Notification`: https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components\n.. _`pip`: https://pip.pypa.io\n.. _`Python installation guide`: http://docs.python-guide.org/en/latest/starting/installation/\n.. _`Github repo`: https://github.com/leandcesar/wa_me\n.. _`tarball`: https://github.com/leandcesar/wa_me/tarball/master\n.. _`Get Started with the WhatsApp Business Cloud API`: https://developers.facebook.com/docs/whatsapp/cloud-api/get-started\n.. _`Cookiecutter`: https://github.com/audreyr/cookiecutter\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n\n\n=======\nHistory\n=======\n\n0.1.0 (2022-12-25)\n------------------\n\n* First release on PyPI.\n* Implement data classes and converters with dacite.\n* Implement HTTP and Client.\n* Implement Bot and Ctx.\n* Implement TTLDict.\n* Implement Routine.\n* Add docs.\n* Add examples.\n\n\n",
    "bugtrack_url": null,
    "license": "MIT license",
    "summary": "A modern, easy to use, feature-rich ready API wrapper for WhatsApp Business Cloud written in Python",
    "version": "0.1.0",
    "split_keywords": [
        "whatsapp"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "e209a23ee4def908a2611c916c2df872",
                "sha256": "3fc1d653153f9a14bb505439737c2030f799a6f9797d068cd62d8c4820703a97"
            },
            "downloads": -1,
            "filename": "wa_me-0.1.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e209a23ee4def908a2611c916c2df872",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.6",
            "size": 3947,
            "upload_time": "2022-12-26T00:21:43",
            "upload_time_iso_8601": "2022-12-26T00:21:43.333837Z",
            "url": "https://files.pythonhosted.org/packages/c1/b2/4e5adb2bf1e18621968b53e5eb2e03f9cb6e0fe42c0d189e99d5ded341ab/wa_me-0.1.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "e5a71fe35a1fb3d0861f69b243b2d6b2",
                "sha256": "deaa5a82076d9873849c73e5db94303ebc6c9288b468a308bde8f9b2e9ec0358"
            },
            "downloads": -1,
            "filename": "wa_me-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "e5a71fe35a1fb3d0861f69b243b2d6b2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 71018,
            "upload_time": "2022-12-26T00:21:46",
            "upload_time_iso_8601": "2022-12-26T00:21:46.003472Z",
            "url": "https://files.pythonhosted.org/packages/e0/c3/81709ce6e68f93fec4f90d5c0d1988658a2e3b0880e859753a965a4a7ee8/wa_me-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-26 00:21:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "leandcesar",
    "github_project": "wa_me",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "wa-me"
}
        
Elapsed time: 0.02829s