Python SDK for the Skala fraud detection API
Project description
Skala Python SDK
Python SDK for the Skala fraud detection API.
Requires Python 3.11+.
Install
pip install skalaio
Quick Start
from skala import Skala, SkalaOptions, ScoreRequest
skala = Skala(SkalaOptions(api_key="sk_live_..."))
result = skala.score(ScoreRequest(
event_type="signup",
ip=req.ip,
email=body.email,
user_agent=req.headers["user-agent"],
))
if result.decision == "block":
return {"error": "Request blocked"}, 403
if result.decision == "step_up":
return {"requires_verification": True}, 200
Report an Outcome
Feed back fraud signals to improve future scoring:
from skala import OutcomeRequest
skala.outcome(OutcomeRequest(
request_id=result.request_id,
outcome="confirmed_fraud",
))
Timeout Fallback
score() auto-allows when the API is unreachable (timeout or network failure), so scoring does not block user traffic.
HTTP API responses (for example 4xx/5xx) still raise errors.
result = skala.score(...)
if hasattr(result, "fallback") and result.fallback:
# request was auto-allowed by SDK fallback
# result.reason_codes is SDK_TIMEOUT_FALLBACK or SDK_NETWORK_FALLBACK
Error Handling
Use structured SDK errors for predictable handling:
from skala import (
SkalaApiError,
SkalaNetworkError,
SkalaTimeoutError,
)
try:
skala.outcome(OutcomeRequest(request_id="req_123", outcome="confirmed_fraud"))
except SkalaTimeoutError:
# request timed out
except SkalaNetworkError:
# API unreachable (DNS/TLS/connectivity)
except SkalaApiError as e:
# API returned non-2xx
print(e.status, e.body, e.request_id)
Configuration
from skala import Skala, SkalaOptions
skala = Skala(SkalaOptions(
api_key="sk_live_...",
base_url="https://apiskala.varityweb.com", # default
timeout_ms=5000, # default
retries=2, # default, only retries 5xx
))
License
MIT
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 skalaio-0.2.0.tar.gz.
File metadata
- Download URL: skalaio-0.2.0.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"EndeavourOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d917c0e38ab5e5a53607a9f36758ef416399bcc3c446b89d5c4950f3b65aca4
|
|
| MD5 |
2d916e285b249b9e104b8e827243277c
|
|
| BLAKE2b-256 |
c03a83e6302685684a0ea603438f789356c9dba4217c4653f957dbbaf624b7bf
|
File details
Details for the file skalaio-0.2.0-py3-none-any.whl.
File metadata
- Download URL: skalaio-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"EndeavourOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff22f8dba570ead8606d23703e80530e7df507e7b14dcc53f5fdd8d679d58fde
|
|
| MD5 |
2ee57ccbc6d1fe54a7b1b18a811ade13
|
|
| BLAKE2b-256 |
8318ba0d103c524de0e4ab2b2ef1d75ab6c000d8158c8dcec1f3e9ea02524990
|