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:
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
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
Drop me a note: dennybritz [at] gmail.com