Skip to main content

Integration layer for WhatsApp Cloud API with Firestore for easy message storage and management.

Project description

whatsapp-wrapper

Integration layer for WhatsApp Cloud API with Firestore for easy message storage and management.

WhatsApp Cloud API Python Package

The WhatsAppAPI Python package provides a comprehensive and easy-to-use interface for interacting with WhatsApp's API. This package enables developers to integrate WhatsApp messaging capabilities into their applications effortlessly. From sending texts, images, videos, and documents to handling media files and managing message databases, this package covers a wide range of functionalities to enhance communication solutions.

Some Features

  • Send Messages: Send text messages, images, videos, documents, audio, and stickers.
  • Media Management: Upload and retrieve media files with support for temporary file caching.
  • Database Integration: Optional Firestore database integration to save chats and messages.
  • Custom Error Handling: Implement custom error handling for robust application performance.
  • Message Replies: Reply to messages to maintain context in conversations.
  • URL Previews: Generate previews for URLs in text messages.
  • Message Reactions: Add emoji reactions to messages.

Installation

To install WhatsAppAPI, use pip:

pip install whatsappapi

Quick Start

Setting Up

To get started, import the WhatsAppAPI class from the package and configure it with your mobile ID and API token.

from whatsapp_wrapper import WhatsAppAPI

api = WhatsAppAPI(mobile_id='your_mobile_id', api_token='your_api_token')

Sending a Text Message

Sending a text message is straightforward:

api.send_text(to='recipient_number', message='Hello, World!')

Sending an Image

To send an image:

api.send_image(to='recipient_number', image_id_or_url='image_url', caption='Check this out!')

Saving Messages to Database

If you want to save messages to a Firestore database, you need to provide a DatabaseConfig during initialization:

from whatsapp_wrapper.whatsapp_db import DatabaseConfig

db_config: DatabaseConfig = {
    'credential_path': 'path/to/your/firestore/credential.json',
    'backup_folder': 'path/to/backup/folder'
}

api = WhatsAppAPI(mobile_id='your_mobile_id', api_token='your_api_token', database_config=db_config)

Messages will then be automatically saved to the database.

Handling Errors

You can provide a custom error handler function during initialization to handle API errors according to your application's requirements.

def custom_error_handler(response, data):
    # Custom error handling logic
    pass


api = WhatsAppAPI(mobile_id='your_mobile_id', api_token='your_api_token', error_handler=custom_error_handler)

References

WhatsApp Documentation

Graph API Documentation

Support and Contributions

For support, please open an issue on the project's GitHub page. Contributions are welcome! If you'd like to contribute, please fork the repository and submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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_wrapper-0.1.6.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

whatsapp_wrapper-0.1.6-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file whatsapp_wrapper-0.1.6.tar.gz.

File metadata

  • Download URL: whatsapp_wrapper-0.1.6.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.9

File hashes

Hashes for whatsapp_wrapper-0.1.6.tar.gz
Algorithm Hash digest
SHA256 e3f88e592dc6f3d90556508be7a5900379dd59cd37d94b8f51bd2c54acd16fbb
MD5 b47ddabe8c2527441e61ff44a66d9cf1
BLAKE2b-256 a2645b2517825af8c52996098da65a323c6f6f73da5ad1c4462c1ad652aac00f

See more details on using hashes here.

File details

Details for the file whatsapp_wrapper-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for whatsapp_wrapper-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 4e52340fd1d62653ec3902191cf2de96536bc6eeeace638d1c7c34fd4ddbf878
MD5 db9eeffaaf17fc90f35489fe31c7839c
BLAKE2b-256 445a58b2bfa1768bbf98edf51d79adb8b92d5d55bb53c71d3fe9a7aa38d816f6

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