Skip to main content

NATS Key-Value

A Python client for the NATS Key-Value store, built on JetStream.

Features

  • Create, update, and delete buckets
  • Put, get, create, update, delete, and purge keys
  • Optimistic concurrency via revisions
  • Per-key history
  • Per-key TTL
  • Watch for changes with key pattern filters
  • List keys and bucket statuses

Installation

pip install nats-key-value

Requires Python 3.13+ and a NATS server with JetStream enabled.

Usage

import asyncio
from nats.client import connect
from nats.jetstream import new as new_jetstream
from nats.key_value import KeyValueConfig, create_or_update_key_value

async def main():
    client = await connect("nats://localhost:4222")
    js = new_jetstream(client)

    kv = await create_or_update_key_value(js, KeyValueConfig(bucket="config"))

    await kv.put("greeting", b"Hello World!")

    entry = await kv.get("greeting")
    print(f"{entry.key} = {entry.value.decode()} (revision {entry.revision})")

    await kv.delete("greeting")

    await client.close()

if __name__ == "__main__":
    asyncio.run(main())

License

MIT

Contributing

Contributions welcome. Submit a Pull Request on GitHub.

Release files for nats-key-value 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nats-key-value 0.1.0
File Size Uploaded
nats_key_value-0.1.0.tar.gz 15.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nats-key-value 0.1.0
File Interpreter ABI Platform
nats_key_value-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 24.1 kB

Release files / nats_key_value-0.1.0.tar.gz

Download URL nats_key_value-0.1.0.tar.gz
Size 15.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1c4a3adfc213815748c6c9191b5711b827584b994bce9d76689b8eb4052d85ba
BLAKE2b-256 checksum
How to use checksums
f626007ab728767a4d465e54c31602b2fc1900a92c24e9954a4446b07079f0dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / nats_key_value-0.1.0-py3-none-any.whl

Download URL nats_key_value-0.1.0-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
342ff16400de934a96c14c4024ef3548cd665342185f73abf67d3778748b9d0f
BLAKE2b-256 checksum
How to use checksums
b2c6e4730da7a83f8857832335ea46c4e459b5379c79ad3ac943c2d94f0cb52d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.0

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