gmail-dump

Dump your gmail account in JSON format

View the Project on GitHub dennybritz/gmail-dump-nodejs

Dump your gmail account in JSON format

On June 26, 2014 Google announced a new Gmail API. Among other things, the API allows developers to read messages, send mail, and manage labels.

This little tool can be used to dump your gmail account, or a subset of specific messages from your gmail account. The output is in JSON format, one message per line. Note that Gmail has a limit of 5-10 getMessage API requests per second. That means dumping your full account may take a while.

In order to run this tools you must obtain credentials through the Google Developer Console:

  1. Visit the Google Developer Console
  2. Create a new project and activate the Gmail API in "APIs & Auth"
  3. In "APIs & Auth" click Credentials -> Create New Client Id -> Installed Application -> Other
  4. Copy the client id and secret
git clone https://github.com/dennybritz/gmail-dump-nodejs.git
cd gmail-dump-nodejs
npm install
cd message-dump
export GOOGLE_CLIENT_ID=<YOUR_CLIENT_ID_FROM_ABOVE>
export GOOGLE_CLIENT_SECRET=<YOUR_CLIENT_SECRET_FROM_ABOVE>
node message-dump-console.js > dump.jsonlines

Dumping specific messages

You can specify an optional query argument to message-dump-console. The query can be any valid gmail query string described in the Gmail documentation. For example:

node message-dump-console.js "before:2013/01/01 after:2012/05/05" > dump.jsonlines

Problems? Feedback?

Drop me a note: dennybritz [at] gmail.com