search_emails from Week 1 used a query string to find emails without knowing IDs upfront. The same search-by-name pattern applies to Sheets. What if you could find your time log by searching for "Time Log" instead of remembering the spreadsheet ID?
GOOGLESHEETS_SEARCH_SPREADSHEETS with a query string. Get back a list of matching spreadsheet dicts each with an ID I can use.
Exactly. Pass a query string and get back matching spreadsheets. Each dict has an id key you pass to read_range or append_row. No copying IDs from the URL bar:
result = toolset.execute_action(
Action.GOOGLESHEETS_SEARCH_SPREADSHEETS,
{"query": "Time Log"}
)
sheets = result.get("files", [])
for s in sheets:
print(f"{s.get('id')}: {s.get('name')}")The response key is "files" not "spreadsheets"? That is the third different key name this week.
Google Drive's API uses "files" as the generic resource list key. Sheets, Docs, and Slides are all Drive files under the hood. The Composio wrapper surfaces the Drive response shape — which uses "files". Same safe .get() reflex, different key name.
So I search for my time log by name, get the ID, and pass it to append_row. No hardcoded IDs in my automation script.
A dynamic pipeline. Name changes? Just change the search query:
def search_sheets(query: str) -> list:
result = toolset.execute_action(
Action.GOOGLESHEETS_SEARCH_SPREADSHEETS,
{"query": query}
)
sheets = result.get("files", [])
print(f"Found {len(sheets)} sheets matching '{query}'")
return sheetsMy script now finds my time log by name instead of hardcoded ID. It will survive a rename.
One caveat: query matching is fuzzy. "Time Log" might return multiple spreadsheets — "Time Log 2025", "Time Log 2026", "Archive — Time Log". Always inspect sheets[0] before assuming you have the right one.
GOOGLESHEETS_SEARCH_SPREADSHEETS finds spreadsheets by name — useful when you have many files and need to locate the right one programmatically:
result = toolset.execute_action(
action=Action.GOOGLESHEETS_SEARCH_SPREADSHEETS,
params={'query': query}
)
sheets = result.get('spreadsheets', [])Each spreadsheet dict includes spreadsheetId — the ID you need for read_range and append_row. Searching by name ('Time Log') is more robust than hardcoding a spreadsheet ID that could change when a file is replaced.
Pattern: search → get ID → read or write. This is the same discover-then-act pattern as list_calendars → find_events.
search_emails from Week 1 used a query string to find emails without knowing IDs upfront. The same search-by-name pattern applies to Sheets. What if you could find your time log by searching for "Time Log" instead of remembering the spreadsheet ID?
GOOGLESHEETS_SEARCH_SPREADSHEETS with a query string. Get back a list of matching spreadsheet dicts each with an ID I can use.
Exactly. Pass a query string and get back matching spreadsheets. Each dict has an id key you pass to read_range or append_row. No copying IDs from the URL bar:
result = toolset.execute_action(
Action.GOOGLESHEETS_SEARCH_SPREADSHEETS,
{"query": "Time Log"}
)
sheets = result.get("files", [])
for s in sheets:
print(f"{s.get('id')}: {s.get('name')}")The response key is "files" not "spreadsheets"? That is the third different key name this week.
Google Drive's API uses "files" as the generic resource list key. Sheets, Docs, and Slides are all Drive files under the hood. The Composio wrapper surfaces the Drive response shape — which uses "files". Same safe .get() reflex, different key name.
So I search for my time log by name, get the ID, and pass it to append_row. No hardcoded IDs in my automation script.
A dynamic pipeline. Name changes? Just change the search query:
def search_sheets(query: str) -> list:
result = toolset.execute_action(
Action.GOOGLESHEETS_SEARCH_SPREADSHEETS,
{"query": query}
)
sheets = result.get("files", [])
print(f"Found {len(sheets)} sheets matching '{query}'")
return sheetsMy script now finds my time log by name instead of hardcoded ID. It will survive a rename.
One caveat: query matching is fuzzy. "Time Log" might return multiple spreadsheets — "Time Log 2025", "Time Log 2026", "Archive — Time Log". Always inspect sheets[0] before assuming you have the right one.
GOOGLESHEETS_SEARCH_SPREADSHEETS finds spreadsheets by name — useful when you have many files and need to locate the right one programmatically:
result = toolset.execute_action(
action=Action.GOOGLESHEETS_SEARCH_SPREADSHEETS,
params={'query': query}
)
sheets = result.get('spreadsheets', [])Each spreadsheet dict includes spreadsheetId — the ID you need for read_range and append_row. Searching by name ('Time Log') is more robust than hardcoding a spreadsheet ID that could change when a file is replaced.
Pattern: search → get ID → read or write. This is the same discover-then-act pattern as list_calendars → find_events.
Create a free account to get started. Paid plans unlock all tracks.