Build a Python script to audit geolocation & blacklist at scale

Quick answer

When a list runs to hundreds or thousands of IPs, you script the audit. This guide sketches the architecture of a Python tool that checks geolocation and blocklist status across many addresses asynchronously — the pattern, not a copy-paste blob, so you understand what you’re building.

Why audit IPs asynchronously?

Auditing IPs is I/O-bound — you spend almost all the time waiting on network responses, not computing. Checking 500 IPs one at a time, each waiting for a reply, takes forever. Doing them concurrently — firing many lookups and handling replies as they arrive — turns minutes into seconds. Python’s asyncio with an async HTTP client (like aiohttp) is the natural fit.

The shape of the script

Four stages: load the IP list (from a file or log extract), look up each IP concurrently against your data sources, collect the results, and write a combined CSV/JSON report. The core is an async function that audits one IP, wrapped in a gather that runs many at once under a concurrency limit.

Where the data comes from

For each IP you need geolocation/ASN and blocklist status. Our developer endpoints provide IP and network data you can query per address from the script. For blocklist status, you query the DNSBL zones over DNS (the same lists our Blacklist Check tool uses). Keep each data source behind its own small async function so the auditor just composes them.

Three things that matter in practice

Rate limiting: don’t fire 1,000 requests at once — cap concurrency (an asyncio.Semaphore) to a sane number so you don’t hammer any service or trip its limits. Error handling: a single IP that errors or times out shouldn’t kill the whole run — catch per-IP exceptions and record a null result. Caching: if the same IPs recur across runs, cache results so you’re not re-querying unchanged data.

Respecting the services you query

Whatever data sources you use, stay within their terms and rate limits — that’s both courteous and what keeps your script working. DNSBLs in particular rate-limit shared lookups, so a clean blocklist result at scale is indicative, not absolute (the same caveat our tools carry). Build in backoff for rate-limit responses rather than retrying blindly.

Output that’s actually useful

Write a CSV with one row per IP: address, country, ASN organisation, reverse DNS, blocklist count. That format drops straight into a spreadsheet for sorting — group by ASN to spot botnet clusters, filter by blocklist hits to find the worst offenders, or hand it to your firewall automation. The report is the point; the async machinery just gets you there quickly.

Related: Developer API · Bulk IP Audit tool

0 IPs logged or stored
2 stacks shown (v4 & v6)
8+ diagnostic tools
lookups, always free