Google Drive is now integrated with the Workspace Events API, which allows third-party developers to create subscriptions on Drive items and receive notifications via Cloud Pub/Sub when those resources change. This offers developers a more reliable, featureful way of receiving events over the current files.watch and changes.watch methods that exist today.
Good news for developers working with Google Drive! Google has just announced that the Google Drive Events API is now available in a Developer Public Preview. This is a significant update for anyone who needs to track changes to files in Google Drive, offering a more robust and feature-rich way to receive notifications.
For a long time, developers have relied on the files.watch and changes.watch methods to monitor file changes. Whilst these methods have been useful, the new Drive Events API, integrated with the Google Workspace Events API, promises a more reliable and scalable solution.
What can you do with the new API?
The new API allows you to subscribe to events on Drive items and receive notifications through Cloud Pub/Sub. In this initial public preview, the following events are supported:
A file has been added to a folder or shared drive.
A file has been moved to a folder or shared drive.
A file has been edited, or a new revision is uploaded.
A file has been trashed or restored from the trash.
An access proposal has been created or resolved for a file.
This opens up a whole range of possibilities for building powerful applications that react in real-time to changes in Google Drive. Imagine creating automated workflows that trigger when a new file is added to a specific folder, or a security tool that alerts you when a sensitive document is moved or trashed.
How to get started
To start using the new Google Drive Events API, you’ll need to be enrolled in the Workspace Developer Public Preview program. Once you’re in, you can find the relevant documentation and getting started guides on the Google Developers site.
A Note for Google Apps Script Developers
You can absolutely use Google Apps Script to make the API calls to create and manage your event subscriptions. However, it is important to be aware that receiving the actual notifications requires a different approach to traditional Apps Script triggers.
The Drive Events API delivers all notifications to a Cloud Pub/Sub topic. This means you will need a Google Cloud Platform (GCP) project to handle these incoming messages. It’s also important to note that, according to the documentation, the Pub/Sub topic you use for notifications must be in the same Google Cloud project that you use to create the event subscription itself.
These new capabilities hopefully unlock some more efficient ways for developers and third parties to monitor Google Drive content.