Integrate VerifyWall with Django in minutes
Add fraud detection to your Django application using Python's requests library and Django's view system.
Install dependencies
Install the requests library and add your API key to Django settings.
pip install requestsCreate a verification service
Create a service module that wraps the VerifyWall API. Import Django settings to access your API key.
import requests
from django.conf import settings
def verify(email=None, ip=None):
response = requests.post(
f"{settings.VERIFYWALL_URL}/v1/verify",
headers={
"Authorization": f"Bearer {settings.VERIFYWALL_API_KEY}",
},
json={"email": email, "ip": ip},
)
response.raise_for_status()
return response.json()["data"]["attributes"]
def check(subject):
response = requests.get(
f"{settings.VERIFYWALL_URL}/v1/check",
headers={
"Authorization": f"Bearer {settings.VERIFYWALL_API_KEY}",
},
params={"q": subject},
)
response.raise_for_status()
return response.json()["data"]["attributes"]Add to your registration view
Call VerifyWall in your registration view to evaluate risk before creating user accounts.
from django.http import JsonResponse
from django.contrib.auth import login
from services.verifywall import verify
def register(request):
if request.method != "POST":
return render(request, "register.html")
email = request.POST["email"]
password = request.POST["password"]
risk = verify(
email=email,
ip=get_client_ip(request),
)
if risk["risk_level"] == "high":
return JsonResponse(
{"error": "We could not verify your identity."},
status=422,
)
user = User.objects.create_user(
email=email,
password=password,
)
user.risk_score = risk["risk_score"]
user.save()
login(request, user)
return redirect("/dashboard")
def get_client_ip(request):
xff = request.META.get("HTTP_X_FORWARDED_FOR")
return xff.split(",")[0] if xff else request.META.get("REMOTE_ADDR")Verify the integration
Test from the Django shell to confirm your API key and connection are working.
# Run: python manage.py shell
from services.verifywall import verify
result = verify(email="[email protected]")
print(result)
# {'risk_score': 65, 'risk_level': 'high', ...}Frequently asked questions
Does VerifyWall work with Django REST Framework?
Yes. Call the verify function in your DRF serializer validate() method or in the view perform_create() hook. The integration pattern is identical — only the Django entry point differs.
Can I run the verification in a Celery task?
Yes. Dispatch a Celery task after registration to check the user asynchronously. Update a risk_score field on the user model and use Django signals or periodic checks to flag high-risk accounts.
How do I handle API timeouts in Django?
Pass a timeout parameter to requests.post(): requests.post(url, json=data, timeout=5). This ensures your registration flow is not blocked if the API is temporarily slow. You can also wrap the call in a try/except and allow the signup through if the API is unreachable.
Related resources
Detection Methods
Documentation
Ready to integrate?
Get your API key and start protecting your Django application in minutes.