Skip to main content

Apphelm Python SDK

The official Python client for Apphelm, for server-side code: product events, identify, fail-closed feature flags, error and message reporting, cron check-ins and tracing. One module, standard library only, Python 3.10 or later.

pip install apphelm

Use a server API key (ahl_…) from your Apphelm workspace and keep it secret. Never ship it in a browser or mobile app.

import os
from apphelm import Apphelm

apphelm = Apphelm(api_key=os.environ["APPHELM_API_KEY"])

# A product event for one person.
apphelm.capture("org_…", "prd_…", distinct_id=customer.id, event_name="invoice_sent")

# Feature flags fail closed: any network, timeout or API error evaluates to False.
if apphelm.is_enabled("new-checkout", customer.id, product_id="prd_…"):
    render_new_checkout()
variant = apphelm.get_feature_flag("org_…", "prd_…", "pricing-test", customer.id)  # variant, True or False

Identify

Every trait needs provenance. A trait without a matching trait_sources entry raises ValueError before anything is sent, because the API would reject it.

apphelm.identify("org_…", "prd_…", external_user_id=account.id,
                 traits={"plan": "builder"},
                 trait_sources={"plan": {"sourceType": "auth", "sourceId": "session", "verification": "integration_verified"}})

Errors and messages

try:
    charge(order)
except Exception as error:
    apphelm.capture_exception("org_…", "prd_…", error, release=os.environ.get("RELEASE"),
                              environment="production", tags={"route": "/charges"}, user_id=account.id)

# Report uncaught exceptions (main thread and other threads) as unhandled issues.
# The previous hooks still run, so the traceback prints and the process exits as before.
restore = apphelm.capture_unhandled("org_…", "prd_…", release=os.environ.get("RELEASE"), environment="production")

apphelm.capture_message("org_…", "prd_…", "Payment provider fell back to retries", level="warning")

Tracebacks are scrubbed of email addresses, keys and query strings before they are sent, and user_id is sent only as a hash. Pass before_send= to the constructor to change or drop exceptions and messages: return the properties (changed or not), or None to drop the event. A hook that raises drops the event.

Tracing

# Continue the caller's trace (from the browser or another service), or start a new one.
with apphelm.start_transaction("org_…", "prd_…", "POST /charges", traceparent=request.headers.get("traceparent")) as tx:
    with tx.start_span("db.query", "select order"):
        ...

Apphelm(api_key, traces_sample_rate=0.2) keeps a share of new transactions; a transaction that continues an incoming traceparent keeps the caller's sampling decision.

Cron check-ins

apphelm.check_in("prd_…", monitor="nightly-export", status="ok", duration_ms=5400)

Errors from the client

Failed requests raise ApphelmError with status and code. Flag checks (is_enabled, get_feature_flag) never raise for a failed request; they return False.

Licence

Proprietary. See LICENSE: use requires an active Apphelm service agreement.

Releasing this package: docs/SDK-RELEASING.md in the Apphelm repository.

Metadata

Release files for apphelm 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for apphelm 0.5.0
File Size Uploaded Provenance
apphelm-0.5.0.tar.gz 12.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for apphelm 0.5.0
File Interpreter ABI Platform
apphelm-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.9 kB

Release files / apphelm-0.5.0.tar.gz

Download URL apphelm-0.5.0.tar.gz
Size 12.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5a7d0d8ed3c4af199aa6835663f3e796ebd36e0c1d07c4130b5def8662d016af
BLAKE2b-256 checksum
How to use checksums
67b1821d1d53ac78788d83462e2deff668f8b11e5ebd2a6c5a78c8b9d92d7691
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / apphelm-0.5.0-py3-none-any.whl

Download URL apphelm-0.5.0-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f7a127568d45aaf38fb983ae5d38c9737e68eb47c30263b915c7ac45239b41f0
BLAKE2b-256 checksum
How to use checksums
a7c154a24948161eca0804594c984b2bd592fbfd3010b2681ceb03fe259e8c9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Security for apphelm 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page