SDKs
Python
The official is-credible package for Python 3.9+, with sync and async clients.
pip install is-credibleWorks with Python 3.9 and later. No dependencies. Includes type hints.
Usage#
import os
from iscredible import IsCredible, decide
client = IsCredible(api_key=os.environ["ISCREDIBLE_API_KEY"], timeout=3, max_retries=1)
result = client.verify({"email": email, "ip": ip, "deviceId": device_id, "accountCreation": True})
action, reasons = decide(result) # "APPROVE" | "REVIEW" | "DENY", plus reasonsCreate the client once and reuse it; it is thread-safe. Results are plain dictionaries with the fields described in Response.
Options#
verify(user_data, ...) accepts:
| Option | Description |
|---|---|
scenario_id | Run one scenario |
scenario_ids | Run these scenarios |
system_scenarios | Always use the built-in scenarios |
Usage checks#
check_usage(user_id, usage, context=None) runs Usage Screening and remembers each answer's recheckAfter, so it only calls the API when a check is due. Call it before every expensive action.
decision = client.check_usage(user.id, {"metric": "ai_tokens", "used": used, "limit": 100000}, {"deviceId": device_id, "ip": ip})
if decision["action"] == "DENY":
return "Free limit reached", 429Pass force=True to skip the cache. The cache lives in memory, per client instance.
Async#
from iscredible import AsyncIsCredible
client = AsyncIsCredible(api_key=os.environ["ISCREDIBLE_API_KEY"])
result = await client.verify({"email": email, "ip": ip})Erasing a user#
client.erase(email="jane@example.com", user_id="user_42")See the Erase API.
Errors#
Failures raise IsCredibleError with status (HTTP status, or 0 for network errors and timeouts), data and retryable. Invalid input raises ValueError before any request.
from iscredible import IsCredibleError
try:
result = client.verify({"email": email})
except IsCredibleError as error:
if error.status == 401:
... # fix the API key
# otherwise fail open