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

@integromat/evernote

v1.25.83

Published

Evernote SDK for Node.js

Downloads

39

Readme

Evernote SDK for JavaScript

Evernote API version 1.25

What is this

A JavaScript API around the Evernote Cloud API.

Required reading

Please check out the Evernote Developers portal page.

Installing

Get the minified version of the SDK here.

Use OAuth for authentication

We recommend using the jsOAuth library for OAuth. It can be downloaded here.

Details on the OAuth process are available here.

Here are the basic steps for OAuth using the jsOAuth library.

(Change this to http://www.evernote.com, when you are ready to activate on production).

var hostName = "http://sandbox.evernote.com"; 

Step 1:

var options,oauth;
 options = {
    consumerKey: <your consumer key>,
    consumerSecret: <your consumer secret>,
    callbackUrl : <your callback url>,
    signatureMethod : "HMAC-SHA1",
};
oauth = OAuth(options);
oauth.request({'method': 'GET', 'url': hostName + '/oauth', 'success': success, 'failure': failure});

Step 2:

In the callback success, get the oauth_token and the oauth_token_secret. Redirect the user for authorization to : evernoteHostName + '/OAuth.action?oauth_token=' + <token from step 1>

Step 3:

In your callback url, get the oauth_verifier and the oauth_token from the query string.

var verifier = <your verifier>;
var oauth_token = <your oauth token>;
var secret = <oauth secret from step 1>;
oauth.setVerifier(verifier);
oauth.setAccessToken([got_oauth,secret]);

Now get the final token.

oauth.request({'method': 'GET', 'url': hostName + '/oauth',
               'success': success, 'failure': failure});

Step 4:

Parse the success callback to get the authentication token.

Example

Once you get the authentication token, note store URL and user store URL from the OAuth step,

var noteStoreURL = <note store url>;
var authenticationToken = <authentication token>;
var noteStoreTransport = new Thrift.BinaryHttpTransport(noteStoreURL);
var noteStoreProtocol = new Thrift.BinaryProtocol(noteStoreTransport);
var noteStore = new NoteStoreClient(noteStoreProtocol);

noteStore.listNotebooks(authenticationToken, function (notebooks) {
		console.log(notebooks);
	},
	function onerror(error) {
		console.log(error);
	}
);

Use with Node

Install

You can install the module using npm.

npm install evernote

OAuth

var client = new Evernote.Client.new({
  consumerKey: 'YOUR API CONSUMER KEY',
  consumerSecret: 'YOUR API CONSUMER SECRET',
  sandbox: [true or false] // Optional (default: true)
});
client.getRequestToken('YOUR CALLBACK URL', function(error, oauthToken, oauthTokenSecret, results) {
  // store tokens in the session
  // and then redirect to client.getAuthorizeUrl(oauthToken)
});

To obtain the access token

client.getAccessToken(oauthToken, oauthTokenSecret, oauthVerifier, function(error, oauthAccessToken, oauthAccessTokenSecret, results) {
  // store 'oauthAccessToken' somewhere
});

Now you can make other API calls

var client = new Evernote.Client({token: oauthAccessToken});
var noteStore = client.getNoteStore();
notebooks = noteStore.listNotebooks(function(err, notebooks) {
  // run this code
});

You can see the actual OAuth sample code in sample/express.

UserStore

Once you acquire token, you can use UserStore. For example, if you want to call UserStore.getUser:

var client = new Evernote.Client(token: token);
var userStore = client.getUserStore();
userStore.getUser(function(err, user) {
  // run this code
});

You can omit authenticationToken in the arguments of UserStore/NoteStore functions.

NoteStore

If you want to call NoteStore.listNotebooks:

var noteStore = client.getNoteStore();
noteStore.listNotebooks(function(err, notebooks) {
  // run this code
});

NoteStore for linked notebooks

If you want to get tags for linked notebooks:

var linkedNotebook = noteStore.listLinkedNotebooks[0]; // any notebook
var sharedNoteStore = client.sharedNoteStore(linkedNotebook);
sharedNoteStore.getSharedNotebookByAuth(function(err, sharedNotebook) {
  sharedNoteStore.listTagsByNotebook(err2, sharedNotebook.notebookGuid, function(tags) {
    // run this code
  });
});

NoteStore for Business

If you want to get the list of notebooks in your business account:

userStore.getUser(function(err, user) {
  if (user.isBusinessUser) {
    client.getBusinessNoteStore().listNotebooks(function(err, notebooks) {
      // run this code
    });
  }
});

Utility methods for Business

This module provides some utility methods to deal with Evernote Business.

List business notebooks

To list all business notebooks the user can access

var client = new Evernote.Client({token: token})
client.listBusinessNotebooks(function(err, businessNotebooks) {
  // run this code
});

Create a business note

To create a business note in a business notebook

var note = new Evernote.Note();
client.listBusinessNotebooks(function(err, notebooks) {
  client.createNoteInBusinessNotebook(note, businessNotebooks[0], function(err, createdNote) {
    // run this code
  });
});

Create a business notebook

To create a business notebook

var notebook = new Evernote.Notebook();
client.createBusinessNotebook(notebook, function(err, createdNotebook) {
  // run this code
});

Get a notebook corresponding to the given business notebook

client.listBusinessNotebooks(function(err, businessNotebooks) {
  client.getCorrespondingNotebook(businessNotebooks[0], function(err, notebook) {
    // run this code
  });
});

Determine if the user is a part of a business

user.isBusinessUser();

Example

You can find a simple client app and a sample app with express under 'sample/express'. Please note that you have to use NodeBinaryHttpTransport instead of BinaryHttpTransport.

FAQ

Does the API support CORS (Cross origin resource sharing)

Not yet. However, there are an increasing number of platforms(phonegap,node.js, etc) that use JavaScript as their language. This SDK works well with those platforms.

Can I test my code in the browser

Yes. You can test your code in Chrome. Open Chrome using open /Applications/Google\ Chrome.app/ --args --disable-web-security .