Skip to main content

unsworn (Python SDK)

Write Unsworn handlers in Python. A handler is a plain function, sync or async:

from unsworn import json

def get_user(req, ctx):
    # req.params["id"] is already validated and converted by Unsworn,
    # and ctx["auth"] holds the verified token claims.
    return json({"id": req.params["id"], "name": "Ada"})
# unsworn.toml
[runtimes.python]
extensions = [".py"]
command = "python3 -u -m unsworn.worker"
protocol = "binary"

[[route]]
path = "/users/{id}"
method = "GET"
handler = "src/users.py#get_user"
params = { id = { type = "integer", min = 1 } }

Replies

Return Response
json(value, status=200, headers=None) JSON body
text(value, status=200, headers=None) Text body
body(bytes_or_iterator, status=200, headers=None) Raw bytes, or streamed when given an iterator or async iterator
{"status": 204} No body
next({"tenant": "acme"}) From a before handler: continue, adding context

The request

req has method, path, route, params, query, raw_query, headers (lowercase names), json, text, body (raw bytes), handler, phase, and cancelled (set when Unsworn cancels the request). ctx is a dict with auth (verified claims) and anything before handlers added.

Sync handlers run in a thread pool, so they don't block other requests. print() output goes to stderr, which Unsworn collects into its logs.

Metadata

Release files for unsworn 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for unsworn 0.1.0
File Size Uploaded Provenance Actions
unsworn-0.1.0.tar.gz 6.3 kB Without provenance Details for unsworn-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for unsworn 0.1.0
File Interpreter ABI Platform Actions
unsworn-0.1.0-py3-none-any.whl Python 3 none any Details for unsworn-0.1.0-py3-none-any.whl

Total release size: 13.7 kB

Release files / unsworn-0.1.0.tar.gz

Download URL unsworn-0.1.0.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d5ab71a90400466ce039c5e99d0337cdc02c0a10da73ea954321103ff207c525
BLAKE2b-256 checksum
How to use checksums
8e3e74e90c71a431eef738ffb1f055feb589391a4a256da09a2cc07961b065f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Omarchy","version":"4.5.0","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / unsworn-0.1.0-py3-none-any.whl

Download URL unsworn-0.1.0-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
29a15f9b7357845e79d37ed261c961e3a3f89a8032caeaa52448e6d0643706ee
BLAKE2b-256 checksum
How to use checksums
ad88feac9a5f9853fbb3dee58de11320c2d9d89f8343c2b8d5fb8ef0a3329d3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Omarchy","version":"4.5.0","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for unsworn 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page