A Node.js script to scan Gmail inbox threads, count label occurrences, and cache thread metadata for faster repeated runs. This was an experiment and a learning project; it should not be considered complete or polished, but it worked for my purposes.
- Uses Gmail API to fetch inbox threads
- Caches thread label data for performance
- Detects stable threads to skip re-fetching (the definition of this is pretty specific to me; as distributed it considers all threads "stable" and will only download new threads from the API)
- Displays label usage counts in inbox
- Supports custom queries (e.g. unread or untagged thread estimates)
-
Clone this repo
-
Run
npm install -
Add your
credentials.json(from Google Cloud Console) -
Run the script:
node gmail-label-counts.js -
Authorize on first run
- .cache/: Local thread metadata cache
- token.json: OAuth token (auto-generated after first run)
- credentials.json: OAuth client secrets from Google (not included)
label:inboxinbox threadsin:inbox is:unreadinbox + unreadin:inbox -label:=p -label:=q -label:=ituseful for me!
MIT