Skip to main content

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.typed included)
  • ✅ Clear error handling (APIError for 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_signup
    • POST /user_login
  • Services

    • POST /register_service
    • POST /delete_service
    • POST /update_service
    • POST /get_root_hash
    • POST /has_service
    • POST /get_service_metadata
    • POST /list_services
    • POST /get_my_services
  • Tokens & Blobs

    • POST /get_token
    • POST /add_blob
    • POST /check_blob

API Overview

Errors

All request failures raise APIError with attributes:

  • message: human-readable message
  • status: "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


Download files

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

Source Distribution

certum_client-0.1.0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

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

certum_client-0.1.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

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

Hashes for certum_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e64226e7132c3c004a8c2383098d7a592a4bdfaf83034e92704fe6132c07d411
MD5 b4948ae127e8bec29205ced3b3cdec3e
BLAKE2b-256 fdceafa98ff8e03d123de9c988192e0d2646611011af5fa6eb98757d3a6ce015

See more details on using hashes here.

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

Hashes for certum_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8f6777c9cae6fc000b90d58add430b84e879d83c36f07b7eddd69f5733b68e06
MD5 f5903c6a6d48139c72736eef074d5487
BLAKE2b-256 c221d7eb54fb3f2d832f3aa3c18c6802c94f6e873d41c0a54d250e2539b14cba

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