Python 3 Script to Get Business Holidays of any Country From Given Date Using calendarific API Full Project For Beginners




A fun Python script that uses an api to get you the holidays of any place you want on a given day


  • It uses an api call to fetch the data
  • Then it transforms it into a json and parses it to get useful information
  • Finally it serves that information to the user

How to use

  • Generate an api key from
  • Create a file api_key.txt, put your api key in and keep it beside the python script
  • Run the script from your console
  • I also used Task Scheduler on Windows to run this script everyday



This script uses the api
import requests
from datetime import date

with open('api_key.txt', 'r') as key: # <-- use your own api key here
	api_key =

country = 'IN' # <-- you can also change the country... just look up the iso code from the docs

now =
day = str(
month = str(now.month)
year = str(now.year)

url = f'{api_key}&country={country}&day={day}&month={month}&year={year}'

	r = requests.get(url)
	data = r.json()

	holidays = data['response']['holidays']

except Exception:
	holidays = None

if holidays is None:
	print("Could not fetch data. Terminating")

elif len(holidays) == 0:
	print("No holidays today...")

	print("\nToday's holidays :")

	for holiday in holidays:


Leave a Reply