Skip to main content

whatsapp_python

whatsapp_python is a Python package designed to simplify the integration and management of WhatsApp messaging flows. It provides a robust set of features for sending messages, handling media, and ensuring secure communication through encryption.

Features

  • Message Sending: Send text, audio, video, and document messages seamlessly via WhatsApp.
  • Interactive Messages: Handle interactive message types such as location requests and call-to-action (CTA) buttons.
  • Media Management: Download and decrypt WhatsApp media files with ease.
  • Encryption Support: Encrypt and decrypt data to ensure secure communication.

Installation

Install the package using pip:

pip install whatsapp_python

Usage

Sending a Text Message

The following example demonstrates how to send a text message using the WhatsappMessage class:

from whatsapp_python import WhatsappMessage

# Initialize the WhatsappMessage object with your credentials
whatsapp = WhatsappMessage(
    api_token="your_api_token",
    api_version="v15.0",
    whatsapp_phone_id="your_phone_id"
)

# Send a text message
response = whatsapp.send_text_message(
    phone="1234567890",
    message="Hello, World!"
)

# Print the response
print(response)

Decrypting Media

The WhatsappMedia class allows you to download and decrypt media files securely. Here's an example:

from whatsapp_python import WhatsappMedia

# Define media metadata
media_data = {
    "file_name": "example.jpg",
    "media_id": "media_id",
    "cdn_url": "https://cdn.example.com/media",
    "encryption_metadata": {
        "encryption_key": "base64_key",
        "hmac_key": "base64_hmac",
        "iv": "base64_iv",
        "plaintext_hash": "hash",
        "encrypted_hash": "hash"
    }
}

# Initialize the WhatsappMedia object
media = WhatsappMedia(media_data)

# Save the decrypted media to a file
success, message = media.save_media(output_path="output.jpg")

# Print the result
print(message)

Handling Interactive Messages

You can also handle interactive messages such as location requests or CTA buttons. Here's a quick example:

from whatsapp_python import WhatsappInteractive

# Initialize the WhatsappInteractive object
interactive = WhatsappInteractive(
    api_token="your_api_token",
    api_version="v15.0",
    whatsapp_phone_id="your_phone_id"
)

# Send a location request
response = interactive.send_location_request(
    phone="1234567890",
    latitude=37.7749,
    longitude=-122.4194,
    name="San Francisco",
    address="California, USA"
)

# Print the response
print(response)

Documentation

For detailed documentation, including advanced usage and API references, please visit the official documentation.

Contributing

Contributions are welcome! If you'd like to contribute, please fork the repository and submit a pull request. For major changes, please open an issue first to discuss what you would like to change.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Support

If you encounter any issues or have questions, feel free to open an issue on the GitHub repository or contact us at sarthaksnh5@gmail.com.

Metadata

Release files for whatsapp-cloud-python 0.1.1

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-cloud-python 0.1.1
File Size Uploaded Provenance Actions
whatsapp_cloud_python-0.1.1.tar.gz 3.1 kB Without provenance Details for whatsapp_cloud_python-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for whatsapp-cloud-python 0.1.1
File Interpreter ABI Platform Actions
whatsapp_cloud_python-0.1.1-py3-none-any.whl Python 3 none any Details for whatsapp_cloud_python-0.1.1-py3-none-any.whl

Total release size: 6.3 kB

Release files / whatsapp_cloud_python-0.1.1.tar.gz

Download URL whatsapp_cloud_python-0.1.1.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a79ad310e9e8665f381976559625541fee692a54e8c48156a52a0c46e47d697c
BLAKE2b-256 checksum
How to use checksums
e2fec4164175fb91fb1e8b434b42d5938ee57026949d7967aaeb08ed61a49198
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / whatsapp_cloud_python-0.1.1-py3-none-any.whl

Download URL whatsapp_cloud_python-0.1.1-py3-none-any.whl
Size 3.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3b16ffb2ab208e3db8942258399ca0dfefb39bd3cfdf9f35ad1b96f91a922b9a
BLAKE2b-256 checksum
How to use checksums
3fc55aec34f5afeb44e408eef012fb9a67338d2ea540216a5aa3b4e8e89d27cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Security for whatsapp-cloud-python 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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