Skip to main content

Official Python SDK for OpenWA WhatsApp API Gateway

Project description

rmyndharis-openwa

Official Python SDK for the OpenWA WhatsApp API Gateway.

A synchronous client built on httpx, with bundled type hints (PEP 561).

Install

Not yet published to PyPI. Until the first release, install from a checkout of the repo (cd sdk/python && pip install -e .) or from git.

pip install rmyndharis-openwa   # once published

Requires Python 3.9+. The importable module is openwa.

Usage

from openwa import OpenWAClient

client = OpenWAClient(
    base_url="https://your-gateway.example.com",
    api_key="owa_k1_…",
)

client.sessions.start("my-session")

result = client.messages.send_text("my-session", {
    "chatId": "628123456789@c.us",
    "text": "Hello from the OpenWA Python SDK!",
})
print(result["messageId"])

The client is also a context manager (it closes the underlying connection pool on exit):

with OpenWAClient(base_url="…", api_key="…") as client:
    client.messages.send_text("my-session", {"chatId": "…@c.us", "text": "hi"})

For tests, pass an httpx transport — no global monkey-patching required:

import httpx
client = OpenWAClient(base_url="…", api_key="…", transport=httpx.MockTransport(handler))

Errors

A non-2xx response raises a typed OpenWAApiError subclass — OpenWAAuthError (401), OpenWAForbiddenError (403), OpenWANotFoundError (404), OpenWAConflictError (409), OpenWARateLimitError (429), OpenWANotImplementedError (501) — each carrying .status and the parsed .body. A timeout raises OpenWATimeoutError.

from openwa import OpenWANotFoundError

try:
    client.sessions.get("missing")
except OpenWANotFoundError as e:
    print(e.status)  # 404

Notes

  • Use HTTPS in production — the API key is sent as X-API-Key and is bearer-equivalent.
  • The SDK does not retry, and never follows redirects (so the key is never re-sent to a redirect target). Path segments are percent-encoded; a base-URL path prefix (e.g. behind a reverse proxy) is preserved.
  • Escape hatch for endpoints the SDK does not wrap: client.request(method, path, query=…, body=…).

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

rmyndharis_openwa-0.1.0.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

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

rmyndharis_openwa-0.1.0-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

Details for the file rmyndharis_openwa-0.1.0.tar.gz.

File metadata

  • Download URL: rmyndharis_openwa-0.1.0.tar.gz
  • Upload date:
  • Size: 20.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.16

File hashes

Hashes for rmyndharis_openwa-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1a3190a25cb9924f4b14e58ce3e0bdfedbb7b62d6ccdc694ca916a070f4fbd67
MD5 7a5affd3fa83c074a5894411e0631fd5
BLAKE2b-256 78930dbbb65ea9ff4d078e13d98e0928c5486a14076b6c094e5d69ca9b876620

See more details on using hashes here.

File details

Details for the file rmyndharis_openwa-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for rmyndharis_openwa-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ba92647983d9ddc6eed734f6fe8890919318400b45e24e5a1bb48296d6d5783c
MD5 e7748c13c71645198e16d09bafbf3ee6
BLAKE2b-256 b0af2e0bc22c3fad4d72cf6119d738c9d127d60ccee736c4261e1e24a58b5c4c

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