Python SDK

The chainscreen package is the official Python client for the ChainScreen API. It handles authentication, retries, rate-limit backoff, and typed response models.

Installation

pip install chainscreen

Quick start

from chainscreen import Client

client = Client(api_key="sk_live_...")

result = client.screen("0x4f47bc496083c727c5fbe3ce9cdf2b0f6496270c", "ethereum")
print(result.level)   # "CRITICAL"
print(result.score)   # 100

if result.is_high_risk:
    raise ValueError(f"High-risk address: {result.level}")

Batch screening

batch = client.screen_batch([
    {"address": "0x4f47bc496083c727c5fbe3ce9cdf2b0f6496270c", "chain": "ethereum"},
    {"address": "0x0000000000000000000000000000000000000000", "chain": "ethereum"},
])
print(batch.summary.critical)  # 1
for r in batch.results:
    print(r.address, r.level)

Error handling

from chainscreen import (
    AuthError, InvalidAddressError,
    QuotaExceededError, RateLimitError, ScreeningError,
)

try:
    result = client.screen(address, chain)
except InvalidAddressError as e:
    print("Bad address:", e)
except QuotaExceededError:
    print("Monthly quota exhausted")
except RateLimitError as e:
    print(f"Rate limited — retry after {e.retry_after}s")
except AuthError:
    print("Invalid API key")
except ScreeningError as e:
    print(f"API error ({e.status_code}): {e}")

Configuration

ParameterDefaultDescription
api_keyrequiredYour sk_live_ or sk_test_ key
base_urlhttps://anchorapi.dev/api/v1Override for self-hosted deployments
timeout10.0Request timeout in seconds

Context manager

with Client(api_key="sk_live_...") as client:
    result = client.screen(address, chain)

Retry behaviour

The SDK automatically retries on 429 (rate limit), 500, 502,503, and 504 responses using exponential backoff (up to 3 attempts). Quota-exceeded errors (429 quota_exceeded) are not retried — you need to upgrade your plan.

Disclaimer: ChainScreen provides sanctions data for informational purposes only. It does not constitute legal advice. Consult qualified legal counsel for compliance decisions.