All Integrations

FastAPI integration

Block disposable emails in FastAPI

You're running a FastAPI service and fake signups keep getting through. Add one async call, in a route or as a dependency, and Fidro checks every email and IP before the account exists.

How it works

Send the user's email and IP to Fidro with httpx's async client, from a route or a dependency, so the check never blocks your event loop. Fidro checks the address, the network and what it has already seen from them, then answers allow, challenge or block. No SDK needed.

One fake signup can look perfectly normal. Five from the same IP in an hour don't. Send event and user_id with each call and Fidro remembers, so it catches the pattern as well as the person. You get a score from 0 to 100 and one answer: allow, challenge or block.

1. Install what you need

pip install httpx

You'll also need an API key. Sign up free and you'll have one in a minute, no card needed.

2. Check every signup

Send the email and IP to POST /api/validate. Fidro checks for disposable domains, missing mail servers, VPNs, proxies and Tor, and answers allow, challenge or block. Let the allows straight in, ask the challenges to confirm their email, and turn the blocks away.

import os
import httpx
from fastapi import Depends, FastAPI, HTTPException, Request

app = FastAPI()
FIDRO_API_KEY = os.environ["FIDRO_API_KEY"]

async def check(email: str, ip: str, event: str) -> dict:
    async with httpx.AsyncClient(timeout=5) as client:
        response = await client.post(
            "https://fidro.io/api/validate",
            headers={"Authorization": f"Bearer {FIDRO_API_KEY}"},
            json={"email": email, "ip": ip, "event": event},
        )
        response.raise_for_status()
        return response.json()

@app.post("/signup")
async def signup(request: Request):
    body = await request.json()
    result = await check(body.get("email"), request.client.host, "signup")

    if result["recommendation"] == "block":
        raise HTTPException(status_code=403, detail="This signup has been flagged as high risk")

    # Create the account...
    return {"recommendation": result["recommendation"]}

# ----- Or as a dependency -----
async def fidro_checkout(request: Request):
    body = await request.json()
    email = body.get("email")
    return await check(email, request.client.host, "checkout") if email else None

@app.post("/checkout")
async def checkout(fidro=Depends(fidro_checkout)):
    if fidro and fidro["recommendation"] == "block":
        raise HTTPException(status_code=403, detail="This checkout has been flagged as high risk")
    return {"status": "ok"}

3. Look up an IP

Just want to know where a request came from? GET /api/ip/{ip} returns the country, city, ISP and network, without scoring. The VPN, proxy and Tor flags come from /api/validate, under data.checks.

import os
import httpx
from fastapi import FastAPI, Request

app = FastAPI()
FIDRO_API_KEY = os.environ["FIDRO_API_KEY"]

async def lookup_ip(ip: str) -> dict:
    async with httpx.AsyncClient(timeout=5) as client:
        response = await client.get(
            f"https://fidro.io/api/ip/{ip}",
            headers={"Authorization": f"Bearer {FIDRO_API_KEY}"},
        )
        response.raise_for_status()
        return response.json()

@app.get("/check-ip")
async def check_ip(request: Request):
    result = await lookup_ip(request.client.host)

    return {
        "country": result["location"].get("country_name"),
        "isp": result["location"].get("isp"),
    }

Want to see real results first? Try any address in the free IP checker.

Next steps

The API reference has every field. The free checker shows you real results. And if you're weighing up alternatives, the comparisons are honest about where others fit.

Frequently Asked Questions

How do I add fraud detection to FastAPI?
Send an async POST request to https://fidro.io/api/validate with httpx, passing the user's email and IP. Fidro returns a risk score from 0 to 100 and one recommendation: allow, challenge or block. It takes a few minutes and fits FastAPI's dependency injection.
Does Fidro have a FastAPI SDK?
You don't need one. Fidro is a plain REST API, so httpx.AsyncClient is all it takes, and it keeps every request non-blocking.
Is Fidro free to use with FastAPI?
Yes. The free plan covers 200 validations a month with no credit card, and it works in any FastAPI service, as a route, a dependency or middleware.
What should I do when Fidro says challenge?
Ask for something a real person will happily do and a script won't: confirm the email address, solve a CAPTCHA, or wait for a quick manual review. Save outright blocks for the clear cases.

Start catching bad signups in the next 5 minutes

Create your account, grab your API key, and send your first request. Free plan with 200 validations/month. No credit card. Cancel anytime.