natsio
A zero-dependency, pure-asyncio NATS client for modern Python — built from scratch for Python 3.13+ and NATS server 2.14+, with nats.go as the behavioral oracle.
pip install natsio # or: uv add natsio
import asyncio
import natsio
async def main() -> None:
async with await natsio.connect("nats://localhost:4222") as nc:
sub = await nc.subscribe("greet.*")
await nc.publish("greet.world", b"hello")
async for msg in sub:
print(msg.subject, msg.data) # greet.world b'hello'
break
asyncio.run(main())
Why natsio
- Zero runtime dependencies — stdlib only. NKey/JWT auth is the single exception and delegates Ed25519 to an audited external backend (below); natsio ships no cryptography of its own. No C extensions.
- Sans-io protocol core — a buffer-fed pull parser with no asyncio imports, fuzz- and property-tested for chunk-boundary correctness, reused under the in-house WebSocket transport (RFC 6455, also stdlib-only).
- Structured concurrency — a TaskGroup-supervised connection lifecycle; no silent task death, every parked await has a wake path from close.
- Modern JetStream only — the ADR-37 simplified consumer API
(
fetch()/next()/consume(), ordered consumers). No deprecated push/pull-subscribe workflow. Key-Value and Object Store included. - Loud failure — bounded queues with configurable policies; nothing is dropped silently, hostile input is a typed error, reads are digest-verified.
- Fully typed — PEP 695 generics,
py.typed, checked withty.
Across the in-repo benchmark harness natsio leads nats-py on 11 of 13 scenarios and ties the other two — see the benchmarks.
Authentication backends
The core client has no runtime dependencies. NKey and JWT (.creds)
authentication needs Ed25519, which natsio deliberately does not ship:
pip install 'natsio[nkeys]' # PyNaCl (recommended)
pip install 'natsio[cryptography]' # if you already depend on `cryptography`
Either backend produces identical keys and signatures (they are
differential-tested against the reference). If your keys live in a KMS or HSM
you need neither — supply your own signer via CallbackAuth and natsio stays
dependency-free.
Documentation & examples
- Docs: guides, API reference, and design decisions —
https://github.com/corruptmane/natsio (see
docs/). - Examples: a dozen runnable, commented scripts from hello-world pub/sub
through JetStream, KV, Object Store, WebSocket, microservices, and graceful
shutdown — in
examples/. - Migrating from nats-py: side-by-side API mappings, an error-type table,
and an honest list of behavioral differences —
docs/migration-from-nats-py.md.
Extensions
Optional features ship as separate distributions that install into the
natsio namespace (the orbit model):
message schedules, JetStream fast-ingest batch publishing, a $SYS monitoring
client, partitioned consumer groups, distributed counters, KV codecs, NATS CLI
context files, OpenTelemetry, and a test-server manager. See
extensions/.
License
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 natsio-1.0.0.tar.gz.
File metadata
- Download URL: natsio-1.0.0.tar.gz
- Upload date:
- Size: 119.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9e2d42eee9f6a28b6f0e5a18538abac81dcdba854abe8e2de4f30d7f29e5a47
|
|
| MD5 |
41cec867124cf9061d87edbeb541e43e
|
|
| BLAKE2b-256 |
482073fe75fc638cf29053eee145191fa7e28f6cd915c1a5b44b6215e7be05e9
|
Provenance
The following attestation bundles were made for natsio-1.0.0.tar.gz:
Publisher:
release.yml on corruptmane/natsio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
natsio-1.0.0.tar.gz -
Subject digest:
b9e2d42eee9f6a28b6f0e5a18538abac81dcdba854abe8e2de4f30d7f29e5a47 - Sigstore transparency entry: 2224577492
- Sigstore integration time:
-
Permalink:
corruptmane/natsio@91a90acb3582a80edb5b57b9dc167e8237424d61 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/corruptmane
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@91a90acb3582a80edb5b57b9dc167e8237424d61 -
Trigger Event:
push
-
Statement type:
File details
Details for the file natsio-1.0.0-py3-none-any.whl.
File metadata
- Download URL: natsio-1.0.0-py3-none-any.whl
- Upload date:
- Size: 147.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
121d4b893eda3c9a96c6b82c993ff7e94c338899d9b2c4d8907e1604a913f31f
|
|
| MD5 |
32516d80e8b45741ab2dd000552e5c23
|
|
| BLAKE2b-256 |
ba2bbe0889d218f98517716a2e59f68e83a386bfa23774ce365e74e8c8ab5dc0
|
Provenance
The following attestation bundles were made for natsio-1.0.0-py3-none-any.whl:
Publisher:
release.yml on corruptmane/natsio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
natsio-1.0.0-py3-none-any.whl -
Subject digest:
121d4b893eda3c9a96c6b82c993ff7e94c338899d9b2c4d8907e1604a913f31f - Sigstore transparency entry: 2224578251
- Sigstore integration time:
-
Permalink:
corruptmane/natsio@91a90acb3582a80edb5b57b9dc167e8237424d61 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/corruptmane
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@91a90acb3582a80edb5b57b9dc167e8237424d61 -
Trigger Event:
push
-
Statement type: