adcharity-remarkable-api v2.0.5
remarkable-api
The unofficial reMarkable API for Node.js
version 2
Version 2 will introduce breaking changes to the API. It is currently a work in progress.
installation
npm install adcharity-remarkable-api
intializing a new device
After you install the remarkable-api
module, you can create a new reMarkable device.
const Device = require("adcharity-remarkable-api")
const reMarkable = new Device()
registering a device
To use this module, you must retrieve a one-time code from the reMarkable dashboard. Confirming your one-time code will return a userToken
that can be used to interact with the device. You should store this token somewhere safe, such as in an environmental variable.
const Device = require("adcharity-remarkable-api")
const reMarkable = new Device()
reMarkable.register("one-time code").then(code => {
console.log(code)
})
setting user token
You can set the userToken
of the device using the refresh
method. This method will also reset storageHost
and notificationsHost
, which are required to upload documents and send messages to the reMarkable.
...
reMarkable.refresh(process.env.USER_TOKEN)
reMarkable.userToken = process.env.USER_TOKEN // will not work
items
items
will return an array of all documents and collections (or folders) on your reMarkable.
...
(async () => {
await reMarkable.refresh(process.env.USER_TOKEN);
reMarkable.items().then(everything => {
console.log(everything);
});
})();
item
If you have an id
for a particular document, you can fetch it with item
. It will return a signle document or collection.
(async () => {
await reMarkable.refresh(process.env.USER_TOKEN);
reMarkable.item("4c8566a1-1d89-4e3d-80e6-5f6bb125c5a7").then(console.log);
})();
upload
upload
takes the file path as a parameter. It is recommended to use __dirname
. Uploading a document will return some very basic metadata, including the document id
and visibleName
.
(async () => {
await reMarkable.refresh(process.env.USER_TOKEN);
const document = await reMarkable.upload(path.join(__dirname, "./example.pdf"))
if(document) {
const item = await reMarkable.item(document.id)
}
})();
item class
Unlike v1 of the reMarkable api, everything returned from items
or item
is encapsulated within an Item
class. This class contains methods that will allow you to delete or modify a particular document.
original metadata
The metadata initially retrieved from reMarkable's cloud servers contains odd capitilizations and spelling errors. Some of the data is not completely necessary and pertains to the details of the request (and not the document itself).
{
"ID": "ec53580c-3579-4fe7-a096-fd1de8011b70", // id
"Version": 0, // version
"Message": "", // removed
"Success": false, // removed
"BlobURLGet": "", // blob
"BlobURLGetExpires": "0001-01-01T00:00:00Z", // blobExpiration
"ModifiedClient": "0001-01-01T00:00:00Z", // lastModified
"Type": "", // type
"VissibleName": "", // visibleName
"CurrentPage": 0, // currentPage
"Bookmarked": false, // bookmarked
"Parent": "" // parent
}
metadata
Metadata in an Item
is non-standard; it does not follow other reMarkable apis. It has been modified to address spelling mistakes (such as VissibleName
) and make the data more convenient for JavaScript programmers.
id
: used to identify documents, can be stored and passed intoitem
type
:DocumentType
orCollectionType
blob
: where the file is locatedblobExpiration
: when the blob will expirelastModified
: when the file was last editedvisibleName
: file or directory visibleNamecurrentPage
: opened pagebookmarked
: starred or notparent
: parent directory
update
update
allows you to change the metadata of a document. The only properties you can change are parent
, bookmarked
, and visibleName
.
(async () => {
await reMarkable.refresh(process.env.USER_TOKEN);
const item = await reMarkable.item("4c8566a1-1d89-4e3d-80e6-5f6bb125c5a7");
item.update({
visibleName: "spanish-test"
}).then(success => {
// success = true or false
})
})();
remove
remove
deletes a document.
(async () => {
await reMarkable.refresh(process.env.USER_TOKEN);
const item = await reMarkable.item("4c8566a1-1d89-4e3d-80e6-5f6bb125c5a7");
item.remove().then(success => {
// success = true or false
})
})();
resources & alternative apis
https://akeil.de/posts/remarkable-cloud-api/
https://github.com/Ogdentrod/reMarkable-typescript
https://github.com/splitbrain/ReMarkableAPI