How to Get an ISO 3166–1 Standardized List of Countries in Node.JS

Prioritizing standardization across your databases will allow your operations to run smoother and provide a better experience for your clients and partners. When working on an international scale, working based on normalized country names will aid in clarification and limit mistakes on location information. This API will provide you with access a list of ISO 3166–1 standardized country names along with their ISO two-letter codes.

Image for post
Image for post

First, we will need to install our client software:

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 we can call our function, AddressCountryList:

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 callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.addressCountryList(callback);

With that, you can ensure that your location data is always correct based on standard metrics. You can retrieve your API Key from the Cloudmersive website at no cost; it will give you access to up to 800 calls across our library of 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