BlogData

A calendar cell can have more than one name

Use a Holiday collection to keep every matching name on a date, and count calendar dates separately from holiday records.

A calendar cell represents a date. The holiday data for that date can contain more than one record, including a public holiday and a cultural observance. Saving one name per date would make the second record disappear before the interface gets a chance to show it.

The Holiday API has two response shapes for different jobs. A full-date path returns one holiday object or null. A collection returns a holidays array with every matching record. These examples use API contract 2.1.0:

GET /holiday/US/2026-12-25
X-API-Version: 2.1.0
GET /holiday/US?year=2026&month=12&day=25

These requests ask about the same date. They don't promise identical response shapes. The first is a single-date lookup, which prefers a public holiday when more than one record is present. The second retains all matches. The US date here illustrates the request forms, without implying that its calendar has multiple entries on that day.

For a calendar view, start with a collection. /holiday/US/2026 returns the published year, and /holiday/US/2026-12 narrows it to December. Query month and day filters can narrow the collection further while keeping its array shape.

Group those records by date for rendering. Each group becomes a cell's list of holiday labels, rather than letting the last row overwrite the first. Keep type alongside each name so a cultural observance can look different from a public holiday. Keep any regions restriction too, so a regional entry doesn't become a country-wide label merely because it appeared in the collection.

A count needs the same distinction. holidays.length counts records. To count distinct dates represented in a returned collection:

const listedDates = new Set(
  result.holidays.map(holiday => holiday.date)
);
const dateCount = listedDates.size;

Neither count calculates days off. Your application's relevant holiday type, region and working calendar still determine which dates belong in that calculation.

A covered period with no matching holidays returns an empty array. An unpublished year returns 404 with the available published range. Keep the calendar unavailable in that case, rather than draw an empty year that looks as though it has no holidays. The API doesn't extend a published calendar by repeating last year's dates.

Use the single-date route when one holiday-or-null answer fits the task. Use the collection when your interface needs to preserve all the names attached to a date.