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.0httpx >= 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
Release history Release notifications | RSS feed
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0876387559b3ce0e1421ce85f5e2c6b6fcfa55aed319bb827dfef12e431362e
|
|
| MD5 |
49ecf1996b8687372962afeebf58ae50
|
|
| BLAKE2b-256 |
4d8ba2dad0c09b1324d2fa3394ee22920e0086729ed98fc6780099d6eaa46303
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fde_sdk-1.0.0.tar.gz -
Subject digest:
f0876387559b3ce0e1421ce85f5e2c6b6fcfa55aed319bb827dfef12e431362e - Sigstore transparency entry: 1007475193
- Sigstore integration time:
-
Permalink:
run-true-decision/rtd-fde@c7258526f035283254202f0af2b524453c5315e9 -
Branch / Tag:
refs/tags/py-sdk-v1.0.0 - Owner: https://github.com/run-true-decision
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-py-sdk.yml@c7258526f035283254202f0af2b524453c5315e9 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4d9c8d92aa4c68c247568000d008729cfef2574dcc132efcaf96cf09ef732d3
|
|
| MD5 |
aa6e37cc730f1792f0e5f5e727e55e17
|
|
| BLAKE2b-256 |
cf74e809a32d4621dacce22bcb52bc416790326d99e3bcd409ccf41a4885708f
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fde_sdk-1.0.0-py3-none-any.whl -
Subject digest:
f4d9c8d92aa4c68c247568000d008729cfef2574dcc132efcaf96cf09ef732d3 - Sigstore transparency entry: 1007475215
- Sigstore integration time:
-
Permalink:
run-true-decision/rtd-fde@c7258526f035283254202f0af2b524453c5315e9 -
Branch / Tag:
refs/tags/py-sdk-v1.0.0 - Owner: https://github.com/run-true-decision
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-py-sdk.yml@c7258526f035283254202f0af2b524453c5315e9 -
Trigger Event:
push
-
Statement type: