Anmelden
Data collection

How to Verify a Residential IP Address Is Genuine Using Python

How to Verify a Residential IP Address Is Genuine Using Python

To verify whether a residential IP is genuine with Python, the most practical 4-step workflow is: validate the IP, reject non-public ranges, query a residential-proxy intelligence dataset, and turn the response into a clear pass/review/fail verdict. This works because Python's ipaddress module can reliably classify valid IPv4/IPv6 and routability-related properties, while IPinfo's residential proxy endpoint returns attribution signals such as service, last_seen, and percent_days_seen.

Step 1: Validate the IP and reject non-public ranges

A valid IP string is not automatically a usable residential IP, so your first gate should be Python's ipaddress.ip_address() plus public-routability checks such as is_global, while excluding obvious non-candidates like private, loopback, reserved, and unspecified ranges. The Python docs explicitly document ip_address() for IPv4/IPv6 validation and expose properties including is_private, is_global, is_reserved, is_loopback, and is_unspecified, which makes this the right first filter before any API lookup.

The rule is simple: if the address is invalid or not globally reachable, stop immediately and mark it as FAIL for residential verification purposes.

import ipaddress

def normalize_public_ip(ip_text: str) -> str:
    ip = ipaddress.ip_address(ip_text.strip())

    if not ip.is_global:
        raise ValueError("IP is not globally reachable.")
    if ip.is_private or ip.is_loopback or ip.is_reserved or ip.is_unspecified:
        raise ValueError("IP is not a public residential candidate.")

    return str(ip)

Step 2: Query a residential-proxy intelligence dataset

Once the IP passes syntax and public-range checks, query a residential-proxy intelligence source instead of guessing from connectivity alone, because IPinfo's residential proxy dataset is specifically built to detect IPs associated with residential proxy providers. Its documented sample response includes service, last_seen, and percent_days_seen, which are exactly the fields you need to judge whether an IP has already been observed in a residential proxy network.

Here is a working Python verifier you can run directly:

import ipaddress
import requests
from dataclasses import dataclass
from typing import Optional

IPINFO_TOKEN = "YOUR_IPINFO_TOKEN"

@dataclass
class VerificationResult:
    ip: str
    valid: bool
    verdict: str
    service: Optional[str] = None
    last_seen: Optional[str] = None
    percent_days_seen: Optional[int] = None
    notes: str = ""

def normalize_public_ip(ip_text: str) -> str:
    ip = ipaddress.ip_address(ip_text.strip())

    if not ip.is_global:
        raise ValueError("IP is not globally reachable.")
    if ip.is_private or ip.is_loopback or ip.is_reserved or ip.is_unspecified:
        raise ValueError("IP is not a public residential candidate.")

    return str(ip)

def check_resproxy(ip: str, token: str) -> dict:
    url = f"https://ipinfo.io/resproxy/{ip}?token={token}"
    r = requests.get(url, timeout=15)
    r.raise_for_status()
    return r.json()

def verify_residential_ip(ip_text: str, token: str) -> VerificationResult:
    try:
        ip = normalize_public_ip(ip_text)
    except ValueError as e:
        return VerificationResult(
            ip=ip_text,
            valid=False,
            verdict="FAIL",
            notes=str(e)
        )

    data = check_resproxy(ip, token)
    service = data.get("service")
    last_seen = data.get("last_seen")
    percent_days_seen = data.get("percent_days_seen")

    if service:
        verdict = "FAIL" if percent_days_seen else "REVIEW"
        return VerificationResult(
            ip=ip,
            valid=True,
            verdict=verdict,
            service=service,
            last_seen=last_seen,
            percent_days_seen=percent_days_seen,
            notes="Residential-proxy attribution detected."
        )

    return VerificationResult(
        ip=ip,
        valid=True,
        verdict="PASS",
        notes="No residential-proxy attribution returned by this dataset."
    )

if __name__ == "__main__":
    target_ip = input("Enter IP address: ").strip()
    result = verify_residential_ip(target_ip, IPINFO_TOKEN)
    print(result)

Step 3: Turn the response into a clear verdict

The result should not be interpreted as a simple yes/no lookup, because a public IP can still be real-looking traffic and also be recognized as part of a residential proxy service in a detection dataset. A practical interpretation framework is to treat "no service returned" as PASS, "service returned with limited context" as REVIEW, and "service returned with clear repeated observation history" as FAIL, because IPinfo's response is designed to expose exactly that attribution history.

VerdictWhat it means
PASSThe IP is valid, globally reachable, and the residential-proxy dataset returned no service attribution for it.
REVIEWThe IP is valid, but the dataset returned proxy-service attribution that needs human review before you trust it for sensitive use.
FAILThe IP is invalid, non-global, or clearly tied to a residential proxy service according to the detection response.

One important limitation should be stated clearly: a clean result today is not universal proof that the IP is permanently unflagged, because the dataset is updated daily and proxy attribution changes over time.

Step 4: Log results and rerun checks periodically

To make this genuinely useful in production, log every verification result to CSV and rerun checks periodically rather than relying on one screenshot or one successful request. That recommendation is grounded in the fact that the residential proxy dataset is updated every 24 hours and exposed through real-time API responses, which means your verification process should be repeatable, not one-off.

Add this logging helper:

import csv
from datetime import datetime

def append_result_to_csv(result, filename="ip_verification_log.csv"):
    with open(filename, "a", newline="", encoding="utf-8") as f:
        writer = csv.writer(f)
        writer.writerow([
            datetime.utcnow().isoformat(),
            result.ip,
            result.valid,
            result.verdict,
            result.service,
            result.last_seen,
            result.percent_days_seen,
            result.notes,
        ])

For batch checks, feed a list of IPs through the same verifier and review anything that lands in REVIEW before you promote it into a production proxy pool.

CTA

If you want to compare your verification workflow against a commercial residential proxy provider, proxy001.com is a useful benchmark because its public site advertises 100M+ residential IPs across 200+ locations, 99.9% uptime, sub-0.3 second speed, and SOCKS5/HTTP(S) support. That makes it a practical external reference point when you want to test whether your Python verification logic can distinguish between a syntactically valid public IP and a route that is actually suitable for residential proxy use.

Mehr lesen

Mehr anzeigen

How to Prevent Facebook Ad Account Bans: Choosing the Right Proxy

Data collection

Why Free Proxies Fail in Market Research ,And What to Use Instead

Residential proxies

Geoblocking and Content Verification: Why Streaming Companies Need Residential IPs

Residential proxies

Haben Sie weitere Fragen
about our products?

Kostenlos starten
Telegram