Single notes can be shared in one of two ways: publicly (using a public note URL) or via email. The latter isn’t exactly sharing as much as it is emailing a copy of a note, so we’re going to focus on the former: sharing via a public shared URL. Note that there isn’t a way to share a single note with only one other person; anybody who knows the URL for a shared note will be able to view it.
In order to share a single note, you’ll need the following information:
- The GUID of the note you’d like to share.
- The ID of the Shard that houses the note to be shared.
- A valid authentication token or developer token.
- Initialized instances of
NoteStore.Client
andUserStore.Client
The Shard ID can be determined at runtime by querying the UserStore:
Assuming all of that is in place, sharing a note is actually quite simple. By calling NoteStore.shareNote
and passing a valid authentication token and the GUID of the note you’d like to share. In return, you’ll get a Share Key from the Evernote Cloud API that can be used in conjunction with the note GUID to view a read-only version of the note.
Here’s a snippet of code that illustrates how the whole process works:
Assuming nothing broke, the above function will return a public note URL that looks something like this:
https://www.evernote.com/shard/s1/sh/36dd7123-12c0-457a-a6d0-75555fcc7770/3afc29de3493d0d333b54cf1822be92c
The last two pieces of data in the URL are the note GUID and the share key.