listEvents
Lists one page of events in a time window. iterateEvents walks every page.
The window's end is exclusive, and a recurring series comes back as its occurrences, each with its own id, unless you set expandRecurring: false. Use iterateEvents when you want every page without handling cursors.
import { listEvents } from '@cal-sdk/core';
const { events, nextPageToken } = await listEvents({
calendar,
timeMin: new Date(),
timeMax: '2026-12-31T00:00:00Z',
});Options
- timeMinDate | string
- Start of the window, inclusive. Events that end after it are returned.
- timeMaxDate | string
- End of the window, exclusive. Events that start before it are returned.
- calendarId?string= 'primary'
- expandRecurring?boolean= true
truereturns occurrences and exceptions, sorted by start.falsereturns series instead.- query?string
- Free-text search. Throws
UnsupportedFunctionalityErrorunlesscapabilities.events.searchis supported. - pageSize?number
- Upper bound on events per page. Providers may return fewer.
- pageToken?string
nextPageTokenfrom the previous page.
Plus the common options. Strings in timeMin and timeMax are parsed as ISO 8601; one without a time is midnight UTC.
Result
- eventsCalendarEvent[]
- nextPageToken?string
- Pass as
pageTokenfor the next page. Missing on the last page. - warningsWarning[]
Throws
InvalidArgumentErrorwhentimeMaxis not aftertimeMin, orpageSizeis not a positive whole number.UnsupportedFunctionalityErrorforqueryon a provider without search.NotFoundErrorwhen the calendar does not exist.
iterateEvents
import { iterateEvents } from '@cal-sdk/core';
for await (const event of iterateEvents({ calendar, timeMin, timeMax })) {
console.log(event.title);
}Takes the same options as listEvents except pageToken, and yields every event, fetching the next page only when the loop needs it. Warnings go to the warnings setting, since there is no result to return them on.