Get Holidays List of a Country from Google Calendar API
Asked Answered
L

3

16

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

Is it Possible? How Can I do this?

Lentissimo answered 14/6, 2015 at 19:53 Comment(1)
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.Hurtado
M
38

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>

Mockheroic answered 4/5, 2017 at 13:0 Comment(11)
How to get another country's Calendar list ??Flieger
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 , subscribe the indian calendar(You can choose what you want) then you can find the calendar name from the calender settings (like this : drive.google.com/file/d/1z6S6GtWL9sfzeVu4CzH7dMCLd0IFNVzi/view). , replace it on the url (like this : drive.google.com/file/d/1VbsAhQaPiU0OUGnGRs19EaRANOwaltDh/view)Mockheroic
hi @Midhun1993, i followed your approach. But i'm keep seeing the "Login Required" message. Please help to advise: drive.google.com/file/d/1wQ8FZPTzDXpZxvDAKNiUDKHqJeniynhd/…Sergius
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.Hierarchize
Hi @BorgyManotoy i think this: restcountries.eu will help you. Please checkMockheroic
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. ThanksHierarchize
looks like the link has changed. I'm getting an 404.Mucous
Yes same - I'm going to go and look at the documentation.Croesus
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?Sapphera
@Sapphera have you gotten any solution?Apples
List of calendar countries: #30834344Inclement
D
8

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#[email protected]",
    "displayName": "Holidays in United States",
    "self": true
   },
   "organizer": {
    "email": "en.usa#[email protected]",
    "displayName": "Holidays in United States",
    "self": true
   },
   "start": {
    "date": "2020-01-01"
   },
   "end": {
    "date": "2020-01-02"
   },
   "transparency": "transparent",
   "visibility": "public",
   "iCalUID": "[email protected]",
   "sequence": 0
  },
  {
.........

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

"summary": "New Year's Day",
Disclimax answered 20/1, 2021 at 8:55 Comment(0)
M
0

https://gist.github.com/dhoeric/76bd1c15168ee0ee61ad3bf1730dcb65

Here is the list of all countries.

need to replace en.indian.official#[email protected] in url.

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

highlighted part need to replace. If you get authentication error then replace

# with %23 and @ with %40

Due some parsing issue it gives authentication issue.

Mantle answered 5/6 at 10:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.