sendgrid-contacts-export

0.0.2 • Public • Published

SendGrid Contacts Export for Node.js

Main repo: https://github.com/huned/nodejs-sendgrid-contacts-export

The simplest way to get all your SendGrid contacts as JSON.

Installation

npm install sendgrid-contacts-export

Usage

Use it like this:

const SendGrid = require(./lib/sendgrid)
const sg = new SendGrid('MY API KEY')
const contacts = await sg.getContacts()
console.log(contacts)

Optionally, specify options using SendGrid's Contacts Export API options. E.g.,

// See SendGrid's Marketing > Contacts > Exports API doc for details.
// https://sendgrid.com/docs/API_Reference/api_v3.html
const opts = {
  "list_ids": [ "string" ],
  "segment_ids": [ "string" ],
  "notifications": {
    "email": "boolean (optional)"
  },
  "file_type": "csv",
  "max_file_size": 5000
}
await sg.getContacts(opts)

Command Line Usage

Clone this repo, then:

SENDGRID_API_KEY=<your api key> npm start

And it will print all your contacts as JSON to stdout.

You can also set SENDGRID_LIST_IDS and SENDGRID_SEGMENT_IDS to comma separated list/segment ids. E.g.,

SENDGRID_API_KEY=<your api key> SENDGRID_LIST_IDS=<list1 id>,<list2 id> npm start

You can also define each of these environment in a ./.env file instead of at the command line, if you wish.

Known Issues

  • No tests yet (maybe you can submit a PR?!)

Author

Huned Botee

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i sendgrid-contacts-export

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

6.36 kB

Total Files

8

Last publish

Collaborators

  • huned