pricing background

Python API Integration for Whois API

SDK

Unlock WHOIS Data with Python: WhoisFreaks SDK Made Simple

The WhoisFreaks Python SDK offers robust WHOIS lookup functionality, allowing developers to access both real-time and historical WHOIS data. This enables you to retrieve comprehensive domain registration details, monitor ownership history, and analyze domain changes making it an essential resource for domain research and cybersecurity efforts.

How to perform WHOIS Lookup(s) Using Python?

The Python WHOIS SDK package enables you to perform a wide range of WHOIS lookups, including live, historical, reverse, and bulk live lookup queries.
To use the WhoisFreaks Python SDK for WHOIS lookups, follow these steps:

First, ensure that Python and the WhoisFreaks Python SDK are installed on your system. To install the necessary modules, please visit the Installation Steps page.
In all lookups, replace "your_api_key" with your actual API key.

1. WHOIS Live Lookup

whois_lookup (with whois='live' as param) fetches real-time WHOIS information for a specific domain using the WhoisFreaks WHOIS Lookup service.

python
whois_lookup(whois='live', api_key='your_api_key', domain_name='example.com')

Parameters:

  1. domain_name: The domain name for which live WHOIS information is requested (e.g., "example.com").
  2. api_key: Get your API key from our billing dashboard.
  3. format: Two formats are available JSON, XML. If you don't specify the 'format' parameter, the default format will be JSON.

Returns:

  1. Success: A JSON string containing the domain_info structure with live domain details.
  2. Error: A JSON string containing the error structure if an API error occurs, or 'nil' if the request fails.

For a comprehensive details of response fields, please refer to the WHOIS Live documentation.

Example Usage:

python
from whoisfreaks import WhoisfreaksApi
from whoisfreaks.core.api_error import ApiError

client = WhoisfreaksApi()

try:
    response = client.whois_lookup(whois='live', api_key='your_api_key', domain_name='example.com')
    response = {k: v for k, v in response.dict().items() if v is not None}     # Filtering the Null values

    print(response)
except ApiError as e:
    print(e.body)

2. WHOIS Bulk Live Lookup

bulk_domain_lookup bulk_domain_lookup retrieves live WHOIS data for multiple domains simultaneously using WhoisFreaks' WHOIS Bulk Lookup module. Please note that the maximum limit is 100 domains per request. If you need to perform a live DNS lookup for more than 100 domains, you can contact us or sign in to submit a bulk request via file upload. You may upload a file containing over 100 domains, up to a maximum of 3,000,000.

python
bulk_domain_lookup(api_key='your_api_key', domain_names=['google.es', 'hey.com', 'jfreaks.com', 'ss.ssss'])

Parameters:

  1. domain_name: A list of strings containing the domain names for which live WHOIS information is requested.
  2. api_key: Get your API key from our billing dashboard.
  3. format: Two formats are available JSON, XML. If you don't specify the 'format' parameter, the default format will be JSON.

Returns:

  1. Success: A JSON list of bulk_whois_response containing a structure with live domain information for all requested domain names in the bulk request.
  2. Error: A JSON string containing the error structure if an API error occurs, or 'nil' if the request fails.

For a comprehensive details of response fields, please refer to the Bulk WHOIS Live documentation.

Example Usage:

python
from whoisfreaks import WhoisfreaksApi
from whoisfreaks.core.api_error import ApiError

client = WhoisfreaksApi()

try:
    response = client.bulk_domain_lookup(api_key='your_api_key', domain_names=['google.es', 'hey.com', 'jfreaks.com', 'ss.ssss'])
    response = {k: v for k, v in response.dict().items() if v is not None}     # Filtering the Null values

    print(response)
except ApiError as e:
    print(e.body)

3. WHOIS Historical Lookup

whois_lookup (with whois='historical' as param) retrieves historical WHOIS information for a domain using WhoisFreaks' Historical Lookup service.

python
.whois_lookup(whois='historical', api_key='your_api_key', domain_name='example.com')

Parameters:

  1. domain_name: The domain name for which historical WHOIS information is requested (e.g., "example.com").
  2. api_key: Get your API key from our billing dashboard.
  3. format: Two formats are available JSON, XML. If you don't specify the 'format' parameter, the default format will be JSON.

Returns:

  1. Success: A JSON string containing the whois_domains_historical structure with historical domain information.
  2. Error: A JSON string containing the error structure if an API error occurs, or 'nil' if the request fails.

For a comprehensive details of response fields, you can visit the WHOIS Historical's documentation.

Example Usage:

python
from whoisfreaks import WhoisfreaksApi
from whoisfreaks.core.api_error import ApiError

client = WhoisfreaksApi()

try:
    response = client.whois_lookup(whois='historical', api_key='your_api_key', domain_name='google.com')
    response = {k: v for k, v in response.dict().items() if v is not None}     # Filtering the Null values

    print(response)
except ApiError as e:
    print(e.body)

Replace "example.com" with the domain you wish to query.

