Metadata-Version: 2.4
Name: zaptilo-whatsapp
Version: 1.0.0
Summary: Zaptilo WhatsApp Business API SDK for Python — Send text, media, and template messages via WhatsApp.
Author-email: Zaptilo <connect@zaptilo.ai>
License: MIT
Project-URL: Homepage, https://zaptilo.ai
Project-URL: Documentation, https://zaptilo.ai/developers
Project-URL: Repository, https://github.com/zaptilo/python-whatsapp
Project-URL: Issues, https://github.com/zaptilo/python-whatsapp/issues
Keywords: whatsapp,api,zaptilo,sdk,whatsapp-business,messaging
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Communications :: Chat
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# Zaptilo WhatsApp Business API SDK for Python

Official Python SDK for the [Zaptilo](https://zaptilo.ai) WhatsApp Business API. Send text, media, and template messages via WhatsApp with a simple, clean API.

**Zero dependencies** — uses only Python standard library.

## Installation

```bash
pip install zaptilo-whatsapp
```

**Requirements:** Python 3.7+

## Quick Start

```python
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](https://web.zaptilo.ai) under **Developer Tools > Access Tokens**.

## Usage

### Send Text Message

```python
client.send_message("919876543210", "Hello! Your order has been confirmed.")
```

### Send Template Message

```python
client.send_template(
    number="919876543210",
    template_name="order_update",
    language="en",
    body_values=["John", "Shipped"],
    header_values=["#ORD-1234"],
)
```

### Send Media Message

```python
# 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

```python
result = client.get_templates()

for template in result["data"]:
    print(f"{template['name']} - {template['status']}")
```

### Check Credit Balance

```python
result = client.get_balance()
print(f"Balance: {result['balance']}")
```

### Verify API Token

```python
result = client.verify()
print(result["message"])  # "API key is valid and active"
```

## Error Handling

```python
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

```python
# 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

```python
# 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!")
```

```python
# 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

- [Zaptilo Website](https://zaptilo.ai)
- [API Documentation](https://zaptilo.ai/developers)
- [Dashboard / Sign Up](https://web.zaptilo.ai)
- [Node.js SDK](https://www.npmjs.com/package/zaptilo-whatsapp)
- [PHP SDK](https://packagist.org/packages/zaptilo/whatsapp)

## License

MIT
