Skip to main content
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.

Key features:

  • Modern interface using async and await
  • Full support for Graph API error handling
  • Optimized for high-load workflows using asyncronous programming
  • Always up to date
  • All of the WhatsApp chat UI features supported

All features

  • Event listener (incoming messages)
  • Async ready
  • Error handling
  • Sending messages
  • Sending messages from different numbers individually
  • Marking messages as read
  • Replying to messages
  • Reacting to messages
  • Sending medias (images, audios, videos, links 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 API1 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.

  1. https://developers.facebook.com/docs/whatsapp/cloud-api ↩

Release files for whatsapp-python 4.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for whatsapp-python 4.3.0
File Size Uploaded
whatsapp_python-4.3.0.tar.gz 41.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for whatsapp-python 4.3.0
File Interpreter ABI Platform
whatsapp_python-4.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 81.2 kB

Release files / whatsapp_python-4.3.0.tar.gz

Download URL whatsapp_python-4.3.0.tar.gz
Size 41.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e7fb9a255c259bbb357d1b7a05d52ece6fa9bd1b9f6a70c5dd6586d57275ecb5
BLAKE2b-256 checksum
How to use checksums
086268d0b6d4940aa50fc02ed6ca03e6f116b8d75a2891975d5fa6322ddf841d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Release files / whatsapp_python-4.3.0-py3-none-any.whl

Download URL whatsapp_python-4.3.0-py3-none-any.whl
Size 39.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a4568c4f59189cd46bc46a1d7dc8d26e9766366e0dceeaba8a61c9cea455a89f
BLAKE2b-256 checksum
How to use checksums
1435e56dfac516e49d22759018e40d51249e6d697537dbd904fb387a8c237416
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Release history Release notifications | RSS feed

This release

4.3.0 This release

2 release files

4.2.0

2 release files

4.0.2

2 release files

4.0.0

2 release files

3.3.9

2 release files

3.2.5

2 release files

3.1.5

2 release files

3.1.1

2 release files

3.1.0

1 release file

3.0.6

2 release files

3.0.5

1 release file

3.0.4

2 release files

3.0.3

2 release files

3.0.2

1 release file

3.0.1

1 release file

3.0.0

1 release file

2.9.3

1 release file

2.4.3

1 release file

2.3.2

1 release file

2.2.2

1 release file

1.1.2

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page