How to Validate a Domain Name in Node.JS

Taking your business online can come with some inherent risks. One way to boost your security is through domain name verification. The following API will help you verify any domain name by contacting DNS services to check for the existence of that domain.

Image for post
Image for post

Our first step is to install our client software:

npm install cloudmersive-validate-api-client --save

Or, you can add this snippet to your package.json:

"dependencies": {
"cloudmersive-validate-api-client": "^1.2.4"
}

Then, we can call our function, DomainCheck:

var CloudmersiveValidateApiClient = require('cloudmersive-validate-api-client');
var defaultClient = CloudmersiveValidateApiClient.ApiClient.instance;
// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';
var apiInstance = new CloudmersiveValidateApiClient.DomainApi();var domain = "domain_example"; // String | Domain name to check, for example \"cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes.var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.domainCheck(domain, callback);

With that, you can help keep your online systems safe and running smoothly. To access your free API Key, you can visit the Cloudmersive website. This will give you access to up to 800 calls across our library of APIs.

Written by

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

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