Skip to main content

WhatsApp Business API Python Library

Project description

whatsapp-cloud-api

WhatsApp Cloud API Python Module

The whatsapp-cloud-api Python module provides a simple and convenient way to interact with WhatsApp Cloud API. This module allows you to send various types of messages, including text messages, images, audio, videos, documents, and media messages. It abstracts away the complexity of the API calls and provides easy-to-use methods for sending different types of messages to WhatsApp users.

Installation

You can install the whatsapp-cloud-api module using pip:

pip install whatsapp-cloud-api

Usage

To use the whatsapp-cloud-api module, you need to import it into your Python script and create an instance of the WhatsApp class by providing the required parameters: phone_number_id and bearer_token.

from whatsapp_cloud_api import WhatsApp

phone_number_id = "your_phone_number_id"
bearer_token = "your_bearer_token"

whatsapp = WhatsApp(phone_number_id, bearer_token)

Sending Text Messages

You can send text messages to WhatsApp users using the send_text_message method.

to = "recipient_phone_number"
message = "Hello, this is a text message."

response = whatsapp.send_text_message(to, message)
print(response.json())

Sending Images

You can send images to WhatsApp users using the send_image_message method.

to = "recipient_phone_number"
image_id_or_url = "image_id_or_url"

response = whatsapp.send_image_message(to, image_id_or_url)
print(response.json())

Sending Audio

You can send audio messages to WhatsApp users using the send_audio_message method.

to = "recipient_phone_number"
audio_id_or_url = "audio_id_or_url"

response = whatsapp.send_audio_message(to, audio_id_or_url)
print(response.json())

Sending Videos

You can send videos to WhatsApp users using the send_video_message method.

to = "recipient_phone_number"
video_id_or_url = "video_id_or_url"

response = whatsapp.send_video_message(to, video_id_or_url)
print(response.json())

Sending Documents

You can send documents to WhatsApp users using the send_document_message method.

to = "recipient_phone_number"
document_id_or_url = "document_id_or_url"

response = whatsapp.send_document_message(to, document_id_or_url)
print(response.json())

Sending Media Messages

You can send media messages (such as images, audio, videos, and documents) to WhatsApp users using the send_media_message method.

to = "recipient_phone_number"
media_type = "image"  # Replace with the desired media type
media_id_or_url = "media_id_or_url"

response = whatsapp.send_media_message(to, media_type, media_id_or_url)
print(response.json())

Sending Reactions

You can send reactions to specific messages using the send_react_to_message method.

to = "recipient_phone_number"
reply_to_message_id = "message_id"
emoji = "👍"  # Replace with the desired emoji

response = whatsapp.send_react_to_message(to, reply_to_message_id, emoji)
print(response.json())

Contributing

If you'd like to contribute to the development of this module or report issues, please feel free to submit a pull request or create an issue on the GitHub repository.

License

This module is released under the MIT License.

Disclaimer

This module is not officially affiliated with WhatsApp or Facebook. It's an independent project developed by the community.

Note: Make sure to replace placeholders (your_phone_number_id, your_bearer_token, etc.) with actual values when using the module.

For more detailed information about the methods and classes provided by the whatsapp-cloud-api module, refer to the module's source code or docstrings.

Project details


Download files

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

Source Distribution

whatsapp_cloud_api-0.0.4.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

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

whatsapp_cloud_api-0.0.4-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file whatsapp_cloud_api-0.0.4.tar.gz.

File metadata

  • Download URL: whatsapp_cloud_api-0.0.4.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for whatsapp_cloud_api-0.0.4.tar.gz
Algorithm Hash digest
SHA256 4f718e9717238ae3158366ac0e24f5aa0d9e48c008ebf9fcb5bcbc242f3ca05f
MD5 32925b2bd5de8400c148da183c0d55e8
BLAKE2b-256 da66d8791ee3443731ab92188de14b4a6d9df03fdfb8ff9954c52ae86004cc2c

See more details on using hashes here.

File details

Details for the file whatsapp_cloud_api-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for whatsapp_cloud_api-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 5a82abb153aaf99846df3c288712f7e7c297533409001e45e3f6f7054becc155
MD5 815052a445f6d2d9fc63d49da310f895
BLAKE2b-256 bbaedb4c74e2d8ea8fc061f8ce72efd6f3dffb0fed5be63608115eacb3049ea5

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