Skip to content
GitHub

Python SDK

The security.dev Python SDK provides a simple way to integrate our security APIs into your Python applications.

Install the SDK:

pip install securitydev
from securitydev import SecurityClient

# Initialize with your API key
client = SecurityClient(key="<your_app_key>")

The IP Intel API is accessible through the user_intel property of the client.

Get information about an email address:

import securitydev

email = "[email protected]"
e = securitydev.user_intel.email(email)
if e.is_disposable:
    print(f"{email} is a diposable mail from {e.providers}")

The IP Intel API is accessible through the ip_intel property of the client.

Get geolocation information for an IP address:

geo = client.ip_intel.geolocate("9.9.9.9")

# Access geolocation data
print(geo.country.name)  # "United States"
print(geo.city.name)     # "Ashburn"
print(geo.location.latitude)  # 39.0438
print(geo.location.longitude) # -77.4874

Get reputation data for an IP address:

rep = client.ip_intel.reputation("9.9.9.9")

# Access reputation data
print(rep.is_abuser)  # False
print(rep.is_tor_exit)  # False
print(rep.is_proxy)    # False
from securitydev import SecurityClient

client = SecurityClient(key="<your_app_key>")

# Get IP reputation data
rep = client.ip_intel.reputation(request.ip)

# Block TOR exit nodes
if rep.is_tor_exit:
    raise Http404("Not Found")
from securitydev import SecurityClient

client = SecurityClient(key="<your_app_key>")

# Get IP geolocation data
geo = client.ip_intel.geolocate(request.ip)

# Restrict access to specific countries
allowed_countries = ["US", "CA", "GB"]
if geo.country.code not in allowed_countries:
    return HttpResponse("Service not available in your region", status=403)