📁 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:
Google Developer Console: Access the Google Developer Console, create a new project, and enable the Google Drive API.
OAuth Consent Screen: Set up the OAuth consent screen with the appropriate scopes.
Credentials: Generate credentials (OAuth client ID).
Scopes
The API uses scopes to determine the level of access that the application requires:
Scope | Description |
---|---|
https://www.googleapis.com/auth/drive | Full access to the user's files. |
https://www.googleapis.com/auth/drive.file | Access to files created or opened by the app. |
https://www.googleapis.com/auth/drive.readonly | Read-only access to file metadata and content. |
https://www.googleapis.com/auth/drive.metadata.readonly | Read-only access to file metadata. |
https://www.googleapis.com/auth/drive.appdata | Access to the application's configuration data. |
https://www.googleapis.com/auth/drive.metadata | Read/write access to file metadata. |
Common Parameters
Parameter | Description | Example Value |
---|---|---|
fileId | The ID of the file to operate on. | {{fileId}} |
revisionId | The ID of the file revision to operate on. | {{revisionId}} |
pageSize | The number of files to return per page. | 100 |
pageToken | The token for continuing a previous list request on the next page. | {{pageToken}} |
fields | The fields to return in the response. | 'nextPageToken, files(id, name)' |
-
Files - List user's files GET {{baseUrl}}/files?driveId={{driveId}}&pageToken={{pageToken}}&q={{query}}&key={{key}}&oauth_token={{oauthToken}}
-
Comments - Create a comment on a file POST {{baseUrl}}/files/:fileId/comments?key={{key}}&oauth_token={{oauthToken}}
-
Comments - Delete a comment DELETE {{baseUrl}}/files/:fileId/comments/:commentId?key={{key}}&oauth_token={{oauthToken}}
-
Comments - Lists a file's comments GET {{baseUrl}}/files/:fileId/comments?pageToken={{pageToken}}&key={{key}}&oauth_token={{oauthToken}}
-
Comments - Get comment by ID GET {{baseUrl}}/files/:fileId/comments/:commentId?key={{key}}&oauth_token={{oauthToken}}
-
Shared Drive - Update metadata for a shared drive PATCH {{baseUrl}}/drives/:driveId?key={{key}}&oauth_token={{oauthToken}}
-
Comments - Update comment PATCH {{baseUrl}}/files/:fileId/comments/:commentId?key={{key}}&oauth_token={{oauthToken}}
-
Shared Drive - Create a shared drive POST {{baseUrl}}/drives?requestId={{requestId}}&key={{key}}&oauth_token={{oauthToken}}
-
Shared Drive - List user's shared drive GET {{baseUrl}}/drives?pageToken={{pageToken}}&q={{query}}&key={{key}}&oauth_token={{oauthToken}}
-
Shared Drive - Permanently delete a shared drive DELETE {{baseUrl}}/drives/:driveId?key={{key}}&oauth_token={{oauthToken}}