Zecto Python SDK
The official Python client for the Zecto messaging API.
Install
pip install zecto
Requires Python 3.9 or newer.
Quick start
from zecto import ZectoClient
with ZectoClient(api_key="YOUR_API_KEY") as client:
client.whatsapp.messages.send_text(
phone_number_id="YOUR_PHONE_NUMBER_ID",
to="923001234567",
body="Hello from Zecto",
)
Create an API key in the Zecto dashboard. Keep it on your server and never ship it in browser or mobile code.
Async
import asyncio
from zecto import AsyncZectoClient
async def main():
async with AsyncZectoClient(api_key="YOUR_API_KEY") as client:
numbers = await client.whatsapp.numbers.list()
print(numbers)
asyncio.run(main())
Every method on ZectoClient has the same name and arguments on AsyncZectoClient.
Messages
wa = client.whatsapp
wa.messages.send_text(phone_number_id, to, "Hi there")
wa.messages.send_image(phone_number_id, to, link="https://example.com/photo.jpg", caption="Our new menu")
wa.messages.send_document(phone_number_id, to, link="https://example.com/invoice.pdf", filename="invoice.pdf")
wa.messages.send_location(phone_number_id, to, latitude=24.8607, longitude=67.0011, name="Head office")
wa.messages.send_buttons(phone_number_id, to, body="Confirm your order?", buttons=["Yes", "No"])
wa.messages.send_cta_url(
phone_number_id, to,
body="Track your parcel",
display_text="Open tracking",
url="https://example.com/track/123",
)
wa.messages.mark_read(phone_number_id, message_id)
wa.messages.list(phone_number_id=phone_number_id, status="delivered", limit=20)
wa.messages.get(message_id)
Also available: send_video, send_audio, send_contacts, send_list, and send(payload) for a raw payload.
Templates
wa.templates.list(status="APPROVED")
# Shows which variables a template needs
wa.templates.example_config(template_id)
wa.messages.send_template(
phone_number_id, to,
template_id=template_id,
body=["Ali", "ORD-1042"],
)
Numbers, account and flows
wa.numbers.list()
wa.numbers.get(phone_number_id)
wa.account.get()
wa.flows.list()
wa.flows.trigger(flow_id, to="923001234567")
wa.flows.set_status(flow_id, "published") # draft, published or paused
wa.flows.rename(flow_id, "Welcome flow")
Errors
Every error raised by the SDK is a subclass of zecto.ZectoError.
from zecto import ZectoError, AuthenticationError, RateLimitError
try:
wa.messages.send_text(phone_number_id, to, "Hi")
except AuthenticationError:
print("Check your API key")
except RateLimitError:
print("Slow down and retry later")
except ZectoError as e:
print(e)
| Status | Exception |
|---|---|
| 400, 422 | ValidationError |
| 401 | AuthenticationError |
| 403 | PermissionDeniedError |
| 404 | NotFoundError |
| 409 | ConflictError |
| 429 | RateLimitError |
| 502 | UpstreamError |
| other 5xx | ServerError |
| network failure | APIConnectionError |
API errors carry status_code, detail and the raw response body.
Options
ZectoClient(
api_key="YOUR_API_KEY",
timeout=30.0, # seconds
)
License
MIT
Metadata
Release files for zecto 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| zecto-0.1.0.tar.gz | 8.6 kB | Without provenance | Details for zecto-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| zecto-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for zecto-0.1.0-py3-none-any.whl |
Total release size: 21.2 kB
Release files / zecto-0.1.0.tar.gz
| Download URL | zecto-0.1.0.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
11e3b8f857573379324688e6dc331fcac8fd9d5a7c2fb4989e4e936871fa59b3
|
|
BLAKE2b-256 checksum How to use checksums |
60532e79b1961855bf60fa2da9036736b3661fbca75e2cc7d02afc6948a1fca7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Release files / zecto-0.1.0-py3-none-any.whl
| Download URL | zecto-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
48042694b7d9a0344411d89f2a8315c8833482b9702fa65993ef303da707c61a
|
|
BLAKE2b-256 checksum How to use checksums |
e3fe3d47475d89b8fc5a8691921884e09a805e8d3cd7e868e9058f87a4987da9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Security for zecto 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.