Docs
Verify emails in FastAPI
Use an async endpoint with httpx. The API key stays on your server; the browser only talks to your own endpoint.
Before you start
Create an API key under Settings → API keys and keep it in an environment variable named VALIDREACH_API_KEY on your server. Never ship it in browser or mobile code.
Example
import os
import httpx
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class EmailIn(BaseModel):
email: str
@app.post("/verify")
async def verify(payload: EmailIn):
async with httpx.AsyncClient(timeout=30) as client:
res = await client.post(
"https://validreach.dev/api/v1/verify/single",
headers={"Authorization": f"Bearer {os.environ['VALIDREACH_API_KEY']}"},
json={"email": payload.email},
)
body = res.json()
if not body.get("success"):
return {"status": "unknown"}
data = body["data"]
return {"status": data["status"], "is_deliverable": data["is_deliverable"]}Handle the result
Branch on data.status. Treat invalid and disposable as rejections, retry unknown later when retryable is true (unknown is not billed), and decide on catchall, risky and role by your own policy. HTTP 402 means out of credits and 429 means rate limited.
Related