Get Gmail storage usage programmatically
How can I get the software to use Gmail? This value appears in two places, but I cannot find an API for it.
The main purpose is to automatically record Gmail storage usage in Google Sheet and a storage usage trend graph.
What I have tried:
- DriveApp.getStorageUsed () does not include Gmail usage.
- Reporting API (
gmail_used_quota_in_mb
) not available for custom Gmail accounts (G Suite only) - Scraper www.google.com/settings/u/0/storage is not possible because login is required even if cookies are changed (possibly new device / IP address detection).
+3
source to share
1 answer
Not the programmatic answer I'm looking for, but this is my manual work until I find the API method:
- Check out the source code google.com/settings/u/0/storage
- Find the exact usage bytes embedded in JSON:
... , [["Drive", ["24004828", "0.02 GB"] ] , ["Gmail", ["4859735562", "4.52 GB"] ] , ["Google Photos", ["0", "0 GB"] ...
- Record that (4 859 735 562) in a Google Sheet along with the current date / time
Using accurate measurements of bytes and seconds, it only takes a few measurements to get an accurate trend. (And I don't need to scale this across multiple accounts.)
0
source to share