Skip to content

Instantly share code, notes, and snippets.

@erikologic
Created June 19, 2026 16:08
Show Gist options
  • Select an option

  • Save erikologic/935e7171711152198b17641d9b4213a4 to your computer and use it in GitHub Desktop.

Select an option

Save erikologic/935e7171711152198b17641d9b4213a4 to your computer and use it in GitHub Desktop.
Restish + Gmail CLI - OAuth pagination tools
# Restish + Gmail CLI
Complete setup for using restish CLI with Gmail API.
## Files
- `restish` - This overview
- `paginate` - Pagination handler
- `CONFIGURATION.md` - OAuth setup
## Quick Start
```bash
restish gmail gmail-users-labels-list me
```
## Usage
### Paginate
```bash
paginate '.nextPageToken' '.messages[]' restish gmail gmail-users-messages-list me
paginate '.nextPageToken' '.labels[]' restish gmail gmail-users-labels-list me
```
### Label operations
```bash
restish gmail gmail-users-messages-modify me MSG_ID -d '{"addLabelIds": ["LABEL_ID"]}'
restish gmail gmail-users-messages-modify me MSG_ID -d '{"removeLabelIds": ["LABEL_ID"]}'
```
### Bulk
```bash
sqlite3 data/gmail.db "SELECT id FROM messages WHERE sender='spam'" | \
while read id; do
restish gmail gmail-users-messages-modify me "$id" -d '{"addLabelIds": ["TRASH"]}'
done
```
All 79 operations: `restish gmail --help`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment