2

Is it possible to get all the documents from google docs using google-docs API?

On the API reference page, I am not able to find API for get all the list of documents

the below api used for get single document using documentId.

GET https://docs.googleapis.com/v1/documents/{documentId}

Reference: https://developers.google.com/docs/api/reference/rest/v1/documents/get

If I forget the document Id, how can get the document? this information not available on the reference api page.

1 Answer 1

4

I believe your goal as follows.

  • You want to retrieve all Google Document files using the method of "documents.get" in Google Docs API.
  • You have no Document IDs of all Google Document files. You are required to retrieve the Document ID.

In order to achieve your goal, I would like to propose to use the following 2 processes.

  1. Retrieve Document IDs of Google Document files.

    • In this case, the method of "Files: list" in Drive API is used. Ref

    • In order to retrieve Google Document files, the search query of mimeType='application/vnd.google-apps.document' and trashed=false is used.

    • The sample curl command is as follows.

        curl \
          'https://www.googleapis.com/drive/v3/files?pageSize=1000&q=mimeType%3D%27application%2Fvnd.google-apps.document%27%20and%20trashed%3Dfalse' \
          --header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
          --header 'Accept: application/json' \
          --compressed
      
    • When you want to retrieve the Google Document files in the specific folder, please use mimeType='application/vnd.google-apps.document' and trashed=false and '###' in parents as the search query.

    • When above curl command is run, the file list including the file IDs is returned.

    • In this sample, the page size is 1000. When you have more document files, please use pageToken.

  2. Retrieve the data from Google Document files.

    • In this case, the method of "documents.get" in Google Docs API is used.
    • Using the file IDs retrieved by above method, you can retrieve all Google Document files. In the current stage, I think that in this case, it is required to request to the endpoint for each Document ID in a loop.
    • In this case, the endpoint in your question can be used.

References:

Sign up to request clarification or add additional context in comments.

1 Comment

@Shakthifuture Thank you for replying. I'm glad this is useful for your situation. Also, I think your this question will be useful for other users.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.