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.