rmyndharis-openwa
Official Python SDK for the OpenWA WhatsApp API Gateway.
A synchronous client built on httpx, with bundled type hints (PEP 561).
Install
pip install rmyndharis-openwa
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))
Search
GET /search is wrapped as client.search.search(params). Only q is required;
the rest (sessionId, chatId, direction, type, from, dateFrom,
dateTo, limit, offset) are optional. dateFrom / dateTo are epoch-ms.
The active search provider (built-in DB full-text, or a plugin) answers; if none
is configured the server returns 501.
res = client.search.search({"q": "invoice", "sessionId": "my-session", "limit": 20})
for hit in res["hits"]:
print(hit["snippet"], hit["score"])
Messaging
Voice notes: pass
ptt=Trueinside the body dict tosend_audioto send a real WhatsApp voice note (PTT). Supplyaudio/ogg; codecs=opusaudio for reliable playback; the server defaults the mimetype to that whenpttis set without one.
Errors
A non-2xx response raises a typed OpenWAApiError subclass — OpenWAAuthError (401),
OpenWAForbiddenError (403), OpenWANotFoundError (404), OpenWAConflictError (409),
OpenWARateLimitError (429), OpenWANotImplementedError (501),
OpenWAServiceUnavailableError (503 — the only retryable one) — 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-Keyand 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=…).
Releasing
Publishing to PyPI is done by the
python-sdk-release.yml
workflow, which authenticates with PyPI Trusted Publishing (OIDC). There is
no PyPI token in the workflow or in the repository secrets: PyPI mints a
short-lived credential from the GitHub OIDC token, so nothing long-lived exists
to leak or rotate.
One-time setup, required before the first tag — on pypi.org, open the project's publishing settings and add a GitHub trusted publisher:
- Owner:
rmyndharis - Repository:
OpenWA - Workflow name:
python-sdk-release.yml
There are no repository secrets to add. Until the trusted publisher exists PyPI rejects the upload, so configure it first.
Cutting a release:
- Bump
versioninpyproject.tomland land it onmain. - Tag that commit
py-sdk-v<version>(e.g.py-sdk-v0.4.0) and push the tag. The SDK has its own version line — the monorepo'sv*tags are the app version and never trigger an SDK publish. - The workflow re-runs the test suite, builds the sdist and wheel, and uploads. The artifacts published are the ones those tests passed against.
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rmyndharis_openwa-0.4.0.tar.gz.
File metadata
- Download URL: rmyndharis_openwa-0.4.0.tar.gz
- Upload date:
- Size: 40.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4dfc2dc9a25d87e21c36dca3e7b7a1cb401e911545d89a57ca8267b9e14d310
|
|
| MD5 |
3d495fa093e5c561c61aabea4ff45d0a
|
|
| BLAKE2b-256 |
d51122c518fbb491ed22113ef86bbbc584ed9e9b076a392cf60c49294d88d5ee
|
Provenance
The following attestation bundles were made for rmyndharis_openwa-0.4.0.tar.gz:
Publisher:
python-sdk-release.yml on rmyndharis/OpenWA
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rmyndharis_openwa-0.4.0.tar.gz -
Subject digest:
f4dfc2dc9a25d87e21c36dca3e7b7a1cb401e911545d89a57ca8267b9e14d310 - Sigstore transparency entry: 2474902073
- Sigstore integration time:
-
Permalink:
rmyndharis/OpenWA@d1900772a005d6e5c314e43cc5f2401796e1251d -
Branch / Tag:
refs/tags/py-sdk-v0.4.0 - Owner: https://github.com/rmyndharis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-sdk-release.yml@d1900772a005d6e5c314e43cc5f2401796e1251d -
Trigger Event:
push
-
Statement type:
File details
Details for the file rmyndharis_openwa-0.4.0-py3-none-any.whl.
File metadata
- Download URL: rmyndharis_openwa-0.4.0-py3-none-any.whl
- Upload date:
- Size: 38.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c26c0dc985d1dd0ab9d73dc16402c5e936b9eab3161675217d16a056fa80542f
|
|
| MD5 |
7133fad5b0d4a7314b1a939fae50d4b1
|
|
| BLAKE2b-256 |
a9e50df04ddbc0b682157968008319ea17cc2bb6db2996f04b4ba4366d18a861
|
Provenance
The following attestation bundles were made for rmyndharis_openwa-0.4.0-py3-none-any.whl:
Publisher:
python-sdk-release.yml on rmyndharis/OpenWA
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rmyndharis_openwa-0.4.0-py3-none-any.whl -
Subject digest:
c26c0dc985d1dd0ab9d73dc16402c5e936b9eab3161675217d16a056fa80542f - Sigstore transparency entry: 2474902368
- Sigstore integration time:
-
Permalink:
rmyndharis/OpenWA@d1900772a005d6e5c314e43cc5f2401796e1251d -
Branch / Tag:
refs/tags/py-sdk-v0.4.0 - Owner: https://github.com/rmyndharis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-sdk-release.yml@d1900772a005d6e5c314e43cc5f2401796e1251d -
Trigger Event:
push
-
Statement type: