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.

1
Install-Module -Name PSCalendarific -Force

The following commands are available in this module.

1
2
3
4
5
6
7
8
Get-Command -Module PSCalendarific
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Get-PSCalendarificCountry                          1.0.0.0    PSCalendarific
Function        Get-PSCalendarificDefaultConfiguration             1.0.0.0    PSCalendarific
Function        Get-PSCalendarificHoliday                          1.0.0.0    PSCalendarific
Function        Register-PSCalendarificDefaultConfiguration        1.0.0.0    PSCalendarific
Function        Unregister-PSCalendarificDefaultConfiguration      1.0.0.0    PSCalendarific

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.

1
2
3
Register-PSCalendarificDefaultConfiguration -APIKey '1562567d51443af046079a9bca8a84a358e2c393' -Country IN -Verbose
WARNING: This command stores specified parameters in a local file. API Key is sensitive information. If you do not 
prefer this, use Unregister-PSCalendarificDefaultConfiguration -APIKey to remove the API key from the store

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.

1
Unregister-PSCalendarificDefaultConfiguration -APIKey -Verbose

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

Get-PSCalendarificDefaultConfiguration

This command gets the stored defaults from the configuration store.

1
2
3
4
Get-PSCalendarificDefaultConfiguration -Verbose
APIKey                                   Country
------                                   -------
1562567d51443af046079a9bca8a84a358e2c393 IN

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.

1
Get-PSCalendarificHoliday

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.

Share on: