0

I have Google Calendar with multiple events, both single and recurring. Occasionally I run a script to refresh it by deleting all existing events and adding new ones, using the Google Calendar API.

To list the events I use, with no additional parameters: https://www.googleapis.com/calendar/v3/calendars/calendarId/events

The problem with this approach is that an empty result set is returned, along with a nextPageToken token. When I fetch the next set of results with the nextPageToken token, another empty set is returned. This loop continues forever.

If I use singleEvents=true then I do not get empty results, but this in turn creates more calendar entries to delete, since recurring events are expanded to single events.

Why do I keep getting an empty result set in the first instance?

What I tried:

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

Result: Empty result set, nextPageToken returned, infinite loop of empty results when fetching nextPageToken.

Fetch URL: https://www.googleapis.com/calendar/v3/calendars/calendarId/events?singleEvents=true

Result: Works, but more results than necessary for deletion are returned.

Example API response without singleEvents=true:

{
 "kind": "calendar#events",
 "etag": "\"p329vtmnsvedos0o\"",
 "summary": "Events",
 "description": "",
 "updated": "2025-07-01T12:26:06.035Z",
 "timeZone": "Europe/London",
 "accessRole": "owner",
 "defaultReminders": [],
 "nextPageToken": "CkwKPAo6CkwIvfvvwgYQmLiFigMSKhooChwKGmZxa2tzMmRjaGdodGtucmt1Mm5xc2pobDFjEggKBgiAhZm-BhoMCPenj8MGENCSitACwD4B",
 "items": []
}
2
  • Please provide a minimal reproducible example also, did you try logging the API response? Was it null or something else? Please share more details. Commented Jun 27 at 12:04
  • @Patsytalk I have added a response from the API and will work on creating a minimal reproducible example. Commented Jul 1 at 12:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.