Chris Malherbe
Chris Malherbe

Reputation: 238

Google Calendar API public holidays

Using the Node https://github.com/google/google-api-nodejs-client library I am trying to access public holidays. I have the auth working and have access to the API. When I test the events. list endpoints with API explorer it works, I suspect that the calendar

calendarId :'en.sa#[email protected]'

exists in my personal calendar but not in the apps calendar.

When I try to get the list of calendars in my node app the list is empty:

calendar.calendarList.list({auth: jwtClient}, calenderGetComplete);

So the events.list doesnt find the calendar.

calendar.events.list({ calendarId :'en.sa#[email protected]', auth: jwtClient}, calenderGetComplete);

So on a personal calendar, one can add other interesting calendars, like the public holiday one, but seems like you can't do it for the calendar the app is using? Seems like the public calendars don't have 'interesting calendars'?

Upvotes: 2

Views: 7604

Answers (2)

Vikash Rathee
Vikash Rathee

Reputation: 2094

I tested to subscribe all holidays calendar to integrate in our appointment scheduling software (DaySchedule) few months back, but this doesn't seems to return complete holidays list for all countries. Especially the state holidays.

So, we published out 11holidays project on GitHub

npm i 11holidays

Get holidays

const holidays = await instance.holidays.list({country: 'US', year: '2023'});

Disclaimer: I am founding members of DaySchedule and 11holidays project.

Upvotes: 0

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 117176

I am not sure how it is you are authenticating Oauth2 or a service account?

There is a difference between calendar lists and calendars. The calendar list is just that little list on the bottom left-hand side of the google calendar website it has no real purpose (IMO). If you are using a service account and grant it access to one of your personal (ex: chrisMalherbe at gmail.com) Google calendars it will have access to it but it won't appear in the service accounts calendar. list unless you insert it there manually. When you add one of these interesting calendars to your personal google calendar page (ex: chrisMalherbe at gmail.com) the website automatically adds it to the calendar. list for you.

It doesn't really need to be there.

As for public calendars, everyone has access and they don't need to be on the calendar list. They are public you can create a public API key and request data from them. I am not sure what calendar en.sa is but I would take your API key and dump this in a web browser just to make sure there is data. If memory serves there are a few with no data, and the data only goes a year ahead I think so if you are looking for holidays in 2020 there won't be any data.

GET https://www.googleapis.com/calendar/v3/calendars/en.sa#[email protected]/events?key=[APIKey]

Or with an access token if you don't want to use a public API key

GET https://www.googleapis.com/calendar/v3/calendars/en.sa#[email protected]/events?access_token=[accesstoken]

I am not a node.js expert but I found this node-google-api it might help I have a tutorial on this its mostly explains how public calendars work however it's in C# may or may not be of any help to you. Public Google Calendars with C#

Upvotes: 2

Related Questions