count_emails from Week 1 showed you how to fetch a list from an API. The same pattern applies to Calendar. GOOGLECALENDAR_LIST_CALENDARS returns all the calendars connected to your account — your primary calendar, client project calendars, shared team calendars.
I have several calendars — personal, client work, a shared team calendar. I need the right calendar ID before I can create events or search for upcoming calls.
Exactly the list-first pattern. Fetch the calendars, inspect the IDs, then use the right one. The response has a calendars key with a list of calendar dicts:
result = toolset.execute_action(Action.GOOGLECALENDAR_LIST_CALENDARS, {})
calendars = result.get("calendars", [])
for cal in calendars:
print(f"{cal.get('id')}: {cal.get('summary')}")I thought Calendar actions need a calendar ID as input. But LIST_CALENDARS takes an empty dict?
List actions fetch all available resources — no ID needed as input because you are asking "what exists?" not "tell me about this specific thing." The IDs in the response are what you pass to FIND_EVENT and CREATE_EVENT.
So I fetch the list once, find my work calendar ID, and hardcode it in the functions that create events. No more copying IDs from the Calendar settings page.
Or look it up dynamically every run. Either way, the ID is one call away:
def list_calendars() -> list:
result = toolset.execute_action(Action.GOOGLECALENDAR_LIST_CALENDARS, {})
calendars = result.get("calendars", [])
print(f"Found {len(calendars)} calendars")
return calendarsMy client project calendar ID is now a variable, not something I look up manually every time.
One edge case: the response key for the list may vary by Composio version. Always use .get() with an empty list default — same reflex as Gmail.
GOOGLECALENDAR_LIST_CALENDARS returns a list of all calendars accessible to the authenticated account:
result = toolset.execute_action(
action=Action.GOOGLECALENDAR_LIST_CALENDARS,
params={}
)
calendars = result.get('calendars', [])Calendar actions require a calendarId. Your primary calendar is usually 'primary', but shared calendars and client-specific calendars have unique IDs. Always list first to find the correct ID before creating events or searching.
Shape of each calendar dict: typically includes id, summary (the display name), and accessRole. Store the id value — that is what subsequent actions need.
count_emails from Week 1 showed you how to fetch a list from an API. The same pattern applies to Calendar. GOOGLECALENDAR_LIST_CALENDARS returns all the calendars connected to your account — your primary calendar, client project calendars, shared team calendars.
I have several calendars — personal, client work, a shared team calendar. I need the right calendar ID before I can create events or search for upcoming calls.
Exactly the list-first pattern. Fetch the calendars, inspect the IDs, then use the right one. The response has a calendars key with a list of calendar dicts:
result = toolset.execute_action(Action.GOOGLECALENDAR_LIST_CALENDARS, {})
calendars = result.get("calendars", [])
for cal in calendars:
print(f"{cal.get('id')}: {cal.get('summary')}")I thought Calendar actions need a calendar ID as input. But LIST_CALENDARS takes an empty dict?
List actions fetch all available resources — no ID needed as input because you are asking "what exists?" not "tell me about this specific thing." The IDs in the response are what you pass to FIND_EVENT and CREATE_EVENT.
So I fetch the list once, find my work calendar ID, and hardcode it in the functions that create events. No more copying IDs from the Calendar settings page.
Or look it up dynamically every run. Either way, the ID is one call away:
def list_calendars() -> list:
result = toolset.execute_action(Action.GOOGLECALENDAR_LIST_CALENDARS, {})
calendars = result.get("calendars", [])
print(f"Found {len(calendars)} calendars")
return calendarsMy client project calendar ID is now a variable, not something I look up manually every time.
One edge case: the response key for the list may vary by Composio version. Always use .get() with an empty list default — same reflex as Gmail.
GOOGLECALENDAR_LIST_CALENDARS returns a list of all calendars accessible to the authenticated account:
result = toolset.execute_action(
action=Action.GOOGLECALENDAR_LIST_CALENDARS,
params={}
)
calendars = result.get('calendars', [])Calendar actions require a calendarId. Your primary calendar is usually 'primary', but shared calendars and client-specific calendars have unique IDs. Always list first to find the correct ID before creating events or searching.
Shape of each calendar dict: typically includes id, summary (the display name), and accessRole. Store the id value — that is what subsequent actions need.
Create a free account to get started. Paid plans unlock all tracks.