Evernote Api Examples



In Part 1 of the tutorial we used the method getNoteBooksList to retrieve a dict with 2 lists of all notebooks. One list with all notebook name and a corresponding list with all guid (the unique identifier). We need the guid of a notebook if we want to restrict our work (e.g. finding notes) to a specific notebook.

  1. Evernote Api Examples Download
  2. How To Use Evernote

Activating an API key. Please note that while the samples for this page show URls beginning with all examples will also work on production by altering the URLs to begin with We recommend beginning your application development on the sandbox. Evernote provides a rich API that developers can use to create custom applications and services that integrate with the Evernote Service. For more information, see the following resources: Evernot. Evernote api: example of php code to retrieve the text of a note. Ask Question Asked 7 years, 11 months ago. Active 5 years, 9 months ago. Viewed 2k times 2. I look for an example of PHP code to retrieve the text of a note on the Evernote server. So far, I only found trivial examples listing the notebooks, and helping to get authenticated.

In the code above we set the notebook by name with setNotebook(). This method calls setNoteBookGuid() which sets the instance variable noteBookGuid.

Now we can retrieve e.g. all tags of a notebook:

getNoteBookTags: This is a method of our class EvernoteStore(). It calls the function listTagsByNotebook of the module NoteStore. It returns a list with this data structure. We store a subset of the tag data in the instance variable noteBookTags.

Now we want to find a note by title. In the NoteStore module there is a function getNote. This function uses the guid (the unique identifier of a note). Hence we first have to find the guid of the note (there is no function like getNoteByTitle). We code the method getNoteByTitle of our class EvernoteStore().

Examples

filter:To find a note by title we have to set a filter. We create the data structure NoteFilter and set various fields. words is the most important one (from the documentation: 'If present, a search query string that will filter the set of notes to be returned. Accepts the full search grammar documented in the Evernote API Overview'). The search grammar is documentedhere. In our example it's pretty simple: e.g. 'intitle:My wonderful recipe'.

resultspec: We also have to define the amount of data returned for a note. We create the data structure NotesMetadataResultSpec. Here we could define all the fields we want returned for a note. If we set no fields, like in our code above, only the guid of a note is returned. If we would like to get the title of the note too, we would define: resultSpec.includeTitle = True.

Given the 2 data structures filter and resultspec we can then call self.noteStore.findNotesMetadata(self.authToken, filter, 0, 250, resultSpec). This function returns a list of notes (notes.notes). See the documentation for further explanations. In our example this is a list of guid for all notes with the same title or the same substring in the title. We then call the method getNoteByGuid of our class EvernoteStore() on each guid in this list and we get a list of notes with all kind of data per note ([self.getNoteByGuid(i.guid) for i in notes.notes]).

The method above first calls the function getNote of the module NoteStore (the documentation says that getNote is depreciated and getNoteWithResultSpec should be used instead. But this function is not available yet). We then create the dict note with data from getNote. Various date fields are translated from the Evernote date format to the Python date format (the function enDateTimeToPythonDateTime in our own dateTime module is pretty simple: fromtimestamp(enTime/1000) where fromtimestamp is a function of the Python datetime module).

To get the content of a note we have to call getNoteContent of the module NoteStore. The field tagGuids from getNote is a list of with all the guid for the tags used in the note. We then call the function getNoteTagNames of the module NoteStore to get the names for all tag guid in this list.

Finally we call the method getAllResourceData of our class EvernoteStore(). This method retrieves resources of a note (e.g. image files) and is discussed in part 3 of this tutorial.

Authentication

Authenticating with the Evernote Cloud API using OAuth

Introduction

The OAuth flow is the a process a user goes through to authorize your application to access their Evernote account on their behalf. The user must approve access from an Evernote domain (www.evernote.com or sandbox.evernote.com). After approval is granted (or rejected) Evernote will then redirect the user back to your application along with the information required to retrieve an access token which will allow you to access Evernote on behalf of the user.

Evernote Api Examples
Developer Tokens

To quickly test the Evernote API on your own account, Get a Developer Token »

The OAuth Flow consists of four parts:


1. Generate a Temporary Token

First you’re application must request Evernote generate a temporary token. A sample request is below:

Note: For production access replace sandbox.evernote.com with www.evernote.com.

The request must be a GET request to the following URL:

MethodEndpoint URL
GEThttps://sandbox.evernote.com/oauth

As a part of this request you must provide a number of URL-encoded parameters including a callback URL (you can use “localhost” for development purposes) where the user will be directed after the user chooses to authorize or reject your application. X 10 for mac os x.

Temporary Token Request Parameters

