> ## Documentation Index
> Fetch the complete documentation index at: https://docs.webrouter.net/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Drive

> Search a Google user's Drive, read file metadata, download files and export Google Docs, Sheets and Slides as text, Markdown, CSV or PDF.

![](https://mintcdn.com/webrouter/gPu3tCeozwRcDBjt/logo/data-apis/google-drive.webp?fit=max\&auto=format\&n=gPu3tCeozwRcDBjt\&q=85\&s=9f1a6753416f152eb335698f82acf962)

[Web Catalog · Productivity](https://docs.webrouter.net/data-apis.md?category=productivity)

Needs&#x20;

`GOOGLE_DRIVE_CLIENT_ID`

,&#x20;

`GOOGLE_DRIVE_CLIENT_SECRET`

,&#x20;

`GOOGLE_DRIVE_REFRESH_TOKEN`

Endpoints

5

Auth

OAuth refresh token

[Vendor docs](https://developers.google.com/workspace/drive/api/reference/rest/v3)

## Setup

| Variable | | What it is |
| - | - | - |
| `GOOGLE_DRIVE_CLIENT_ID` | required | the OAuth client id of a Google Cloud OAuth app with the Google Drive API enabled (Google Cloud console > APIs & Services > Credentials) |
| `GOOGLE_DRIVE_CLIENT_SECRET` | required | that OAuth app's client secret |
| `GOOGLE_DRIVE_REFRESH_TOKEN` | required | a refresh token minted with that OAuth app for [https://www.googleapis.com/auth/drive.readonly](https://www.googleapis.com/auth/drive.readonly) (or drive.metadata.readonly for metadata only) |

Put them in your environment or `.env`; [Data APIs](https://docs.webrouter.net/vendors.md) covers the other ways.

## Notes

* Own-account API: sees what the Google user who granted the refresh token can see. drive.readonly is a restricted scope; an app used outside its own Google Workspace may need Google's verification.
* Responses are minimal by default; set fields to get more than id, name and mimeType (and nextPageToken for paging).
* Google Docs, Sheets and Slides have no bytes to download; export them. Other files download with alt=media.

## Endpoints

GET

Search files

Files and folders the user can access, filtered by a Drive query and sorted.

[Open](#google-drive-files-list)

GET

Get file metadata

A file's metadata: name, type, size, owners, dates, parents and links, as chosen by fields.

[Open](#google-drive-files-get)

GET

Download a file's content

The bytes of a file stored in Drive (PDF, image, upload). Not for Google Docs, Sheets or Slides.

[Open](#google-drive-files-download)

GET

Export a Google Doc, Sheet or Slides file

A Google Workspace document converted to another format: text, Markdown, PDF, CSV, Office.

[Open](#google-drive-files-export)

GET

Get the user and storage quota

The signed-in user, storage quota and, on request, import and export formats.

[Open](#google-drive-about-get)

### Search files

GET

`/files`

`google-drive.files.list`

Files and folders the user can access, filtered by a Drive query and sorted.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`q`</td><td>string</td><td>query</td><td>Drive search query. Example `name contains 'budget' and trashed = false`</td></tr>
    <tr><td>`orderBy`</td><td>string</td><td>query</td><td>Comma-separated keys, add ' desc' to reverse: createdTime, folder, modifiedByMeTime, modifiedTime, name, name\_natural, quotaBytesUsed, recency, sharedWithMeTime, starred, viewedByMeTime. Example `modifiedTime desc`</td></tr>

    <tr>
      <td>
        `pageSize`
      </td>

      <td>
        integer
      </td>

      <td>
        query
      </td>

      <td>
        Files per page, at most 1000.
      </td>
    </tr>

    <tr>
      <td>
        `pageToken`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        nextPageToken from the previous page.
      </td>
    </tr>

    <tr><td>`corpora`</td><td>string</td><td>query</td><td>Which collection to search; default user. One of `user`, `domain`, `drive`, `allDrives`</td></tr>

    <tr>
      <td>
        `driveId`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Shared drive id, with corpora=drive.
      </td>
    </tr>

    <tr>
      <td>
        `includeItemsFromAllDrives`
      </td>

      <td>
        boolean
      </td>

      <td>
        query
      </td>

      <td>
        Include shared-drive items as well as My Drive.
      </td>
    </tr>

    <tr>
      <td>
        `supportsAllDrives`
      </td>

      <td>
        boolean
      </td>

      <td>
        query
      </td>

      <td>
        Set true to reach files in shared drives.
      </td>
    </tr>

    <tr>
      <td>
        `spaces`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Comma-separated: drive, appDataFolder.
      </td>
    </tr>

    <tr>
      <td>
        `fields`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Which fields to return, e.g. 'nextPageToken,files(id,name,mimeType,modifiedTime,owners(emailAddress))'. Without it only kind, id, name and mimeType come back.
      </td>
    </tr>
  </tbody>
</table>

[Vendor docs](https://developers.google.com/workspace/drive/api/reference/rest/v3/files/list)

```python Python theme={null}
router.call_data_api("google-drive.files.list", {'q': "name contains 'budget' and trashed = false", 'orderBy': 'modifiedTime desc'})
```

```text MCP theme={null}
call_data_api(endpoint="google-drive.files.list", params={"q": "name contains 'budget' and trashed = false", "orderBy": "modifiedTime desc"})
```

> [!NOTE]
>
> * Ask for nextPageToken in fields, or you cannot page. Shared-drive items need includeItemsFromAllDrives=true and supportsAllDrives=true.

### Get file metadata

GET

`/files/{fileId}`

`google-drive.files.get`

A file's metadata: name, type, size, owners, dates, parents and links, as chosen by fields.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `fileId`

        required
      </td>

      <td>
        string
      </td>

      <td>
        path
      </td>

      <td>
        The file id (from files.list, or the /d/\<id>/ part of a Drive URL).
      </td>
    </tr>

    <tr>
      <td>
        `supportsAllDrives`
      </td>

      <td>
        boolean
      </td>

      <td>
        query
      </td>

      <td>
        Set true to reach files in shared drives.
      </td>
    </tr>

    <tr>
      <td>
        `fields`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Which fields to return, e.g. 'nextPageToken,files(id,name,mimeType,modifiedTime,owners(emailAddress))'. Without it only kind, id, name and mimeType come back.
      </td>
    </tr>
  </tbody>
</table>

[Vendor docs](https://developers.google.com/workspace/drive/api/reference/rest/v3/files/get)

### Download a file's content

GET

`/files/{fileId}`

`google-drive.files.download`

The bytes of a file stored in Drive (PDF, image, upload). Not for Google Docs, Sheets or Slides.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `fileId`

        required
      </td>

      <td>
        string
      </td>

      <td>
        path
      </td>

      <td>
        The file id (from files.list, or the /d/\<id>/ part of a Drive URL).
      </td>
    </tr>

    <tr><td>`alt` required</td><td>string</td><td>query</td><td>Must be 'media' to get the content instead of metadata. One of `media` Example `media`</td></tr>

    <tr>
      <td>
        `acknowledgeAbuse`
      </td>

      <td>
        boolean
      </td>

      <td>
        query
      </td>

      <td>
        Accept the risk of downloading a file flagged as malware; only for the file's owner or shared drive organizer.
      </td>
    </tr>

    <tr>
      <td>
        `supportsAllDrives`
      </td>

      <td>
        boolean
      </td>

      <td>
        query
      </td>

      <td>
        Set true to reach files in shared drives.
      </td>
    </tr>
  </tbody>
</table>

[Vendor docs](https://developers.google.com/workspace/drive/api/reference/rest/v3/files/get)

> [!NOTE]
>
> * Google Workspace files (Docs, Sheets, Slides) answer an error here; use files.export.

### Export a Google Doc, Sheet or Slides file

GET

`/files/{fileId}/export`

`google-drive.files.export`

A Google Workspace document converted to another format: text, Markdown, PDF, CSV, Office.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `fileId`

        required
      </td>

      <td>
        string
      </td>

      <td>
        path
      </td>

      <td>
        The file id (from files.list, or the /d/\<id>/ part of a Drive URL).
      </td>
    </tr>

    <tr><td>`mimeType` required</td><td>string</td><td>query</td><td>Target format, as a full MIME type. Docs: text/plain, text/markdown, text/html, application/pdf, application/vnd.openxmlformats-officedocument.wordprocessingml.document. Sheets: text/csv (first sheet only), application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/pdf. Slides: text/plain, application/pdf, application/vnd.openxmlformats-officedocument.presentationml.presentation. Example `text/markdown`</td></tr>
  </tbody>
</table>

[Vendor docs](https://developers.google.com/workspace/drive/api/reference/rest/v3/files/export)

> [!NOTE]
>
> * Exported content is limited to 10 MB.

### Get the user and storage quota

GET

`/about`

`google-drive.about.get`

The signed-in user, storage quota and, on request, import and export formats.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`fields` required</td><td>string</td><td>query</td><td>Required here: which fields, e.g. 'user,storageQuota' or 'exportFormats'. Example `user,storageQuota`</td></tr>
  </tbody>
</table>

[Vendor docs](https://developers.google.com/workspace/drive/api/reference/rest/v3/about/get)

```python Python theme={null}
router.call_data_api("google-drive.about.get", {'fields': 'user,storageQuota'})
```

```text MCP theme={null}
call_data_api(endpoint="google-drive.about.get", params={"fields": "user,storageQuota"})
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.