Email validation · Integrations · Python

Integration guide

Email validation in Python.

Validate any email address from Python with one API call using requests or httpx. Working code, the real JSON response shape, error handling, and where the call belongs in a Django or FastAPI project.

In this guide

Endpoint1 POST
Median responseSub-1s
Free tier100 / month
Standard plan$49.99 / 50,000

How do I validate an email with Python?

No SDK to install. requests or httpx, whichever your project already depends on.

Python, with requests

import os import requests API = "https://api.trueguard.io/v2/email/validation" def validate_email(email: str) -> dict: res = requests.post( API, headers={"X-API-KEY": os.environ["TRUEGUARD_KEY"]}, json={"email": email}, timeout=5, ) res.raise_for_status() return res.json() result = validate_email("founder@yourcompany.com") if result["deliverability"]["status"] == "invalid": # reject the submission ...

One header, one body field

Set X-API-KEY to your key and POST a JSON body with a single email field. HTTPS only. The response carries the seven signals plus one deliverability status.

Response fields you will branch on

deliverability.status

safe, risky, invalid or unknown. This is the field to branch on.

syntax.isValid

RFC 5322 format check. Deterministic, so a false here is always a typo or a malformed address.

quality.isDisposable

True for throwaway providers. Usually a hard block at signup.

deliverability.isCatchall

True when the domain accepts any address. The status is then risky, unless a second check confirmed or ruled out the mailbox.

quality.isRole

info@, support@, sales@. Route these differently rather than rejecting them.

Run it once before you write any code.

The same endpoint the snippet above calls. 10 free checks a day, no key needed.

Or try

Where should the call live in a Python app?

Your API key is a secret. Where you put this call decides whether it stays one.

In a template or client-facing view

Do not put the key anywhere that reaches the client, and do not call the endpoint inline in a template render. Keep it in a service function your view calls, with the key read from the environment.

In a service module, called from your view

A Django form's clean method, a DRF serializer validator or a FastAPI dependency are all good homes. The key stays server-side in an environment variable and you branch on the status before the record is saved.

What the endpoint returns

{ "email": "founder@yourcompany.com", "rawEmail": "founder@yourcompany.com", "syntax": { "isValid": true }, "deliverability": { "status": "safe", "isSmtpValid": true, "isMxValid": true, "isCatchall": false, "isInboxFull": false, "isDeliverable": true, "isDisabled": false, "mxRecords": ["mx1.yourcompany.com", "mx2.yourcompany.com"] }, "domain": { "name": "yourcompany.com", "age": 2841, "isLive": true, "isRisky": false }, "quality": { "isDisposable": false, "isFree": false, "isRole": false, "isSubaddress": false } }

How do I handle errors and rate limits in Python?

from requests import HTTPError, Timeout try: result = validate_email(email) except HTTPError as err: status = err.response.status_code if status == 429: # quota or rate limit: allow with a flag return allow_with_flag(email) if status == 401: logger.error("Trueguard key rejected") return allow_with_flag(email) except Timeout: return allow_with_flag(email)

Status

What to do

200

Validation ran. Read deliverability.status and branch.

400

Malformed request body. Check you are sending JSON with an email field.

401

Missing or rejected API key. Log it loudly: every request is failing.

429

Rate limit or monthly quota reached. Allow the user through with a flag and alert yourself; do not block real signups on your own quota.

5xx

Retry once with a short backoff, then fall back to allowing with a flag.

Which Python frameworks does this work with?

It is one HTTPS request, so anything that can make one works. These are the stacks people ask about.

DjangoDjango REST FrameworkFastAPIFlaskCelery taskspandas scriptsAWS LambdaAirflow DAGs

Django form validation

Call validate_email in the form's clean_email method, so an invalid address shows as a field error before the user is saved.

FastAPI dependency

Wrap the check in an async dependency built on httpx and inject it into your signup route. The event loop stays free while the mail server answers.

pandas list cleaning

Validate a DataFrame column, write the status back as a new column, and keep only the safe rows before an import or a campaign.

Nightly re-check with Celery

Re-check stored addresses in a scheduled task and flag contacts whose mailbox has become invalid since they signed up.

What it costs once you ship.

Three tiers. The free plan needs no card and runs the production endpoint.

Free

$0 forever

100 validations / month

Overage: n/a

Get started free

Standard

Popular

$49.99 / month

50,000 validations / month

Overage: $0.001 per validation

Get your API key

Custom

Contact us

500,000+ validations / month

Overage: Negotiated

Talk to us

Frequently asked questions

The full field reference lives in the API documentation.

requests or httpx?

Either. requests is the shortest path in a synchronous view; httpx is the better fit inside FastAPI or anything async, because it will not block the event loop.

Where does this belong in Django?

In a service function called from the form's clean method or a serializer validator, so the verdict is available before the model is saved and the error surfaces on the field the user can fix.

How do I validate a whole CSV?

Loop the column and call the endpoint per row, with a small concurrency limit and a retry on 429. A 50,000-row list fits inside the Standard plan quota; there is no bulk upload endpoint.

What timeout should I set?

Around 5 seconds. Median response is under a second, but SMTP checks wait on the destination server. On timeout, allow the record with a flag rather than blocking a real user.

Is there an official Python SDK?

No. The endpoint is one POST with one header and one body field, so a ten-line function covers it and there is no dependency to keep up to date.

Validate emails from Python in minutes.

100 validations a month, free, no card. Working code above, production endpoint, same response shape on every plan.

Get your free API key

No credit card required.

trueguard-logo© 2026 Trueguardinfo@trueguard.io