BOOKBEYWhatsApp API

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.

HTTPerror codeMeaning & fix
401unauthorized / invalid_api_keyKey missing, wrong, or revoked. Re-copy it from API Keys.
402no_active_planNo active plan on the account. Buy or renew a plan.
403account_suspendedAccount suspended. Contact support / clear dues.
422invalid_jsonBody was not valid JSON. Check Content-Type and payload.
422invalid_numberDestination number malformed. Use country code + number, digits only.
429quota_exceeded / rate_limitedMonthly quota used up, or sending too fast. Check status.php; retry with backoff.
500server_errorTransient server error. Retry; if it persists, contact support.

Troubleshooting

  • network_error: host can't reach https://bookbey.com — check egress/proxy (set HTTPS_PROXY if 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.