Search code examples
pythongoogle-calendar-api

Google calendar api: getting eventdetails from different calendars


Is it possible with python and the google calendar api to retrieve event details from different calendars.

For example: I want to display a family calendar on one screen. To do this, I want to retrieve all the appointments from the calendars of my wife, my children and me.

I already tried the quickstart.py script from google and added an array with the different calendar ids. But it only retreived event details from one calendar.


Solution

  • There's no way to do this with one request. With gcsa you can do:

    from gcsa.google_calendar import GoogleCalendar
    
    gc = GoogleCalendar()
    events = list(gc.get_events(start, end, calendar_id='calendar1'))
    events.extend(gc.get_events(start, end, calendar_id='calendar2'))
    events.extend(gc.get_events(start, end, calendar_id='calendar3'))
    ...
    
    events.sort() # if you need to sort events by time
    

    But you need to have an access to all calendars.