Home > Software design >  How to deal with recurring events using the google calendar API?
How to deal with recurring events using the google calendar API?

Time:02-06

I'm using the Google Calendar API and nodejs. I have an app that allows patients to book appointments with doctors. But first, I check the doctor's calendar to make sure they do not have appointments at this time. How can I tell if an event is recurring? Does it show up multiple times when I make a list API call or only once?

CodePudding user response:

Does it show up multiple times when I made a list API call or only once?

By default, it'll come up only once. You'll need to include the singleEvents parameter and set it to true for the reoccurring events that are reoccurring to show up in the API response (otherwise only the first time the reoccurring event was scheduled will be included).

calendar.events.list({ calendarId: theCalendarId, singleEvents: true })

CodePudding user response:

When you have a recurrent event the ID changes a lot. For example, a regular event ID would look like 3qoortuglk75k7fjhgmd9k2enn, but the event ID from a recurrent event would be like 3qoortuglk75k7fjhgmd9k2enn_20220217T160000Z. If you see it has additional information related to the date and time. You could try to use something like that to recognize if the event is recurrent or not.

When listing events with the API you also have the request parameter singleEvents. You could use it to list only single events and compare them to the full list of events to see which ones are recurrent events.

  •  Tags:  
  • Related