Python client (sync + async) for the CertumTree API.
Project description
certum-client
Typed Python client for the CertumTree API with both synchronous and asynchronous support. Built on httpx, it provides a clean, type-safe interface for all endpoints exposed by the CertumTree service.
Features
- ✅ Synchronous (
CertumClient) and asynchronous (AsyncCertumClient) APIs - ✅ Strong typing with PEP 561 (
py.typedincluded) - ✅ Clear error handling (
APIErrorfor server/HTTP issues) - ✅ Built-in blob hash helper (
compute_blob_hash) ensuring correct 16-character hex format - ✅ Service pagination with lazy iterators
- ✅ Easy to extend and integrate
Installation
pip install certum_client
Requires Python 3.8+ and httpx>=0.27.
Quick Start
Synchronous Example
from certum_client import CertumClient, compute_blob_hash
with CertumClient("http://localhost:8000") as c:
c.user_login("alice", "secret")
token = c.register_service("notes", username="alice", password="secret")
# The API expects 16 hex characters (8-byte hash)
h = compute_blob_hash(b"hello world")
c.add_blob("alice.notes", token, h)
print("Root:", c.get_root_hash("alice.notes"))
# Lazy iteration through all services
for svc in c.iter_services("alice", per_page=50):
print(svc.service_name)
Asynchronous Example
import asyncio
from certum_client import AsyncCertumClient, compute_blob_hash
async def main():
async with AsyncCertumClient("http://localhost:8000") as c:
await c.user_login("bob", "p455")
token = await c.register_service("inbox", username="bob", password="p455")
h = compute_blob_hash(b"mail-42")
await c.add_blob("bob.inbox", token, h)
page = await c.list_services("bob", num_results=10)
print(page.total, [s.service_name for s in page.services])
asyncio.run(main())
Endpoints Covered
-
Users
POST /user_signupPOST /user_login
-
Services
POST /register_servicePOST /delete_servicePOST /update_servicePOST /get_root_hashPOST /has_servicePOST /get_service_metadataPOST /list_servicesPOST /get_my_services
-
Tokens & Blobs
POST /get_tokenPOST /add_blobPOST /check_blob
API Overview
Errors
All request failures raise APIError with attributes:
message: human-readable messagestatus: "ERR" or "OK"payload: full JSON payload returned by the server
Blob Hashing
The server requires 16-character hex strings (len == 16), which correspond to 8-byte hashes. Use the included helper:
from certum_client import compute_blob_hash
h = compute_blob_hash(b"hello")
assert len(h) == 16 # Always correct for API
Development
Clone and install locally:
git clone https://github.com/hex358/certum_client.git
cd certum_client
pip install -e .
License
MIT License © 2025 Mike Issakov
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 certum_client-0.1.0.tar.gz.
File metadata
- Download URL: certum_client-0.1.0.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e64226e7132c3c004a8c2383098d7a592a4bdfaf83034e92704fe6132c07d411
|
|
| MD5 |
b4948ae127e8bec29205ced3b3cdec3e
|
|
| BLAKE2b-256 |
fdceafa98ff8e03d123de9c988192e0d2646611011af5fa6eb98757d3a6ce015
|
File details
Details for the file certum_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: certum_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f6777c9cae6fc000b90d58add430b84e879d83c36f07b7eddd69f5733b68e06
|
|
| MD5 |
f5903c6a6d48139c72736eef074d5487
|
|
| BLAKE2b-256 |
c221d7eb54fb3f2d832f3aa3c18c6802c94f6e873d41c0a54d250e2539b14cba
|