nats-py
NATS client for Python
What it is and what it does
nats-py is an asyncio-native Python client for NATS, a lightweight distributed messaging system. It provides a clean async/await interface for publishing and subscribing to messages across a network, supporting both simple pub-sub patterns and request-reply interactions. The client handles connection management, message routing, and error recovery automatically.
Beyond basic messaging, the package includes JetStream support for persistent message streams, allowing you to store and replay messages, create durable subscribers that survive restarts, and implement ordered consumption with flow control. It also supports TLS encryption, NKEYS authentication, and JWT credentials for secure deployments. With no external runtime dependencies, it installs cleanly into any Python 3.7+ environment.
Use it for:
- Build microservices that communicate asynchronously via pub-sub topics without tight coupling.
- Implement request-reply patterns where one service asks another for data and waits for a response.
- Create persistent message queues using JetStream to ensure messages are not lost if subscribers are temporarily offline.
- Distribute work across multiple workers by publishing tasks to a queue group and letting subscribers process them in parallel.
- Monitor and log events from distributed systems by publishing events to a central NATS server.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
An asyncio Python client for connecting to and messaging through NATS, a distributed messaging system, with support for core pub-sub, request-reply, and JetStream persistence patterns.
Yes. nats-py is actively maintained, has no external dependencies, and provides a straightforward asyncio interface to a mature messaging system. Install it if you need lightweight async messaging, pub-sub distribution, or persistent queues in a distributed architecture. The only prerequisite is access to a NATS server; for learning, the public demo server works, but production requires your own deployment.
Install
nats-py on PyPI
pip
pip install nats-pyuv
uv add nats-pypoetry
poetry add nats-pyInstalling nats-py
Before you install
Low friction: pure Python wheel with no runtime dependencies. Actively maintained with a recent release (70 days ago) and steady commit activity. Supports Python 3.7 through 3.13.
License in practice
Apache-2.0 permissive license allows commercial and private use with minimal restrictions; you must include a copy of the license and note any modifications.
Quickstart
pip install nats-py
import asyncio
import nats
async def main():
nc = await nats.connect("nats://demo.nats.io:4222")
await nc.publish("foo", b'Hello')
await nc.drain()
asyncio.run(main())
Requires a running NATS server to connect to; the example uses a public demo server but production use typically requires your own server instance.
Verify before relying
- Performance characteristics (throughput, latency) under typical production loads.
- Clustering and failover behavior when connecting to multiple NATS servers.
- Memory footprint and resource usage for long-lived connections with high message volume.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 70 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 5,452,904/month — #2,096 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: nats_py-2.15.0-py3-none-any.whl
Tags
More Distributed Computing packages
gRPC Python is an HTTP/2-based RPC framework…
permissive · top 100 on PyPI
execnetexecnet lets you spawn and communicate with…
permissive · top 1,000 on PyPI
cloudpickleCloudpickle extends Python's standard pickle…
permissive · top 1,000 on PyPI
smart-openProvides a unified, open()-compatible Python…
permissive · top 1,000 on PyPI
portalockerPortalocker provides cross-platform file…
permissive · top 1,000 on PyPI
rayRay is a distributed computing framework that…
permissive · top 1,000 on PyPI
gcloud-aio-pubsubAsyncio and threadsafe Python client for Google…
permissive · top 15,000 on PyPI
google-cloud-pubsubPython client library for Google Cloud Pub/Sub,…
permissive · top 1,000 on PyPI
slixmppSlixmpp is an async-first XMPP library for…
permissive · top 15,000 on PyPI
faststreamAn asynchronous Python framework for building…
permissive · top 5,000 on PyPI
solace-pubsubplusSolace Messaging API for Python provides client…
permissive · top 15,000 on PyPI
zulipPython client library for sending and receiving…
permissive · top 15,000 on PyPI
nkeysGenerates, manages, and verifies Ed25519-based…
permissive · top 15,000 on PyPI
nucliadb-telemetryAdds distributed tracing to FastAPI, gRPC, and…
permissive · top 15,000 on PyPI
google-cloud-pubsublitePython client library for Google Cloud Pub/Sub…
permissive · top 5,000 on PyPI
azure-servicebusAzure Service Bus client library for Python…
unclear · top 1,000 on PyPI