skillfed

nats-py

NATS client for Python

nats-py v2.15.0 5.5M downloads/30d#2,096 on PyPI1,242
Permissive license Apache-2.0 Active released

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-py

uv

uv add nats-py

poetry

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 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

Intended Audience :: DevelopersProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

nats messaging client pythonasyncio message brokerdistributed messaging pythonpub-sub messaging systemjetstream persistent messagingrequest-reply patternnats async client
async-messagingdistributed-systemspub-sub

More Distributed Computing packages