Skip to main content

Official Python SDK for the Wazen WhatsApp API

Project description

Wazen Python SDK

Official Python SDK for the Wazen WhatsApp API.

PyPI Python

Installation

pip install wazen

Quick Start

from wazen import Wazen

wazen = Wazen("wz_your_api_key")

# Send a message
message = wazen.messages.send("session-id", to="+1234567890", type="text", content="Hello from Wazen!")

# List sessions
sessions = wazen.sessions.list()

# Check if a number is on WhatsApp
result = wazen.contacts.check("session-id", phone="+1234567890")

Async Usage

from wazen import AsyncWazen

wazen = AsyncWazen("wz_your_api_key")

message = await wazen.messages.send("session-id", to="+1234567890", type="text", content="Hello!")

Resources

All resources are accessible as properties on the client instance.

Sessions

wazen.sessions.create()
wazen.sessions.list()
wazen.sessions.get("session-id")
wazen.sessions.delete("session-id")
wazen.sessions.restart("session-id")
wazen.sessions.get_qr("session-id")
wazen.sessions.factory_reset("session-id")

Messages

# Send text
wazen.messages.send("session-id", to="+1234567890", type="text", content="Hello!")

# Send image
wazen.messages.send("session-id", to="+1234567890", type="image", media_url="https://example.com/photo.jpg")

# Get message history
wazen.messages.list("session-id", direction="outgoing", limit=10)

# Get single message
wazen.messages.get("session-id", "message-id")

Groups

wazen.groups.list("session-id")
wazen.groups.create("session-id", subject="Team Chat", participants=["+1234567890"])
wazen.groups.get("session-id", "group-id")
wazen.groups.update("session-id", "group-id", subject="New Name")
wazen.groups.leave("session-id", "group-id")
wazen.groups.manage_participants("session-id", "group-id", action="add", participants=["+0987654321"])
wazen.groups.send_message("session-id", "group-id", type="text", content="Hello group!")

Channels

wazen.channels.create("session-id", name="Product Updates", description="Latest news")
wazen.channels.send_message("session-id", "channel-id", type="text", content="New release!")

Contacts

# Check single number
wazen.contacts.check("session-id", phone="+1234567890")

# Bulk check
wazen.contacts.bulk_check("session-id", phones=["+1234567890", "+0987654321"])

Warming

wazen.warming.start("session-id", contacts=[
    {"phone": "+1234567890", "name": "Alice"},
    {"phone": "+0987654321"},
])
wazen.warming.get_status("session-id")
wazen.warming.pause("session-id")
wazen.warming.resume("session-id")
wazen.warming.cancel("session-id")

Webhooks

wazen.webhooks.create(
    url="https://your-app.com/webhooks/wazen",
    events=["message.received", "message.delivered"],
)
wazen.webhooks.list()
wazen.webhooks.update("webhook-id", enabled=False)
wazen.webhooks.delete("webhook-id")
wazen.webhooks.test("webhook-id")
wazen.webhooks.get_logs("webhook-id")

Account

account = wazen.account.get()
usage = wazen.account.get_usage()

API Keys

key = wazen.api_keys.create(name="new-key")
wazen.api_keys.list()
wazen.api_keys.revoke("key-id")

Configuration

wazen = Wazen(
    "wz_your_api_key",
    base_url="https://wazen.dev/api/v1",  # default
    timeout=30,                            # default, in seconds
)

Error Handling

from wazen import Wazen, WazenApiError

try:
    wazen.messages.send("session-id", to="+1234567890", type="text", content="Hi")
except WazenApiError as e:
    print(e.status_code)  # HTTP status code
    print(e.error_code)   # API error code
    print(e.message)      # Error message

Requirements

  • Python 3.10 or later
  • A Wazen account with an active subscription
  • An API key from your Dashboard

Links

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wazen-0.4.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wazen-0.4.0-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file wazen-0.4.0.tar.gz.

File metadata

  • Download URL: wazen-0.4.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for wazen-0.4.0.tar.gz
Algorithm Hash digest
SHA256 cb4eafe46f1ad55636c7c523bd6fc2bf9921089ac0e70c1c164111deba7f8070
MD5 c1197660ae2155c50e213c44a6ae572f
BLAKE2b-256 3348b0852a36692c2949bbdaf25d8ac3ecf42e0b0cdb0bd00127d1b79e01bb83

See more details on using hashes here.

File details

Details for the file wazen-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: wazen-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for wazen-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3d8efae2e40160104f9c98cc596cde40866d32c7021bb276460a308fa6224f60
MD5 29d2008c601023739cc92bdb5a292cca
BLAKE2b-256 a13db304cd708cac3ac11f2ec67bf2fc2a79f014788464567a4449fca16296ec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page