{"id":2246,"library":"python-whois","title":"Python WHOIS Client","description":"python-whois is a Python library for querying WHOIS servers directly and parsing domain registration information. It aims to provide structured data for various Top-Level Domains (TLDs) and is currently at version 0.9.6, with recent activity in October 2025. The library focuses on direct server queries rather than relying on intermediate web services.","status":"active","version":"0.9.6","language":"en","source_language":"en","source_url":"https://github.com/richardpenman/whois","tags":["networking","whois","domain information","parsing","security"],"install":[{"cmd":"pip install python-whois","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Improved parsing of various date formats in WHOIS records into datetime objects.","package":"python-dateutil","optional":true},{"reason":"Required for SOCKS proxy support.","package":"PySocks","optional":true}],"imports":[{"note":"The primary function is accessed directly via 'whois.whois(domain)'. Do not confuse with other 'whois' libraries or attempt to import sub-modules directly without explicit documentation.","wrong":"from whois import whois_query_function","symbol":"whois","correct":"import whois"}],"quickstart":{"code":"import whois\n\n# Query WHOIS for a domain\ndomain = \"example.com\"\nw = whois.whois(domain)\n\n# Access parsed attributes\nprint(f\"Domain Name: {w.domain_name}\")\nprint(f\"Registrar: {w.registrar}\")\nprint(f\"Creation Date: {w.creation_date}\")\nprint(f\"Expiration Date: {w.expiration_date}\")\nprint(f\"Name Servers: {w.name_servers}\")\n\n# Print all found attributes (as a dictionary)\n# print(w.text) # Uncomment to see the raw WHOIS text\n# print(w)","lang":"python","description":"The quickstart demonstrates how to import the `whois` module and use the `whois.whois()` function to retrieve and parse domain registration data. Key attributes like domain name, registrar, dates, and name servers are easily accessible. The raw WHOIS text is also available."},"warnings":[{"fix":"Always validate the returned data and implement error handling for missing attributes. Consider falling back to raw text parsing for critical, unparsed fields if needed.","message":"WHOIS data is semi-structured and can vary significantly between TLDs and registrars. Parsing may not always be 100% accurate or complete, and some fields might be missing or in unexpected formats.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Implement robust error handling, retry mechanisms with exponential backoff, and consider using a SOCKS proxy (with PySocks installed and configured via the SOCKS environment variable) for improved reliability or to circumvent IP-based restrictions.","message":"Direct WHOIS queries can be subject to rate limiting, firewalls, or network issues, leading to timeouts. Some WHOIS servers might be temporarily unavailable or return incomplete responses.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Verify installation with `pip show python-whois`. If you have a local `whois.py` file, rename it. If using an alternative `whois` library, ensure you are importing it correctly as per its documentation.","message":"Due to multiple Python libraries existing with 'whois' in their name (e.g., `pythonwhois`, `whoisdomain`, `ipwhois`), it's common to encounter `AttributeError: module 'whois' has no attribute 'whois'` if the wrong package is installed or a local file conflicts. Ensure you have installed `python-whois` (from richardpenman) and that no local `whois.py` file shadows the library.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}