Skip to main content

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 with ty.

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

Apache-2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

natsio-1.0.0.tar.gz (119.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

natsio-1.0.0-py3-none-any.whl (147.3 kB view details)

Uploaded Python 3

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

Hashes for natsio-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b9e2d42eee9f6a28b6f0e5a18538abac81dcdba854abe8e2de4f30d7f29e5a47
MD5 41cec867124cf9061d87edbeb541e43e
BLAKE2b-256 482073fe75fc638cf29053eee145191fa7e28f6cd915c1a5b44b6215e7be05e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for natsio-1.0.0.tar.gz:

Publisher: release.yml on corruptmane/natsio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for natsio-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 121d4b893eda3c9a96c6b82c993ff7e94c338899d9b2c4d8907e1604a913f31f
MD5 32516d80e8b45741ab2dd000552e5c23
BLAKE2b-256 ba2bbe0889d218f98517716a2e59f68e83a386bfa23774ce365e74e8c8ab5dc0

See more details on using hashes here.

Provenance

The following attestation bundles were made for natsio-1.0.0-py3-none-any.whl:

Publisher: release.yml on corruptmane/natsio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 files

0.12.0

2 files

0.11.0

2 files

0.10.0

2 files

0.9.0

2 files

0.2.1

2 files

0.2.0

2 files

0.1.0

2 files

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