For Google Drive apps that must track changes to files, the
changes
collection provides an efficient
way to detect all file changes, including those shared with a user. If the file
has changed, the collection provides the current state of each file.
Get start page token
To request the page token for the current state of the account, use the
changes.getStartPageToken
.
Store and use this token in your initial call to
changes.list
.
To retrieve the current page token:
Java
Python
PHP
.NET
Node.js
Get changes
To retrieve the list of changes for the currently signed in user, send a GET
request to the changes
collection, as detailed in the
changes.list
.
Entries in the changes
collection are in chronological order (the oldest
changes appear first). The includeRemoved
and restrictToMyDrive
query
parameters determine whether the response should include removed or shared
items.
Java
Python
PHP
.NET
Node.js
The changes
collection in the
response might contain a
nextPageToken
. If the nextPageToken
is listed, it can be used to gather the
next page of changes. If it's not listed, the client application should store
the newStartPageToken
in the response for future use. With the page token
stored, the client application is prepared to query again for future changes.
Receive notifications
Use the changes.watch
method to
subscribe to updates in the change log. Notifications don't contain details
about the changes. Instead, they indicate that new changes are available. To
retrieve the actual changes, poll the change feed as described in Get
changes.
For more information, see Notifications for resource changes.