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_secretis fixed at creation and cannot be changed afterwards.
Development
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clovrix-1.0.0.tar.gz.
File metadata
- Download URL: clovrix-1.0.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d232a31531ea295e663a554f2765b10ae771a1348dea81fd74258880931d7e86
|
|
| MD5 |
1245cb57e7ba5977bcc54084d7c833e8
|
|
| BLAKE2b-256 |
6de8fcb9596861b1609894824e2c5a665b2d8a209774336e7ce249a315acee88
|
Provenance
The following attestation bundles were made for clovrix-1.0.0.tar.gz:
Publisher:
release.yml on clovrix/sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clovrix-1.0.0.tar.gz -
Subject digest:
d232a31531ea295e663a554f2765b10ae771a1348dea81fd74258880931d7e86 - Sigstore transparency entry: 1828848486
- Sigstore integration time:
-
Permalink:
clovrix/sdk@338b81ce835843f38c6cd5c2e332a67bfa983df2 -
Branch / Tag:
refs/tags/python/v1.0.0 - Owner: https://github.com/clovrix
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@338b81ce835843f38c6cd5c2e332a67bfa983df2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file clovrix-1.0.0-py3-none-any.whl.
File metadata
- Download URL: clovrix-1.0.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b6d5f6c4254a4f905ffc9b911fbb2506413237131cf9ad6f117899ba984afba
|
|
| MD5 |
de09dc0105d6da1ca80cdf7abb41356c
|
|
| BLAKE2b-256 |
d34f7556a8d541dee5513643795886eecad9ac265bab162419587f297a339337
|
Provenance
The following attestation bundles were made for clovrix-1.0.0-py3-none-any.whl:
Publisher:
release.yml on clovrix/sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clovrix-1.0.0-py3-none-any.whl -
Subject digest:
8b6d5f6c4254a4f905ffc9b911fbb2506413237131cf9ad6f117899ba984afba - Sigstore transparency entry: 1828848528
- Sigstore integration time:
-
Permalink:
clovrix/sdk@338b81ce835843f38c6cd5c2e332a67bfa983df2 -
Branch / Tag:
refs/tags/python/v1.0.0 - Owner: https://github.com/clovrix
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@338b81ce835843f38c6cd5c2e332a67bfa983df2 -
Trigger Event:
push
-
Statement type: