Skip to main content

Python SDK for PetBox — config client (ETag-aware polling) and a Data-module client (raw parameterized SQL pass-through).

Project description

petbox-client (Python)

Sync, zero-dependency Python SDK for PetBox config. Fetches resolved config from /v1/conf with ETag-aware background polling. Supports all four response templates (flat, dotnet, envvar, envvar-deep).

This is the Python analog of the TypeScript SDK @stdray-npm/petbox-client. Data + Log surfaces land later, matching the TS roadmap.

Install

pip install petbox-client

Usage

import os
from petbox_client import PetBoxConfigClient, PetBoxConfigClientOptions

client = PetBoxConfigClient(PetBoxConfigClientOptions(
    endpoint="https://petbox.3po.su",
    api_key=os.environ["PETBOX_API_KEY"],
    tags={"env": "prod", "project": "kpvotes"},
))

# Initial fetch + start background polling.
config = client.start()
print(config.get("db.host"))
print(config.get_number("db.port"))
print(config.get_bool("features.cache"))

# React to live config changes.
client.on("change", lambda cfg: print("config updated", cfg.data))
client.on("error", lambda err: print("poll failed", err))

# Stop polling when done (or use the client as a context manager).
client.dispose()

One-shot fetch without keeping an instance:

from petbox_client import fetch_config, PetBoxConfigClientOptions

config = fetch_config(PetBoxConfigClientOptions(
    endpoint="https://petbox.3po.su",
    api_key="...",
    tags={"env": "prod"},
    refresh_interval=0,  # disable polling
))

API

  • PetBoxConfigClient(options)fetch(), start(), stop(), dispose(), on(event, listener) / off(...) for "change" and "error", current property.
  • ResolvedConfigget(path), get_number(path), get_bool(path), get_json(path), to_env(), data, etag. For the flat template get("db.host") traverses the nested tree; for the other templates it does a direct key lookup.
  • fetch_config(options) — one-shot convenience.
  • PetBoxConfigError — structured API error with status and body.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

petbox_client-0.1.0.dev325.tar.gz (37.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

petbox_client-0.1.0.dev325-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file petbox_client-0.1.0.dev325.tar.gz.

File metadata

  • Download URL: petbox_client-0.1.0.dev325.tar.gz
  • Upload date:
  • Size: 37.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for petbox_client-0.1.0.dev325.tar.gz
Algorithm Hash digest
SHA256 e5a713ffe71682fb3e575c8484d53dbc89b62296786cbda74e2d129e3aa1b937
MD5 ea6f37fe96f5ac3a6ed9b15270f0bdcd
BLAKE2b-256 17ad24acb81d04f66be65841b9827f4e0ef47f0271da674d8994a042ea98bd67

See more details on using hashes here.

File details

Details for the file petbox_client-0.1.0.dev325-py3-none-any.whl.

File metadata

  • Download URL: petbox_client-0.1.0.dev325-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for petbox_client-0.1.0.dev325-py3-none-any.whl
Algorithm Hash digest
SHA256 f9f0dea25a9c62b4eb3dc08761f07a3cc394bc3a295b31354affba9cba44ff8f
MD5 8691ad446dcf7bb6c8d9dcf3aac78389
BLAKE2b-256 8e1f42c17282d3b436e20d2dec00da7a00c6787b13c25acab7a4e2bace33f17f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page