API overview

Every function calsdk exports, with links to its options and result.

calsdk is ten functions, and they all work the same way. Each takes one options object, with a provider as calendar, and returns a promise, except iterateEvents, which returns an async iterator. Import them from @cal-sdk/core.

FunctionWhat it does
listCalendarsCalendars the user can see
getEventOne event by id
listEventsOne page of events in a time window
iterateEventsEvery event in a time window, page by page
createEventCreate an event or series
updateEventChange an event, an occurrence or a series
deleteEventDelete an event, an occurrence or a series
getFreeBusyBusy blocks for one or more calendars
findFreeTimeSlots when every calendar, across providers, is free
syncEventsChanges since a stored cursor

Common options

Every function except findFreeTime takes these. findFreeTime takes maxRetries and abortSignal, and headers and providerOptions per provider.

calendarCalendarProvider
The provider to call, such as google({ accessToken }).
maxRetries?number= 2
Retries for rate limits, timeouts, server errors and network failures. Creates only retry rate limits.
abortSignal?AbortSignal
Cancels the call, including waits between retries.
headers?Record<string, string>
Extra HTTP headers sent with each provider request.
providerOptions?ProviderOptionsFor<C, Operation>
Provider-specific input, keyed by provider id. Typed by the provider in calendar.

Common result fields

Every result except findFreeTime's has these. findFreeTime returns slots and warnings.

warningsWarning[]
Parts of the request the provider could not honor, or fallbacks used.
providerMetadata?ProviderMetadata
Provider-specific output for the call.
response?{ headers?: Record<string, string>; body?: unknown }
The raw response, for debugging only.

Other exports

  • Types: CalendarEvent, Calendar, EventTime, EventInput, EventPatch, Attendee, BusyBlock, SyncChange, UpdateScope, SendUpdates, Warning, CalendarProvider, CalendarCapabilities and the options and result type of each function. See Types.
  • Errors: CalsdkError and every subclass. See Errors.
  • WarningsSetting, the type of globalThis.CALSDK_WARNINGS. See Warnings.

On this page