Calendarific for Elixir Hex pmhex.pm downloads

An Elixir wrapper for the holiday API Calendarific (https://calendarific.com/)

Installation

This package can be installed by adding calendarific to your list of dependencies in mix.exs:

def deps do
[
{:calendarific, "~> 0.2.0"}
]
end

Note: Starting with 0.2.0, this library uses Elixir's built-in JSON module and therefore requires Elixir 1.18 or later. Use ~> 0.1 if you need to support older Elixir versions.

Configuration

To make calls to Calendarific, it is necessary to configure your Calendarific API Key on your config.exs file:

config :calendarific, api_key: System.get_env("CALENDARIFIC_API_KEY")
# OR
config :calendarific, api_key: "YOUR API KEY"

Examples

Holidays

To fetch holidays for a given country and year, you can use the holidays/2 method:

iex> Calendarific.holidays(country: "US", year: 2021)
[
%Calendarific.Types.Holiday{
country: %Calendarific.Types.Country{id: "us", name: "United States"},
date: %Calendarific.Types.Date{
datetime: %Calendarific.Types.DateTime{day: 1, month: 1, year: 2021},
iso: "2021-01-01"
},
description: "New Year's Day is the first day of the Gregorian calendar, which is widely used in many countries such as the USA.",
locations: "All",
name: "New Year's Day",
states: "All",
type: ["National holiday"]
},
...
]

Documentation

The docs can be found at https://hexdocs.pm/calendarific.

License

More info at LICENSE.