Python-Bibliothek — pip-Installation
pip install email-validator-client
Typsicherer Python-Client für email-validaton.com. Synchron + asynchron, Pandas-kompatibel.
Installation
pip install email-validator-client
# With async (httpx):
pip install email-validator-client[async]
# With Pandas:
pip install email-validator-client[pandas]
# Everything:
pip install email-validator-client[all]
Voraussetzungen: Python 3.10+, pydantic>=2.0, requests>=2.28.
Schnellstart
from email_validator_client import Client
client = Client('ev_your_api_key')
result = client.verify('user@gmail.com')
if result.is_valid:
print(f'Valid — confidence: {result.confidence}')
elif result.is_disposable:
print('Disposable email — reject!')
elif result.is_catch_all:
print('Catch-all — caution')
Asynchron (httpx)
import asyncio
from email_validator_client import Client
async def main():
client = Client('ev_...')
result = await client.verify_async('user@gmail.com')
print(result.status)
# Bulk async with concurrency control
emails = ['a@b.com', 'c@d.com', 'e@f.com']
results = await client.verify_bulk_async(emails, concurrency=10)
asyncio.run(main())
Pandas-Integration
import pandas as pd
from email_validator_client import Client
from email_validator_client.pandas import verify_dataframe
client = Client('ev_...')
# Load CSV, verify emails, export
df = pd.read_csv('subscribers.csv')
enriched = verify_dataframe(client, df, email_column='email')
enriched.to_csv('verified.csv', index=False)
# Filter deliverable only
deliverable = enriched[enriched['is_deliverable']]
Typsichere Modelle (Pydantic v2)
| Klasse | Wichtigste Eigenschaften |
|---|---|
VerificationResult |
email, status, reason, confidence, mx_server, mx_list, smtp_response, source_ip, duration_ms, remaining_credits, is_yahoo |
AccountInfo |
email, plan, plan_name, credits_remaining, credits_used, credits_limit, plan_type, subscription_active, free_remaining, total_remaining |
CreditInfo |
has_credits, credits_remaining |
Praktische Eigenschaften
| Eigenschaft | Rückgabewert | Bedingung |
|---|---|---|
is_valid | bool | status == 'valid' |
is_invalid | bool | status == 'invalid' |
is_risky | bool | status == 'risky' |
is_catch_all | bool | status == 'catch_all' |
is_disposable | bool | status == 'disposable' |
is_deliverable | bool | valid || risky || catch_all |
costs_credit | bool | valid || invalid |
Fehlerbehandlung
| Ausnahme | Wann |
|---|---|
AuthenticationError | Ungültiger oder fehlender API-Schlüssel (HTTP 401/403) |
RateLimitError | 60 Anfragen/Min. oder stündliches Limit. e.retry_after_seconds |
NoCreditsError | Guthaben aufgebraucht |
ApiError | Netzwerkfehler, Zeitüberschreitung, unerwartete Antwort |
from email_validator_client import (
AuthenticationError, RateLimitError, NoCreditsError, ApiError
)
try:
result = client.verify('user@example.com')
except RateLimitError as e:
sleep(e.retry_after_seconds) # wait & retry
except NoCreditsError:
print('Upgrade your plan')
CI/CD-Integration
# validate_deploy_emails.py
from email_validator_client import Client
import sys
client = Client('ev_...')
for path in sys.argv[1:]:
with open(path) as f:
for line in f:
if '@' in line:
r = client.verify(line.strip())
if r.is_invalid:
print(f'INVALID: {line.strip()}')
sys.exit(1)
print('All emails valid')
v1.0.0 · MIT-Lizenz · Python 3.10+ · Pydantic v2 · requests | httpx | pandas