How to lookup domain WHOIS in Salesforce Apex

Looking up WHOIS for a domain is a very basic need, but can be annoying to set up. Today we will show you an alternative approach that will boost you straight to results. Let’s dive in.

First things first, download the Cloudmersive Validate API Client and unzip it into the folder of your Apex project.

With our API now accessible, we can call domainPost, as you see here:

SwagDomainApi api = new SwagDomainApi();SwagClient client = api.getClient();// Configure API key authorization: ApikeyApiKeyAuth Apikey = (ApiKeyAuth) client.getAuthentication('Apikey');Apikey.setApiKey('YOUR API KEY');Map<String, Object> params = new Map<String, Object>{'domain' => 'domain_example'};try {// cross your fingersSwagWhoisResponse result = api.domainPost(params);System.debug(result);} catch (Swagger.ApiException e) {// ...handle your exceptions}

Not bad. Here is how your response will be presented back to you.

"ValidDomain": true,
"RegistrantName": "string",
"RegistrantOrganization": "string",
"RegistrantEmail": "string",
"RegistrantStreetNumber": "string",
"RegistrantStreet": "string",
"RegistrantCity": "string",
"RegistrantStateOrProvince": "string",
"RegistrantPostalCode": "string",
"RegistrantCountry": "string",
"RegistrantRawAddress": "string",
"RegistrantTelephone": "string",
"WhoisServer": "string",
"RawTextRecord": "string",
"CreatedDt": "2020-02-18T05:11:39.894Z"

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store