Python Google Sheets API: Get Sheet Id by Sheet Name

Jul 16, 2019
credentials = ...service = build('sheets', 'v4', credentials=credentials)# sheet = service.spreadsheets()SPREADSHEET_ID = ...SHEET_NAME = ...spreadsheet = service.spreadsheets().get(spreadsheetId=SPREADSHEET_ID).execute()sheet_id = Nonefor _sheet in spreadsheet['sheets']:    if _sheet['properties']['title'] == sheet_name:        sheet_id = _sheet['properties']['sheetId']print(f"{SHEET_NAME}={sheet_id}")

NOTE: Refer Setup and Access Google Sheets API With Python.

NOTE: Refer Android (Java/Kotlin) Google Sheets API: Get Sheet Name or Id.

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.