Disposable email detection SDK for Python
Project description
syvel
Official Python SDK for Syvel — disposable email detection API.
Detect throwaway addresses, role accounts, and undeliverable domains before they pollute your database. Works with Python 3.10+, supports both sync and async, and has zero runtime dependencies beyond httpx.
Install
pip install syvel
Quick start
Synchronous
import os
from syvel import Syvel, SyvelError, SyvelTimeoutError
client = Syvel(api_key=os.environ["SYVEL_API_KEY"])
try:
result = client.check_email("user@example.com")
if result and result.is_risky:
print(f"Blocked: {result.reason} (score {result.risk_score})")
else:
print("Email looks good")
except SyvelTimeoutError:
pass # Always fail open on timeouts
except SyvelError as e:
print(f"API error {e.status_code}: {e}")
Asynchronous
import os
from syvel import AsyncSyvel
async def validate(email: str) -> bool:
async with AsyncSyvel(api_key=os.environ["SYVEL_API_KEY"]) as client:
result = await client.check_email(email)
return result is None or not result.is_risky
Fail-open (silent) mode
When you'd rather accept every user than block one legitimate signup, use silent=True. All errors are suppressed and methods return None:
client = Syvel(api_key=os.environ["SYVEL_API_KEY"], silent=True)
result = client.check_email("user@example.com")
# Returns None on any error — never blocks your signup flow
if result and result.is_risky:
print("Risky email detected")
Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key |
str |
— | Required. Your Syvel API key (sv_...). Get one at syvel.io/dashboard. |
base_url |
str |
https://api.syvel.io |
Override the API base URL (useful for testing). |
timeout |
float |
3.0 |
Request timeout in seconds. |
silent |
bool |
False |
When True, all errors return None instead of raising. |
API reference
check(domain)
Check a bare domain for disposable-email risk.
result = client.check("yopmail.com")
check_email(email)
Check a full email address. Passes the complete address to the API to enable local-part analysis (role account detection, random pattern scoring).
result = client.check_email("admin@example.com")
usage()
Get the current monthly quota and usage for your project.
usage = client.usage()
print(f"{usage.used}/{usage.limit} checks used this month")
logs(cursor=None, limit=None)
Retrieve a paginated page of recent request logs.
page = client.logs(limit=50)
for entry in page.items:
print(entry.target, entry.risk_score)
# Fetch next page
if page.next_cursor:
next_page = client.logs(cursor=page.next_cursor, limit=50)
stats()
Retrieve time-series analytics for the last 30 days.
points = client.stats()
for point in points:
print(f"{point.date}: {point.total} checks, {point.risky} risky")
list_keys() / create_key(name) / revoke_key(key_id)
Manage API keys for your project.
keys = client.list_keys()
new_key = client.create_key("Staging")
print(new_key.id)
client.revoke_key(new_key.id)
All methods are available on AsyncSyvel as coroutines — prefix them with await.
Response fields
| Field | Type | Description |
|---|---|---|
email |
str |
Masked email address ("a9****e5@yopmail.com"). |
is_risky |
bool |
True when risk_score ≥ 65. Use as your primary signal. |
risk_score |
int |
0 (safe) → 100 (confirmed disposable). |
reason |
str |
"safe" | "disposable" | "undeliverable" | "role_account" |
deliverability_score |
int |
Likelihood (0–100) that mail will be delivered. |
did_you_mean |
str | None |
Typo correction suggestion (e.g. "hotmail.com" for "hotmial.com"). |
is_free_provider |
bool |
True for Gmail, Yahoo, etc. |
is_corporate_email |
bool |
True for business domains. |
is_alias_email |
bool |
True for privacy-relay services (SimpleLogin, AnonAddy, etc.). |
mx_provider_label |
str | None |
Human-readable name of the mail provider. |
Error handling
All errors inherit from SyvelError. Catch specific subclasses for fine-grained handling:
from syvel import (
SyvelError,
SyvelAuthError,
SyvelForbiddenError,
SyvelValidationError,
SyvelRateLimitError,
SyvelTimeoutError,
)
try:
result = client.check_email("user@example.com")
except SyvelAuthError:
# Invalid or missing API key
print("Check your SYVEL_API_KEY")
except SyvelRateLimitError as e:
# Monthly quota exceeded
print(f"Quota resets at {e.reset_at}")
except SyvelTimeoutError:
# Request took longer than `timeout` seconds
pass # Always fail open
except SyvelValidationError:
# Invalid email or domain format
pass
except SyvelForbiddenError:
# Origin not whitelisted for this API key
pass
except SyvelError as e:
# Catch-all for unexpected API errors
print(f"Syvel error {e.status_code}: {e}")
| Exception | HTTP | Cause |
|---|---|---|
SyvelAuthError |
401 | Invalid or missing API key |
SyvelForbiddenError |
403 | Origin not authorised for this key |
SyvelValidationError |
422 | Invalid email or domain format |
SyvelRateLimitError |
429 | Monthly quota exceeded |
SyvelTimeoutError |
— | Request exceeded the configured timeout |
SyvelError |
any | Unexpected API error |
Framework examples
Django
# validators.py
import os
from django.core.exceptions import ValidationError
from syvel import Syvel
_client = Syvel(api_key=os.environ["SYVEL_API_KEY"], silent=True)
def validate_not_disposable(value: str) -> None:
result = _client.check_email(value)
if result and result.is_risky:
raise ValidationError(
"Please use a permanent email address.",
code="disposable_email",
)
# forms.py
from django import forms
from .validators import validate_not_disposable
class SignupForm(forms.Form):
email = forms.EmailField(validators=[validate_not_disposable])
FastAPI
import os
from functools import lru_cache
from typing import Annotated
from fastapi import Depends, FastAPI, HTTPException
from syvel import AsyncSyvel, CheckResult
app = FastAPI()
@lru_cache(maxsize=1)
def get_client() -> AsyncSyvel:
return AsyncSyvel(api_key=os.environ["SYVEL_API_KEY"], silent=True)
async def email_risk(
email: str,
client: AsyncSyvel = Depends(get_client),
) -> CheckResult | None:
return await client.check_email(email)
EmailRisk = Annotated[CheckResult | None, Depends(email_risk)]
@app.post("/signup")
async def signup(email: str, risk: EmailRisk):
if risk and risk.is_risky:
raise HTTPException(422, f"Disposable email not allowed ({risk.reason})")
return {"status": "ok"}
Flask
import os
from flask import Flask, abort, request
from syvel import Syvel
app = Flask(__name__)
_client = Syvel(api_key=os.environ["SYVEL_API_KEY"], silent=True)
@app.before_request
def check_email():
if request.endpoint == "register" and request.method == "POST":
email = request.form.get("email", "")
result = _client.check_email(email)
if result and result.is_risky:
abort(422, "Disposable email addresses are not allowed.")
Context manager
Use Syvel or AsyncSyvel as a context manager to ensure connections are released when you're done:
# Sync
with Syvel(api_key="sv_...") as client:
result = client.check("yopmail.com")
# Async
async with AsyncSyvel(api_key="sv_...") as client:
result = await client.check("yopmail.com")
For long-lived processes (web servers), create the client once at startup and call client.close() / await client.aclose() on shutdown instead.
Contributing
Pull requests are welcome. For major changes, please open an issue first.
git clone https://github.com/syvel-io/syvel-python.git
cd syvel-python
pip install -e ".[dev]"
# Run tests
pytest
# Lint + type-check
ruff check src tests
mypy src
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file syvel-0.1.0.tar.gz.
File metadata
- Download URL: syvel-0.1.0.tar.gz
- Upload date:
- Size: 19.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba8932a13bb32de8f2d604a7bb8ba46a81215f3e94304508a603f2197f58bf4d
|
|
| MD5 |
8c5ccb7ef7ce0fb09f69fa674fea15ef
|
|
| BLAKE2b-256 |
7cbf2ea4eb5a45f27db457b519f777406583a4bd69543b38aa6215e6d6b6f739
|
Provenance
The following attestation bundles were made for syvel-0.1.0.tar.gz:
Publisher:
publish.yml on Syvel-io/syvel-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
syvel-0.1.0.tar.gz -
Subject digest:
ba8932a13bb32de8f2d604a7bb8ba46a81215f3e94304508a603f2197f58bf4d - Sigstore transparency entry: 1227479971
- Sigstore integration time:
-
Permalink:
Syvel-io/syvel-python@5f040aad0da41f58f4ad418dfb3d9a8246c105bd -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Syvel-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5f040aad0da41f58f4ad418dfb3d9a8246c105bd -
Trigger Event:
push
-
Statement type:
File details
Details for the file syvel-0.1.0-py3-none-any.whl.
File metadata
- Download URL: syvel-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b4f4ab6f47736901725118839857a71ef2aa25562871a2241972db8d60f7925
|
|
| MD5 |
ff949dea7111fcfc51740f9cc9d9e9c7
|
|
| BLAKE2b-256 |
9f1ad0972b138fa1a065593ef43fa508bfb8d1091e89dc14751c5ec557f19c64
|
Provenance
The following attestation bundles were made for syvel-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Syvel-io/syvel-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
syvel-0.1.0-py3-none-any.whl -
Subject digest:
8b4f4ab6f47736901725118839857a71ef2aa25562871a2241972db8d60f7925 - Sigstore transparency entry: 1227480059
- Sigstore integration time:
-
Permalink:
Syvel-io/syvel-python@5f040aad0da41f58f4ad418dfb3d9a8246c105bd -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Syvel-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5f040aad0da41f58f4ad418dfb3d9a8246c105bd -
Trigger Event:
push
-
Statement type: