bq-nats-client
Python gRPC client for the NATS Go daemon. Exposes publish, subscribe, and JetStream operations via a thin async API that mirrors nats.py.
Architecture
Python app ──gRPC (Bearer JWT)──► Go daemon ──NATS──► NATS server
The Go daemon runs as its own deployment and owns the NATS connection. This library only connects to it over gRPC — it does not start or bundle the daemon. On the first call the client authenticates with its api-key, gets a short-lived JWT, and attaches it to every request automatically.
Install
pip install bq-nats-client
Configuration
The client reads these env vars (explicit constructor args take precedence):
| Env | Meaning | Default |
|---|---|---|
BQ_NATS_GRPC_ADDR |
address of the running daemon | localhost:50052 |
BQ_NATS_API_KEY |
api-key the daemon verifies (→ JWT) | — |
BQ_NATS_TLS_CA |
CA cert to verify the daemon's TLS cert | — (plaintext) |
Usage
import asyncio
from nats_client import NATSClient, Msg
async def main():
# grpc_addr + api_key come from env, or pass explicitly:
nc = NATSClient(grpc_addr="localhost:50052", api_key="<prime-api-key>")
# plain publish
await nc.publish("orders.new", b'{"id": 1}')
# JetStream
await nc.jetstream()
ack = await nc.js_publish("orders.new", b'{"id": 2}')
print(f"ack: stream={ack.stream} seq={ack.seq}")
# subscribe
async def on_msg(msg: Msg):
print(f"[{msg.subject}] {msg.data}")
await nc.subscribe("orders.>", cb=on_msg)
await asyncio.sleep(10)
await nc.close()
asyncio.run(main())
API
NATSClient(grpc_addr=None, api_key=None, tls_ca=None)
| Method | Description |
|---|---|
publish(subject, payload, reply, headers) |
Core NATS publish |
jetstream(prefix, domain, timeout) |
Configure JetStream context (call once) |
js_publish(subject, payload, ...) → PubAck |
JetStream publish |
subscribe(subject, cb, queue, ...) → Task |
Subscribe; cb fires per message |
close() |
Cancel subscribers and close gRPC channel |
Requirements
- Go daemon running as a separate process/deployment (
just run, or a compiledgo/distbinary) - NATS server reachable from the daemon
- A valid api-key for the daemon to verify
Metadata
Release files for bq-nats-client 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bq_nats_client-0.1.6.tar.gz | 62.7 kB | Without provenance | Details for bq_nats_client-0.1.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bq_nats_client-0.1.6-py3-none-any.whl | Python 3 | none | any | Details for bq_nats_client-0.1.6-py3-none-any.whl |
Total release size: 73.6 kB
Release files / bq_nats_client-0.1.6.tar.gz
| Download URL | bq_nats_client-0.1.6.tar.gz |
|---|---|
| Size | 62.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
af8b5b493e7ef13ebfba38eafd1afc8af367cb9b1c2a4b76e42004f3f7385f88
|
|
BLAKE2b-256 checksum How to use checksums |
7b760b7dc176e907f61cfbad3322e83ae4e00660c834bf1f576395c1e39ed3c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.22
|
Release files / bq_nats_client-0.1.6-py3-none-any.whl
| Download URL | bq_nats_client-0.1.6-py3-none-any.whl |
|---|---|
| Size | 10.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
af291fda70d2868c4427cf886e461646c8eb7ae69be260e3cc0c3b2daaea8d85
|
|
BLAKE2b-256 checksum How to use checksums |
56e80f8ebf01b9966e6664db01f3986ba1f1b17351b06af732bb30b495ea8812
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.22
|
Security for bq-nats-client 0.1.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.