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.3.0.tar.gz (9.1 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.3.0-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for wazen-0.3.0.tar.gz
Algorithm Hash digest
SHA256 b21aa35e67fc781bd3c6271d5a228f2f49336a8f24318f83ab5f161f038f31ce
MD5 b9052b8550b1c0a3724502ccd30310af
BLAKE2b-256 b623eaf0b5f56381322bcb6f2b375f6617f209357b7d896bd924589444ed4a0a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: wazen-0.3.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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9df8fe5ca1cc7e87aeff78542aafa0201800b67a34ea08b46bffda45f0c1a63b
MD5 6256282393908a77cbdbc43422888a18
BLAKE2b-256 3b694e1464dbfdd72a7a605a73c33ed3a2e63ebf9aa9f27140da5343ca3d569a

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