Zaptilo WhatsApp Business API SDK for Python — Send text, media, and template messages via WhatsApp.
Project description
Zaptilo WhatsApp Business API SDK for Python
Official Python SDK for the Zaptilo WhatsApp Business API. Send text, media, and template messages via WhatsApp with a simple, clean API.
Zero dependencies — uses only Python standard library.
Installation
pip install zaptilo-whatsapp
Requirements: Python 3.7+
Quick Start
from zaptilo_whatsapp import Zaptilo
client = Zaptilo("YOUR_API_TOKEN")
# Send a text message
client.send_message("919876543210", "Hello from Zaptilo!")
Get your API token from the Zaptilo Dashboard under Developer Tools > Access Tokens.
Usage
Send Text Message
client.send_message("919876543210", "Hello! Your order has been confirmed.")
Send Template Message
client.send_template(
number="919876543210",
template_name="order_update",
language="en",
body_values=["John", "Shipped"],
header_values=["#ORD-1234"],
)
Send Media Message
# Send image
client.send_media("919876543210", "https://example.com/photo.jpg", "image", "Check this out!")
# Send document
client.send_media("919876543210", "https://example.com/invoice.pdf", "document", "Your invoice")
# Send video
client.send_media("919876543210", "https://example.com/video.mp4", "video")
List Templates
result = client.get_templates()
for template in result["data"]:
print(f"{template['name']} - {template['status']}")
Check Credit Balance
result = client.get_balance()
print(f"Balance: {result['balance']}")
Verify API Token
result = client.verify()
print(result["message"]) # "API key is valid and active"
Error Handling
from zaptilo_whatsapp import Zaptilo, ZaptiloException
client = Zaptilo("YOUR_API_TOKEN")
try:
client.send_message("919876543210", "Hello!")
except ZaptiloException as e:
print(f"Error: {e}")
print(f"Status code: {e.status_code}")
Configuration
# Custom base URL (for self-hosted or staging)
client = Zaptilo("YOUR_TOKEN", base_url="https://your-domain.com")
# Custom timeout (default: 30 seconds)
client = Zaptilo("YOUR_TOKEN", timeout=60)
API Reference
| Method | Description |
|---|---|
send_message(number, message) |
Send a text message |
send_media(number, media_url, media_type, caption) |
Send image, video, or document |
send_template(number, template_name, language, body_values, header_values) |
Send a template message |
get_templates() |
List all approved templates |
get_balance() |
Get current credit balance |
verify() |
Verify API token and subscription status |
Django / Flask Integration
# Django - settings.py
ZAPTILO_API_TOKEN = os.environ.get("ZAPTILO_API_TOKEN")
# In your view
from zaptilo_whatsapp import Zaptilo
from django.conf import settings
client = Zaptilo(settings.ZAPTILO_API_TOKEN)
client.send_message("919876543210", "Hello from Django!")
# Flask
import os
from zaptilo_whatsapp import Zaptilo
client = Zaptilo(os.environ["ZAPTILO_API_TOKEN"])
@app.route("/notify")
def notify():
client.send_message("919876543210", "Hello from Flask!")
return "Sent!"
Links
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zaptilo_whatsapp-1.0.0.tar.gz.
File metadata
- Download URL: zaptilo_whatsapp-1.0.0.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6dd62f9bf02ed2343a0c2eb32a45732e2a2810f9600bbf7d1e2bd47f235209c0
|
|
| MD5 |
c8e05fccfe452100a4002b333a9c01e2
|
|
| BLAKE2b-256 |
824966b61d007d44063cbc40a9fccd1a49ca54fb23697c8470368c07cdb462ad
|
File details
Details for the file zaptilo_whatsapp-1.0.0-py3-none-any.whl.
File metadata
- Download URL: zaptilo_whatsapp-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
676c7611573db6a70d76bcf42d70218b34143b4f932c8cbea99916dbf90ab7be
|
|
| MD5 |
ae6c7816f15e24d3b4e6cb8fe9fe13b7
|
|
| BLAKE2b-256 |
e1ea8dca8671cfe935b98742903dc0389a7a52f7fcabd803ee1f61a4d638b797
|