Skip to content

Response models

Holiday dataclass

Holiday(description: str = None, day: int = None, month: int = None, date: date = None, holiday_type: CalHolidayType = None, status: CalHolidayStatus = None, country_code: str = 'MA')

Represents a Holiday

HolidayCheckResult dataclass

HolidayCheckResult(date: date = None, is_holiday: bool = None, description: str = None, holiday_type: CalHolidayType = None, status: CalHolidayStatus = None, country_code: str = 'MA')

The result of is-holiday check. If the date is a Holiday, holds also its description, type and status

DaysCount dataclass

DaysCount(start_date: date = None, end_date: date = None, count: int = None, freq: CalFreq = None)

Counts the number of business days between 2 dates.

start_date and end_date are open business days

CalSpan dataclass

CalSpan(start_date: date = None, end_date: date = None, year: int = None, semester: int = None, quarter: int = None, month: int = None, country_code: str = 'MA')

Represents the span of a period delimited by the interval start/end date (open day inclusive)

i.e: 2026-S1 = CalSpan(year=2026, semester=1, start_date=2026-01-02, end_date=2026-06-30)

Attributes:

  • key (str) –

    A Unique key to identify the span. Takes the form of {year}-{span}{span-number}.

key property

key: str

A Unique key to identify the span. Takes the form of {year}-{span}{span-number}.

i.e: "2025-Q3", 2025-S1, 2025-M8

NextDate dataclass

NextDate(date: date, next_date: date)

Holds the requested date and the next_date

PreviousDate dataclass

PreviousDate(date: date, previous_date: date)

Holds the requested date and the previous_date

ApiHealth dataclass

ApiHealth(api_status: str = None, appname: str = APPLICATION_NAME)

Chack the status of the API. It doesn't need an APIKEY

Tagged Calendar

TaggedYear dataclass

TaggedYear(year: int = None, counts: TaggedDaysCount = None, months: list[TaggedMonth] = list())

A full year of the Tagged Calendar, month by month

Methods:

  • month –

    Get a month of the year

Attributes:

days property

days: list[TaggedDay]

Ordered days of the year

month

month(month: int) -> TaggedMonth

Get a month of the year

Parameters:

  • month

    (int) –

    Month number (1 → 12)

Raises:

Source code in pycalendar_api/models/tagged.py
120
121
122
123
124
125
126
127
128
129
130
131
132
def month(self, month: int) -> TaggedMonth:
    """Get a month of the year

    Args:
        month (int): Month number (1 → 12)

    Raises:
        KeyError: Month not in the year
    """
    for m in self.months:
        if m.month == month:
            return m
    raise KeyError(month)

TaggedMonth dataclass

TaggedMonth(year: int = None, month: int = None, label: str = None, weekday_labels: list[str] = list(), counts: TaggedDaysCount = None, weeks: list[list[TaggedDay | None]] = list())

A month of the Tagged Calendar laid out in ISO weeks (Monday → Sunday), ready to be rendered as a calendar grid.

weeks is a list of 7 days lists, the days outside the month are None. weekday_labels are the column headers (MO → SU).

Attributes:

  • days (list[TaggedDay]) –

    Ordered days of the month, without the None padding of the weeks

days property

days: list[TaggedDay]

Ordered days of the month, without the None padding of the weeks

TaggedDay dataclass

TaggedDay(date: date = None, day_kind: DayKind = None, is_business_day: bool = None, is_weekend: bool = None, is_holiday: bool = None, holiday_type: CalHolidayType = None, status: CalHolidayStatus = None, description: str = None, label: str = None, country_code: str = 'MA')

A day of the Tagged Calendar, tagged with its day_kind.

holiday_type, status and description are only defined when is_holiday is True. A holiday falling on a weekend has is_holiday=True and day_kind=DayKind.WEEKEND.

TaggedDaysCount dataclass

TaggedDaysCount(business_days: int = None, weekend_days: int = None, holidays: int = None)

Number of days by day_kind. The sum equals the number of days of the period.

A holiday falling on a weekend is counted in weekend_days

Attributes:

  • total (int) –

    Number of days of the period

total property

total: int

Number of days of the period