15

I want to extract some country's holiday list from Google Calendar API using JavaScript.

Is it Possible? How Can I do this?

Mohammed Safeer
  • 20,751
  • 8
  • 75
  • 78
  • I don't believe google holds list of holidays for different countries in any API. You can find public calendars with country specific holidays though. – Mike Szyndel Jun 14 '15 at 21:31

2 Answers2

35

Yes, using Google API you can do that.

  • Create an API app in the google developer account

  • From the "Credentials" tab you can create an API key, you get something like this AIzaSyBcOT_DpEQysiwFmmmZXupKpnrOdJYAhhM

  • Then, you can access holidays calendar using this URL

    https://www.googleapis.com/calendar/v3/calendars/en.uk%23holiday%40group.v.calendar.google.com/events?key=<YOUR API KEY>

Midhun
  • 1,107
  • 10
  • 24
  • 2
    How to get another country's Calendar list ?? – BarmanInfo Nov 02 '17 at 10:27
  • Replace the calender name on the url. If you want an indian holiday calender you can see all available holiday calenders in following url : [link](https://calendar.google.com/calendar/render#settings-dir_10%7Choliday) , subscribe the indian calendar(You can choose what you want) then you can find the calendar name from the calender settings (like this : https://drive.google.com/file/d/1z6S6GtWL9sfzeVu4CzH7dMCLd0IFNVzi/view). , replace it on the url (like this : https://drive.google.com/file/d/1VbsAhQaPiU0OUGnGRs19EaRANOwaltDh/view) – Midhun Nov 03 '17 at 06:56
  • 7
    hi @Midhun1993, i followed your approach. But i'm keep seeing the "Login Required" message. Please help to advise: https://drive.google.com/file/d/1wQ8FZPTzDXpZxvDAKNiUDKHqJeniynhd/view?usp=sharing – 夏期劇場 Apr 06 '18 at 08:32
  • this may not be directly connected to the question, but is there an API where we could get the list of country codes... like I would want to display the countries (code) to a select dropdown. The user could then select which could he/she wants to use to get the list of holidays. – Borgy Manotoy May 28 '18 at 12:51
  • 2
    Hi @BorgyManotoy i think this: https://restcountries.eu/ will help you. Please check – Midhun May 28 '18 at 13:45
  • 2
    thanks Midhun1993, but I think I needed the list of countries that I could use in the api (in your answer). Currently tested it with `us`, `uk`, `singapore`, `china`, `indian`, `philippines`, `spain`... but there are still a lot of countries which I want to use but don't know the value to supply in the API call. This is why I wanted to get the list of countries (code) that I could use in calling this API. Thanks – Borgy Manotoy May 28 '18 at 14:09
  • looks like the link has changed. I'm getting an 404. – MRonline Feb 08 '20 at 15:42
  • Yes same - I'm going to go and look at the documentation. – Kiran Jul 26 '20 at 09:18
  • 2
    This works great for countries. Currently the API returns holidays for 3 years `past one year`, `current year` and `future year` for the specified country. Is there a way to get a particular year in past or in future? – nishant Mar 10 '21 at 12:20
  • @nishant have you gotten any solution? – Bhaven Shah Apr 01 '22 at 04:59
  • List of calendar countries: https://stackoverflow.com/questions/30833844/get-holidays-list-of-a-country-from-google-calendar-api – Rajesh Gauswami Aug 28 '23 at 08:24
7

google provides API for holiday list.

https://www.googleapis.com/calendar/v3/calendars/en.uk%23holiday%40group.v.calendar.google.com/events?key=YourApiKey

  1. like we want holiday list for USA

then, change this text in url

calendars/en.usa

Example :- https://www.googleapis.com/calendar/v3/calendars/en.usa%23holiday%40group.v.calendar.google.com/events?key=YourApiKey

after this,

  1. we get all Holiday event list in "items" Array.

like this,

 "items": [
  {
   "kind": "calendar#event",
   "etag": "\"3101513576000000\"",
   "id": "20200101_60o30dr46oo30c1g60o30dr56g",
   "status": "confirmed",
   "htmlLink": "https://www.google.com/calendar/event?eid=MjAyMDAxMDFfNjBvMzBkcjQ2b28zMGMxZzYwbzMwZHI1NmcgZW4udXNhI2hvbGlkYXlAdg",
   "created": "2019-02-21T13:46:28.000Z",
   "updated": "2019-02-21T13:46:28.000Z",
   "summary": "New Year's Day",
   "creator": {
    "email": "en.usa#holiday@group.v.calendar.google.com",
    "displayName": "Holidays in United States",
    "self": true
   },
   "organizer": {
    "email": "en.usa#holiday@group.v.calendar.google.com",
    "displayName": "Holidays in United States",
    "self": true
   },
   "start": {
    "date": "2020-01-01"
   },
   "end": {
    "date": "2020-01-02"
   },
   "transparency": "transparent",
   "visibility": "public",
   "iCalUID": "20200101_60o30dr46oo30c1g60o30dr56g@google.com",
   "sequence": 0
  },
  {
.........

we will get all detail in there like, Holiday name of day in "summary" key

"summary": "New Year's Day",
Shirsh Shukla
  • 5,491
  • 3
  • 31
  • 44