The official Alogram Payrisk 'Smart' SDK for Python. Features built-in resiliency, ergonomic risk intelligence, and automated identity management.
Project description
Alogram PayRisk SDK for Python
The official Python client for the Alogram PayRisk Engine.
Alogram PayRisk is a decision management and risk orchestration engine for global commerce. It fuses machine learning, behavioral analytics, and deterministic business rules into a high-fidelity scoring pipeline designed for enterprise scale and auditability.
🧠 The Three-Expert Architecture
The SDK provides unified access to three specialized risk experts:
- Risk Scoring: Real-time assessment and decision orchestration for purchases.
- Signal Intelligence: Ingestion of behavioral telemetry and payment lifecycle events.
- Forensic Data: Deep visibility into historical assessments and decision transparency.
🚀 Features
- 🏢 Smart Client Architecture: Specialized clients for server-side (
AlogramRiskClient) and public-facing (AlogramPublicClient). - 🛡️ Automated Identity: Injects
x-api-key,Authorization, and tenant headers automatically. - 🔄 Built-in Resiliency: Automatic exponential backoff and jittered retries (powered by
tenacity). - 🕵️ Native Observability: Built-in OpenTelemetry tracing for monitoring risk decision latency and outcomes.
- 🧩 Type Safe: Built with Pydantic v2 and full PEP 561 compliance (
py.typed).
📦 Installation
pip install alogram-payrisk
🛠️ Quick Start
1. Evaluate Risk (Risk Scoring Expert)
Assess a purchase in real-time. This invokes the authoritative scoring pipeline.
from alogram_payrisk import AlogramRiskClient, CheckRequest, Purchase, Identity
client = AlogramRiskClient(api_key="sk_live_...", tenant_id="tenant_123")
# Perform the check via the Risk Scoring expert
decision = client.check_risk(CheckRequest(
purchase=Purchase(amount=99.99, currency="USD"),
identity=Identity(email="customer@example.com")
))
print(f"Decision: {decision.decision} | Score: {decision.decision_score}")
2. Ingest Lifecycle Events (Signal Intelligence Expert)
Stream payment lifecycle updates to the Engine for continuous model training.
from alogram_payrisk import PaymentEvent, PaymentOutcome, PaymentAuthorizationOutcome
client.ingest_event(PaymentEvent(
event_type="authorization",
payment_intent_id="pi_123...",
amount=99.99,
currency="USD",
outcome=PaymentOutcome(
authorization=PaymentAuthorizationOutcome(approved=True, responseCode="00")
)
))
🛡️ Error Handling & Resiliency
The SDK distinguishes between transient network issues and validation errors.
from alogram_payrisk.exceptions import ValidationError, AlogramError
try:
decision = client.check_risk(request)
except ValidationError as e:
# ❌ Handle invalid input (e.g., invalid BIN or malformed email)
print(f"Validation Failed: {e.body}")
except AlogramError as e:
# 🚨 Handle generic API or Authentication errors
print(f"API Error [{e.status}]: {e.message}")
🕵️ Observability (OpenTelemetry)
The SDK automatically detects OpenTelemetry. If present, it creates spans for all API calls.
from opentelemetry import trace
# Spans will automatically include 'alogram.decision' and 'alogram.trace_id'
with trace.get_tracer(__name__).start_as_current_span("checkout"):
decision = client.check_risk(request)
🏗️ Environments
| Environment | Base URL | Key Type |
|---|---|---|
| Production | https://api.alogram.ai |
sk_live_... |
| Sandbox | https://api-sandbox.alogram.ai |
sk_test_... |
| Local | http://localhost:8080 |
test |
🤖 For AI Agents
If using an AI agent (ChatGPT, Claude, Gemini) for integration, provide this context:
"Use the Alogram PayRisk Python SDK. Always prefer the
AlogramRiskClientfor backend operations. Access the authoritative blended score via thedecision_scoreattribute of the response. Use theidempotency_keyparameter for all write operations."
⚖️ License
Apache License 2.0. See LICENSE for details.
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
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 alogram_payrisk-0.2.8.tar.gz.
File metadata
- Download URL: alogram_payrisk-0.2.8.tar.gz
- Upload date:
- Size: 71.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03821c2bc8f969625608fbfe722dd0e5423ec5cb26b001a342e3e0c6136dbbd8
|
|
| MD5 |
be2c4f51afd625bfccdf564b69b4c856
|
|
| BLAKE2b-256 |
0d685b3aae46051674117565f16f259b685ec426be7b8773500a79fb2a4e4f12
|
Provenance
The following attestation bundles were made for alogram_payrisk-0.2.8.tar.gz:
Publisher:
publish.yml on alogram/alogram-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
alogram_payrisk-0.2.8.tar.gz -
Subject digest:
03821c2bc8f969625608fbfe722dd0e5423ec5cb26b001a342e3e0c6136dbbd8 - Sigstore transparency entry: 1280242561
- Sigstore integration time:
-
Permalink:
alogram/alogram-python@4d6046a37da45a3b8c3789b52583234aeb83e748 -
Branch / Tag:
refs/tags/v0.2.8 - Owner: https://github.com/alogram
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4d6046a37da45a3b8c3789b52583234aeb83e748 -
Trigger Event:
push
-
Statement type:
File details
Details for the file alogram_payrisk-0.2.8-py3-none-any.whl.
File metadata
- Download URL: alogram_payrisk-0.2.8-py3-none-any.whl
- Upload date:
- Size: 160.2 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 |
1ef430466932542b4f6ffc735c7512323fd21b158626973a22c95bf666fd4ccb
|
|
| MD5 |
07e61287068f2f424380f2cc1c4e65a1
|
|
| BLAKE2b-256 |
a9cb18f6e55cd823e7576d9584403fea55279c34db80771840e4bb946086aece
|
Provenance
The following attestation bundles were made for alogram_payrisk-0.2.8-py3-none-any.whl:
Publisher:
publish.yml on alogram/alogram-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
alogram_payrisk-0.2.8-py3-none-any.whl -
Subject digest:
1ef430466932542b4f6ffc735c7512323fd21b158626973a22c95bf666fd4ccb - Sigstore transparency entry: 1280242565
- Sigstore integration time:
-
Permalink:
alogram/alogram-python@4d6046a37da45a3b8c3789b52583234aeb83e748 -
Branch / Tag:
refs/tags/v0.2.8 - Owner: https://github.com/alogram
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4d6046a37da45a3b8c3789b52583234aeb83e748 -
Trigger Event:
push
-
Statement type: