TrustBeat Python SDK
Qualified electronic timestamps and Merkle anchoring — eIDAS-compliant, over a simple API.
Part of TrustBeat — digital trust infrastructure for the EU. All SDKs (Python, TypeScript, Java, C#, Go): trustbeat.eu/sdks.
Install
pip install trustbeat
Quickstart
from trustbeat import TrustBeat
tb = TrustBeat(api_key="tb_live_...")
# Anchor a file (SHA-256 computed locally, file never leaves your machine).
# anchor_file_wait() blocks until the proof is ready (next batch, up to 11 min).
proof = tb.anchor_file_wait("contract.pdf")
print(proof.id) # tracking ID
print(proof.anchored_at) # ISO 8601 timestamp
print(proof.merkle_root) # Merkle root of the batch
# Verify locally — no network call
assert tb.verify(proof)
# Or anchor a raw SHA-256 hash without blocking, then wait for the proof.
job = tb.anchor("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
print(job.id) # tracking ID, returned immediately (202)
proof = tb.anchor_wait(job.id) # blocks up to 11 min
Tamper-Evident Logs (NIS2)
Anchor a log hash together with canonical metadata for NIS2 Article 21 audit trails. The server seals your metadata into the Merkle leaf, so the proof covers both the log content and its context.
import hashlib
from trustbeat import TrustBeat, LogMetadata, LogSource, LogSourceIdentity, LogTimeEnvelope
tb = TrustBeat(api_key="tb_live_...")
# Hash the log yourself — content never leaves your machine.
with open("app.log", "rb") as f:
log_hash = hashlib.sha256(f.read()).hexdigest()
job = tb.anchor_log(
log_hash,
LogMetadata(
log_source=LogSource(uri="/var/log/app.log", name="Application log"),
source_identity=LogSourceIdentity(hostname="web-01", service_name="payments"),
time_envelope=LogTimeEnvelope(start_at="2026-04-15T00:00:00Z",
end_at="2026-04-15T23:59:59Z"),
),
label="incident-2026-05",
)
print(job.id, job.combined_hash)
# Wait for the qualified anchor (next batch, up to 11 min), then verify locally.
proof = tb.anchor_log_wait(job.id)
assert proof.verification_status == "VERIFIED"
assert tb.verify(proof.proof)
Webhooks
If your account has a webhook secret configured, every delivery is signed with
an X-TrustBeat-Signature header. Verify it with the raw request body —
before any JSON parsing:
from trustbeat import verify_webhook_signature
# e.g. in a Flask/FastAPI handler; body must be the raw bytes as received
if not verify_webhook_signature(raw_body, signature_header, webhook_secret):
raise ValueError("Invalid webhook signature")
Also available as TrustBeat.verify_webhook_signature(...). Rejects replays
older than 5 minutes by default (tolerance_secs to override).
Portable proof bundles for offline verification: export_ai_decision(id),
export_verification(id), export_log(id) — each returns raw JSON bundle bytes.
Requirements
- Python 3.9+
- Zero runtime dependencies (stdlib only)
Documentation
Full API reference and guides at api.trustbeat.eu/docs
License
MIT — see LICENSE
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 trustbeat-0.3.0.tar.gz.
File metadata
- Download URL: trustbeat-0.3.0.tar.gz
- Upload date:
- Size: 29.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53bed030335a07325a6a15f554d71050c487ff2efc30ff0c77acb865f5291660
|
|
| MD5 |
47ab318eae3ab2e5792d0eb34e043b97
|
|
| BLAKE2b-256 |
39ba8ea35e02380c8656cab97fdfbcdac029be95346a7cd7b410dfbdb2167bc4
|
Provenance
The following attestation bundles were made for trustbeat-0.3.0.tar.gz:
Publisher:
publish.yml on TrustBeat/sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
trustbeat-0.3.0.tar.gz -
Subject digest:
53bed030335a07325a6a15f554d71050c487ff2efc30ff0c77acb865f5291660 - Sigstore transparency entry: 2201808091
- Sigstore integration time:
-
Permalink:
TrustBeat/sdk-python@af60d8f197cb4c57c3722f69d3d940acea68101e -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/TrustBeat
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@af60d8f197cb4c57c3722f69d3d940acea68101e -
Trigger Event:
push
-
Statement type:
File details
Details for the file trustbeat-0.3.0-py3-none-any.whl.
File metadata
- Download URL: trustbeat-0.3.0-py3-none-any.whl
- Upload date:
- Size: 21.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc82a921b858883465da72015d4d1d35cc150db16d537441dac23b011585d8c8
|
|
| MD5 |
e593204c172b3ede30b23b527d2e2d0e
|
|
| BLAKE2b-256 |
4902a19d6ac3ae8cddd2119b07979722d3a3670fb6fbca09641335581c44a720
|
Provenance
The following attestation bundles were made for trustbeat-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on TrustBeat/sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
trustbeat-0.3.0-py3-none-any.whl -
Subject digest:
bc82a921b858883465da72015d4d1d35cc150db16d537441dac23b011585d8c8 - Sigstore transparency entry: 2201808153
- Sigstore integration time:
-
Permalink:
TrustBeat/sdk-python@af60d8f197cb4c57c3722f69d3d940acea68101e -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/TrustBeat
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@af60d8f197cb4c57c3722f69d3d940acea68101e -
Trigger Event:
push
-
Statement type: