Django integration
Block disposable emails in Django
You're running a Django app and fake signups keep getting through. Add one call to your signup view, or a small middleware, and Fidro checks every email and IP before the account exists.
How it works
Send the user's email and IP to Fidro with requests, from a view or a small middleware. Fidro checks the address, the network and what it has already seen from them, then answers allow, challenge or block. No Django package 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 requests
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.
# fidro/client.py
import os
import requests
FIDRO_API_KEY = os.environ["FIDRO_API_KEY"]
def check_signup(email: str, ip: str) -> dict:
response = requests.post(
"https://fidro.io/api/validate",
headers={"Authorization": f"Bearer {FIDRO_API_KEY}"},
json={"email": email, "ip": ip, "event": "signup"},
timeout=5,
)
response.raise_for_status()
return response.json()
def client_ip(request) -> str:
forwarded = request.META.get("HTTP_X_FORWARDED_FOR")
return forwarded.split(",")[0].strip() if forwarded else request.META.get("REMOTE_ADDR", "")
# ----- In a view -----
# views.py
import json
from django.http import JsonResponse
from django.views.decorators.http import require_POST
from fidro.client import check_signup, client_ip
@require_POST
def signup_view(request):
email = json.loads(request.body).get("email")
result = check_signup(email, client_ip(request))
if result["recommendation"] == "block":
return JsonResponse({"error": "This signup has been flagged as high risk"}, status=403)
# Create the account...
return JsonResponse({"recommendation": result["recommendation"]})
# ----- Or as middleware -----
# middleware.py
import json
import requests
from fidro.client import check_signup, client_ip
class FidroFraudMiddleware:
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
return self.get_response(request)
def process_view(self, request, view_func, view_args, view_kwargs):
if request.method == "POST":
try:
email = json.loads(request.body).get("email")
if email:
request.fidro_result = check_signup(email, client_ip(request))
except (ValueError, requests.RequestException):
pass # Fail open: never block real users on an outage
return None
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.
# fidro/client.py
import os
import requests
FIDRO_API_KEY = os.environ["FIDRO_API_KEY"]
def lookup_ip(ip: str) -> dict:
response = requests.get(
f"https://fidro.io/api/ip/{ip}",
headers={"Authorization": f"Bearer {FIDRO_API_KEY}"},
timeout=5,
)
response.raise_for_status()
return response.json()
# ----- In a view -----
# views.py
from django.http import JsonResponse
from fidro.client import client_ip, lookup_ip
def check_ip_view(request):
result = lookup_ip(client_ip(request))
return JsonResponse({
"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 Django?
Does Fidro have a Django SDK?
Is Fidro free to use with Django?
What should I do when Fidro says challenge?
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.