files

GET /files/{fileId}

Changed on

Gets a file's metadata or content by ID. For more information, see Search for files and folders. If you provide the URL parameter alt=media, then the response includes the file contents in the response body. Downloading content with alt=media only works if the file is stored in Drive. To download Google Docs, Sheets, and Slides use files.export instead. For more information, see Download and export files.

Request

  • Base URL
    https://www.googleapis.com/drive/v3
  • Auth
    • OAuth 2 and OAuth 2
      Implicithttps://accounts.google.com/o/oauth2/auth
      Scopeshttps://www.googleapis.com/auth/drive
      Authorization codehttps://accounts.google.com/o/oauth2/auth
      Token URLhttps://accounts.google.com/o/oauth2/token
      Scopeshttps://www.googleapis.com/auth/drive
    • or OAuth 2 and OAuth 2
      Implicithttps://accounts.google.com/o/oauth2/auth
      Scopeshttps://www.googleapis.com/auth/drive.appdata
      Authorization codehttps://accounts.google.com/o/oauth2/auth
      Token URLhttps://accounts.google.com/o/oauth2/token
      Scopeshttps://www.googleapis.com/auth/drive.appdata
    • or OAuth 2 and OAuth 2
      Implicithttps://accounts.google.com/o/oauth2/auth
      Scopeshttps://www.googleapis.com/auth/drive.file
      Authorization codehttps://accounts.google.com/o/oauth2/auth
      Token URLhttps://accounts.google.com/o/oauth2/token
      Scopeshttps://www.googleapis.com/auth/drive.file
    • or OAuth 2 and OAuth 2
      Implicithttps://accounts.google.com/o/oauth2/auth
      Scopeshttps://www.googleapis.com/auth/drive.meet.readonly
      Authorization codehttps://accounts.google.com/o/oauth2/auth
      Token URLhttps://accounts.google.com/o/oauth2/token
      Scopeshttps://www.googleapis.com/auth/drive.meet.readonly
    • or OAuth 2 and OAuth 2
      Implicithttps://accounts.google.com/o/oauth2/auth
      Scopeshttps://www.googleapis.com/auth/drive.metadata
      Authorization codehttps://accounts.google.com/o/oauth2/auth
      Token URLhttps://accounts.google.com/o/oauth2/token
      Scopeshttps://www.googleapis.com/auth/drive.metadata
    • or OAuth 2 and OAuth 2
      Implicithttps://accounts.google.com/o/oauth2/auth
      Scopeshttps://www.googleapis.com/auth/drive.metadata.readonly
      Authorization codehttps://accounts.google.com/o/oauth2/auth
      Token URLhttps://accounts.google.com/o/oauth2/token
      Scopeshttps://www.googleapis.com/auth/drive.metadata.readonly
    • or OAuth 2 and OAuth 2
      Implicithttps://accounts.google.com/o/oauth2/auth
      Scopeshttps://www.googleapis.com/auth/drive.photos.readonly
      Authorization codehttps://accounts.google.com/o/oauth2/auth
      Token URLhttps://accounts.google.com/o/oauth2/token
      Scopeshttps://www.googleapis.com/auth/drive.photos.readonly
    • or OAuth 2 and OAuth 2
      Implicithttps://accounts.google.com/o/oauth2/auth
      Scopeshttps://www.googleapis.com/auth/drive.readonly
      Authorization codehttps://accounts.google.com/o/oauth2/auth
      Token URLhttps://accounts.google.com/o/oauth2/token
      Scopeshttps://www.googleapis.com/auth/drive.readonly

Path parameters

fileIdstring required

The ID of the file.

Query parameters

acknowledgeAbuseboolean

Whether the user is acknowledging the risk of downloading known malware or other abusive files. This is only applicable when the alt parameter is set to media and the user is the owner of the file or an organizer of the shared drive in which the file resides.

includeLabelsstring

A comma-separated list of IDs of labels to include in the labelInfo part of the response.

