Skip to main content

Installation

pip install txcloud

Quick Start

from txcloud import TXCloud
import os

txcloud = TXCloud(api_key=os.environ.get("TXCLOUD_API_KEY"))

verification = txcloud.identity.verify(
    document_front=document_base64,
    country="MA",
    document_type="national_id"
)

print(verification.status)

Configuration

txcloud = TXCloud(
    api_key="txc_live_xxx",
    environment="production",  # or "sandbox"
    timeout=30,
    max_retries=3
)

Async Support

from txcloud import AsyncTXCloud
import asyncio

async def main():
    txcloud = AsyncTXCloud(api_key=os.environ["TXCLOUD_API_KEY"])
    verification = await txcloud.identity.verify(...)
    print(verification.status)

asyncio.run(main())

Error Handling

from txcloud.exceptions import (
    TXCloudError,
    ValidationError,
    RateLimitError
)

try:
    result = txcloud.identity.verify(...)
except ValidationError as e:
    print(f"Validation failed: {e.message}")
except RateLimitError as e:
    print(f"Rate limited, retry after: {e.retry_after}")
except TXCloudError as e:
    print(f"API error: {e.code}")

Type Hints

Full type hints for IDE support:
from txcloud.types import Verification, VerifyRequest

request: VerifyRequest = {
    "document_front": "...",
    "country": "MA"
}

verification: Verification = txcloud.identity.verify(**request)