PowerShell wrapper around the Calendarific API

Calendarific offers a webservice for listing holidays from different countries. They also have an API that can be used by developers to implement this holiday queries in the their own applications.

Accessing this API requires an API key which can be registered for free at https://calendarific.com/signup.

This module is a wrapper around the Calendarific API. You can install the module from the PowerShell Gallery.

The following commands are available in this module.

Register-PSCalendarificDefaultConfiguration

This command helps set the parameter defaults for accessing the API. At present, this command supports only storing APIKey and Country values as default configuration. API key must always be provided and the Get-PSCalendarificHoliday requires Country name as well for listing the holidays. Therefore, these configuration settings can be stored locally so that other commands in the module can be used without explicitly providing any of these parameters.

Note: Storing API key on local filesystem is not a good practice.

This command has no mandatory parameters. You can specify either APIKey or Country or both. When you need to update either configuration parameters, just specify the parameter you want to update.

Unregister-PSCalendarificDefaultConfiguration

This command helps you remove the stored API key or just delete the configuration store itself.

If you do not specify any parameters, the configuration store gets deleted.

Get-PSCalendarificDefaultConfiguration

This command gets the stored defaults from the configuration store.

Get-PSCalendarificHoliday

This command lists all holidays for a given country based on the parameters supplied. If you do not provide any parameters, this commands tries to find and use the default parameter values from the configuration store.

The following are different parameters supported with this command.

Parameter NameDescriptionDefault Value
APIKeyKey to access the APINo default Value. When not specified, the command will try to use the default parameter from configuration store.
CountryCountryNo default Value. When not specified, the command will try to use the default parameter from configuration store.
YearYear for which the holidays need to be listedThe command internally defaults to the current year.
MonthMonth for which the holidays need to be listed.No default value but the valid values are 1 .. 12
DayDay for which the holidays need to be listed.No default value but the valid values are 1 .. 31.
TypeType of holidaysNo default value but the valid values are national, local, religious, and observance.

This module is available on GitHub as well in case you want to contribute or create issues.

About the author: Ravikanth C

Ravikanth is the founder and editor of the PowerShell Magazine. He is also a PowerShell MVP who works at Dell Inc. He blogs at http://www.ravichaganti.com/blog and you can follow him on Twitter @ravikanth.

Related Posts