Your append_row requires a spreadsheet ID. But hardcoding an ID means if you create a new MRR tracker for the new fiscal year, you have to update the code. How do you find the right sheet by name?
After append_row I realise I'm hardcoding the sheet ID. When I create a new tracker for Q2, I'll have to remember to update it. That's a maintenance headache.
GOOGLESHEETS_SEARCH_SPREADSHEETS finds spreadsheets by name or keyword. The response is a list of sheet metadata dicts — each with id, name, and webViewLink. You search once, save the ID, use it in read_range and append_row:
result = toolset.execute_action(
Action.GOOGLESHEETS_SEARCH_SPREADSHEETS,
{"query": query}
)
sheets = result.get("spreadsheets", [])
for sheet in sheets:
print(sheet.get("name"), sheet.get("id"))What does the query match? Just the title, or also content inside the sheet?
Google Drive search matches the file title primarily. query='MRR Tracker' finds all spreadsheets with 'MRR Tracker' in the name. Content search is more limited in the API. Use descriptive file names and the search will be reliable. Here's the full function:
def search_sheets(query: str) -> list:
result = toolset.execute_action(
Action.GOOGLESHEETS_SEARCH_SPREADSHEETS,
{"query": query}
)
sheets = result.get("spreadsheets", [])
print(f"Found {len(sheets)} sheets matching '{query}'")
return sheetsSo search_sheets('MRR Tracker Q2') gives me the ID, and I pass that directly to append_row. No hardcoded IDs, no maintenance headache.
Composable plumbing. The search result feeds the append. No copy-pasting IDs from a browser tab.
Search then read-or-write. Three Sheets actions now — read_range, append_row, search_sheets. The whole spreadsheet workflow is in Python.
If multiple sheets match the query, take the first result or filter by name exactly: next((s for s in sheets if s['name'] == 'MRR Tracker'), None). A vague query can return the wrong sheet.
GOOGLESHEETS_SEARCH_SPREADSHEETS finds spreadsheets by name. Using search instead of hardcoded IDs makes your automation resilient to yearly tracker refreshes — when you create a new MRR Tracker for Q2, the function finds it automatically without any code changes.
toolset.execute_action(
Action.GOOGLESHEETS_SEARCH_SPREADSHEETS,
{"query": "MRR Tracker"}
){"spreadsheets": [{"id": "1abc...", "name": "MRR Tracker 2026", "webViewLink": "..."}]}Vague queries can match multiple sheets. Filter by exact name: next((s for s in sheets if s['name'] == 'exact_name'), None).
Your append_row requires a spreadsheet ID. But hardcoding an ID means if you create a new MRR tracker for the new fiscal year, you have to update the code. How do you find the right sheet by name?
After append_row I realise I'm hardcoding the sheet ID. When I create a new tracker for Q2, I'll have to remember to update it. That's a maintenance headache.
GOOGLESHEETS_SEARCH_SPREADSHEETS finds spreadsheets by name or keyword. The response is a list of sheet metadata dicts — each with id, name, and webViewLink. You search once, save the ID, use it in read_range and append_row:
result = toolset.execute_action(
Action.GOOGLESHEETS_SEARCH_SPREADSHEETS,
{"query": query}
)
sheets = result.get("spreadsheets", [])
for sheet in sheets:
print(sheet.get("name"), sheet.get("id"))What does the query match? Just the title, or also content inside the sheet?
Google Drive search matches the file title primarily. query='MRR Tracker' finds all spreadsheets with 'MRR Tracker' in the name. Content search is more limited in the API. Use descriptive file names and the search will be reliable. Here's the full function:
def search_sheets(query: str) -> list:
result = toolset.execute_action(
Action.GOOGLESHEETS_SEARCH_SPREADSHEETS,
{"query": query}
)
sheets = result.get("spreadsheets", [])
print(f"Found {len(sheets)} sheets matching '{query}'")
return sheetsSo search_sheets('MRR Tracker Q2') gives me the ID, and I pass that directly to append_row. No hardcoded IDs, no maintenance headache.
Composable plumbing. The search result feeds the append. No copy-pasting IDs from a browser tab.
Search then read-or-write. Three Sheets actions now — read_range, append_row, search_sheets. The whole spreadsheet workflow is in Python.
If multiple sheets match the query, take the first result or filter by name exactly: next((s for s in sheets if s['name'] == 'MRR Tracker'), None). A vague query can return the wrong sheet.
GOOGLESHEETS_SEARCH_SPREADSHEETS finds spreadsheets by name. Using search instead of hardcoded IDs makes your automation resilient to yearly tracker refreshes — when you create a new MRR Tracker for Q2, the function finds it automatically without any code changes.
toolset.execute_action(
Action.GOOGLESHEETS_SEARCH_SPREADSHEETS,
{"query": "MRR Tracker"}
){"spreadsheets": [{"id": "1abc...", "name": "MRR Tracker 2026", "webViewLink": "..."}]}Vague queries can match multiple sheets. Filter by exact name: next((s for s in sheets if s['name'] == 'exact_name'), None).
Create a free account to get started. Paid plans unlock all tracks.