4. WHOIS Reverse Lookup

whois_lookup (with whois='reverse' as param) performs a reverse WHOIS lookup using the WhoisFreaks' reverse lookup module from Python SDK.

python
whois_lookup(whois='reverse', api_key='your_api_key', keyword='example')

Parameters:

  1. keyword: The keyword to search for in domain records.
  2. email: The email address to search for in domain records.
  3. company: The company name to search for in domain records.
  4. owner: The owner name to search for in domain records.
  5. Provide only one parameter from the four options mentioned above.
  6. mode: Two modes are available mini & default. Just like Reverse Lookup whois.reverse_lookup is used to perform a reverse WHOIS lookup in mini mode with an extra param in it i.e., mode='mini'. By default, mode is set to default.
  7. format: Two formats are available JSON, XML. If you don't specify the 'format' parameter, the default format will be JSON.
  8. exact: The 'exact' parameter can be either 'true' or 'false'. Exact match is allowed only in case of keywords, owner/registrant, or company, not emails as in case of emails response is already fetched based on exact match.
  9. page: The optional page number for paginated results. Leave empty for the first page.
  10. api_key: Get your API key from our billing dashboard.

Returns:

  1. Success: A JSON string containing a whois_domains_historical struct with reverse WHOIS information and some other info.
  2. Error: A JSON string containing the error structure if an API error occurs, or 'nil' if the request fails.

For detailed info about the response fields, you can visit the Reverse WHOIS Lookup's documentation.

Example Usage:

python
from whoisfreaks import WhoisfreaksApi
from whoisfreaks.core.api_error import ApiError

client = WhoisfreaksApi()

try:
    response = client.whois_lookup(whois='reverse', api_key='your_api_key', keyword='example')
    response = {k: v for k, v in response.dict().items() if v is not None}     # Filtering the Null values

    print(response)
except ApiError as e:
    print(e.body)

Replace keyword, email, owner, company, and page with the desired keyword, email address, owner name, company name, and page number, respectively.

5. IP WHOIS Lookup

ip_whois_lookup fetches real-time WHOIS information for a specific domain using the WhoisFreaks WHOIS Lookup service.

python
ip_whois_lookup(api_key='your_api_key', ip='1.1.1.1')

Parameters:

  1. ip: The IPv4 or IPv6 for which IP WHOIS information are requested (e.g., "8.8.8.8", "fe80::200:5aee:feaa:20a2").
  2. api_key: Get your API key from our billing dashboard.
  3. format: Two formats are available JSON, XML. If you don't specify the 'format' parameter, the default format will be JSON.

Returns:

  1. Success: A JSON string containing the ip_info structure with different IP details.
  2. Error: A JSON string containing the error structure if an API error occurs, or 'nil' if the request fails.

For a more details related to the response fields, you can visit the IP Lookup's documentation.

Example Usage:

python
from whoisfreaks import WhoisfreaksApi
from whoisfreaks.core.api_error import ApiError

client = WhoisfreaksApi()

try:
    response = client.ip_whois_lookup(api_key='your_api_key', ip='1.1.1.1')
    response = {k: v for k, v in response.dict().items() if v is not None}     # Filtering the Null values

    print(response)
except ApiError as e:
    print(e.body)

Replace "fe80::200:5aee:feaa:20a2" with the IPv4 or IPv6 you wish to query.

6. ASN WHOIS Lookup

asn_lookup fetches real-time ASN information for a specific Autonomous System Number using the WhoisFreaks ASN Lookup tool.

python
asn_lookup(api_key='your_api_key', asn='1213')

Parameters:

  1. asn: The ASN number for which information is being requested (e.g., "1" or "AS1").
  2. api_key: Get your API key from our billing dashboard.
  3. format: Two formats are available JSON, XML. If you don't specify the 'format' parameter, the default format will be JSON.

Returns:

  1. Success: A JSON string containing the asn_info structure with real time ASN details.
  2. Error: A JSON string containing the error structure if an API error occurs, or 'nil' if the request fails.

For a comprehensive details of response fields, please refer to the ASN Lookup's documentation.

Example Usage:

python
from whoisfreaks import WhoisfreaksApi
from whoisfreaks.core.api_error import ApiError

client = WhoisfreaksApi()

try:
    response = client.asn_lookup(api_key='your_api_key', asn='1213')
    response = {k: v for k, v in response.dict().items() if v is not None}     # Filtering the Null values

    print(response)
except ApiError as e:
    print(e.body)

Replace "AS1213" with the ASN you wish to query.

Other SDK Lookups

WHOIS lookups

Offers live, reverse, historical, IP, ASN, and bulk domain WHOIS lookups.

Learn more

DNS Lookups

Provides live, reverse, historical, and bulk DNS lookup services.

Learn more

Domain Availability

Checks domain availability across TLDs and suggests alternatives.

Learn more

SSL Lookups

Performs SSL lookup and shows certificate chain from start to present.

Learn more