Metadata-Version: 2.1
Name: natsio
Version: 0.2.1
Summary: NATS client for Python
Project-URL: Homepage, https://github.com/corruptmane/natsio
Project-URL: Repository, https://github.com/corruptmane/natsio
Author-email: Corrupt Mane <corruptmane@gmail.com>
Maintainer-email: Corrupt Mane <corruptmane@gmail.com>
License-Expression: MIT
License-File: LICENSE
Keywords: asyncio,client,nats,nats-client,nats-python,nats.io
Classifier: Development Status :: 1 - Planning
Classifier: Environment :: Console
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# natsio – Modern Python client for NATS

---

## Basic usage

```python
import asyncio

from natsio.client import NATSCore, ClientConfig
from natsio.messages import CoreMsg


async def callback(msg: CoreMsg) -> None:
    text = f"Received message from {msg.subject}: {msg.payload}"
    if msg.headers:
        text += f" with headers: {msg.headers}"
    print(text)
    if msg.reply_to:
        await msg.reply(b"OK")


async def main() -> None:
    config = ClientConfig(servers=["nats://localhost:4222"])

    async with NATSCore(config) as client:
        sub = await client.subscribe("foo.>", callback=callback)
        await sub.unsubscribe(max_msgs=3) # Automatically unsubscribe after 3 messages

        await client.publish("foo.bar", b"Hello, World!", reply_to="foo.bar.reply")
        await client.publish("foo.baz", b"Hello, World!", headers={"x": "y"})

        await asyncio.Future()


def run() -> None:
    asyncio.run(main())


if __name__ == "__main__":
    run()
```

---

## Installation

```bash
pip install natsio
```
