Python SDK
Overview
A Python client that uses only the standard library (no requests needed). Works on Python 3.7+ and drops into Django, Flask, FastAPI or plain scripts.
Requirements
- Python 3.7 or newer
- Outbound HTTPS to
https://bookbey.com - An API key and active plan
Download
Get it from Client area → Downloads → Python SDK. The zip contains the bookbey_whatsapp package, pyproject.toml, an example and a README.
Installation
pip install . # or copy the bookbey_whatsapp/ folder into your project
Authentication
Every request must carry your API key. Both header forms are accepted — use either one:
Authorization: Bearer YOUR_API_KEY # or X-API-Key: YOUR_API_KEY
Keys are issued per client in Client area → API Keys, are scoped to your account, and are stored only as hashes. Your API base URL is https://bookbey.com/public/api.
Quick start
from bookbey_whatsapp import BookbeyWhatsApp, BookbeyError
wa = BookbeyWhatsApp("YOUR_API_KEY", "https://bookbey.com/public/api")
try:
r = wa.send_text("9198XXXXXXXX", "Hello from BOOKBEY!")
print("sent", r["id"], "remaining", r["remaining"])
except BookbeyError as e:
print(e.code, e.message) Method reference
wa.send_text(to, text) wa.send_image(to, url, caption="") wa.send_document(to, url, filename="", caption="") wa.send_document_data(to, base64_str, filename, caption="") wa.send_template(to, template, params=None, lang="en_US") wa.send(payload) wa.status() wa.verify() # bool
Methods return the API dict and raise BookbeyError (.code, .status, .message) on failure.
Use in Django/Flask
Instantiate once (e.g. in settings or an app module) and reuse. Keep the key in an environment variable, never in source control:
import os from bookbey_whatsapp import BookbeyWhatsApp wa = BookbeyWhatsApp(os.environ["BOOKBEY_KEY"], os.environ["BOOKBEY_API"])
Phone number format
Phone numbers are digits only, in international format without a leading + or spaces — country code followed by the number, e.g. 9198XXXXXXXX for India. Modules that take orders will prefix a configurable default country code to any local number that is missing one.
Status & quota
Check your plan and remaining quota at any time:
curl https://bookbey.com/public/api/status.php -H "X-API-Key: YOUR_API_KEY"
=> {"ok":true,"plan":"Basic","limit":2000,"used":3,"remaining":1997} Error handling
Errors are returned as JSON with ok:false, a machine-readable error code and a human message. The HTTP status reflects the error class.
| HTTP | error code | Meaning & fix |
|---|---|---|
| 401 | unauthorized / invalid_api_key | Key missing, wrong, or revoked. Re-copy it from API Keys. |
| 402 | no_active_plan | No active plan on the account. Buy or renew a plan. |
| 403 | account_suspended | Account suspended. Contact support / clear dues. |
| 422 | invalid_json | Body was not valid JSON. Check Content-Type and payload. |
| 422 | invalid_number | Destination number malformed. Use country code + number, digits only. |
| 429 | quota_exceeded / rate_limited | Monthly quota used up, or sending too fast. Check status.php; retry with backoff. |
| 500 | server_error | Transient server error. Retry; if it persists, contact support. |
Troubleshooting
network_error: host can't reach https://bookbey.com — check egress/proxy (setHTTPS_PROXYif needed).ssl.SSLCertVerificationError: update system CA certs (pip install certifi/ OS cert update).unauthorized: re-copy the key; strip whitespace.
FAQ
Does it need requests? No — urllib only. Async? The calls are blocking; wrap in a thread/executor for async frameworks.
Need help? Open a ticket from Client area → Support. Your API base URL is https://bookbey.com/public/api.