Can I use multiple calendarID's with the google calendar api?

Viewed 831

I want to use the Google Calendar api with multiple calendar IDs. How can I get this working in the following code?

function listUpcomingEvents() {
        gapi.client.calendar.events.list({
          'calendarId': 'calenderID',
          'timeMin': (new Date()).toISOString(),
          'showDeleted': false,
          'singleEvents': true,
          'maxResults': 10,
          'orderBy': 'startTime'
        }).then(function(response) {
          var events = response.result.items;
          appendPre('Afspraken:');

          if (events.length > 0) {
            for (i = 0; i < events.length; i++) {
              var event = events[i];
              var when = event.start.dateTime;
              if (!when) {
                when = event.start.date;
              }
              appendPre(event.summary + ' (' + when + ')')
            }
          } else {
            appendPre('Geen afspraken vandaag');
          }
        });
      }

1 Answers

The events.list method has one primary parameter for the call that being calendar id

GET https://www.googleapis.com/calendar/v3/calendars/calendarId/events

Each call to this endpoint is for a single calendar id. Its not possible to make single request to this endpoint or any of the other Google calendar api endpoints with multiple calendar ids. You will need to make a request for each calendar you would like to retrieve data on.

Related