L O R I C A / docs
SDKS

Python SDK

The Python SDK wraps every endpoint with a typed client. Sync and async variants. Validates JWTs locally on the verify path so you don't have to pull in pyjwt separately unless you want to.

Install

pip install lorica-sdk

Synchronous client

from lorica_sdk import Lorica
import os

client = Lorica(api_key=os.environ["LORICA_API_KEY"],
                signing_secret=os.environ["LORICA_SIGNING_SECRET"])

# Enroll
client.enroll(user_id="usr_abc", frames=[frame_jpeg_b64])

# Verify
result = client.verify(
    user_id="usr_abc",
    action="withdrawal",
    amt="50000",
    asset="USDT",
    frames=[frame1_b64, frame2_b64],
)

# JWT validated locally; .claims is the parsed payload
if result.match and result.score >= 0.9:
    process_withdrawal(user_id="usr_abc", lorica_jwt=result.jwt)

# Delete
client.delete_user(user_id="usr_abc")

Async client

from lorica_sdk import AsyncLorica
import asyncio
import os

async def run():
    client = AsyncLorica(api_key=os.environ["LORICA_API_KEY"],
                        signing_secret=os.environ["LORICA_SIGNING_SECRET"])
    result = await client.verify(
        user_id="usr_abc", action="withdrawal", frames=[...]
    )
    return result

result = asyncio.run(run())

Type hints

Every method is type-annotated. VerifyResult exposes .jwt (str), .match (bool), .score (float), .claims (TypedDict mirroring the JWT payload), and .verification_id (str). Use mypy --strict against your integration to catch shape mismatches at type-check time.

Error handling

The SDK raises typed exceptions for each HTTP error code: LoricaInvalidCredentials, LoricaUserNotEnrolled, LoricaLowConfidence, LoricaLivenessFailed, LoricaRateLimited, etc. All inherit from LoricaError. The LoricaRateLimited exception exposes retry_after in seconds.

from lorica_sdk import Lorica, LoricaLowConfidence, LoricaRateLimited
import time

try:
    result = client.verify(...)
except LoricaLowConfidence as e:
    queue_for_manual_review(user_id, e.score)
except LoricaRateLimited as e:
    time.sleep(e.retry_after)
    result = client.verify(...)  # retry once