How to lookup domain WHOIS in Salesforce Apex

Cloudmersive
1 min readFeb 18, 2020

--

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"
}

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet