Skip to main content

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

PyPI version License

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, handle RateLimitError gracefully, and ensure you use the idempotency_key from 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

alogram_payrisk-0.1.6.tar.gz (63.6 kB view details)

Uploaded Source

Built Distribution

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

alogram_payrisk-0.1.6-py3-none-any.whl (141.1 kB view details)

Uploaded Python 3

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

Hashes for alogram_payrisk-0.1.6.tar.gz
Algorithm Hash digest
SHA256 4ee6e2ef4013d540a6c8f221059a72ba313636579e883a637511a1d9d37442b4
MD5 c08744fcdb17cda1e099ddeb768ad173
BLAKE2b-256 471cf927ca1fda056df3e772b31b995c345919c9ae89046fbb43776cd2903266

See more details on using hashes here.

Provenance

The following attestation bundles were made for alogram_payrisk-0.1.6.tar.gz:

Publisher: publish.yml on alogram/alogram-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for alogram_payrisk-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ce9712f68d83b19a9587d98ef9966c1fc8994f01f192eb5c6081e3186ebf14ca
MD5 d16134c5e95f5882e3376fedc30ca9b9
BLAKE2b-256 841444a28d0aa866b6fd733c146e4c46b1823e765060d00fa40e9ed697826ff0

See more details on using hashes here.

Provenance

The following attestation bundles were made for alogram_payrisk-0.1.6-py3-none-any.whl:

Publisher: publish.yml on alogram/alogram-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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