0

Get Event

by
Published today

Get one calendar event by id.

Script gcal Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 5 hours ago
1
//native
2

3
/**
4
 * Get Event
5
 * Get one event by id: title, times, attendees and their RSVPs, recurrence, conference link, etc. For an instance of a recurring event (id `<series>_<start>`), `recurringEventId` points at the series.
6
 */
7
export async function main(
8
  auth: RT.Gcal,
9
  event_id: string,
10
  calendar_id: string = "primary",
11
  time_zone: string | undefined
12
) {
13
  const url = new URL(
14
    `https://www.googleapis.com/calendar/v3/calendars/${encodeURIComponent(calendar_id || "primary")}/events/${event_id}`
15
  )
16
  if (time_zone != null && time_zone !== "")
17
    url.searchParams.append("timeZone", time_zone)
18

19
  const response = await fetch(url, {
20
    headers: {
21
      Authorization: `Bearer ${auth.token}`,
22
      Accept: "application/json",
23
    },
24
  })
25
  if (!response.ok) {
26
    throw new Error(`${response.status} ${await response.text()}`)
27
  }
28

29
  return await response.json()
30
}
31