Developer Knowledge Hub

Technical Guides & Architecture

Authoritative references on Indian holiday regulations, HRMS leave automation patterns, and multi-state compliance integration.

Developer Recipes5 min readUpdated Sep 2026

India Calendar API Integration Recipes: Node.js, Python, Go & cURL

Production-ready, copy-pasteable code snippets for fetching state holidays, querying date ranges, checking holiday status, and handling network timeouts.

1. Python (Requests & Pydantic)

Clean Python script for fetching all Gazetted holidays for Karnataka (`KA`) in 2026 with structured typing:
Code Reference
import requests
from typing import List, Optional
from pydantic import BaseModel

class Holiday(BaseModel):
    name: str
    date: str
    day: str
    type: str
    description: Optional[str] = None

def get_karnataka_holidays(year: int = 2026) -> List[Holiday]:
    url = f"https://calendar-api-d7a8.onrender.com/v1/holidays"
    params = {"country": "IN", "year": year, "region": "KA"}
    
    response = requests.get(url, params=params, timeout=10)
    response.raise_for_status()
    payload = response.json()
    
    return [Holiday(**item) for item in payload.get("data", [])]

if __name__ == "__main__":
    holidays = get_karnataka_holidays()
    print(f"Fetched {len(holidays)} holidays.")
    for h in holidays[:3]:
        print(f"- {h.date} ({h.day}): {h.name} [{h.type}]")

2. TypeScript / JavaScript (Modern Fetch)

Browser and Node 18+ compliant ES module snippet:
Code Reference
/**
 * Check if a given date is a public holiday in Delhi
 */
async function checkDelhiHoliday(dateString) {
  const url = new URL('https://calendar-api-d7a8.onrender.com/v1/date/is-holiday');
  url.searchParams.set('country', 'IN');
  url.searchParams.set('date', dateString);
  url.searchParams.set('region', 'DL');

  const res = await fetch(url);
  if (!res.ok) throw new Error(`API returned status ${res.status}`);
  
  const data = await res.json();
  return {
    isHoliday: data.is_holiday,
    name: data.holiday?.name || null,
    type: data.holiday?.type || null
  };
}

// Example usage
checkDelhiHoliday('2026-01-26').then(console.log);

3. Go (net/http)

High-performance Golang client implementation:
Code Reference
package main

import (
	"encoding/json"
	"fmt"
	"net/http"
	"time"
)

type HolidayResponse struct {
	Success bool `json:"success"`
	Data    []struct {
		Name string `json:"name"`
		Date string `json:"date"`
		Type string `json:"type"`
	} `json:"data"`
}

func main() {
	client := &http.Client{Timeout: 10 * time.Second}
	url := "https://calendar-api-d7a8.onrender.com/v1/holidays?country=IN&year=2026&region=MH"

	resp, err := client.Get(url)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	var result HolidayResponse
	if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
		panic(err)
	}

	fmt.Printf("Maharashtra Holidays: %d found\n", len(result.Data))
}
Topics:#india holiday api python#calendar api nodejs example#golang public holiday check#curl rest api calendar#free indian holiday rest api
Test in API Playground