Build an Indian holiday calendar with a free API

Pull national and gazetted holidays for any year and drop them into a calendar or "next holiday" widget.

By the apibharat.com team ยท

The goal

Show India's national and gazetted holidays for a year โ€” as a list, a calendar, or a "next public holiday" badge. The free Holidays API returns them for any year in one call.

The endpoint

endpoint
GET https://api.apibharat.com/v1/holidays/{year}
response (GET /v1/holidays/2026)
{
  "success": true,
  "data": {
    "year": 2026,
    "count": 17,
    "holidays": [
      { "holiday_date": "2026-01-26", "name": "Republic Day", "type": "National", "day_of_week": "Monday" },
      { "holiday_date": "2026-08-15", "name": "Independence Day", "type": "National", "day_of_week": "Saturday" }
    ]
  },
  "message": "Holidays found for 2026"
}

JavaScript โ€” render a list

javascript
async function loadHolidays(year) {
  const res = await fetch(`https://api.apibharat.com/v1/holidays/${year}`);
  const json = await res.json();
  if (!json.success) return [];
  return json.data.holidays;
}

loadHolidays(2026).then(list => {
  const ul = document.getElementById("holidays");
  list.forEach(h => {
    const li = document.createElement("li");
    li.textContent = `${h.holiday_date} โ€” ${h.name} (${h.day_of_week})`;
    ul.appendChild(li);
  });
});

Python

python
import requests

def next_holiday(year):
    r = requests.get(f"https://api.apibharat.com/v1/holidays/{year}")
    data = r.json()
    if not data["success"]:
        return None
    return data["data"]["holidays"][0]  # already sorted by date

print(next_holiday(2026))

PHP

php
<?php
$year = 2026;
$json = json_decode(file_get_contents("https://api.apibharat.com/v1/holidays/$year"), true);
if ($json["success"]) {
    foreach ($json["data"]["holidays"] as $h) {
        echo $h["holiday_date"] . " โ€” " . $h["name"] . PHP_EOL;
    }
}

Notes

  • Holidays are returned sorted by date, each with its type (National / Gazetted) and day_of_week.
  • Festival dates are lunar, so confirm the current year is available before relying on it in production.
  • A missing or invalid year returns success: false โ€” handle that before iterating.

See the Holidays API reference for the full field list.