Skip to main content

whois21

version stars forks pipeline status

WHOIS21 is a simple and easy to use python package that lets you easily query whois information of a domain.

Features

WHOIS

  • Query whois information of a TLD from various whois servers and parse the results.
  • Get the Registration Information of a domain from different RDAP servers and parse the results.
  • Get IP information from ip-api.com.
  • Any idea? Feel free to open an issue or submit a merge request.

Issues

Installation

Well, this is a python package so the first thing you need is python.

If you don't have python installed, please visit Python.org and install the latest version of python based on your OS.

Then you can install whois21 using pip module:

# Use this command to get the latest version from pypi.org and install it automatically
python -m pip install whois21 -U

# OR
# Download the release file from GitLab: https://gitlab.com/CodeWriter21/whois21/-/releases
# And install it using this command
pip install whois21-x.x.x.tar.gz

Or you can clone the repository and run:

python -m build .

Dependencies

  • httpx: Used for:
    • Downloading list of whois and RDAP servers.
    • Downloading RDAP information.
  • importlib_resources: Used for:
    • Reading the bundled fallback copies of the server lists.
  • platformdirs: Used for:
    • Locating the user cache directory for RDAP/WHOIS bootstrap files.
  • chardet: Used for:
    • Detecting the encoding of the whois response.
  • log21: Used for:
    • Argument Parsing.
    • Colorized Logging.
    • Printing collected data in pprint or tree format.
  • os (A core python module): Used for:
    • Working with files and directories.
  • asyncio (A core python module): Used for:
    • Establishing async TCP connections to the whois servers.
    • Running concurrent lookups.
  • json (A core python module): Used for:
    • Parsing JSON data from RDAP servers.
    • Parsing RDAP server list.
    • Saving collected whois or/and RDAP data to a file.
    • Loading some package data from a file.
  • datetime (A core python module): Used for:
    • Converting Creation/Updated/Expiration date to a usable python datetime object.
  • ipaddress (A core python module): Used for:
    • Validating IPv4 and IPv6 addresses.
  • typing (A core python module): Used for:
    • Type checking.
    • Type hinting.

Changes

2.0.1

  • Migrated project URLs from GitHub to GitLab.

2.0.0

  • New query()/aquery() (+ bulk variants) on a single async core.
  • Typed exceptions with on_error='capture' opt-out; per-stage .errors.
  • Shared RDAP core, user cache dir with no_disk support and bootstrap TTL.
  • Robust UTC date parsing, ip-api.com rate limiting, rewritten CLI.
  • See CHANGELOG.md for the full list.

1.4.7

  • Update log21 to v3.0.0
  • Update LICENSE

Usage Examples

CLI Examples

  • Example 1: Query whois information of google.com
# -v : verbose mode
whois21 -v google.com
  • Example 2: Query whois information of 3 domains and save the results to a directory
# -R : saves the results as raw text
# -n: avoids printing the results to the screen
# -o results: saves the results to `./results` directory
whois21 -R -n -o results google.com facebook.com pinterest.com
  • Example 3: Query whois information of 3 IPs and save the results to a directory
# Options explained in the examples above
whois21 -R -n -v -o results 1.1.1.1 157.240.20.174 64.91.226.82
  • Example 4: Query RDAP information of domains and IPs and save the results to a file
# -r: Gets the RDAP information of the queried domains and IPs
whois21 -n -o results -r microsoft.com python.org 140.82.121.3 185.147.178.13

Python Code Examples

  • Example 1: Query whois information of GitHub.com (synchronous).
# First step is to import the package
import whois21

query = 'github.com'

# Second step is to run the lookup (raises WhoisError when every strategy fails;
# pass on_error='capture' to get success/error attributes instead)
whois = whois21.query(query)

# And basically you are done!
# Now you can print the results
import log21  # I use log21 to print the results in a cool way 8D

# Print the results in a nice way
# PPrint the dictionary
log21.pprint(whois.whois_data)
# Tree-Print the dictionary
log21.tree_print(whois.whois_data)

# Or you can print the results in as raw text
print(whois.raw.decode('utf-8'))

# Or you can access each part of the results individually
print(f'Creation date   : {whois.creation_date}')
print(f'Expiration date : {whois.expires_date}')
print(f'Updated date    : {whois.updated_date}')
  • Example 2: The same lookup, asynchronously.
import asyncio
import whois21


async def main():
    whois = await whois21.aquery('github.com')
    print(whois.creation_date)


asyncio.run(main())

About

Author: CodeWriter21 (Mehrad Pooryoussof)

GitLab: CodeWriter21

Telegram Channel: @CodeWriter21

Aparat Channel: CodeWriter21

License

License

apache-2.0

Donate

In order to support this project you can donate some crypto of your choice 8D

Donate Addresses

Or if you can't, simply give this project one star on GitLab :)

References

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

whois21-2.0.1.tar.gz (39.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

whois21-2.0.1-py3-none-any.whl (43.6 kB view details)

Uploaded Python 3

File details

Details for the file whois21-2.0.1.tar.gz.

File metadata

  • Download URL: whois21-2.0.1.tar.gz
  • Upload date:
  • Size: 39.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.11 {"installer":{"name":"uv","version":"0.12.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for whois21-2.0.1.tar.gz
Algorithm Hash digest
SHA256 0c0b1340e5b85a31a9f83d2be4adf3a7b534d33fb4c4106a49566b402bbbc68c
MD5 a02d32670cf081e9a50e53be8d5f1e2f
BLAKE2b-256 a674a70e98329118cb01c65da84ad7886bcc3632fdc4a3312cc0cf1cb460b03d

See more details on using hashes here.

File details

Details for the file whois21-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: whois21-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 43.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.11 {"installer":{"name":"uv","version":"0.12.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for whois21-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ce1de4c9a54f7301e7fea09c485c3dc565da81e18a9bfdd2f4a893849e4127eb
MD5 b791959bf8cf760ea2243ebec47245af
BLAKE2b-256 5223a28d015e5a5a0c42ee902f57375d5553e89c9df61ce0c1eaa84e0689faa6

See more details on using hashes here.

Release history Release notifications | RSS feed

2.0.2

2 files

This release

2.0.1 This release

2 files

2.0.0

2 files

1.4.7

2 files

1.4.6

2 files

1.4.5

2 files

1.4.4

2 files

1.4.3

2 files

1.4.2

2 files

1.4.1

2 files

1.4.0

2 files

1.3.0

2 files

1.2.1

2 files

1.2.0

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page