Metadata-Version: 2.3
Name: whois21
Version: 2.0.1
Summary: A simple and easy to use Python package that lets you query whois/RDAP information of a domain/IP.
Keywords: python,python3,CodeWriter21,WHOIS,whois21,RDAP,Registration Data Access Protocol,DNS,ASN
Author: CodeWriter21(Mehrad Pooryoussof)
Author-email: CodeWriter21(Mehrad Pooryoussof) <CodeWriter21@gmail.com>
License: Apache License 2.0
Classifier: Programming Language :: Python :: 3
Requires-Dist: log21>=3.10.0
Requires-Dist: chardet>=7.6.0
Requires-Dist: importlib-resources>=6.1.0
Requires-Dist: httpx>=0.28.1
Requires-Dist: platformdirs>=4.3.6
Requires-Python: >=3.11
Project-URL: Donations, https://gitlab.com/CodeWriter21/whois21/-/blob/master/DONATE.md
Project-URL: Homepage, https://gitlab.com/CodeWriter21/whois21
Project-URL: Source, https://gitlab.com/CodeWriter21/whois21
Description-Content-Type: text/markdown

whois21
=====

![version](https://img.shields.io/pypi/v/whois21)
![stars](https://img.shields.io/gitlab/stars/CodeWriter21%2Fwhois21)
![forks](https://img.shields.io/gitlab/forks/CodeWriter21%2Fwhois21)
[![pipeline status](https://gitlab.com/CodeWriter21/whois21/badges/master/pipeline.svg)](https://gitlab.com/CodeWriter21/whois21/-/commits/master)

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](https://gitlab.com/CodeWriter21/whois21/-/issues) or submit a
  merge request.

![Issues](https://img.shields.io/gitlab/issues/open/CodeWriter21%2Fwhois21)

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](https://python.org) and
install the latest version of python based on your OS.

Then you can install whois21 using pip module:

```shell
# 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](https://gitlab.com/CodeWriter21/whois21) and run:

```shell
python -m build .
```

### Dependencies

+ [httpx](https://www.python-httpx.org/): Used for:
  + Downloading list of whois and RDAP servers.
  + Downloading RDAP information.
+ [importlib_resources](https://importlib-resources.readthedocs.io/en/latest/): Used for:
  + Reading the bundled fallback copies of the server lists.
+ [platformdirs](https://platformdirs.readthedocs.io/): Used for:
  + Locating the user cache directory for RDAP/WHOIS bootstrap files.
+ [chardet](https://pypi.org/project/chardet/): Used for:
  + Detecting the encoding of the whois response.
+ [log21](https://gitlab.com/CodeWriter21/log21): Used for:
  + Argument Parsing.
  + Colorized Logging.
  + Printing collected data in pprint or tree format.
+ [os](https://docs.python.org/3/library/os.html) (A core python module): Used for:
  + Working with files and directories.
+ [asyncio](https://docs.python.org/3/library/asyncio.html) (A core python module):
  Used for:
  + Establishing async TCP connections to the whois servers.
  + Running concurrent lookups.
+ [json](https://docs.python.org/3/library/json.html) (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](https://docs.python.org/3/library/datetime.html) (A core python module):
  Used for:
  + Converting Creation/Updated/Expiration date to a usable python datetime object.
+ [ipaddress](https://docs.python.org/3/library/ipaddress.html) (A core python module):
  Used for:
  + Validating IPv4 and IPv6 addresses.
+ [typing](https://docs.python.org/3/library/typing.html) (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](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

```shell
# -v : verbose mode
whois21 -v google.com
```

+ Example 2: Query whois information of 3 domains and save the results to a directory

```shell
# -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

```shell
# 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

```shell
# -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).

```python
# 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.

```python
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](https://gitlab.com/CodeWriter21)

Telegram Channel: [@CodeWriter21](https://t.me/CodeWriter21)

Aparat Channel: [CodeWriter21](https://www.aparat.com/CodeWriter21)

### License

![License](https://img.shields.io/gitlab/license/CodeWriter21%2Fwhois21)

[apache-2.0](http://www.apache.org/licenses/LICENSE-2.0)

### Donate

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

[Donate Addresses](https://gitlab.com/CodeWriter21/whois21/-/blob/master/DONATE.md)

Or if you can't, simply give [this project](https://gitlab.com/CodeWriter21/whois21)
one star on GitLab :)

References
----------

+ WHOIS (Wikipedia): [https://en.wikipedia.org/wiki/WHOIS](https://en.wikipedia.org/wiki/WHOIS)
+ Domains: [https://www.iana.org/domains/root/db/](https://www.iana.org/domains/root/db/)
+ Registration Data Access Protocol (RDAP) (
  Wikipedia): [https://en.wikipedia.org/wiki/Registration_Data_Access_Protocol](https://en.wikipedia.org/wiki/Registration_Data_Access_Protocol)
+ RDAP Response Profile (
  PDF): [https://www.icann.org/en/system/files/files/rdap-response-profile-15feb19-en.pdf](https://www.icann.org/en/system/files/files/rdap-response-profile-15feb19-en.pdf)
+ RFC 9224 Finding the Authoritative Registration Data Access Protocol (RDAP) Service
  [https://www.rfc-editor.org/rfc/rfc9224.html](https://www.rfc-editor.org/rfc/rfc9224.html)
+ Registration Data Access Protocol (RDAP) Query
  Format: [https://www.rfc-editor.org/rfc/rfc7482.html](https://www.rfc-editor.org/rfc/rfc7482.html)
+ Registration Data Access Protocol (RDAP) Object
  Tagging: [https://www.rfc-editor.org/rfc/rfc8521.html](https://www.rfc-editor.org/rfc/rfc8521.html)
+ Finding the Authoritative Registration Data (RDAP)
  Service: [https://www.rfc-editor.org/rfc/rfc7484.html](https://www.rfc-editor.org/rfc/rfc7484.html)
+ JSON Responses for the Registration Data Access Protocol (RDAP):
  [https://www.rfc-editor.org/rfc/rfc7483](https://www.rfc-editor.org/rfc/rfc7483)
+ Registration Data Access Protocol (RDAP) Partial
  Response: [https://www.rfc-editor.org/rfc/rfc8982.html](https://www.rfc-editor.org/rfc/rfc8982.html)
+ vCard Format
  Specification: [https://www.rfc-editor.org/rfc/rfc6350.txt](https://www.rfc-editor.org/rfc/rfc6350.txt)
+ vCard (Wikipedia): [https://en.wikipedia.org/wiki/VCard](https://en.wikipedia.org/wiki/VCard)
+ Notes on vCard, LDIF and mappings to
  RDF: [https://www.w3.org/2002/12/cal/vcard-notes.html](https://www.w3.org/2002/12/cal/vcard-notes.html)
