Skip to content

meisnate12/NagerAPI

Repository files navigation

Welcome to Nager Public Holiday API's documentation!

Build Coverage

Read the Docs

GitHub release (latest by date)

PyPI

Downloads

GitHub commits since latest release (by date) for a branch

GitHub Sponsor

Overview

Unofficial Python bindings for the Nager Public Holiday API. The goal is to make interaction with the API as easy as possible.

Installation & Documentation

pip install nagerapi

Documentation can be found at Read the Docs.

Connecting to Nager

Getting a NagerObjectAPI Instance

To connect to the Nager Public Holiday API you use the ~nagerapi.NagerObjectAPI object.

from nagerapi import NagerObjectAPI

nager = NagerObjectAPI()
import nagerapi

nager = nagerapi.NagerObjectAPI()

Usage Examples

Example: List all 2022 US Holidays.

In this one we get the US ~nagerapi.Country Object and call public_holidays from that object.

from nagerapi import NagerObjectAPI

nager = NagerObjectAPI()
country = nager.country("US")

for holiday in country.public_holidays(2022):
    print(f"{holiday.name} is on {holiday.date.strftime('%Y-%m-%d')}")

Alternatively you can call public_holidays from the ~nagerapi.NagerObjectAPI object directly providing the country code.

from nagerapi import NagerObjectAPI

nager = NagerObjectAPI()

for holiday in nager.public_holidays(2022, "US"):
    print(f"{holiday.name} is on {holiday.date.strftime('%Y-%m-%d')}")

Usage & Contributions

  • Source is available on the Github Project Page.
  • Contributors to NagerAPI own their own contributions and may distribute that code under the MIT license.