Whois Domain
raw JSON → 1.20260326.1 verified Fri May 01 auth: no python
Python library for retrieving WHOIS information of domains. Provides domain registration details like registrar, creation date, expiration date, and name servers. Supports a wide range of TLDs through embedded server configurations. Current version: 1.20260326.1, requires Python >=3.9. Active development with monthly releases.
pip install whois Common errors
error AttributeError: module 'whois' has no attribute 'whois' ↓
cause The library is imported but the import is wrong or the package is not installed correctly.
fix
Ensure you installed the correct package: 'pip install whois'. Then use 'import whois' and call 'whois.whois(domain)'.
error whois.parser.PywhoisError: Failed to parse WHOIS response for <domain> ↓
cause The WHOIS server returned an unexpected format or the domain has no WHOIS record.
fix
Verify the domain exists and is registered. If the issue persists, try querying with a different server or update the library to the latest version.
error TypeError: 'str' object is not callable ↓
cause Accidentally imported the function as 'from whois import whois' but later reassigned 'whois' to a string or other non-callable.
fix
Use 'import whois' and call 'whois.whois()', not 'whois()' directly.
Warnings
gotcha Import the library using 'import whois', not 'from whois import whois'. The module name and function name are the same, which can be confusing. ↓
fix Use 'import whois' then call 'whois.whois(domain)'.
deprecated The 'whois' function returns a simple object in older versions; newer versions return a more structured object. Avoid relying on attribute names without checking the actual response. ↓
fix Always access fields using dict-like or attribute access after checking the object type.
gotcha WHOIS servers often have rate limits. Making many queries in quick succession may result in temporary IP bans or incomplete results. ↓
fix Add delays between queries (e.g., time.sleep(1)) or use a rotating proxy list.
breaking The 'tld' parameter behavior changed in 1.20240129.1. The library now handles some second-level domains for .uk differently. ↓
fix If you rely on custom TLD handling, verify results for .uk domains.
Imports
- whois
import whois
Quickstart
import whois
domain = whois.whois('example.com')
print(domain.text)