Skip to main content

Python SDK for the FDE Fraud Decision Engine API

Project description

fde-sdk

Python SDK for the FDE Fraud Decision Engine API.

Handles JWT+HMAC authentication automatically and provides typed methods for all three V1 risk endpoints.

Installation

pip install fde-sdk
# or from source:
pip install -e sdks/python/

Requirements

  • Python 3.9+
  • PyJWT >= 2.0
  • httpx >= 0.24

Quick Start

import asyncio
import os
from fde_sdk import FdeClient
from fde_sdk.types import EvaluateRequest, EventDetailModel, LoginDetail, CustKV

async def main():
    async with FdeClient(
        endpoint="https://fde.run-true.com",
        jwt_signing_key=os.environ["FDE_JWT_SIGNING_KEY"],
        hmac_key=os.environ["FDE_HMAC_KEY"],
        client_id=os.environ["FDE_CLIENT_ID"],
    ) as client:
        request = EvaluateRequest(
            eventCode="login",
            sessionId="sess-abc123",
            deviceToken=os.environ["DEVICE_TOKEN"],   # fingerprint from your SDK
            userId="user-42",
            eventDetail=EventDetailModel(
                Login=LoginDetail(
                    UserLoginName="alice@example.com",
                    Cust=[CustKV(key="browser", value="chrome")],
                )
            ),
        )
        response = await client.evaluate_risk(request)
        print(f"Decision: {response['decision']}  Score: {response['risk_score']}")

asyncio.run(main())

Authentication

The SDK generates a fresh HS256 JWT (5-minute expiry) and computes an HMAC-SHA256 body signature for every request. The HMAC algorithm is:

body_hash   = SHA256(body_bytes).hexdigest()
sign_string = timestamp + "\n" + body_hash
signature   = HMAC-SHA256(hmac_key_bytes, sign_string).hexdigest()

The body bytes used for signing are identical to the bytes sent over HTTP — no intermediate re-serialisation.

API Methods

evaluate_risk(request, explain=False) -> RiskEvaluateResponse

POST /v1/risk/evaluate — real-time fraud score and decision.

Response keys: request_id, risk_score (int), risk_level, decision. Optional: banking_rule_details, explanation (when explain=True), risk_labels, data_quality, list_actions.

submit_outcome(request) -> OutcomeResponse

POST /v1/risk/outcome — record the outcome of a transaction.

Response key: request_id.

submit_labels(request) -> SubmitLabelsResponse

POST /v1/risk/labels — submit fraud ground-truth labels (up to 100 per call).

Response keys: request_id, created, not_found, errors, results.

Error Handling

from fde_sdk import FdeApiError

try:
    resp = await client.evaluate_risk(request)
except FdeApiError as e:
    print(f"HTTP {e.status_code}: {e.detail}")

Event Types

EventDetail field Event code examples
Login login
Register register
Transaction transaction, wire, ach
LoginResult login_result
RegisterResult register_result
PasswordChange password_change
EmailChange email_change
SecurityVerification otp_verify, captcha
PaymentResult payment_result
SmsResult sms_result

Development

cd sdks/python
pip install -e ".[dev]"
pytest tests/ -v

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

fde_sdk-1.0.0.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

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

fde_sdk-1.0.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file fde_sdk-1.0.0.tar.gz.

File metadata

  • Download URL: fde_sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fde_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f0876387559b3ce0e1421ce85f5e2c6b6fcfa55aed319bb827dfef12e431362e
MD5 49ecf1996b8687372962afeebf58ae50
BLAKE2b-256 4d8ba2dad0c09b1324d2fa3394ee22920e0086729ed98fc6780099d6eaa46303

See more details on using hashes here.

Provenance

The following attestation bundles were made for fde_sdk-1.0.0.tar.gz:

Publisher: publish-py-sdk.yml on run-true-decision/rtd-fde

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

File details

Details for the file fde_sdk-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: fde_sdk-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fde_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f4d9c8d92aa4c68c247568000d008729cfef2574dcc132efcaf96cf09ef732d3
MD5 aa6e37cc730f1792f0e5f5e727e55e17
BLAKE2b-256 cf74e809a32d4621dacce22bcb52bc416790326d99e3bcd409ccf41a4885708f

See more details on using hashes here.

Provenance

The following attestation bundles were made for fde_sdk-1.0.0-py3-none-any.whl:

Publisher: publish-py-sdk.yml on run-true-decision/rtd-fde

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