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 Alogram PayRisk 'Smart' SDK for Python. Built for modern financial systems that require high resiliency, ergonomic risk intelligence, and automated identity management.
🚀 Features
- 🏢 Smart Client Architecture: Specialized clients for server-side (
AlogramRiskClient) and public-facing (AlogramPublicClient) environments. - 🛡️ Automated Identity: Injects
x-api-key,Authorization, and tenant headers automatically. - 🔄 Built-in Resiliency: Transparent exponential backoff and jittered retries powered by
tenacity. - 🕵️ OpenTelemetry Ready: Native tracing support for deep observability into risk decisions.
- 🧩 Type Safe: Built with Pydantic v2 and full PEP 561 compliance (
py.typed).
📦 Installation
pip install alogram-payrisk
🛠️ Quick Start
Evaluate Risk (Server-Side)
from alogram_payrisk import AlogramRiskClient
from alogram_payrisk.models import CheckRequest, Purchase, Identity
# Initialize the smart client
client = AlogramRiskClient(
api_key="sk_live_your_secret_key",
tenant_id="tenant_123"
)
# Perform the check with automatic retries and tracing
decision = client.check_risk(CheckRequest(
purchase=Purchase(amount=99.99, currency="USD"),
identity=Identity(email="customer@example.com")
))
print(f"Risk Decision: {decision.decision}")
🛡️ Error Handling
The SDK provides specific exceptions for robust error state management:
from alogram_payrisk.exceptions import RateLimitError, ValidationError, AlogramError
try:
decision = client.check_risk(request)
except RateLimitError:
# 🔄 Standard exponential backoff is handled by the SDK
pass
except ValidationError as e:
# ❌ Check e.body for specific field validation errors
print(f"Invalid request: {e}")
except AlogramError as e:
# 🚨 Generic fallback for other API issues
print(f"API Error: {e.status_code}")
🔑 Authentication & Keys
To use the Alogram SDK, you need API keys from the Alogram Dashboard.
| Key Type | Prefix | Client | Use Case |
|---|---|---|---|
| Secret Key | sk_live_... |
AlogramRiskClient |
Server-side risk checks. Never expose. |
| Publishable Key | pk_live_... |
AlogramPublicClient |
Frontend signals & browser ingestion. |
🤖 For AI Agents (Integration Context)
If you are using an AI agent (like ChatGPT, Claude, or Gemini) to help with your integration, provide it with the following context:
"I am integrating the Alogram PayRisk Python SDK. I need to implement a risk check during my checkout endpoint. Use the
AlogramRiskClient, handleRateLimitErrorgracefully, and ensure you use theidempotency_keyfrom my transaction ID."
🧪 Local Testing & Mocking
For fast unit tests without network dependencies, use the built-in MockRiskClient.
from alogram_payrisk.testing import MockRiskClient
mock = MockRiskClient()
mock.queue_decision("decline", score=0.95, reason="high_risk_ip")
# Your app code uses the mock as if it were a real client
decision = my_app.process_checkout(mock)
assert decision.decision == "decline"
🏗️ Environment Testing
Alogram Sandbox
For safe integration testing without impacting production data, point your client to the Sandbox environment:
client = AlogramRiskClient(
api_key="sk_test_...",
base_url="https://api-sandbox.alogram.ai"
)
Local Emulator
For hermetic local testing, run the Alogram Local Emulator:
docker run -p 8080:8080 alogram/payrisk-emulator
Point your client to the local instance:
client = AlogramRiskClient(base_url="http://localhost:8080", api_key="test")
📚 Documentation
For full API reference, visit docs.alogram.ai.
⚖️ 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.1.6.tar.gz.
File metadata
- Download URL: alogram_payrisk-0.1.6.tar.gz
- Upload date:
- Size: 63.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ee6e2ef4013d540a6c8f221059a72ba313636579e883a637511a1d9d37442b4
|
|
| MD5 |
c08744fcdb17cda1e099ddeb768ad173
|
|
| BLAKE2b-256 |
471cf927ca1fda056df3e772b31b995c345919c9ae89046fbb43776cd2903266
|
Provenance
The following attestation bundles were made for alogram_payrisk-0.1.6.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.1.6.tar.gz -
Subject digest:
4ee6e2ef4013d540a6c8f221059a72ba313636579e883a637511a1d9d37442b4 - Sigstore transparency entry: 943724080
- Sigstore integration time:
-
Permalink:
alogram/alogram-python@ec160ec8a1cd3e308e54ba7d4ea065f1702fbabc -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/alogram
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ec160ec8a1cd3e308e54ba7d4ea065f1702fbabc -
Trigger Event:
push
-
Statement type:
File details
Details for the file alogram_payrisk-0.1.6-py3-none-any.whl.
File metadata
- Download URL: alogram_payrisk-0.1.6-py3-none-any.whl
- Upload date:
- Size: 141.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce9712f68d83b19a9587d98ef9966c1fc8994f01f192eb5c6081e3186ebf14ca
|
|
| MD5 |
d16134c5e95f5882e3376fedc30ca9b9
|
|
| BLAKE2b-256 |
841444a28d0aa866b6fd733c146e4c46b1823e765060d00fa40e9ed697826ff0
|
Provenance
The following attestation bundles were made for alogram_payrisk-0.1.6-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.1.6-py3-none-any.whl -
Subject digest:
ce9712f68d83b19a9587d98ef9966c1fc8994f01f192eb5c6081e3186ebf14ca - Sigstore transparency entry: 943724151
- Sigstore integration time:
-
Permalink:
alogram/alogram-python@ec160ec8a1cd3e308e54ba7d4ea065f1702fbabc -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/alogram
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ec160ec8a1cd3e308e54ba7d4ea065f1702fbabc -
Trigger Event:
push
-
Statement type: