Skip to content
Software capabilities
Google Drive

Sync Google Drive file changes

Capture a start page token, page through changes.list, and persist newStartPageToken for the next incremental sync. Include removed entries when your index must detect deletion or lost access.

Documentation reviewed · 3 methods with sources

Ways to do it

  1. API: GET /drive/v3/changes/startPageToken
  2. API: GET /drive/v3/changes
  3. SDK: drive.changes().list()
API

GET /drive/v3/changes/startPageToken

Request the starting page token for a user or shared drive before the first change poll.

Read source: Drive getStartPageToken reference
Requirements
An authorized Google OAuth token, such as one with drive.metadata.readonly scope. For a shared drive, provide driveId and supportsAllDrives=true.
Limitations
The start token marks the boundary for future changes. Use files.list to build an initial inventory.

Example shell

curl --fail 'https://www.googleapis.com/drive/v3/changes/startPageToken' -H "Authorization: Bearer $GOOGLE_ACCESS_TOKEN"
API

GET /drive/v3/changes

Read change pages using pageToken, then store newStartPageToken after the final page.

Read source: Drive changes.list reference
Requirements
A Drive page token and OAuth credentials for the same user or shared drive that issued the token.
Limitations
Commit the changes before advancing the stored cursor. A removed entry can mean deletion or loss of access. For a shared drive, use driveId, supportsAllDrives=true, and includeItemsFromAllDrives=true.

Example shell

curl --fail --get 'https://www.googleapis.com/drive/v3/changes' -H "Authorization: Bearer $GOOGLE_ACCESS_TOKEN" --data-urlencode "pageToken=$DRIVE_PAGE_TOKEN" --data-urlencode 'includeRemoved=true' --data-urlencode 'spaces=drive'
SDK

drive.changes().list()

Use the Python client to retrieve a page of file changes with the saved token.

Read source: Google Drive change-feed client examples
Requirements
An authenticated Drive v3 service from google-api-python-client and a start or continuation token.
Limitations
An empty changes array can still come with a nextPageToken. Keep reading pages until Drive supplies newStartPageToken.

Example text

page = drive.changes().list(
    pageToken=saved_page_token, spaces="drive", includeRemoved=True
).execute()