Skip to main content

Open source Python wrapper for the WhatsApp Cloud API

Project description

This is a clone of the original repository: https://github.com/filipporomani/whatsapp

I have removed Flask and uvicorn from dependencies. I will try to mantain this repository up to date with the original one.

logo

whatsapp-python

Free, open-source Python wrapper for the WhatsApp Cloud API.
Forked from Neurotech-HQ/heyoo.

Made in Italy Downloads Monthly Downloads Weekly Downloads

Installation

To install the library you can either use pip (latest release version):

pip install whatsapp-python

You can also install the development GitHub version (always up to date):

git clone https://github.com/yoandresaav/whatsapp-python-cloud-api.git
cd whatsapp
pip install .

If you want to use a local enviroment you can also use hatch:

git clone https://github.com/yoandresaav/whatsapp-python-cloud-api.git
cd whatsapp
pip install hatch
hatch shell

Documentation is available in the wiki section on GitHub.

Why choose this library?

The main reason why I decided to fork the original library is that it uses an old version of the API, it's missing many useful features and it's almost not mantained anymore.

In this fork I added app events (to listen to incoming messages) and implemented an easier way to send/receive messages and media by using the Message object.

I fixed some bugs and added many features, however the library still needs a lot of work to be done even if it's working and usable.

Supported features:

  • Listening to events (messages, media, etc.)
  • Sending messages
  • Marking messages as read
  • Sending Media (images, audio, video and documents)
  • Sending location
  • Sending interactive buttons
  • Sending template messages
  • Parsing messages and media received

Obtaining the WhatsApp API credentials

To use the WhatsApp API you need to create a Facebook Business account and a WhatsApp Business account.

[!TIP]
To create an account, I recommend to follow this video.

Pricing of the API

Whereas using third-party providers of the WhatsApp API can result in monthly fees, using the WhatsApp API^1 offered directly by Facebook is much cheaper, even if the billing documentation is quite difficult to understand.

[!CAUTION]
It is now mandatory to add a credit card to the WhatsApp account (at least for me) in order to use the service. I was even charged a fee for using a non-test phone number (~€1.20), so be careful when using the API! I'm not responsible for any costs you may face by using the API.

All the prices are available in the WhatsApp API docs.

[!TIP]
One recommendation I can give you is to use a test number (you can get a free phone number and use it for testing purposes only).

Migrating from Neurotech-HQ/heyoo

You can ignore this if it's your first time using the library.

  • Any version >1.1.2 is incompatible with the original heyoo library! Be careful updating! Read the docs first!
  • Any version <=1.1.2 is fully compatible with the original heyoo library and doesn't include breaking changes.

Switching from heyoo to whatsapp-python doesn't require any change for versions up to 1.1.2: just uninstall heyoo, install whatsapp-python==1.1.2 and change the import name from heyoo to whatsapp.

For versions GREATER THAN 1.1.2, messages have became objects, so you need to change your code to use the new methods.

[!NOTE]
Documentation for version 1.1.2 can be found here.

Contributing

If you are facing any issues or have any questions, please open a new issue!

This is an open source project published under the MIT License.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

whatsapp_python_cloud_api-3.1.3.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

whatsapp_python_cloud_api-3.1.3-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file whatsapp_python_cloud_api-3.1.3.tar.gz.

File metadata

File hashes

Hashes for whatsapp_python_cloud_api-3.1.3.tar.gz
Algorithm Hash digest
SHA256 bcb10a41b82c073d695e3db81e6afe64614d7302337c73b67f2018a79a1f8571
MD5 a86917cb490f731379cf5a4855cab885
BLAKE2b-256 c8424d276b3d2e8f8c182b3356f58861f5c7e30da789949fe2ee1fa409c0d47c

See more details on using hashes here.

File details

Details for the file whatsapp_python_cloud_api-3.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for whatsapp_python_cloud_api-3.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 74bc217e5138baa9121e7422b1c502159b48d076d77d85c748b7efc960182ad6
MD5 66dc5c659b71c6d580142d7744abdb4d
BLAKE2b-256 961a10a99363753533994d16a9b200ae88510b8faf06182ac81bc8b7fb78bf40

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page