Fidro + FastAPI Integration
Async fraud detection for FastAPI. Follow this guide to add email validation and IP intelligence in minutes.
Overview
To integrate Fidro with FastAPI, use the httpx async client to send a POST request to the Fidro API with the user's email and IP address. Fidro returns email validation, disposable domain detection, IP geolocation, VPN detection, and a fraud risk score in a single async API call. FastAPI's async-first design pairs perfectly with Fidro's API — no SDK is needed, and httpx handles non-blocking requests out of the box.
Fidro is a fraud detection API that combines email validation, IP intelligence, geolocation analysis, and Stripe chargeback prevention in a single API call. It returns a risk score with a clear recommendation — allow, review, or block — so you can stop fraud without building your own scoring logic.
1. Install Dependencies
pip install httpx
You will also need a Fidro API key. Sign up for free to get one.
2. Email Validation
Send a POST request to Fidro's /v1/validate endpoint with the user's email address and optional IP. Fidro validates the email, checks for disposable domains, analyzes the IP for VPN/proxy/Tor usage, and returns a risk score with a clear recommendation — allow, review, or block.
import os
import httpx
from fastapi import FastAPI, Request, HTTPException
app = FastAPI()
FIDRO_API_KEY = os.environ["FIDRO_API_KEY"]
async def validate_email(email: str, ip: str) -> dict:
async with httpx.AsyncClient() as client:
response = await client.post(
"https://api.fidro.io/v1/validate",
headers={
"Authorization": f"Bearer {FIDRO_API_KEY}",
"Content-Type": "application/json",
},
json={"email": email, "ip": ip},
)
response.raise_for_status()
return response.json()
@app.post("/signup")
async def signup(request: Request):
body = await request.json()
email = body.get("email")
ip = request.client.host
result = await validate_email(email, ip)
data = result["data"]
if data["recommendation"] == "refund":
raise HTTPException(status_code=403, detail="Signup blocked due to fraud risk")
return {
"message": "Signup successful",
"risk_score": data["risk_score"],
"recommendation": data["recommendation"],
}
# ----- Dependency injection example -----
from fastapi import Depends
async def get_fidro_result(request: Request):
body = await request.json()
email = body.get("email")
if not email:
return None
ip = request.client.host
return await validate_email(email, ip)
@app.post("/checkout")
async def checkout(fidro=Depends(get_fidro_result)):
if fidro and fidro["data"]["recommendation"] == "refund":
raise HTTPException(status_code=403, detail="Transaction blocked")
return {"status": "ok"}
3. IP Lookup
Send a POST request to Fidro's /v1/ip-lookup endpoint with an IP address. Fidro returns geolocation data (country, city, ISP), VPN and proxy detection, Tor exit node identification, and threat intelligence — all in a single API call.
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() as client:
response = await client.post(
"https://api.fidro.io/v1/ip-lookup",
headers={
"Authorization": f"Bearer {FIDRO_API_KEY}",
"Content-Type": "application/json",
},
json={"ip": ip},
)
response.raise_for_status()
return response.json()
@app.get("/check-ip")
async def check_ip(request: Request):
ip = request.client.host
result = await lookup_ip(ip)
data = result["data"]
return {
"country": data["country"],
"is_vpn": data["is_vpn"],
}
Next steps
Explore the full API reference, try the free email checker, or see how Fidro compares to other solutions.
Frequently Asked Questions
How do I add fraud detection to FastAPI?
Does Fidro have a FastAPI SDK?
Is Fidro free to use with FastAPI?
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.
Get Started Free