Python SDK
Official Python SDK for ReachScore with async support.
Installation
pip install reachscore
# or
poetry add reachscoreQuick Start
example.pypython
123456789101112131415import os from reachscore import ReachScore client = ReachScore(api_key=os.environ["REACHSCORE_API_KEY"]) # Create a test test = client.tests.create( from_address="hello@yourdomain.com", subject="Welcome to our platform", html_body="<h1>Hello!</h1>", providers=["gmail", "outlook"], ) print(f"Test ID: {test.id}") print(f"Score: {test.score}")
Async Support
The SDK provides an async client for use with asyncio:
async_example.pypython
123456789101112131415import asyncio import os from reachscore import AsyncReachScore async def main(): client = AsyncReachScore(api_key=os.environ["REACHSCORE_API_KEY"]) test = await client.tests.create( from_address="hello@yourdomain.com", subject="Welcome to our platform", ) print(f"Score: {test.score}") asyncio.run(main())
Configuration Options
client = ReachScore(
api_key=os.environ["REACHSCORE_API_KEY"],
# Optional: custom base URL for self-hosted
base_url="https://api.reachscore.co/v1",
# Optional: request timeout in seconds
timeout=30,
# Optional: number of retries for failed requests
max_retries=3,
)Error Handling
from reachscore import ReachScore, ReachScoreError
try:
test = client.tests.create(...)
except ReachScoreError as e:
print(f"API Error: {e.message}")
print(f"Error Code: {e.code}")
print(f"Request ID: {e.request_id}")