Skip to main content

Official Python SDK for the Clovrix Public API

Project description

clovrix

Official Python SDK for the Clovrix Public API. Sync and async clients built on httpx, fully typed.

Install

pip install clovrix

Requires Python 3.9+.

Authentication

Create an API token from your organization's Settings → API tokens page, then either pass it to the client or expose it as an environment variable:

export CLOVRIX_TOKEN="icr_xxxxxxxx…"

Resolution order: token= argument → CLOVRIX_TOKEN env var → otherwise a ClovrixConfigError is raised. The host defaults to https://app.clovrix.com; override with base_url= or CLOVRIX_API_URL (scheme + host only — the /api/public/v1 path is added for you).

Usage

from clovrix import Client

clovrix = Client()  # token from CLOVRIX_TOKEN

# Fetch every entry in an environment as a dict.
config = clovrix.get_entries("backend", "production")
print(config["DATABASE_URL"])

# Fetch a single entry (raises NotFoundError if unset).
entry = clovrix.get_entry("backend", "production", "DATABASE_URL")
print(entry.key, entry.value, entry.is_secret)

# Write one entry. is_secret applies only when the key is first created.
result = clovrix.set_entry("backend", "production", "API_KEY", "s3cr3t", is_secret=True)
print(result.created)  # True if newly created, False if a new version

# Write up to 100 entries atomically; returns the number written.
from clovrix import WriteItem

written = clovrix.set_entries("backend", "production", [
    WriteItem(key="FEATURE_X", value="on"),
    {"key": "API_KEY", "value": "s3cr3t", "is_secret": True},  # mappings work too
])

Use it as a context manager to close the underlying HTTP connection pool:

with Client() as clovrix:
    config = clovrix.get_entries("backend", "production")

Load straight into the process environment:

import os
os.environ.update(clovrix.get_entries("backend", "production"))

Async

import asyncio
from clovrix import AsyncClient

async def main():
    async with AsyncClient() as clovrix:
        config = await clovrix.get_entries("backend", "production")
        print(config)

asyncio.run(main())

Configuration

Client(
    token="icr_…",            # default: CLOVRIX_TOKEN
    base_url="https://…",     # default: CLOVRIX_API_URL or https://app.clovrix.com
    timeout=30.0,             # per-request timeout (seconds)
    user_agent="my-app/1.0",
    http_client=my_httpx_client,  # bring your own httpx.Client / httpx.AsyncClient
)

Error handling

Every failed request raises a subclass of ClovrixError. API errors expose .status_code; a billing block also exposes .billing_status.

Exception Cause
ClovrixConfigError Missing token / misconfiguration
ClovrixConnectionError Network failure or timeout (no HTTP response)
AuthenticationError 401 — missing/invalid/expired token
BillingError 402 — billing pending or restricted (.billing_status)
ForbiddenError 403 — token role lacks access
NotFoundError 404 — project/environment/key not found
ValidationError 400 / 413 / 422 — invalid request, nothing written
ServerError 5xx
from clovrix import NotFoundError, BillingError

try:
    entry = clovrix.get_entry("backend", "production", "MAYBE")
except NotFoundError:
    ...  # key isn't set
except BillingError as err:
    print("billing:", err.billing_status)

Limits

  • Keys match ^[A-Z_][A-Z0-9_]*$, max 128 chars.
  • Values are UTF-8 up to 32 KiB.
  • Bulk write ≤ 100 keys (atomic); bulk fetch ≤ 500 entries per project.
  • is_secret is fixed at creation and cannot be changed afterwards.

Development

python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest

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

clovrix-0.1.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

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

clovrix-0.1.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file clovrix-0.1.0.tar.gz.

File metadata

  • Download URL: clovrix-0.1.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for clovrix-0.1.0.tar.gz
Algorithm Hash digest
SHA256 00fcc83edaa0cb2ca77775f216fc39856723f38f7e5a81a79f5d23a6bc505959
MD5 095889ddfa62039a1df3d95e99fc9df1
BLAKE2b-256 e55917d4524d20b52933eca1ced6b0ed5388dc6e9bc9486952970794911e2bec

See more details on using hashes here.

Provenance

The following attestation bundles were made for clovrix-0.1.0.tar.gz:

Publisher: release.yml on clovrix/sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file clovrix-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: clovrix-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for clovrix-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fbef75974d1a96a657c5568adb0a0222a9aae3582d448f1be401b4b0f4911e3d
MD5 f87d50975feee4bfc47e8acb21cfcf63
BLAKE2b-256 977353166506e462955402d870e52cffdd8879ea35d5238599a7c13972342ad1

See more details on using hashes here.

Provenance

The following attestation bundles were made for clovrix-0.1.0-py3-none-any.whl:

Publisher: release.yml on clovrix/sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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