--- id: nats-py version: "2.15.0" license: Apache-2.0 license_treatment: permissive maintenance: active --- # nats-py — NATS client for Python License: permissive · Maintenance: active · Downloads: 5.5M/mo ## 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 above — 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 pip install nats-py uv add nats-py poetry add nats-py ## Installing 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_current - Install friction: low - Maintenance: active - Downloads: 5.5M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags nats messaging client python, asyncio message broker, distributed messaging python, pub-sub messaging system, jetstream persistent messaging, request-reply pattern, nats async client, async-messaging, distributed-systems, pub-sub [View on SkillFed](https://skillfed.io/packages/nats-py) · [View on PyPI](https://pypi.org/project/nats-py/)