Python client SDK for NornWeave - Inbox-as-a-Service API for AI Agents
Project description
NornWeave Python Client
The NornWeave Python library provides convenient access to the NornWeave APIs from Python.
Table of Contents
Installation
pip install nornweave-client
Or install from source using uv (recommended) or pip:
cd clients/python
# Using uv (recommended)
uv pip install -e .
# Or with pip
pip install -e .
Usage
Instantiate and use the client with the following:
from nornweave_client import NornWeave
client = NornWeave(base_url="http://localhost:8000")
# Create an inbox
inbox = client.inboxes.create(name="Support", email_username="support")
print(f"Created inbox: {inbox.email_address}")
# List inboxes
for inbox in client.inboxes.list():
print(inbox.name)
# Get an inbox
inbox = client.inboxes.get(inbox_id="...")
# Delete an inbox
client.inboxes.delete(inbox_id="...")
# Send a message
response = client.messages.send(
inbox_id="...",
to=["recipient@example.com"],
subject="Hello",
body="This is the message body in **Markdown**."
)
# List messages
for message in client.messages.list(inbox_id="..."):
print(message.content_clean)
# List threads
for thread in client.threads.list(inbox_id="..."):
print(f"{thread.subject} - {thread.message_count} messages")
# Get thread with messages
thread = client.threads.get(thread_id="...")
for msg in thread.messages:
print(f"{msg.role}: {msg.content}")
# Search messages
results = client.search.query(query="invoice", inbox_id="...")
for result in results:
print(result.content_clean)
Async Client
The SDK also exports an async client so that you can make non-blocking calls to our API.
import asyncio
from nornweave_client import AsyncNornWeave
client = AsyncNornWeave(base_url="http://localhost:8000")
async def main() -> None:
inbox = await client.inboxes.create(name="Support", email_username="support")
print(f"Created inbox: {inbox.email_address}")
asyncio.run(main())
Exception Handling
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error will be thrown.
from nornweave_client import ApiError
try:
client.inboxes.get(inbox_id="nonexistent")
except ApiError as e:
print(e.status_code) # 404
print(e.body) # {"detail": "Inbox not found"}
Specific exception types:
NotFoundError- 404 responsesValidationError- 422 responses (invalid request data)RateLimitError- 429 responsesServerError- 5xx responses
Advanced
Access Raw Response Data
The SDK provides access to raw response data, including headers, through the .with_raw_response property.
response = client.inboxes.with_raw_response.create(
name="Support",
email_username="support"
)
print(response.headers) # httpx.Headers
print(response.status_code) # 201
print(response.data) # Inbox object
Retries
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long as the request is deemed retryable and the number of retry attempts has not grown larger than the configured retry limit (default: 2).
A request is deemed retryable when any of the following HTTP status codes is returned:
- 408 (Timeout)
- 429 (Too Many Requests)
- 5XX (Internal Server Errors)
Use the max_retries request option to configure this behavior.
client.inboxes.create(
name="Support",
email_username="support",
request_options={"max_retries": 1}
)
Timeouts
The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
from nornweave_client import NornWeave
# Client-level timeout
client = NornWeave(
base_url="http://localhost:8000",
timeout=20.0,
)
# Request-level timeout override
client.inboxes.create(
name="Support",
email_username="support",
request_options={"timeout": 5.0}
)
Custom Client
You can override the httpx client to customize it for your use-case. Some common use-cases include support for proxies and transports.
import httpx
from nornweave_client import NornWeave
client = NornWeave(
base_url="http://localhost:8000",
httpx_client=httpx.Client(
proxy="http://my.test.proxy.example.com",
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
),
)
For async:
import httpx
from nornweave_client import AsyncNornWeave
client = AsyncNornWeave(
base_url="http://localhost:8000",
httpx_client=httpx.AsyncClient(
proxy="http://my.test.proxy.example.com",
),
)
Pagination
Paginated requests will return a SyncPager or AsyncPager, which can be used as generators for the underlying objects.
# Iterate over all items
for inbox in client.inboxes.list():
print(inbox.name)
# Paginate page-by-page
for page in client.inboxes.list().iter_pages():
print(f"Page with {len(page.items)} items")
for inbox in page.items:
print(inbox.name)
# Async iteration
async for inbox in async_client.inboxes.list():
print(inbox.name)
Releasing
Instruction for Python client developers.
Version Bumping
cd clients/python
# Patch release (0.1.0 → 0.1.1)
uv version patch
# Minor release (0.1.1 → 0.2.0)
uv version minor
# Major release (0.2.0 → 1.0.0)
uv version major
Publishing
-
Bump version and commit:
uv version patch git add pyproject.toml uv.lock git commit -m "chore: release v$(grep '^version' pyproject.toml | cut -d'"' -f2)"
-
Create and push tag:
VERSION=$(grep '^version' pyproject.toml | cut -d'"' -f2) git tag "v$VERSION" git push origin main --tags
-
GitHub Actions automatically publishes to PyPI with attestations.
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
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 nornweave_client-0.1.0.tar.gz.
File metadata
- Download URL: nornweave_client-0.1.0.tar.gz
- Upload date:
- Size: 18.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5ee670828b9554a4429c0627cff3b471e7a3f4533abb1245e3d0a97d921233c
|
|
| MD5 |
00886f11b78eac99fa5ae1fc27e1c6fe
|
|
| BLAKE2b-256 |
6da06523d21669970b33ac9dac7e89ea5bee1a0a3dc0306ad6089b9888b84545
|
Provenance
The following attestation bundles were made for nornweave_client-0.1.0.tar.gz:
Publisher:
release.yml on DataCovey/nornweave
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nornweave_client-0.1.0.tar.gz -
Subject digest:
b5ee670828b9554a4429c0627cff3b471e7a3f4533abb1245e3d0a97d921233c - Sigstore transparency entry: 907064775
- Sigstore integration time:
-
Permalink:
DataCovey/nornweave@b260f911a4c16fb6aefc80cb7b951ebcf17d3a51 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/DataCovey
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b260f911a4c16fb6aefc80cb7b951ebcf17d3a51 -
Trigger Event:
push
-
Statement type:
File details
Details for the file nornweave_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: nornweave_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b623d717ba49d5b4c2e57007a9276c53ae1d8eb4621ab1cae9b0730ec25dbea
|
|
| MD5 |
2493725b2b3dce9b37e215d95510efe3
|
|
| BLAKE2b-256 |
fdbb40711c7f0ac8d03fa03fcdb46ebd67f60f5475f093a1015153bd521c3bab
|
Provenance
The following attestation bundles were made for nornweave_client-0.1.0-py3-none-any.whl:
Publisher:
release.yml on DataCovey/nornweave
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nornweave_client-0.1.0-py3-none-any.whl -
Subject digest:
8b623d717ba49d5b4c2e57007a9276c53ae1d8eb4621ab1cae9b0730ec25dbea - Sigstore transparency entry: 907064835
- Sigstore integration time:
-
Permalink:
DataCovey/nornweave@b260f911a4c16fb6aefc80cb7b951ebcf17d3a51 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/DataCovey
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b260f911a4c16fb6aefc80cb7b951ebcf17d3a51 -
Trigger Event:
push
-
Statement type: