Skip to main content

Open source Python wrapper for the WhatsApp Cloud API

Project description

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, with the latest features and bug fixes):

git clone https://github.com/filipporomani/whatsapp.git
cd whatsapp
pip install .

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

git clone https://github.com/filipporomani/whatsapp.git
cd whatsapp
pip install hatch
hatch shell

Documentation is available in the wiki here 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 and it's 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. The API version is always up to date and I'm always adding new features and fixing bugs.

I fixed some bugs and added many features, however the library can still be improved.

Supported features:

  • Listening to events (messages, media, etc.)
  • Sending messages
  • Sending messages from different numbers individually
  • Marking messages as read
  • Replying to messages
  • Reacting to messages
  • Sending Media (images, audio, video and documents)
  • Sending location
  • Sending interactive buttons
  • Sending template messages
  • Parsing messages and media received
  • Sending contacts

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 tiny 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.

The API should be, however, free for testing purposes with the provided test phone number.

All the prices are available in the WhatsApp API docs.

[!TIP]
I recomend to use a test number, as you you can get a free one and use it for testing purposes.

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 GNU Affero General Public License v3.

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-4.0.0.post1.tar.gz (32.4 kB view details)

Uploaded Source

Built Distribution

whatsapp_python-4.0.0.post1-py3-none-any.whl (28.3 kB view details)

Uploaded Python 3

File details

Details for the file whatsapp_python-4.0.0.post1.tar.gz.

File metadata

  • Download URL: whatsapp_python-4.0.0.post1.tar.gz
  • Upload date:
  • Size: 32.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for whatsapp_python-4.0.0.post1.tar.gz
Algorithm Hash digest
SHA256 43f693df95406599bcca3a2806ee4ad3b0d7cca4549861cc7c3105c33709717b
MD5 491b18c5a48109244ffd2f81fcc8993f
BLAKE2b-256 c6fece8beae0f6ef371b4ef9be83e7cc228d537a5ea5e92f9059c7bb85455633

See more details on using hashes here.

File details

Details for the file whatsapp_python-4.0.0.post1-py3-none-any.whl.

File metadata

File hashes

Hashes for whatsapp_python-4.0.0.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 8e2009cfcce00aeecfb691efdbc2237748eeaba62f29eda6e2f2756b9f948342
MD5 70982b020598d555e451944756ee7a23
BLAKE2b-256 319b7bb3b6b8b1f0d08c47ddc313b02c1e6367845ff898ab9e669064a5888af9

See more details on using hashes here.

Supported by

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