ipwhois
ipwhois is a Python package designed for retrieving and parsing whois data for both IPv4 and IPv6 addresses. It is currently at version 1.3.0 and actively maintained, though its release cadence can be irregular.
Warnings
- breaking The `IPWhois.lookup()` method was deprecated in older versions (around 0.15.0) and completely removed in v1.0.0. Calling it will result in an AttributeError or similar failure.
- breaking Version 1.2.0 removed several previously deprecated functions and parameters, including `asn.IPASN._parse_fields_*`, `net.Net.lookup_asn`, `asn_alts`, and `allow_permutations`. Code relying on these will break.
- gotcha If you are using an older version of `ipwhois` with a newer version of `dnspython`, you might encounter issues related to deprecated `dnspython` query methods. `ipwhois` v1.3.0 addressed this compatibility.
- gotcha Frequent or excessive queries, particularly against services like LACNIC, can lead to rate limiting based on your source IP, resulting in latency or blocked requests.
- gotcha The `root_ent_check` argument in `IPWhois.lookup_rdap()` (introduced in v1.2.0) defaults to `True`. While this provides more complete data, it can significantly increase the number of queries and potentially trigger rate-limiting.
Install
-
pip install ipwhois
Imports
- IPWhois
from ipwhois.ipwhois import IPWhois
from ipwhois import IPWhois
Quickstart
from ipwhois import IPWhois from pprint import pprint # Using a public IP for demonstration ip_address = '74.125.225.229' # Initialize IPWhois object obj = IPWhois(ip_address) # Perform RDAP lookup (recommended method) # depth=1 retrieves top-level network information # For more recursive lookups, increase depth results = obj.lookup_rdap(depth=1) pprint(results)