A note export API written in Scala based on the Evernote SDK. Compiles to both the JVM and JS (via Scala.js) backends. Currently supports both 2.11.x and 2.12.x.
In your build.sbt
:
resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
libraryDependencies += "me.assil" %% "everexport" % "0.3-SNAPSHOT"
npm install everexport
On the JVM (Scala):
import me.assil.everexport.{EverExport, Note, Notebook}
import scala.concurrent.{Await, Future}
import scala.concurrent.duration._
import scala.util.Try
// Global EC for executing Futures
import scala.concurrent.ExecutionContext.Implicits.global
object QuickStart extends App {
// https://dev.evernote.com/doc/articles/dev_tokens.php
val token: String = ???
val exporter = new EverExport(token, sandbox = true)
// Get all notebooks in user's account
val notebooksFuture: Future[Vector[Notebook]] = exporter.listNotebooks
// Return all note titles for the *first* notebook
val noteTitlesFuture: Future[Vector[String]] =
for (
notebooks <- notebooksFuture;
titles <- exporter.getNoteTitles(notebooks(0).guid)
) yield titles
// Export all notes from *second* notebook (assuming it exists!)
val notesFuture: Future[Vector[Try[Note]]] =
for (
notebooks <- notebooksFuture;
notes <- exporter.exportNotebook(notebooks(1).guid)
) yield notes
// Wait 5 seconds for last Future to complete
val notes = Await.result(notesFuture, 5.seconds)
// Display notes exported from second notebook
println(notes)
}
In JS:
const everexport = require('everexport')
const token = process.env.EVERNOTE_TOKEN // Same token as above
const exporter = new everexport.EverExport(token, true)
// Fetch all notebooks in user's account
exporter.listNotebooks()
// Then fetch all notes in *first* notebook
.then(notebooks => {
const n = notebooks[0]
return exporter.exportNotebook(n.guid)
})
// Then display each note's title and creation time
.then(notes => {
notes.forEach(note => {
console.log('Title: ' + note.title + ', Created on: ' + note.created)
});
})
First, make sure you have sbt
1.x installed.
Run sbt everexportJVM/package
. JAR in jvm/target/scala-2.12
.
Run sbt everexportJS/fullOptJS
. Optimized JS in js/target/scala-2.12/scalajs-bundler/main
.