DisposableGuard

FastAPI (Python)

import os, httpx
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel

app = FastAPI()

class SignupRequest(BaseModel):
    email: str
    password: str

async def is_disposable(email: str) -> bool:
    async with httpx.AsyncClient() as client:
        r = await client.get(
            "https://api.disposableguard.com/v1/check",
            params={"email": email},
            headers={"Authorization": f"Bearer {os.environ['DG_KEY']}"},
            timeout=5.0,
        )
        if not r.is_success:
            return False
        return r.json()["is_disposable"]

@app.post("/signup")
async def signup(req: SignupRequest):
    if await is_disposable(req.email):
        raise HTTPException(status_code=400, detail="Please use a real email address.")
    # ...signup logic
    return {"ok": True}

Notes

Requires httpx for async HTTP. Install with `pip install httpx`.