This project is no longer maintained. Feel free to fork and take over.
A JS wrapper for the SimpleNote API. Routes all requests through
YQL (via HTTPS) using the included
Open Data table (see src/
folder). Needs jQuery.
All requests to the SimpleNote API are routed through YQL via HTTPS since
cross-domain POST requests aren't possible with AJAX. For that, simplenote-js
is making use of a custom Open Data table (see src/yql_simplenote.xml
). The
default table URL is this GitHub project's
raw view of that file.
It might be a good idea to host your own table XML somewhere to have more
control over what is going on between YQL and SimpleNote API, and to be
unaffected by changes to the table that might occur during future development
and which may break functionality in case of a version mismatch between the
JS library you're using and the table file in this here GitHub repository.
(See SimpleNote
's setOpenDataTable()
method for that.)
It's rather straightforward: first, authenticate, and if you've done so successfully, go nuts.
Authenticating:
var s = new SimpleNote();
SN.enableDebug( true ); // because we're curious
SN.auth({
email: "test@example.com",
password: "myPassword",
success: function() {
console.log( SN.isLoggedIn() );
// >> true
},
error: function( code ) {
console.error( "Authentication error: " + code );
}
});
Searching for notes:
SN.searchNotes({
query: "simplenote",
maxResults: 3,
success: function( resultsHash ) {
console.info( resultsHash.totalRecords );
// >> 32 (or some other number)
console.info( resultsHash.notes );
// >> [
// >> {
// >> key: "[SimpleNote-internal ID string]",
// >> body: "this is a note\nwith more than one line"
// >> },
// >> {
// >> key: "[another SimpleNote-internal ID string]",
// >> body: "this is a another note\nwith more than one line"
// >> },
// >> {
// >> key: "[yet another SimpleNote-internal ID string]",
// >> body: "this is a 3rd note"
// >> }
// >> ]
},
error: function( code ) {
console.error( code );
}
});
Getting the notes index:
SN.retrieveIndex({
success: function( resultsArray ) {
console.info( resultsArray );
// >> [
// >> {
// >> key: "[SimpleNote-internal ID string]",
// >> deleted: false,
// >> modify: [Date object]
// >> },
// >> {
// >> key: "[another SimpleNote-internal ID string]",
// >> deleted: true,
// >> modify: [Date object]
// >> },
// >> …
// >> ]
},
error: function( code ) {
console.error( code );
}
});
Creating a note:
SN.createNote({
body: "This is a new note!\nIt's awesome.",
success: function( noteID ) {
console.info( noteID );
// >> "[new SimpleNote-internal ID string]"
},
error: function( code ) {
console.error( code );
}
});
Updating a note:
SN.updateNote({
key: "[SimpleNote-internal ID string]",
body: "This is the revised note!\nIt's even awesomer.",
success: function( noteID ) {
console.info( noteID );
// >> "[SimpleNote-internal ID string]"
},
error: function( code ) {
console.error( code );
}
});
Retrieving a note:
SN.retrieveNote({
key: "[SimpleNote-internal ID string]",
success: function( noteHash ) {
console.info( noteHash );
// >> {
// >> body: "my example note",
// >> key: "[SimpleNote-internal ID string]",
// >> modifydate: [Date object],
// >> createdate: [Date object],
// >> deleted: false
// >> }
},
error: function( code ) {
console.error( code );
}
});
Deleting a note:
SN.deleteNote({
key: "[SimpleNote-internal ID string]",
success: function( noteID ) {
console.info( noteID );
// >> "[SimpleNote-internal ID string]"
},
error: function( code ) {
console.error( code );
}
});
The simplenote-js API documentation is included in this repository and the
related download packages.
It's been generated using YUIDoc (run make docs
in the repo's root folder);
the documentation for the current stable version is available online
here.
The SimpleNote API documentation is available from the SimpleNote API Google Groups page.
There's a QUnit-based test suite
(tests-in-tests/
shocker!) with 130+ tests.
- jQuery 1.4+
- jquery-base64
Carlo Zottmann, municode.de, carlo@municode.de. Nice to meet you.
Dual-license, MIT & GNU GPL v2.