How to Get a Country’s Regional Information in Node.JS

Cloudmersive
2 min readSep 22, 2020

Knowing who your audience is and where they are from will help you understand your client base and tailor their experience. This information can also help you plan and execute business strategies that are reliant on time zones and knowledge of the EU membership status for your clients’ locations. The following API will allow you to retrieve regional information about any input country, including sub-region and continent data.

Our first step is to run this command to install the SDK:

npm install cloudmersive-validate-api-client –save

You can also add this snippet to your package.json:

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

Then, you can call our function, AddressGetCountryRegion:

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.AddressApi();var input = new CloudmersiveValidateApiClient.ValidateCountryRequest(); // ValidateCountryRequest | Input requestvar callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.addressGetCountryRegion(input, callback);

Now, you will be supplied with an in-depth understanding of your clientele and their regional affiliations. To access your personal API Key, visit the Cloudmersive website. With this, you will gain access to 800 free monthly calls across our library of APIs.

--

--

Cloudmersive

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