GOV.UK Bank Holidays

0.19 · active · verified Thu Apr 16

This library provides a convenient way to load the official list of bank holidays in the United Kingdom directly from GOV.UK. Currently at version 0.19, it is actively maintained with frequent updates to include new holiday data as published by GOV.UK, alongside regular maintenance for Python version compatibility.

Common errors

Warnings

Install

Imports

Quickstart

Initializes the `BankHolidays` class, demonstrating how to fetch all holidays for a specific division and retrieve the next upcoming holiday. It also shows how to use the cached holiday data offline.

from govuk_bank_holidays.bank_holidays import BankHolidays

# Initialize the BankHolidays object (fetches data from GOV.UK by default)
bank_holidays = BankHolidays()

# Get all bank holidays for England and Wales
print("Bank holidays for England and Wales:")
for holiday in bank_holidays.get_holidays(division=BankHolidays.ENGLAND_AND_WALES):
    print(f"  {holiday['title']} on {holiday['date']}")

# Get the next upcoming bank holiday for Scotland
next_scottish_holiday = bank_holidays.get_next_holiday(division=BankHolidays.SCOTLAND)
if next_scottish_holiday:
    print(f"\nNext Scottish bank holiday: {next_scottish_holiday['title']} on {next_scottish_holiday['date']}")

# Use cached holidays only (no internet connection required)
cached_holidays = BankHolidays(use_cached_holidays=True)
print(f"\nTotal cached holidays: {len(cached_holidays.get_holidays())}")

view raw JSON →