API

New JavaScript SDK for Evernote Developers

Posted by Mustafa Furniturewala on 07 Mar 2013

Posted by Mustafa Furniturewala on 07 Mar 2013

Comment

Co-written by Mustafa Furniturewala, iOS Software Engineer and
Josh Mangum, Senior Software Engineer

 

Providing developers with great tools is one of our favorite things to do. During the last few months several of our developers needed better access to our Thrift API from JavaScript for our browser extensions and Windows 8 clients. We want you to be able to play with it too.

So we are excited to announce the new JavaScript SDK for Evernote. The SDK supports all the Evernote Thrift API’s. Both the minified version of the Evernote for JS SDK and the uncompressed version is open source and available on Github. It’s based on JavaScript code that translates binary Thrift Protocol into JavaScript objects, and should also be useful to the wider thrift community.

This new thrift library will be a great foundation for building node.js server integrations, browser extensions and PhoneGap/Cordova, Windows 8, and Blackberry apps.

Here’s an example to get the list of notebooks from the Evernote account:


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(authToken, function (notebooks) {
          console.log(notebooks);
     },
     function onerror(error) {
          console.log(error);
     }
);

 

This is from our example iPhone PhoneGap app downloadable here:

Note that the included jsOAuth library is fine for the the PhoneGap app, but because you should not reveal your consumer secret, don’t use the jsOAuth flow where users could see your consumer secret in your code. One alternative is to do the authentication flow natively and pass the authentication token to the browser scope. For browser extensions, you will need to do the authentication on the server side and have the extension request the token from the server.

Our SDK is on Github so that you can send us issues, hack it, send us pull requests and let us know how we can make it better.

Prototyping In the Browser

You can also do rapid development and prototyping in the browser. It’s terrific for doing prototypes for things like PhoneGap and Windows 8, or trying out ideas. Unfortunately, web apps aren’t yet a good fit for live customer applications. Binary data handling is a newish feature for browsers. Chrome 7, IE 10, and Safari 5.1 are needed to use it. Also we haven’t enabled CORS headers on our servers, so you won’t be able to make cross domain requests yet.

For personal use, you can solve the cross origin problem by disabling the web-security check, let’s try with Chrome.

On mac:

$ open -a Google\ sChrome --args --disable-web-security

On Windows use the command prompt and type:

chrome.exe --disable-web-security

and on linux:

google-chrome --disable-web-security

For development you can use your developer token. To get other users involved you’ll need to do a little bit of OAuth flow management on the server. Instructions for doing that are here. Once you get the OAuth token from the server flow, the same example from PhoneGap above will work on the browser.

Using our developer forum, please let us know if you have any questions or find any bugs. We have more updates planned and would love to hear feedback and suggestions.

View more stories in 'API'

7 Comments RSS

  • Raymond Camden

    I’d also recommend making use of Ripple. Then you don’t have to worry about launching Chrome w/ the command line arg.

  • Cenk Ozan Kahraman

    I was going mad over a problem with another evernote library for javascript. Seeing this made me very happy. I hope I don’t get jinxes or anything but I hope I can finish my evernote extension with this. Thanks guys :)

    • Mustafa Furniturewala

      We are working on creating a sample Node js app. Stay tuned.

      • Jeevan

        ok thanks, waiting for it.

        Any idea on when it will be ready. I am eagerly waiting for it to integrate it with my application.

        • Mustafa Furniturewala

          It’s up now : https://github.com/evernote/evernote-sdk-js