Integrate real-time email verification into your Python application in minutes
using the requests library.
pip install requests
Send a GET request with the email and your API token.
The helper below also handles interim Unknown results by waiting
RetryAfterSeconds and retrying automatically.
import time
import requests
API_URL = "https://api.validemail.net/"
API_KEY = "YOUR_API_KEY" # find it in your ValidEmail dashboard
def verify_email(email: str, max_retries: int = 3) -> dict:
"""Verify an email address, retrying while the result is still pending."""
for _ in range(max_retries):
response = requests.get(API_URL, params={"email": email, "token": API_KEY}, timeout=90)
response.raise_for_status()
result = response.json()
# "Unknown" means the verification is still in progress (e.g. greylisting).
retry_after = result.get("RetryAfterSeconds")
if result["State"] == "Unknown" and retry_after:
time.sleep(retry_after)
continue
return result
return result # still pending after max_retries — treat as risky
result = verify_email("someone@example.com")
print(f"Valid: {result['IsValid']}")
print(f"Score: {result['Score']}")
print(f"State: {result['State']}")
print(f"Reason: {result['Reason']}")
if result["IsValid"] and result["Score"] >= 80:
print("Safe to send.")
State = "Unknown")
Some mail servers greylist first-time senders or respond slowly. Instead of failing, the API returns an
interim 200 OK result with State = "Unknown", a Reason of
PENDING or GREYLISTED, and a RetryAfterSeconds hint while the
verification finishes in the background.
RetryAfterSeconds seconds, then repeat the same request to get the final verdict.Unknown as "not yet decided" — never as a delivery failure.The balance endpoint is free to call and never consumes a credit — perfect for a pre-flight check before verifying a large list.
balance = requests.get(
"https://api.validemail.net/balance",
params={"token": API_KEY},
timeout=30,
).json()["balance"]
print(f"Credits remaining: {balance}")
| HTTP Status | Meaning | What to do |
|---|---|---|
| 200 OK | The request was processed. Check State — a result with State = "Unknown" and a RetryAfterSeconds value is an interim answer, not a final verdict. |
Use the result. If State is Unknown, retry the same request after RetryAfterSeconds. |
| 400 Bad Request | Missing email/token parameter, no credits remaining, or a transient processing failure. |
Check the response text. If you are out of credits, top up your balance before retrying. |
| 401 Unauthorized | The API key is invalid or unknown. | Verify the token value against the API key shown in your dashboard. |
| 403 Forbidden | The account attached to this API key is inactive. | Contact info@validemail.net to reactivate the account. |
| 429 Too Many Requests | You exceeded your per-second request limit. The response body includes the configured limit. | Slow down and retry with backoff, or contact us to raise your rate limit. |
Explore every response field and status code in the full API reference.