includePermissionsForViewstring

Specifies which additional view's permissions to include in the response. Only published is supported.

supportsAllDrivesboolean

Whether the requesting application supports both My Drives and shared drives.

supportsTeamDrivesboolean

Deprecated: Use supportsAllDrives instead.

Response

Successful response

appPropertiesobject

A collection of arbitrary key-value pairs which are private to the requesting app. Entries with null values are cleared in update and copy requests. These properties can only be retrieved using an authenticated request. An authenticated request uses an access token obtained with a OAuth 2 client ID. You cannot use an API key to retrieve private properties.

copyRequiresWriterPermissionboolean

Whether the options to copy, print, or download this file should be disabled for readers and commenters.

createdTimestring date-time

The time at which the file was created (RFC 3339 date-time).

descriptionstring

A short description of the file.

driveIdstring

Output only. ID of the shared drive the file resides in. Only populated for items in shared drives.

explicitlyTrashedboolean

Output only. Whether the file has been explicitly trashed, as opposed to recursively trashed from a parent folder.

exportLinksobject

Output only. Links for exporting Docs Editors files to specific formats.

fileExtensionstring

Output only. The final component of fullFileExtension. This is only available for files with binary content in Google Drive.

folderColorRgbstring

The color for a folder or a shortcut to a folder as an RGB hex string. The supported colors are published in the folderColorPalette field of the about resource. If an unsupported color is specified, the closest color in the palette is used instead.

fullFileExtensionstring

Output only. The full file extension extracted from the name field. May contain multiple concatenated extensions, such as "tar.gz". This is only available for files with binary content in Google Drive. This is automatically updated when the name field changes, however it's not cleared if the new name doesn't contain a valid extension.

hasAugmentedPermissionsboolean

Output only. Whether there are permissions directly on this file. This field is only populated for items in shared drives.

hasThumbnailboolean

Output only. Whether this file has a thumbnail. This doesn't indicate whether the requesting app has access to the thumbnail. To check access, look for the presence of the thumbnailLink field.

headRevisionIdstring

Output only. The ID of the file's head revision. This is currently only available for files with binary content in Google Drive.

iconLinkstring

Output only. A static, unauthenticated link to the file's icon.

idstring

The ID of the file.

inheritedPermissionsDisabledboolean

Whether this file has inherited permissions disabled. Inherited permissions are enabled by default.

isAppAuthorizedboolean

Output only. Whether the file was created or opened by the requesting app.

kindstring

Output only. Identifies what kind of resource this is. Value: the fixed string "drive#file".

md5Checksumstring

Output only. The MD5 checksum for the content of the file. This is only applicable to files with binary content in Google Drive.

mimeTypestring

The MIME type of the file. Google Drive attempts to automatically detect an appropriate value from uploaded content, if no value is provided. The value cannot be changed unless a new revision is uploaded. If a file is created with a Google Doc MIME type, the uploaded content is imported, if possible. The supported import formats are published in the about resource.

modifiedByMeboolean

Output only. Whether the file has been modified by this user.

modifiedByMeTimestring date-time

The last time the file was modified by the user (RFC 3339 date-time).

modifiedTimestring date-time

he last time the file was modified by anyone (RFC 3339 date-time). Note that setting modifiedTime will also update modifiedByMeTime for the user.

namestring

The name of the file. This isn't necessarily unique within a folder. Note that for immutable items such as the top-level folders of shared drives, the My Drive root folder, and the Application Data folder, the name is constant.

originalFilenamestring

The original filename of the uploaded content if available, or else the original value of the name field. This is only available for files with binary content in Google Drive.

ownedByMeboolean

Output only. Whether the user owns the file. Not populated for items in shared drives.

parentsstring[]

The ID of the parent folder containing the file. A file can only have one parent folder; specifying multiple parents isn't supported. If not specified as part of a create request, the file is placed directly in the user's My Drive folder. If not specified as part of a copy request, the file inherits any discoverable parent of the source file. Update requests must use the addParents and removeParents parameters to modify the parents list.

