{"id":15070054,"url":"https://github.com/pogzyb/asyncwhois","last_synced_at":"2025-10-06T04:09:30.224Z","repository":{"id":41069560,"uuid":"252333321","full_name":"pogzyb/asyncwhois","owner":"pogzyb","description":"Python WHOIS and RDAP utility for querying and parsing information about Domains, IPv4s, IPv6s, and AS numbers ","archived":false,"fork":false,"pushed_at":"2024-02-13T12:22:21.000Z","size":456,"stargazers_count":54,"open_issues_count":2,"forks_count":16,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-04-14T08:41:56.985Z","etag":null,"topics":["asyncio","hacktoberfest","ipv4","python","python3","rdap","rdap-client","tld","tor","whois","whois-client","whois-information","whois-lookup"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pogzyb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-04-02T02:12:56.000Z","updated_at":"2024-03-19T06:27:45.000Z","dependencies_parsed_at":"2024-02-13T14:32:28.197Z","dependency_job_id":null,"html_url":"https://github.com/pogzyb/asyncwhois","commit_stats":{"total_commits":223,"total_committers":5,"mean_commits":44.6,"dds":0.04035874439461884,"last_synced_commit":"c281a6c6fdbb6d7e1a1763b7b005b6f323f2e133"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pogzyb%2Fasyncwhois","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pogzyb%2Fasyncwhois/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pogzyb%2Fasyncwhois/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pogzyb%2Fasyncwhois/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pogzyb","download_url":"https://codeload.github.com/pogzyb/asyncwhois/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252853857,"owners_count":21814597,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asyncio","hacktoberfest","ipv4","python","python3","rdap","rdap-client","tld","tor","whois","whois-client","whois-information","whois-lookup"],"created_at":"2024-09-25T01:46:46.415Z","updated_at":"2025-10-06T04:09:25.203Z","avatar_url":"https://github.com/pogzyb.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"### asyncwhois\n\n[![PyPI version](https://badge.fury.io/py/asyncwhois.svg)](https://badge.fury.io/py/asyncwhois)\n![build-workflow](https://github.com/pogzyb/asyncwhois/actions/workflows/build-and-test.yml/badge.svg)\n[![codecov](https://codecov.io/gh/pogzyb/asyncwhois/branch/main/graph/badge.svg?token=Q4xtgezXGX)](https://codecov.io/gh/pogzyb/asyncwhois)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\n`asyncwhois` | Python utility for WHOIS and RDAP queries.\n\n#### Quickstart\n\n```python\nimport asyncio\nfrom pprint import pprint\n\nimport asyncwhois\n\n# pick a domain\ndomain = 'bitcoin.org'\n# domain could also be a URL; asyncwhois uses tldextract to parse the URL\n# domain = 'https://www.google.com?q=asyncwhois'\n\n# basic example\nquery_string, parsed_dict = asyncwhois.whois(domain)\n# query_string  # The semi-free text output from the whois server\n# parsed_dict   # A dictionary of key:values extracted from `query_string`\n\n# asyncio example\nloop = asyncio.get_event_loop()\nquery_string, parsed_dict = loop.run_until_complete(asyncwhois.aio_whois(domain))\n\npprint(parsed_dict)\n\"\"\"\n{created: datetime.datetime(2008, 8, 18, 13, 19, 55),\n dnssec: 'unsigned',\n domain_name: 'bitcoin.org',\n expires: datetime.datetime(2029, 8, 18, 13, 19, 55),\n name_servers: ['dns1.registrar-servers.com', 'dns2.registrar-servers.com'],\n registrant_address: 'P.O. Box 0823-03411',\n registrant_city: 'Panama',\n registrant_country: 'PA',\n registrant_name: 'WhoisGuard Protected',\n registrant_organization: 'WhoisGuard, Inc.',\n registrant_state: 'Panama',\n registrant_zipcode: '',\n registrar: 'NAMECHEAP INC',\n status: ['clientTransferProhibited '\n          'https://icann.org/epp#clientTransferProhibited'],\n updated: datetime.datetime(2019, 11, 24, 13, 58, 35, 940000)}\n ...\n \"\"\"\n\n# set `find_authoritative_server=False` to only query the TLD's whois server as specified in the IANA root db. \n# this will generally speed up execution times, but responses may not include complete information. \nquery_string, parsed_dict = asyncwhois.whois(\"google.com\", find_authoritative_server=False)\n\n# support for IPv4, IPv6, and ASNs too\nipv4 = \"8.8.8.8\"\nquery_string, parsed_dict = asyncwhois.whois(ipv4)\npprint(parsed_dict)\n\"\"\"\n{abuse_address: None,\n abuse_email: 'network-abuse@google.com',\n abuse_handle: 'ABUSE5250-ARIN',\n abuse_name: 'Abuse',\n abuse_phone: '+1-650-253-0000',\n abuse_rdap_ref: 'https://rdap.arin.net/registry/entity/ABUSE5250-ARIN',\n cidr: '8.8.8.0/24',\n net_handle: 'NET-8-8-8-0-2',\n net_name: 'GOGL',\n net_range: '8.8.8.0 - 8.8.8.255',\n net_type: 'Direct Allocation',\n org_address: '1600 Amphitheatre Parkway',\n org_city: 'Mountain View',\n org_country: 'US',\n org_id: 'GOGL',\n ...\n\"\"\"\n```\n\n#### RDAP\n\nThe [whodap](https://github.com/pogzyb/whodap) project is used behind the scenes to perform RDAP queries.\n\n```python\ndomain = \"https://google.com\"\nquery_string, parsed_dict = asyncwhois.rdap(domain)\n# OR with asyncio\nquery_string, parsed_dict = loop.run_until_complete(asyncwhois.aio_rdap(domain))\n\n# Reusable client (caches the RDAP bootstrap server list, so it is faster for doing multiple calls)\nclient = asyncwhois.DomainClient()\nfor domain in [\"google.com\", \"tesla.coffee\", \"bitcoin.org\"]:\n    query_string, parsed_dict = client.rdap(domain)\n    # query_string, parsed_dict = await client.aio_rdap(domain)\n\n# Using a proxy or need to configure something HTTP related? Try reconfiguring the client:\nwhodap_client = whodap.DNSClient.new_client(\n    httpx_client=httpx.Client(proxies=\"https://proxy:8080\")\n)\n# whodap_client = await whodap.DNSClient.new_aio_client(httpx_client=httpx.AsyncClient(proxies=\"https://proxy:8080\"))\nclient = asyncwhois.DomainClient(whodap_client=whodap_client)\n\n```\n\n#### Proxies\n\nSOCKS proxies are supported for WHOIS and RDAP queries.\n\n```python\nimport whodap\n\ntor_host = \"localhost\"\ntor_port = 9050\n\n# WHOIS\nquery_string, parsed_dict = asyncwhois.whois(\n    \"8.8.8.8\", proxy_url=f\"socks5://{tor_host}:{tor_port}\"\n)\n\n# RDAP\nimport httpx\nfrom httpx_socks import SyncProxyTransport, AsyncProxyTransport  # EXTERNAL DEPENDENCY for SOCKS Proxies \n\ntransport = SyncProxyTransport.from_url(f\"socks5://{tor_host}:{tor_port}\")\nhttpx_client = httpx.Client(transport=transport)\nwhodap_client = whodap.IPv6Client.new_client(httpx_client=httpx_client)\nquery_string, parsed_dict = asyncwhois.rdap('2001:4860:4860::8888', whodap_client=whodap_client)\n\ntransport = AsyncProxyTransport.from_url(f\"socks5://{tor_user}:{tor_pw}@{tor_host}:{tor_port}\")\nasync with httpx.AsyncClient(transport=transport) as httpx_client:\n    whodap_client = await whodap.DNSClient.new_aio_client(httpx_client=httpx_client)\n    query_string, parsed_dict = await asyncwhois.aio_rdap('bitcoin.org', whodap_client=whodap_client)\n\n```\n\n#### Exported Functions\n\n| Function/Object    | Description                                             |\n|--------------------|---------------------------------------------------------|\n| `DomainClient`     | Reusable client for  WHOIS or RDAP domain queries       |\n| `NumberClient`     | Reusable client for WHOIS or RDAP ipv4/ipv6 queries     |\n| `ASNClient`        | Reusable client for RDAP asn queries                    |\n| `whois`            | WHOIS entrypoint for domain, ipv4, or ipv6 queries      |\n| `rdap`             | RDAP entrypoint for domain, ipv4, ipv6, or asn queries  |\n| `aio_whois`        | async counterpart to `whois`                            |\n| `aio_rdap`         | async counterpart to `rdap`                             |\n| `whois_ipv4`       | [DEPRECATED] WHOIS lookup for ipv4 addresses            |\n| `whois_ipv6`       | [DEPRECATED] WHOIS lookup for ipv6 addresses            |\n| `rdap_domain`      | [DEPRECATED] RDAP lookup for domain names               |\n| `rdap_ipv4`        | [DEPRECATED] RDAP lookup for ipv4 addresses             |\n| `rdap_ipv6`        | [DEPRECATED] RDAP lookup for ipv6 addresses             |\n| `rdap_asn`         | [DEPRECATED] RDAP lookup for Autonomous System Numbers  |\n| `aio_whois_domain` | [DEPRECATED] async counterpart to `whois_domain`        |\n| `aio_whois_ipv4`   | [DEPRECATED] async counterpart to `whois_ipv4`          |\n| `aio_whois_ipv6`   | [DEPRECATED] async counterpart to `whois_ipv6`          |\n| `aio_rdap_domain`  | [DEPRECATED] async counterpart to `rdap_domain`         |\n| `aio_rdap_ipv4`    | [DEPRECATED] async counterpart to `rdap_ipv4`           |\n| `aio_rdap_ipv6`    | [DEPRECATED] async counterpart to `rdap_ipv6`           |\n| `aio_rdap_asn`     | [DEPRECATED] async counterpart to `rdap_asn`            |\n\n#### Contributions\n\nParsed output not what you expected? Unfortunately, \"the format of responses [from a WHOIS server] follow a semi-free text format\". Therefore,\nsituations will arise where this module does not support parsing the output from a specific server, and you may find\nyourself needing more control over how parsing happens. Fortunately, you can create customized parsers to suit your needs.\n\nExample: This is a snippet of the output from running the \"whois google.be\" command.\n```python\nDomain:\tgoogle.be\nStatus:\tNOT AVAILABLE\nRegistered:\tTue Dec 12 2000\n\nRegistrant:\n    Not shown, please visit www.dnsbelgium.be for webbased whois.\n\nRegistrar Technical Contacts:\n    Organisation:\tMarkMonitor Inc.\n    Language:\ten\n    Phone:\t+1.2083895740\n    Fax:\t+1.2083895771\n\nRegistrar:\n    Name:\t MarkMonitor Inc.\n    Website: http://www.markmonitor.com\n\nNameservers:\n    ns2.google.com\n    ns1.google.com\n    ns4.google.com\n    ns3.google.com\n\nKeys:\n\nFlags:\n    clientTransferProhibited\n...\n```\nIn this case, the \"name servers\" are listed on separate lines. The default BaseParser regexes\nwon't find all of these server names. In order to accommodate this extra step, the \"parse\" method was\noverwritten within the parser subclass as seen below:\n```python\nclass RegexBE(BaseParser):\n    _be_expressions = {  # the base class (BaseParser) will handle these regexes\n        BaseKeys.CREATED: r'Registered: *(.+)',\n        BaseKeys.REGISTRAR: r'Registrar:\\n.+Name: *(.+)',\n        BaseKeys.REGISTRANT_NAME: r'Registrant:\\n *(.+)'\n    }\n    \n    def __init__(self):\n        super().__init__()\n        self.update_reg_expressions(self._be_expressions)\n    \n    def parse(self, blob: str) -\u003e Dict[str, Any]:\n        # run base class parsing for other keys\n        parsed_output = super().parse(blob)\n        # custom parsing is needed to extract all the name servers\n        ns_match = re.search(r\"Name servers: *(.+)Keys: \", blob, re.DOTALL)\n        if ns_match:\n            parsed_output[BaseKeys.NAME_SERVERS] = [m.strip() for m in ns_match.group(1).split('\\n') if m.strip()]\n        return parsed_output\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpogzyb%2Fasyncwhois","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpogzyb%2Fasyncwhois","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpogzyb%2Fasyncwhois/lists"}