Lists the user's files.
This method accepts the q
parameter, which is a search query combining one or more search terms. For more information, see the Search for files & folders
guide.
HTTP request
GET https://www.googleapis.com/drive/v2/files
The URL uses gRPC Transcoding syntax.
Query parameters
corpora
string
Bodies of items (files/documents) to which the query applies. Supported bodies are default
, domain
, drive
and allDrives
. Prefer default
or drive
to allDrives
for efficiency.
corpus
(deprecated)
enum (
Corpus
)
Deprecated: The body of items (files/documents) to which the query applies. Use corpora
instead.
driveId
string
ID of the shared drive to search.
includeItemsFromAllDrives
boolean
Whether both My Drive and shared drive items should be included in results.
includeTeamDriveItems
(deprecated)
boolean
Deprecated: Use includeItemsFromAllDrives
instead.
maxResults
integer
The maximum number of files to return per page. Partial or empty result pages are possible even before the end of the files list has been reached.
orderBy
string
A comma-separated list of sort keys. Valid keys are:
-
createdDate
: When the file was created. -
folder
: The folder ID. This field is sorted using alphabetical ordering. -
lastViewedByMeDate
: The last time the file was viewed by the user. -
modifiedByMeDate
: The last time the file was modified by the user. -
modifiedDate
: The last time the file was modified by anyone. -
quotaBytesUsed
: The number of storage quota bytes used by the file. -
recency
: The most recent timestamp from the file's date-time fields. -
sharedWithMeDate
: When the file was shared with the user, if applicable. -
starred
: Whether the user has starred the file. -
title
: The title of the file. This field is sorted using alphabetical ordering, so 1, 12, 2, 22. -
title_natural
: The title of the file. This field is sorted using natural sort ordering, so 1, 2, 12, 22.
Each key sorts ascending by default, but can be reversed with the 'desc' modifier. Example usage: ?orderBy=folder,modifiedDate desc,title
.
Note that there's a current limitation for users with approximately one million files in which the requested sort order is ignored.
pageToken
string
Page token for files.
projection
(deprecated)
enum (
Projection
)
Deprecated: This parameter has no function.
q
string
Query string for searching files.
spaces
string
A comma-separated list of spaces to query. Supported values are drive
, and appDataFolder
.
supportsAllDrives
boolean
Whether the requesting application supports both My Drives and shared drives.
supportsTeamDrives
(deprecated)
boolean
Deprecated: Use supportsAllDrives
instead.
teamDriveId
(deprecated)
string
Deprecated: Use driveId
instead.
includeLabels
string
A comma-separated list of IDs of labels to include in the labelInfo
part of the response.
Request body
The request body must be empty.
Response body
A list of files.
If successful, the response body contains data with the following structure:
JSON representation |
---|
{
"items"
:
[
{
object (
|
Fields | |
---|---|
items[]
|
The list of files. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched. |
nextPageToken
|
The page token for the next page of files. This will be absent if the end of the files list has been reached. If the token is rejected for any reason, it should be discarded, and pagination should be restarted from the first page of results. |
kind
|
This is always |
etag
|
The ETag of the list. |
selfLink
|
A link back to this list. |
incompleteSearch
|
Whether the search process was incomplete. If true, then some search results may be missing, since all documents were not searched. This may occur when searching multiple drives with the "allDrives" corpora, but all corpora could not be searched. When this happens, it is suggested that clients narrow their query by choosing a different corpus such as "default" or "drive". |
nextLink
|
A link to the next page of files. |
Authorization scopes
Requires one of the following OAuth scopes:
-
https://www.googleapis.com/auth/docs
-
https://www.googleapis.com/auth/drive
-
https://www.googleapis.com/auth/drive.appdata
-
https://www.googleapis.com/auth/drive.apps.readonly
-
https://www.googleapis.com/auth/drive.file
-
https://www.googleapis.com/auth/drive.meet.readonly
-
https://www.googleapis.com/auth/drive.metadata
-
https://www.googleapis.com/auth/drive.metadata.readonly
-
https://www.googleapis.com/auth/drive.photos.readonly
-
https://www.googleapis.com/auth/drive.readonly
Some scopes are restricted and require a security assessment for your app to use them. For more information, see the Authorization guide .
Corpus
Enums | |
---|---|
DEFAULT
|
The items that the user has accessed. |
DOMAIN
|
Items shared to the user's domain. |