Skip to main content

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.

Metadata

Release files for whatsapp-wrapper 0.1.7

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-wrapper 0.1.7
File Size Uploaded
whatsapp_wrapper-0.1.7.tar.gz 14.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for whatsapp-wrapper 0.1.7
File Interpreter ABI Platform
whatsapp_wrapper-0.1.7-py3-none-any.whl Python 3 none any Details

Total release size: 28.4 kB

Release files / whatsapp_wrapper-0.1.7.tar.gz

Download URL whatsapp_wrapper-0.1.7.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7baea1e5538c1072e4829e8ef6b39e2cbf5ffb5bce10c9728490cf84cc4febb8
BLAKE2b-256 checksum
How to use checksums
8534589cdd8e24dcb8872d9c6d7709b86249586067061aada01ab95c96639d0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Release files / whatsapp_wrapper-0.1.7-py3-none-any.whl

Download URL whatsapp_wrapper-0.1.7-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
133d0c4ca5844f5c35c8e5ee4ef805b2292970d56e52fc8b96a095f639003c8f
BLAKE2b-256 checksum
How to use checksums
efe46c8b413752264825382048ac422d9c36957d24c16daf5c463ab25dfb2952
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Release history Release notifications | RSS feed

This release

0.1.7 This release

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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