This guide walks you through detecting VPN, proxy, TOR, and bot IP addresses in Python using the Focsec API.

By the end, you'll be able to check any IP address and determine whether it's hiding behind a VPN service, proxy server, or the TOR network.

1

Install the requests library

We'll use the requests library to make HTTP calls to the Focsec API. Install it with pip:

bash
pip install requests
2

Check an IP for VPN or proxy

Here's a simple example that checks if an IP address is using a VPN or proxy.

Don't have an API key yet? Sign up for free to get one.

python
import requests

API_KEY = "your-api-key-here"
IP_ADDRESS = "82.40.11.200"

response = requests.get(
    f"https://api.focsec.com/v1/ip/{IP_ADDRESS}",
    headers={"Authorization": API_KEY}
)

data = response.json()
print(data)

API Response

The API returns detection flags for VPN, proxy, TOR, and bots, plus geolocation details:

Response
{
  "ip": "82.40.11.200",
  "is_vpn": false,
  "is_proxy": false,
  "is_bot": false,
  "is_tor": false,
  "is_datacenter": false,
  "city": "London",
  "country": "United Kingdom",
  "iso_code": "gb",
  "is_in_european_union": false,
  "flag": "šŸ‡¬šŸ‡§",
  "autonomous_system_number": 5089,
  "autonomous_system_organization": "Virgin Media Limited"
}
3

Detect suspicious IPs

Create a function to check if an IP is using any anonymization method:

python
import requests

def check_ip(ip_address: str, api_key: str) -> dict:
    """Check if an IP is a VPN, proxy, TOR, or bot."""
    response = requests.get(
        f"https://api.focsec.com/v1/ip/{ip_address}",
        headers={"Authorization": api_key}
    )
    response.raise_for_status()
    return response.json()

def is_suspicious(data: dict) -> bool:
    """Returns True if IP is VPN, proxy, TOR, datacenter, or bot."""
    return any([
        data.get("is_vpn"),
        data.get("is_proxy"),
        data.get("is_tor"),
        data.get("is_bot"),
        data.get("is_datacenter"),
    ])

# Usage
result = check_ip("82.40.11.200", "your-api-key")

if is_suspicious(result):
    print(f"VPN/Proxy detected: {result['ip']}")
else:
    print(f"Clean IP: {result['ip']}")

Next steps

You're ready to detect VPN and proxy IPs in your Python application. Check the API Reference for all available response fields and error codes.

Ready to get started?

Sign up for a free account and start detecting VPNs, proxies, and bots in your application.

Get your API key »