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.2.0.tar.gz (8.9 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.2.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for wazen-0.2.0.tar.gz
Algorithm Hash digest
SHA256 201f72a3ce7c1f0fa8a01703258240a5d3407ce3eced16db1f651a66c252f575
MD5 c4610cd88c5a636d50bc2bf2322d64ff
BLAKE2b-256 7c1b7933514dc66629ab90666a4bd16f4e710a07252417db89aa00611011cf2e

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for wazen-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3ad6f9d3ecb07d6291b29d0c8e41156f74e7f4855e8ecd22eb23901f96864898
MD5 ad9922e3996f7a1220ad9e15236cf451
BLAKE2b-256 33427a6214c648805f1c3417f759ec6b244195c06c0aebaa2bd0cb72f0b77901

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