How to lookup domain WHOIS in Python
3 min readAug 27, 2019
Today’s tutorial will cover looking up WHOIS for a domain using a Cloudmersive API. Let’s dive straight in. First up, use pip installer to install our Validate API Client:
pip install git+https://github.com/Cloudmersive/Cloudmersive.APIClient.Python.Validate.git
Second, simply call the function domain_post, and that’s about it!
from __future__ import print_function
import time
import cloudmersive_validate_api_client
from cloudmersive_validate_api_client.rest import ApiException
from pprint import pprint# Configure API key authorization: Apikey
configuration = cloudmersive_validate_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['Apikey'] = 'Bearer'# create an instance of the API class
api_instance = cloudmersive_validate_api_client.DomainApi(cloudmersive_validate_api_client.ApiClient(configuration))
domain = 'domain_example' # str | Domain name to check, for example \"cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes.try:
# Get WHOIS information for a domain
api_response = api_instance.domain_post(domain)
pprint(api_response)
except ApiException as e:
print("Exception when calling DomainApi->domain_post: %s\n" % e)
Seriously, it’s that easy. Let’s look at an example result using “microsoft.com”:
{
"ValidDomain": true,
"WhoisServer": "whois.verisign-grs.com",
"RawTextRecord": "Domain Name: microsoft.com\r\nRegistry Domain ID: 2724960_DOMAIN_COM-VRSN\r\nRegistrar WHOIS Server: whois.markmonitor.com\r\nRegistrar URL: http://www.markmonitor.com\r\nUpdated Date: 2014-10-15T04:00:12-0700\r\nCreation Date: 1991-05-01T21:00:00-0700\r\nRegistrar Registration Expiration Date: 2021-05-02T21:00:00-0700\r\nRegistrar: MarkMonitor, Inc.\r\nRegistrar IANA ID: 292\r\nRegistrar Abuse Contact Email: abusecomplaints@markmonitor.com\r\nRegistrar Abuse Contact Phone: +1.2083895740\r\nDomain Status: clientUpdateProhibited (https://www.icann.org/epp#clientUpdateProhibited)\r\nDomain Status: clientTransferProhibited (https://www.icann.org/epp#clientTransferProhibited)\r\nDomain Status: clientDeleteProhibited (https://www.icann.org/epp#clientDeleteProhibited)\r\nDomain Status: serverUpdateProhibited (https://www.icann.org/epp#serverUpdateProhibited)\r\nDomain Status: serverTransferProhibited (https://www.icann.org/epp#serverTransferProhibited)\r\nDomain Status: serverDeleteProhibited (https://www.icann.org/epp#serverDeleteProhibited)\r\nRegistry Registrant ID: \r\nRegistrant Name: Domain Administrator\r\nRegistrant Organization: Microsoft Corporation\r\nRegistrant Street: One Microsoft Way, \r\nRegistrant City: Redmond\r\nRegistrant State/Province: WA\r\nRegistrant Postal Code: 98052\r\nRegistrant Country: US\r\nRegistrant Phone: +1.4258828080\r\nRegistrant Phone Ext: \r\nRegistrant Fax: +1.4259367329\r\nRegistrant Fax Ext: \r\nRegistrant Email: domains@microsoft.com\r\nRegistry Admin ID: \r\nAdmin Name: Domain Administrator\r\nAdmin Organization: Microsoft Corporation\r\nAdmin Street: One Microsoft Way, \r\nAdmin City: Redmond\r\nAdmin State/Province: WA\r\nAdmin Postal Code: 98052\r\nAdmin Country: US\r\nAdmin Phone: +1.4258828080\r\nAdmin Phone Ext: \r\nAdmin Fax: +1.4259367329\r\nAdmin Fax Ext: \r\nAdmin Email: domains@microsoft.com\r\nRegistry Tech ID: \r\nTech Name: MSN Hostmaster\r\nTech Organization: Microsoft Corporation\r\nTech Street: One Microsoft Way, \r\nTech City: Redmond\r\nTech State/Province: WA\r\nTech Postal Code: 98052\r\nTech Country: US\r\nTech Phone: +1.4258828080\r\nTech Phone Ext: \r\nTech Fax: +1.4259367329\r\nTech Fax Ext: \r\nTech Email: msnhst@microsoft.com\r\nName Server: ns4.msft.net\r\nName Server: ns3.msft.net\r\nName Server: ns1.msft.net\r\nName Server: ns2.msft.net\r\nDNSSEC: unsigned\r\nURL of the ICANN WHOIS Data Problem Reporting System: http://wdprs.internic.net/\r\n>>> Last update of WHOIS database: 2019-08-27T15:34:45-0700 <<<\r\n\r\nFor more information on WHOIS status codes, please visit:\r\n https://www.icann.org/resources/pages/epp-status-codes\r\n\r\nIf you wish to contact this domain’s Registrant, Administrative, or Technical\r\ncontact, and such email address is not visible above, you may do so via our web\r\nform, pursuant to ICANN’s Temporary Specification. To verify that you are not a\r\nrobot, please enter your email address to receive a link to a page that\r\nfacilitates email communication with the relevant contact(s).\r\n\r\nWeb-based WHOIS:\r\n https://domains.markmonitor.com/whois\r\n\r\nIf you have a legitimate interest in viewing the non-public WHOIS details, send\r\nyour request and the reasons for your request to whoisrequest@markmonitor.com\r\nand specify the domain name in the subject line. We will review that request and\r\nmay ask for supporting documentation and explanation.\r\n\r\nThe data in MarkMonitor’s WHOIS database is provided for information purposes,\r\nand to assist persons in obtaining information about or related to a domain\r\nname’s registration record. While MarkMonitor believes the data to be accurate,\r\nthe data is provided \"as is\" with no guarantee or warranties regarding its\r\naccuracy.\r\n\r\nBy submitting a WHOIS query, you agree that you will use this data only for\r\nlawful purposes and that, under no circumstances will you use this data to:\r\n (1) allow, enable, or otherwise support the transmission by email, telephone,\r\nor facsimile of mass, unsolicited, commercial advertising, or spam; or\r\n (2) enable high volume, automated, or electronic processes that send queries,\r\ndata, or email to MarkMonitor (or its systems) or the domain name contacts (or\r\nits systems).\r\n\r\nMarkMonitor.com reserves the right to modify these terms at any time.\r\n\r\nBy submitting this query, you agree to abide by this policy.\r\n\r\nMarkMonitor is the Global Leader in Online Brand Protection.\r\n\r\nMarkMonitor Domain Management(TM)\r\nMarkMonitor Brand Protection(TM)\r\nMarkMonitor AntiCounterfeiting(TM)\r\nMarkMonitor AntiPiracy(TM)\r\nMarkMonitor AntiFraud(TM)\r\nProfessional and Managed Services\r\n\r\nVisit MarkMonitor at https://www.markmonitor.com\r\nContact us at +1.8007459229\r\nIn Europe, at +44.02032062220\r\n----\r\n",
"CreatedDt": null
}