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": []
}