Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/swinton/gmail-repl
A REPL for GMail
https://github.com/swinton/gmail-repl
cli gmail gmail-api nodejs repl shell
Last synced: about 1 month ago
JSON representation
A REPL for GMail
- Host: GitHub
- URL: https://github.com/swinton/gmail-repl
- Owner: swinton
- License: isc
- Created: 2023-05-20T17:40:29.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-08T15:35:08.000Z (over 1 year ago)
- Last Synced: 2024-10-30T04:29:01.208Z (3 months ago)
- Topics: cli, gmail, gmail-api, nodejs, repl, shell
- Language: JavaScript
- Homepage: https://github.com/swinton/gmail-repl
- Size: 38.1 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# ๐ `gmail-repl`
> A REPL for GMail
## Setup
Follow [the Node.js quickstart](https://developers.google.com/gmail/api/quickstart/nodejs) from theย Gmail for Developers guide, and make sure your [desktop application credentials](https://developers.google.com/gmail/api/quickstart/nodejs#authorize_credentials_for_a_desktop_application) are stored in a `credentials.json` file -- see [`credentials-example.json`](credentials.example.json) for an example.
## Usage
```shell
./repl.js
```## Examples
### Get profile
> [`users.getProfile`](https://developers.google.com/gmail/api/reference/rest/v1/users/getProfile)```javascript
await profile()
```### List messages
> [`users.messages.list`](https://developers.google.com/gmail/api/reference/rest/v1/users.messages/list)- See: [Search operators you can use with Gmail](https://support.google.com/mail/answer/7190?hl=en)
```javascript
// List all messages
await messages()// List all from
await messages('from:[email protected]')// List unread from sent after
await messages('from:[email protected] is:unread after:2023/05/19')
```### Read a message
> [`users.messages.get`](https://developers.google.com/gmail/api/reference/rest/v1/users.messages/get)```javascript
await message('1883a5111e8ef47c')
```### List threads
> [`users.threads.list`](https://developers.google.com/gmail/api/reference/rest/v1/users.threads/list)- See: [Search operators you can use with Gmail](https://support.google.com/mail/answer/7190?hl=en)
```javascript
// List all threads
await threads()// List all from
await threads('from:[email protected]')// List unread from sent after
await threads('from:[email protected] is:unread after:2023/05/19')```
### Read a thread
> [`users.threads.get`](https://developers.google.com/gmail/api/reference/rest/v1/users.threads/get)```javascript
await thread('1883b361aaef86b6')
```### Batch delete
> [`users.messages.batchDelete`](https://developers.google.com/gmail/api/reference/rest/v1/users.messages/batchDelete)- See: [Search operators you can use with Gmail](https://support.google.com/mail/answer/7190?hl=en)
#### Batch delete unimportant promotional messages
```javascript
await batchDeleteMessages('category:promotions -is:important -is:starred')
```#### Batch delete messages from before 2021
```javascript
await batchDeleteMessages('before:2021/01/01')
```