Truelist Python SDK
Official Python SDK for the Truelist.io email validation API. Validate email addresses in real-time with a simple, type-safe interface.
- Sync and async clients
- Automatic retries with exponential backoff
- Full type annotations (mypy strict compatible)
- Minimal dependencies (just
httpx) - Python 3.9+
Start free — 100 validations + 10 enhanced credits, no credit card required. Get your API key →
Installation
pip install truelist
Quick Start
from truelist import Truelist
client = Truelist("your-api-key")
result = client.email.validate("user@example.com")
print(result.state) # "ok"
print(result.sub_state) # "email_ok"
print(result.domain) # "example.com"
print(result.is_valid) # True
Async Usage
from truelist import AsyncTruelist
client = AsyncTruelist("your-api-key")
result = await client.email.validate("user@example.com")
print(result.is_valid)
await client.close()
Or use an async context manager:
async with AsyncTruelist("your-api-key") as client:
result = await client.email.validate("user@example.com")
Error Handling
from truelist import Truelist, AuthenticationError, RateLimitError, ApiError
client = Truelist("your-api-key")
try:
result = client.email.validate("user@example.com")
except AuthenticationError:
# Invalid or missing API key (HTTP 401/403)
print("Check your API key")
except RateLimitError as e:
# Too many requests (HTTP 429)
print(f"Rate limited. Retry after {e.retry_after} seconds")
except ApiError as e:
# Other API errors
print(f"API error {e.status_code}: {e.message}")
All errors inherit from TruelistError, so you can catch that as a catch-all:
from truelist import TruelistError
try:
result = client.email.validate("user@example.com")
except TruelistError as e:
print(f"Something went wrong: {e.message}")
Configuration
client = Truelist(
"your-api-key",
base_url="https://api.truelist.io", # default
timeout=30.0, # seconds, default
max_retries=2, # default
)
Context Manager
Both sync and async clients support context managers for automatic cleanup:
# Sync
with Truelist("your-api-key") as client:
result = client.email.validate("user@example.com")
# Async
async with AsyncTruelist("your-api-key") as client:
result = await client.email.validate("user@example.com")
Retries
The SDK automatically retries failed requests with exponential backoff:
- Retried: HTTP 429 (rate limit), 500, 502, 503, 504, connection errors, timeouts
- Not retried: HTTP 401, 403, 422, and other client errors
- Backoff: Starts at 0.5s, doubles each attempt, capped at 8s
- 429 responses: Uses the
Retry-Afterheader when provided
Set max_retries=0 to disable retries.
API Methods
Email Validation
result = client.email.validate("user@example.com")
Account Info
account = client.account.get()
print(account.email) # "you@company.com"
print(account.name) # "Your Name"
print(account.payment_plan) # "pro"
Types Reference
ValidationResult
| Field | Type | Description |
|---|---|---|
email |
str |
The email address that was validated |
domain |
str |
The domain of the email address |
canonical |
str | None |
The canonical (local) part of the email |
mx_record |
str | None |
The MX record for the domain |
first_name |
str | None |
First name associated with the email, if available |
last_name |
str | None |
Last name associated with the email, if available |
state |
str |
One of: ok, email_invalid, risky, unknown, accept_all |
sub_state |
str |
Detailed reason (see below) |
verified_at |
str | None |
Timestamp of when the verification was performed |
suggestion |
str | None |
Suggested correction, if any |
Convenience properties: is_valid, is_invalid, is_risky, is_unknown, is_disposable, is_role
Sub-states
| Sub-state | Description |
|---|---|
email_ok |
Email is valid |
is_disposable |
Disposable email provider |
is_role |
Role-based address (info@, admin@, etc.) |
unknown_error |
Could not determine status |
failed_smtp_check |
SMTP check failed |
AccountInfo
| Field | Type | Description |
|---|---|---|
email |
str |
Account email address |
name |
str |
Account holder name |
uuid |
str |
Account UUID |
time_zone |
str | None |
Account time zone |
is_admin_role |
bool |
Whether the user has admin role |
payment_plan |
str |
Current payment plan |
Exceptions
| Exception | Description |
|---|---|
TruelistError |
Base exception for all SDK errors |
AuthenticationError |
Invalid or missing API key (401/403) |
RateLimitError |
Rate limit exceeded (429) |
ApiError |
Other API errors (has status_code and body) |
ConnectionError |
Failed to connect to API |
TimeoutError |
Request timed out |
Getting Started
Sign up for a free Truelist account to get your API key. The free plan includes 100 validations and 10 enhanced credits — no credit card required.
License
MIT
Metadata
Release files for truelist 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| truelist-0.1.0.tar.gz | 10.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| truelist-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.3 kB
Release files / truelist-0.1.0.tar.gz
| Download URL | truelist-0.1.0.tar.gz |
|---|---|
| Size | 10.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9f104055c879b2c5da5ae280f8f1795ddb2c2f6304dfb371956d02ed298cc14e
|
|
BLAKE2b-256 checksum How to use checksums |
7e2f750caad8ff825215af4ed5d91c4ad65e541656ba7b251deeedc5ab329721
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|
Release files / truelist-0.1.0-py3-none-any.whl
| Download URL | truelist-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
416ab19cb4a8894e4199f74f669f45c4dbe6fae4731f3d34ea8004258ae46200
|
|
BLAKE2b-256 checksum How to use checksums |
0bcb5c96c1b734fa4e5198887f46a55cc9dfa5119fba9dbdb2ec2c449c733fb0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|
Security for truelist 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.