A full list of required parameters can be seen in the table below. Yandex for mac os x. If you don't have an API key (oauth_consumer_key) you can get one here:

Description
oauth_callback
URL that is redirected to after the user authorizes your application access
oauth_consumer_key
sampleKey
*
oauth_signature
xCYjTiyz7GZiElg1uQaHGQ6I
*
oauth_timestamp
1429565574
*

Note: * The parameters oauth_nonce, oauth_signature, oauth_signature_method, oauth_timestamp, and oauth_version are parameters that are provided by most Evernote SDKs and OAuth libraries. If you are interested in developing an OAuth1 library for your platform please see the OAuth1 3LO specification.

Temporary Token Response

Upon transmission of a valid request you will receive the following response:

This response contains the following parameters:

Name
Sample
Temporary OAuth token
oauth_callback_confirmed
true

2. Request User Authorization

After you have retrieved the temporary token from Evernote you must redirect the user to Evernote for the user to approve access of their Evernote account to your application.

Redirection URL

Your application must use the value of the oauth_token parameter, retrieved in the last step, when redirecting the user to https://sandbox.evernote.com/OAuth.action to begin the authorization process as demonstrated in this sample redirection URL:

After the user has granted or rejected access to their Evernote account the user will be redirected back to the URL specified in the oauth_callback parameter in your temporary token request. A sample redirect URL can be seen below with the parameters expected of a user that has granted access to their Evernote account: Download word office for mac.

Callback URL Parameters
Description
oauth_token
sampleKey-121.14C..
(Optional) Present only if the user grants access to your application
sandbox_lnb
Boolean for API key permissions (see permissions for more info)

Please note that the callback for rejected and authorized apps will be the same with the exception of that a rejected callback will not contain the parameter oauth_verifier, as seen in the example below:


3. Retrieve Access Token

The following is an example of a request to retrieve an access token:

The request must be a GET request to the following URL:

Method
GET

The request must also include the URL-encoded OAuth-signed parameters listed in the table below. Please note that if you did not receive the oauth_verifier parameter in the callback the user did not grant your application access to their Evernote account and you cannot make a valid access token request

Access Token Request Parameters
Name
Sample
The API key used to identify your application
oauth_token
sampleKey-121.14C..
OAuth verify provided at callback if the user grants access
oauth_nonce
3166905818410889691
*
oauth_signature_method
HMAC-SHA1
*
oauth_version
1.0

Note: * The parameters oauth_nonce, oauth_signature, oauth_signature_method, oauth_timestamp, and oauth_version are provided by most Evernote SDKs and OAuth libraries. If you are interested in developing an OAuth1 library for your platform please see the OAuth1 3LO specification.

Access Token Response

If successful you will receive a response similar to the sample below:

the response will contain the following parameters:

Description
oauth_token
Access token to access the API on behalf of the user
oauth_token_secret
edam_shard
s432
User ID of the user (useful for webhook notifications)
edam_expires
expiration date of the token (UNIX timestamp in milliseconds)
edam_noteStoreUrl
URL of the note store of the user’s personal notes
edam_webApiUrlPrefix
https://sandbox.evernote.com/shard/s432/
Access Token Expiration
Evernote api examples for schools

Each access token has an expiration date. By default, the duration of access token validity is 1 year from the date of issue. The user can alter this duration to 1 day, 1 week or 1 month. In all these cases (including tokens valid for 1 year), the expiration date will be included as the parameter edam_expires. The value of this parameter will be a standard UNIX timestamp in units of milliseconds indicating the date and time of expiration.


Evernote

4. Next Steps for Accessing the API

Using the value of oauth_token above (it should start with the form S=s432:U=4a535ee:E=154d.) you can now make requests to the API on behalf of the user that approved your application! You can use this token to perform actions in Evernote like saving content and data to notes and notebooks and (if your API key has the permission to do so) reading notes, notebooks, tags, performing searches and retrieving business data for use in your application.

Now that you have an authentication token here are some suggested next steps to dive in with the API:

  • Take a look at our SDK's sample code using your authentication token
  • Explore the API methods you can call using your access token
  • Understand Evernote's sharded service architecture for NoteStore, which can vary by user (you can learn more about sharding and Evernote's architecture in this tech blog post).
  • Learn how to revoke access tokens.

Evernote Api Examples Download

Activating an API key

Please note that while the samples for this page show URls beginning with https://sandbox.evernote.com all examples will also work on production by altering the URLs to begin with https://www.evernote.com. We recommend beginning your application development on the sandbox.

How To Use Evernote

To move your key to production please request your API key be activated on production.