npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sequencemedia/gmail-api

v1.1.171

Published

The `@sequencemedia/gmail-api` package is an `async` interface to the Gmail API by Google.

Downloads

495

Readme

@sequencemedia/gmail-api

The @sequencemedia/gmail-api package is an async interface to the Gmail API by Google.

  • It exports functions for querying and requesting Gmail messages, drafts, and labels
  • It must be authorised to do so by a human

Usage

Messages

import getGmail from '@sequencemedia/gmail-api/src/gmail'

import {
  getMessages
} from '@sequencemedia/gmail-api/src/gmail/messages/list'

import {
  getMessage
} from '@sequencemedia/gmail-api/src/gmail/messages'

const gmail = await getGmail()
const messageList = await getMessages(gmail, { max: 100 })
const messages = await Promise.all(messagesList.map((message) => getMessage(gmail, message)))

messages
  .forEach((message) => {
    console.log(message)
  })

Labels and drafts follow the same pattern.

Labels

import getGmail from '@sequencemedia/gmail-api/src/gmail'

import {
  getLabels
} from '@sequencemedia/gmail-api/src/gmail/labels/list'

import {
  getLabel
} from '@sequencemedia/gmail-api/src/gmail/labels'

const gmail = await getGmail()
const labelList = await getLabels(gmail)
const labels = await Promise.all(labelsList.map((label) => getLabel(gmail, label)))

labels
  .forEach((label) => {
    console.log(label)
  })

See also messages and drafts.

Drafts

import getGmail from '@sequencemedia/gmail-api/src/gmail'

import {
  getDrafts
} from '@sequencemedia/gmail-api/src/gmail/drafts/list'

import {
  getDraft
} from '@sequencemedia/gmail-api/src/gmail/drafts'

const gmail = await getGmail()
const draftList = await getDrafts(gmail, { max: 100 })
const drafts = await Promise.all(draftsList.map((draft) => getDraft(gmail, draft)))

drafts
  .forEach((draft) => {
    console.log(draft)
  })

See also labels and messages.

Credentials

You must supply public or internal oAuth 2.0 credentials for an application registered with the Google developer console which has the Gmail API enabled, and a credentials token authorising the application to access a Gmail account you control. (The credentials identify your application. The credentials token confirms that your application is authorised to access your Gmail account.)

Configuration

Credentials and credentials tokens can be supplied either as environment variables or as arguments on the command line.

Environment variables

You can supply paths to files on the file system:

CREDENTIALS_PATH
CREDENTIALS_TOKEN_PATH

Or, you can supply JSON:

CREDENTIALS_JSON
CREDENTIALS_TOKEN_JSON

Credentials and credentials tokens supplied as environment variables containing JSON are never written to the file system.

Command-line arguments

Similarly, you can supply paths to files on the file system:

--credentials-path
--credentials-token-path

Or, you can supply JSON:

--credentials-json
--credentials-token-json

Again, credentials and credentials tokens supplied as command-line arguments containing JSON are never written to the file system.

Precedence

  • Command-line arguments supersede environment variables (so if you have supplied both, the command line arguments will be used)
  • JSON supersedes paths (so if you have supplied both, the JSON will be used, and nothing will touch the file system)

Privacy Policy

The @sequencemedia/gmail-api package does not store any data from Gmail, nor does it gather usage data.