📁 Google Drive API

Number of APIs: 48

The Google Drive API allows developers to manage files in Drive, including uploading, downloading, searching, detecting changes, and updating sharing permissions. This API is comprehensive, offering functionalities for managing various aspects of Google Drive.

Technical Concepts

File ID

What is a File ID?: A unique identifier for a file in Google Drive, used in API calls to specify which file to operate on.

Revision ID

What is a Revision ID?: A unique identifier for a revision of a file in Google Drive. It's used to specify which revision to manage in the API calls.

Obtaining Access Tokens

To use the Google Drive API, an OAuth 2.0 token is necessary:

  1. Google Developer Console: Access the Google Developer Console, create a new project, and enable the Google Drive API.

  2. OAuth Consent Screen: Set up the OAuth consent screen with the appropriate scopes.

  3. Credentials: Generate credentials (OAuth client ID).

Scopes

The API uses scopes to determine the level of access that the application requires:

ScopeDescription
https://www.googleapis.com/auth/driveFull access to the user's files.
https://www.googleapis.com/auth/drive.fileAccess to files created or opened by the app.
https://www.googleapis.com/auth/drive.readonlyRead-only access to file metadata and content.
https://www.googleapis.com/auth/drive.metadata.readonlyRead-only access to file metadata.
https://www.googleapis.com/auth/drive.appdataAccess to the application's configuration data.
https://www.googleapis.com/auth/drive.metadataRead/write access to file metadata.

Common Parameters

ParameterDescriptionExample Value
fileIdThe ID of the file to operate on.{{fileId}}
revisionIdThe ID of the file revision to operate on.{{revisionId}}
pageSizeThe number of files to return per page.100
pageTokenThe token for continuing a previous list request on the next page.{{pageToken}}
fieldsThe fields to return in the response.'nextPageToken, files(id, name)'
  1. Files - List user's files GET {{baseUrl}}/files?driveId={{driveId}}&pageToken={{pageToken}}&q={{query}}&key={{key}}&oauth_token={{oauthToken}}

  2. Comments - Create a comment on a file POST {{baseUrl}}/files/:fileId/comments?key={{key}}&oauth_token={{oauthToken}}

  3. Comments - Delete a comment DELETE {{baseUrl}}/files/:fileId/comments/:commentId?key={{key}}&oauth_token={{oauthToken}}

  4. Comments - Lists a file's comments GET {{baseUrl}}/files/:fileId/comments?pageToken={{pageToken}}&key={{key}}&oauth_token={{oauthToken}}

  5. Comments - Get comment by ID GET {{baseUrl}}/files/:fileId/comments/:commentId?key={{key}}&oauth_token={{oauthToken}}

  6. Shared Drive - Update metadata for a shared drive PATCH {{baseUrl}}/drives/:driveId?key={{key}}&oauth_token={{oauthToken}}

  7. Comments - Update comment PATCH {{baseUrl}}/files/:fileId/comments/:commentId?key={{key}}&oauth_token={{oauthToken}}

  8. Shared Drive - Create a shared drive POST {{baseUrl}}/drives?requestId={{requestId}}&key={{key}}&oauth_token={{oauthToken}}

  9. Shared Drive - List user's shared drive GET {{baseUrl}}/drives?pageToken={{pageToken}}&q={{query}}&key={{key}}&oauth_token={{oauthToken}}

  10. Shared Drive - Permanently delete a shared drive DELETE {{baseUrl}}/drives/:driveId?key={{key}}&oauth_token={{oauthToken}}