How to obtain Evernote API Developer Token (with sample code)

Tadashi Shigeoka ·  Thu, May 2, 2019

I’ll introduce a case study of obtaining and using a Developer Token to use the Evernote API.

Evernote

Evernote API Developer Token Acquisition Page

Obtain the Developer Token from Developer Tokens - Evernote Developers.

Developer Tokens | Evernote API
Developer tokens allow you to use the Evernote API to access your personal Evernote account. To learn more about using developer tokens, visit dev.evernote.com.

Source: (Sandbox) Developer Tokens

Testing the Developer Token

The following code was rewritten to work with Node.js v10, referencing these two official documents:

Notebook List Acquisition Sample Code (Node.js)

const Evernote = require('evernote');

const developerToken = "YOUR_DEVELOPER_TOKEN";
 
const client = new Evernote.Client({token: developerToken});

// Set up the NoteStore client 
const noteStore = client.getNoteStore();
 
// Make API calls
noteStore.listNotebooks().then(function(notebooks) {
  // notebooks is the list of Notebook objects
  for (let i in notebooks) {
    console.log("Notebook: " + notebooks[i].name);
  }
});

Execution Results

$ node index.js
Notebook: 
Notebook: プロジェクトその1

UnhandledPromiseRejectionWarning Error

By the way, if you use the Sample Code as-is, the following error occurs in Node.js v10:

$ node index.js
(node:17090) UnhandledPromiseRejectionWarning: Incorrect number of arguments passed to listNotebooks: expected 0 but found 1
(node:17090) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:17090) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

That’s all from the Gemba, where we want to obtain a Developer Token and use the Evernote API.