How to Retrieve the Public Holidays for a Country in Node.JS

Working with entities internationally means being understanding of timelines and holidays that might interfere with plans. Furthermore, if your organization has locations in different countries, it is necessary to know the public holidays in those locations for your employees. The following API will retrieve all of the public holidays for a given year is a specified country, with support for over 100 countries.

Image for post
Image for post

To use this API, 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 the function:

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

This will return the English Name of the holiday, the local name, the date it occurs, the holiday type, and whether the holiday is nationwide.

You can retrieve the API Key from the at no cost and with no commitment. This will provide you with 800 monthly 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