Skip to main content

A Python package for managing WhatsApp flows, handling encyption and decryption and for handling media download from facebook.

Project description

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.

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_python-0.1.1.tar.gz (3.1 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_python-0.1.1-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file whatsapp_cloud_python-0.1.1.tar.gz.

File metadata

  • Download URL: whatsapp_cloud_python-0.1.1.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for whatsapp_cloud_python-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a79ad310e9e8665f381976559625541fee692a54e8c48156a52a0c46e47d697c
MD5 ecf37036d693214417c2001987dff736
BLAKE2b-256 e2fec4164175fb91fb1e8b434b42d5938ee57026949d7967aaeb08ed61a49198

See more details on using hashes here.

File details

Details for the file whatsapp_cloud_python-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for whatsapp_cloud_python-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3b16ffb2ab208e3db8942258399ca0dfefb39bd3cfdf9f35ad1b96f91a922b9a
MD5 9a29b85dc05715dd064a94c1dd9615c7
BLAKE2b-256 3fc55aec34f5afeb44e408eef012fb9a67338d2ea540216a5aa3b4e8e89d27cc

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