IP to ASN Lookup
NOC Operator Toolkit
Longest-prefix-match routing table lookup against a live RouteViews BGP feed. IPv4 and IPv6. Free. No API key. No rate limits (be reasonable).
I had an old blocklist to audit. Specifically, checking whether a few hundred thousand IP prefixes still had legitimate owners in the routing table. Every public IP→ASN service I found either had rate limits too low to be useful, questionable data freshness, or a pricing page where a free tier used to be. I wasn’t interested in paying for the privilege of getting throttled more politely. So I built my own.
Feel free to query this API heavily (please stay under 100 requests per second, there is actual hardware behind this). IP→ASN mapping is sourced from the RouteViews BGP table data (both IPv4 and IPv6), imported every 4 hours. ASN registrant info is pulled directly from the RIR WHOIS servers (ARIN, RIPE, APNIC, LACNIC, AFRINIC) and cached for 24 hours to avoid overwhelming them.
Query the API
Enter any IPv4 or IPv6 address, or a CIDR prefix.
API Documentation
No authentication required. CORS headers are included on all responses.
Look up an IP address or CIDR prefix. Returns JSON with the longest matching BGP prefix and full ASN registrant information.
| Parameter | Type | Description |
|---|---|---|
| ip | string | An IPv4 or IPv6 address (8.8.8.8) or CIDR prefix (8.8.8.0/24). |
Identical lookup via JSON body. Useful when scripting bulk queries or when the IP address contains characters that are awkward to URL-encode.
| Field | Type | Description |
|---|---|---|
| query | string | The IP or prefix you submitted. |
| prefix | string | Longest-matching BGP prefix in the RouteViews routing table. |
| prefix_last_updated | string | UTC timestamp (ISO 8601) of the last RouteViews import that saw this prefix. Confirms data freshness. |
| asn | integer | Originating autonomous system number. |
| asn_name | string | Short AS name from the RIR (e.g. GOOGLE, CLOUDFLARE). |
| org_name | string | Full registered organisation name. |
| country | string | ISO 3166-1 alpha-2 country code of the registrant. |
| description | string | Free-text description or remarks from the RIR record. |
| rir | string | Registry that holds the ASN: ARIN, RIPE, APNIC, LACNIC, or AFRINIC. |
| whois_raw | string | First 4 KB of the raw WHOIS response text for the ASN. |
| cache_hit | boolean | true if the WHOIS result was served from the Redis cache (24-hour TTL). |
| HTTP | Meaning |
|---|---|
400 | Missing or invalid ip parameter. |
404 | No BGP prefix found that covers the queried address. |
503 | Database temporarily unavailable. |
Common Questions
Everything you probably wanted to know but the man page didn’t cover.
What is an ASN (Autonomous System Number)?
What is longest-prefix match and why does it matter?
10.0.0.0/8 and 10.1.0.0/16 exist, a query for 10.1.2.3
returns 10.1.0.0/16 because /16 is more specific. This is important for IP-to-ASN
lookups because the same IP block can be sub-allocated — you want the most specific announcement,
not just any covering aggregate.
Is the API really free with no rate limits?
How fresh is the data?
prefix_last_updated field (UTC ISO 8601 timestamp) so you can see exactly
when that particular prefix was last confirmed in the global table. ASN WHOIS registrant
data is fetched live on the first query for each ASN, then cached in Redis for
24 hours. The cache_hit field tells you whether the WHOIS
data came from cache or a live RIR lookup.
Does it support IPv6?
2606:4700::1) and IPv6 CIDR
prefixes (e.g. 2606:4700::/32). IPv4 routing data comes from the RouteViews
route-views2 collector and IPv6 data from the route-views6 collector.
Both are stored in the same PostgreSQL table and queried transparently.
Where does the ASN registrant data come from?
whois.iana.org to determine which RIR is
responsible, then querying that RIR (ARIN, RIPE, APNIC, LACNIC, or AFRINIC) for the full
record. Results are cached in Redis for 24 hours.