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
Metadata
Release files for natsio 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| natsio-1.0.1.tar.gz | 126.0 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| natsio-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 275.4 kB
Release files / natsio-1.0.1.tar.gz
| Download URL | natsio-1.0.1.tar.gz |
|---|---|
| Size | 126.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
692a2a36efedaac927dddea3ef657c777fb78bef7d2dc2aa9eb9a31449ad97c1
|
|
BLAKE2b-256 checksum How to use checksums |
0b4e48aefa96f6eb6ca0e59b295c5d4fc94836adc2a2b4d13a77683294226301
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.
Transparency logRelease files / natsio-1.0.1-py3-none-any.whl
| Download URL | natsio-1.0.1-py3-none-any.whl |
|---|---|
| Size | 149.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4b2f3a4a5b9b5d665d3d80f88dbeefbae82cd249fdd3526de4d66b45805ffd14
|
|
BLAKE2b-256 checksum How to use checksums |
e4ef48a999794b3c71a59113bab6f3f10dda4d01ab43a86ea13cea00baf41b86
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.
Transparency logSecurity for natsio 1.0.1
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for natsio-1.0.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.
Transparency logA 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.