permissionIdsstring[]

Output only. List of permission IDs for users with access to this file.

propertiesobject

A collection of arbitrary key-value pairs which are visible to all apps. Entries with null values are cleared in update and copy requests.

quotaBytesUsedstring int64

Output only. The number of storage quota bytes used by the file. This includes the head revision as well as previous revisions with keepForever enabled.

resourceKeystring

Output only. A key needed to access the item via a shared link.

sha1Checksumstring

Output only. The SHA1 checksum associated with this file, if available. This field is only populated for files with content stored in Google Drive; it's not populated for Docs Editors or shortcut files.

sha256Checksumstring

Output only. The SHA256 checksum associated with this file, if available. This field is only populated for files with content stored in Google Drive; it's not populated for Docs Editors or shortcut files.

sharedboolean

Output only. Whether the file has been shared. Not populated for items in shared drives.

sharedWithMeTimestring date-time

The time at which the file was shared with the user, if applicable (RFC 3339 date-time).

sizestring int64

Output only. Size in bytes of blobs and Google Workspace editor files. Won't be populated for files that have no size, like shortcuts and folders.

spacesstring[]

Output only. The list of spaces which contain the file. The currently supported values are drive, appDataFolder, and photos.

starredboolean

Whether the user has starred the file.

teamDriveIdstring

Deprecated: Output only. Use driveId instead.

thumbnailLinkstring

Output only. A short-lived link to the file's thumbnail, if available. Typically lasts on the order of hours. Not intended for direct usage on web applications due to Cross-Origin Resource Sharing (CORS) policies. Consider using a proxy server. Only populated when the requesting app can access the file's content. If the file isn't shared publicly, the URL returned in files.thumbnailLink must be fetched using a credentialed request.

thumbnailVersionstring int64

Output only. The thumbnail version for use in thumbnail cache invalidation.

trashedboolean

Whether the file has been trashed, either explicitly or from a trashed parent folder. Only the owner may trash a file, but other users can still access the file in the owner's trash until it's permanently deleted.

trashedTimestring date-time

The time that the item was trashed (RFC 3339 date-time). Only populated for items in shared drives.

versionstring int64

Output only. A monotonically increasing version number for the file. This reflects every change made to the file on the server, even those not visible to the user.

viewedByMeboolean

Output only. Whether the file has been viewed by this user.

viewedByMeTimestring date-time

The last time the file was viewed by the user (RFC 3339 date-time).

viewersCanCopyContentboolean

Deprecated: Use copyRequiresWriterPermission instead.

webContentLinkstring

Output only. A link for downloading the content of the file in a browser. This is only available for files with binary content in Google Drive.

webViewLinkstring

Output only. A link for opening the file in a relevant Google editor or viewer in a browser.

writersCanShareboolean

Whether users with only writer permission can modify the file's permissions. Not populated for items in shared drives.

Changes

    • info

      the security scope https://www.googleapis.com/auth/drive was added to the endpoint's security scheme Oauth2

    • info

      the security scope https://www.googleapis.com/auth/drive was added to the endpoint's security scheme Oauth2c

    • info

      the security scope https://www.googleapis.com/auth/drive.readonly was removed from the endpoint's security scheme Oauth2

    • info

      the security scope https://www.googleapis.com/auth/drive.readonly was removed from the endpoint's security scheme Oauth2c

    • info

      the security scope https://www.googleapis.com/auth/drive was added to the endpoint's security scheme Oauth2

    • info

      the security scope https://www.googleapis.com/auth/drive was added to the endpoint's security scheme Oauth2c

    • info

      the security scope https://www.googleapis.com/auth/drive.readonly was removed from the endpoint's security scheme Oauth2

    • info

      the security scope https://www.googleapis.com/auth/drive.readonly was removed from the endpoint's security scheme Oauth2c