javagoogle-sheetsgoogle-sheets-api

Get the list of all spreadsheets associated with Google account using Sheets API v4


Using Google Sheets API v4, I am looking to get the list of spreadsheets attached to my account. I did much research but have not found any solutions for that.


Solution

  • To get list of all files of specific type, you can use drive API v3. Below is an example to get all sheets from drive of authenticated user.

    drive.files.list({
        q: "mimeType='application/vnd.google-apps.spreadsheet'",
        fields: 'nextPageToken, files(id, name)'
    }, (err, response) => {
        //Your code
    })
    

    You can pass file type in MIME type as 'q' parameter. You can get list of drive MIME types here.

    source: https://developers.google.com/sheets/api/guides/migration#list_spreadsheets_for_the_authenticated_user