rmapi-js
    Preparing search index...

    Interface RemarkableApi

    the api for accessing remarkable functions

    There are roughly two types of functions.

    • high-level api functions that provide simple access with a single round trip based on the web api
    • low-level wrapped functions that take more round trips, but provide more control and may be faster since they can be cached.

    Most of these functions validate the return values so that typescript is accurate. However, sometimes those return values are more strict than the "true" underlying types. If this happens, please submit a an issue. In the mean time, you should be able to use the low level api to work around any restrictive validation.

    interface RemarkableApi {
        raw: RawRemarkableApi;
        get deviceId(): string;
        bulkDelete(refs: readonly ItemRef[], refresh?: boolean): Promise<ItemRef[]>;
        bulkMove(
            refs: readonly ItemRef[],
            parent: string,
            refresh?: boolean,
        ): Promise<ItemRef[]>;
        bulkPurge(refs: readonly ItemRef[], refresh?: boolean): Promise<void>;
        clearCache(): void;
        delete(ref: ItemRef, refresh?: boolean): Promise<ItemRef>;
        dumpCache(): string;
        getContent(ref: ItemRef): Promise<Content>;
        getDocumentArchive(ref: ItemRef): Promise<Uint8Array<ArrayBufferLike>>;
        getEpub(ref: ItemRef): Promise<Uint8Array<ArrayBufferLike>>;
        getHighlightPages(ref: ItemRef): Promise<Map<string, Highlight[][]>>;
        getHighlights(
            ref: ItemRef,
            pageId: string,
        ): Promise<Highlight[][] | undefined>;
        getMetadata(ref: ItemRef): Promise<Metadata>;
        getPagedata(ref: ItemRef): Promise<string[] | undefined>;
        getPageMetadata(
            ref: ItemRef,
            pageId: string,
        ): Promise<PageMetadata | undefined>;
        getPageMetadataPages(ref: ItemRef): Promise<Map<string, PageMetadata>>;
        getPdf(ref: ItemRef): Promise<Uint8Array<ArrayBufferLike>>;
        getRmPage(ref: ItemRef, pageId: string): Promise<RmPage | undefined>;
        getRmPages(ref: ItemRef): Promise<Map<string, RmPage>>;
        getTemplate(ref: ItemRef): Promise<TemplateContent | undefined>;
        listen(): AsyncGenerator<SyncEvent, void, undefined>;
        listItems(refresh?: boolean): Promise<Entry[]>;
        listRefs(refresh?: boolean): Promise<ItemRef[]>;
        move(ref: ItemRef, parent: string, refresh?: boolean): Promise<ItemRef>;
        pruneCache(refresh?: boolean): Promise<void>;
        purge(ref: ItemRef, refresh?: boolean): Promise<void>;
        purgeTrash(refresh?: boolean): Promise<ItemRef[]>;
        putDocumentArchive(
            buffer: Uint8Array,
            options?: PutDocumentOptions,
        ): Promise<ItemRef>;
        putEpub(
            visibleName: string,
            buffer: Uint8Array,
            opts?: PutOptions,
        ): Promise<ItemRef>;
        putFolder(
            visibleName: string,
            __namedParameters?: FolderOptions,
            refresh?: boolean,
        ): Promise<ItemRef>;
        putHighlightPages(
            ref: ItemRef,
            pages: ReadonlyMap<string, readonly Highlight[][]>,
            refresh?: boolean,
        ): Promise<ItemRef>;
        putHighlights(
            ref: ItemRef,
            pageId: string,
            highlights: readonly Highlight[][],
            refresh?: boolean,
        ): Promise<ItemRef>;
        putPagedata(
            ref: ItemRef,
            templates: readonly string[],
            refresh?: boolean,
        ): Promise<ItemRef>;
        putPageMetadata(
            ref: ItemRef,
            pageId: string,
            meta: PageMetadata,
            refresh?: boolean,
        ): Promise<ItemRef>;
        putPageMetadataPages(
            ref: ItemRef,
            pages: ReadonlyMap<string, PageMetadata>,
            refresh?: boolean,
        ): Promise<ItemRef>;
        putPdf(
            visibleName: string,
            buffer: Uint8Array,
            opts?: PutOptions,
        ): Promise<ItemRef>;
        putRmPage(
            ref: ItemRef,
            pageId: string,
            page: RmPage,
            refresh?: boolean,
        ): Promise<ItemRef>;
        putRmPages(
            ref: ItemRef,
            pages: ReadonlyMap<string, RmPage>,
            refresh?: boolean,
        ): Promise<ItemRef>;
        putTemplate(
            ref: ItemRef,
            template: TemplateContent,
            refresh?: boolean,
        ): Promise<ItemRef>;
        rename(
            ref: ItemRef,
            visibleName: string,
            refresh?: boolean,
        ): Promise<ItemRef>;
        star(ref: ItemRef, starred: boolean, refresh?: boolean): Promise<ItemRef>;
        updateCollection(
            ref: ItemRef,
            content: Partial<CollectionContent>,
            refresh?: boolean,
        ): Promise<ItemRef>;
        updateDocument(
            ref: ItemRef,
            content: Partial<DocumentContent>,
            refresh?: boolean,
        ): Promise<ItemRef>;
        updateTemplate(
            ref: ItemRef,
            content: Partial<TemplateContent>,
            refresh?: boolean,
        ): Promise<ItemRef>;
        uploadEpub(visibleName: string, buffer: Uint8Array): Promise<ItemRef>;
        uploadFolder(visibleName: string): Promise<ItemRef>;
        uploadPdf(visibleName: string, buffer: Uint8Array): Promise<ItemRef>;
    }
    Index

    scoped access to the raw low-level api

    • get deviceId(): string

      the id this api is registered under

      This is the uuid passed to register, which reMarkable stamps on everything this client does. Tablets use their serial instead.

      Returns string

    • delete many entries

      Parameters

      • refs: readonly ItemRef[]

        references to the entries to delete

      • refresh: boolean = false

      Returns Promise<ItemRef[]>

      references to the deleted entries, each with its new hash

      await api.bulkDelete([file]);
      
    • move many entries

      Parameters

      • refs: readonly ItemRef[]

        references to the entries to move

      • parent: string

        the directory id to move the entries to, "" (root) and "trash" are special ids

      • refresh: boolean = false

      Returns Promise<ItemRef[]>

      references to the moved entries, each with its new hash

      const next = await api.bulkMove([file], dir.id);
      
    • permanently delete many entries

      The bulk form of purge, done in a single root write.

      Parameters

      • refs: readonly ItemRef[]

        references to the entries to purge

      • refresh: boolean = false

      Returns Promise<void>

      await api.bulkPurge([file]);
      
    • completely delete the cache

      If the cache is causing memory issues, you can clear it, but this will hurt performance.

      Returns void

    • delete an entry

      Parameters

      • ref: ItemRef

        a reference to the entry to delete

      • refresh: boolean = false

      Returns Promise<ItemRef>

      a reference to the deleted entry, with its new hash

      await api.delete(file);
      
    • get the current cache value as a string

      You can use this to warm start a new instance of remarkable with any previously cached results.

      Returns string

    • get the content metadata for an item

      Parameters

      • ref: ItemRef

        a reference to the item (e.g. from listItems or listRefs)

      Returns Promise<Content>

      the content

      If this fails validation and you still want to get the content, you can use the low-level api to get the raw text of the .content file in the RawEntry for this hash.

    • get a document's entire contents as a zip archive

      This gets every file associated with a document and puts them into a zip archive.

      Parameters

      • ref: ItemRef

        a reference to the document (e.g. from listItems)

      Returns Promise<Uint8Array<ArrayBufferLike>>

      This is an experimental feature. The resulting archive round-trips back through putDocumentArchive.

    • get the epub associated with a document

      This returns the raw input epub if a document was created from an epub.

      Parameters

      • ref: ItemRef

        a reference to the document (e.g. from listItems)

      Returns Promise<Uint8Array<ArrayBufferLike>>

      the epub bytes

    • get every highlighted page of a document, keyed by page id

      Parameters

      • ref: ItemRef

        a reference to the document

      Returns Promise<Map<string, Highlight[][]>>

      the highlights in page order, omitting pages with none

    • get a single page's text highlights

      These are separate from the highlighter strokes drawn in a .rm scene.

      Parameters

      • ref: ItemRef

        a reference to the document

      • pageId: string

        the id of the page, from the document's .content page list

      Returns Promise<Highlight[][] | undefined>

      the page's highlights, or undefined if the page has none

      if pageId is not a page of the document

    • get the metadata for an item

      Parameters

      • ref: ItemRef

        a reference to the item (e.g. from listItems or listRefs)

      Returns Promise<Metadata>

      the metadata

      If this fails validation and you still want to get the content, you can use the low-level api to get the raw text of the .metadata file in the RawEntry for this hash.

    • get a document's per-page template names

      The .pagedata file lists one template name per page, in page order (an empty string for a page with no template).

      Parameters

      • ref: ItemRef

        a reference to the document

      Returns Promise<string[] | undefined>

      the per-page template names, or undefined if the document has no .pagedata

    • get a single page's layer metadata

      Parameters

      • ref: ItemRef

        a reference to the document

      • pageId: string

        the id of the page, from the document's .content page list

      Returns Promise<PageMetadata | undefined>

      the page's layer metadata, or undefined if the page has none

      if pageId is not a page of the document

    • get every page's layer metadata, keyed by page id

      Parameters

      • ref: ItemRef

        a reference to the document

      Returns Promise<Map<string, PageMetadata>>

      the layer metadata in page order, omitting pages with none

    • get the pdf associated with a document

      This returns the raw input pdf, not the rendered pdf with any markup.

      Parameters

      • ref: ItemRef

        a reference to the document (e.g. from listItems)

      Returns Promise<Uint8Array<ArrayBufferLike>>

      the pdf bytes

    • get a single page's parsed reMarkable lines (.rm) drawing

      Parameters

      • ref: ItemRef

        a reference to the document (e.g. from listItems)

      • pageId: string

        the id of the page, from the document's .content page list (see getRmPages for every page)

      Returns Promise<RmPage | undefined>

      the parsed page, or undefined if the page exists but has no .rm drawing (a page you haven't drawn on has no .rm file)

      if pageId is not a page of the document

    • get every drawn page of a document, parsed, keyed by page id

      Returns a map from page id to its parsed RmPage, iterating in the page order given by the document's .content. Pages with no drawing (and soft-deleted pages) are omitted. Version 3, 5, and 6 pages are all supported.

      Parameters

      • ref: ItemRef

        a reference to the document (e.g. from listItems)

      Returns Promise<Map<string, RmPage>>

      the drawn pages, keyed by page id, in document order

    • get a template attached to an item as a .template sidecar

      This is distinct from a TemplateEntry (whose template is its .content); collections and documents can carry a template this way.

      Parameters

      • ref: ItemRef

        a reference to the item

      Returns Promise<TemplateContent | undefined>

      the template content, or undefined if the item has no .template

    • listen for sync notifications

      reMarkable sends one every time a device finishes syncing. It names the device, not what changed, so use it as a cue to re-read.

      The socket is reopened when the server drops it, which happens every few minutes. Leaving the loop closes it. Session tokens expire after a few hours, and this throws once reconnecting with an expired one fails.

      reMarkable authorizes the handshake with a header, which node and bun can attach but a browser's WebSocket can't, so this is server side only.

      Returns AsyncGenerator<SyncEvent, void, undefined>

      the notifications, in the order they arrive

      for await (const { attributes } of api.listen()) {
      if (attributes.sourceDeviceID !== api.deviceId) {
      const entries = await api.listItems(true);
      }
      }
    • list all items

      Items include both collections and documents. Documents that are in folders will have their parent set to something other than "" or "trash", but everything will be returned by this function.

      Parameters

      • refresh: boolean = false

        if true, refresh the root hash before listing

      Returns Promise<Entry[]>

      a list of all items with some metadata

      await api.listItems();
      

      This is now backed by the low level api, and you may notice some performance degradation if not taking advantage of the cache.

    • list a reference to every item, backed by the low level api

      Unlike listItems this doesn't read each item's metadata, so it's cheaper but only gives you ids and hashes.

      Parameters

      • refresh: boolean = false

        if true, refresh the root hash before listing

      Returns Promise<ItemRef[]>

    • move an entry

      Parameters

      • ref: ItemRef

        a reference to the entry to move

      • parent: string

        the id of the directory to move the entry to, "" (root) and "trash" are special parents

      • refresh: boolean = false

      Returns Promise<ItemRef>

      a reference to the moved entry, with its new hash

      const next = await api.move(doc, dir.id);
      
    • prune the cache so that it contains only reachable hashes

      The cache is append only, so it can grow without bound, even as hashes become unreachable. In the future, this may have better cache management to track this in real time, but for now, you can call this method, to keep it from growing continuously.

      Parameters

      • Optionalrefresh: boolean

        whether to refresh the root hash before pruning

      Returns Promise<void>

      This won't necessarily reduce the cache size. In order to see if hashes are reachable we first have to search through all existing entry lists.

    • permanently delete an entry

      Unlike delete, which moves an entry to the trash where the device can still restore it, this drops the entry from the account outright. Its files stay in the cloud, but nothing points at them anymore and nothing brings the entry back.

      Only the entry named goes: purging a folder leaves everything inside it pointing at a parent that's no longer there. Those entries stay in the account and listItems still returns them, but no folder holds them, so nothing browsing the tree will find them. Purge the contents first, or use purgeTrash, which takes the whole tree.

      Parameters

      • ref: ItemRef

        a reference to the entry to purge

      • refresh: boolean = false

      Returns Promise<void>

      await api.purge(file);
      
    • permanently delete everything in the trash

      Trashing a folder doesn't touch what's inside it — those entries keep naming the folder as their parent, which is what lets the device restore them together — so the trash holds the whole tree hanging off it, not just the entries whose parent is "trash". This purges all of it in one root write.

      Parameters

      • refresh: boolean = false

        if true, refresh the root hash before purging

      Returns Promise<ItemRef[]>

      references to the entries that were purged

      await api.purgeTrash();
      

      Finding that tree means reading every item's metadata, so this costs about as much as listItems.

    • upload a document archive produced by getDocumentArchive

      This explodes the zip archive back into its constituent files, uploads each as a blob, and commits a new document into the root.

      Parameters

      • buffer: Uint8Array

        the archive bytes, as returned by getDocumentArchive

      • options: PutDocumentOptions = {}

        overrides for parent and visible name

      Returns Promise<ItemRef>

      This is an experimental feature. A fresh document id is generated, so re-uploading to the same account doesn't collide with the original. Like the other low-level puts, this may throw a GenerationError if the generation is stale, requiring a retry.

    • use the low-level api to add an epub document

      Since this uses the low-level api, it provides more options than uploadEpub, but is a little more finicky. Notably, it may throw a GenerationError if the generation doesn't match the current server generation, requiring you to retry until it works.

      Parameters

      • visibleName: string

        the name to display on the reMarkable

      • buffer: Uint8Array

        the raw epub

      • opts: PutOptions = {}

        put options

      Returns Promise<ItemRef>

      the entry for the newly inserted document

      GenerationError if the generation doesn't match the current server generation

    • create a folder

      Parameters

      • visibleName: string
      • __namedParameters: FolderOptions = {}
      • refresh: boolean = false

      Returns Promise<ItemRef>

    • write several pages' text highlights in one commit

      Parameters

      • ref: ItemRef

        a reference to the document

      • pages: ReadonlyMap<string, readonly Highlight[][]>

        the highlights to write, keyed by page id, replacing any already on those pages and leaving every other page alone

      • refresh: boolean = false

      Returns Promise<ItemRef>

      a reference to the updated document, with its new hash

      GenerationError if the generation doesn't match the current server generation

      if any key is not a page of the document

    • write a single page's text highlights, replacing any already there

      Parameters

      • ref: ItemRef

        a reference to the document

      • pageId: string

        the id of the page, from the document's .content page list

      • highlights: readonly Highlight[][]

        the highlights to write

      • refresh: boolean = false

      Returns Promise<ItemRef>

      a reference to the updated document, with its new hash

      GenerationError if the generation doesn't match the current server generation

      if pageId is not a page of the document

    • set a document's per-page template names

      Parameters

      • ref: ItemRef

        a reference to the document

      • templates: readonly string[]

        one template name per page, in page order, an empty string for a page with no template

      • refresh: boolean = false

      Returns Promise<ItemRef>

      a reference to the updated document, with its new hash

      GenerationError if the generation doesn't match the current server generation

    • write a single page's layer metadata, replacing any already there

      Parameters

      • ref: ItemRef

        a reference to the document

      • pageId: string

        the id of the page, from the document's .content page list

      • meta: PageMetadata

        the layer metadata to write

      • refresh: boolean = false

      Returns Promise<ItemRef>

      a reference to the updated document, with its new hash

      GenerationError if the generation doesn't match the current server generation

      if pageId is not a page of the document

    • write several pages' layer metadata in one commit

      Parameters

      • ref: ItemRef

        a reference to the document

      • pages: ReadonlyMap<string, PageMetadata>

        the layer metadata to write, keyed by page id, replacing any already on those pages and leaving every other page alone

      • refresh: boolean = false

      Returns Promise<ItemRef>

      a reference to the updated document, with its new hash

      GenerationError if the generation doesn't match the current server generation

      if any key is not a page of the document

    • use the low-level api to add a pdf document

      Since this uses the low-level api, it provides more options than uploadPdf, but is a little more finicky. Notably, it may throw a GenerationError if the generation doesn't match the current server generation, requiring you to retry until it works.

      Parameters

      • visibleName: string

        the name to display on the reMarkable

      • buffer: Uint8Array

        the raw pdf

      • opts: PutOptions = {}

        put options

      Returns Promise<ItemRef>

      the entry for the newly inserted document

      When zoomMode is "customFit" the customZoom* fields describe the view, all in the source page's device pixels: customZoomPageWidth and customZoomPageHeight are the page dimensions scaled by the device dpi (pagePt * dpi / 72, see deviceScreens), and the centers are in those pixels.

      The view always has the device's aspect ratio — you control its height and position, not its shape. customZoomScale = screenHeight / viewHeight in device pixels (screenHeight fixed per model, see deviceScreens), normalized to 1:1 native pixels: at 1 the view is screen-tall, showing screenHeight / customZoomPageHeight of the page.

      customZoomCenterX offsets the center of the view horizontally from the page center, and customZoomCenterY is the absolute distance of the center down from the top of the page; the view's width follows from its height and the device aspect ratio.

      The fields are a single document-wide setting, but customZoomCenterY is applied against each page's own rendered height. On a page rendered taller than customZoomPageHeight that distance is a smaller fraction of the page, so the view sits higher and cuts off the bottom; on a shorter page it sits lower and cuts off the top. customZoomScale (a ratio) and customZoomCenterX (an offset from center) do not shift with page size.

      GenerationError if the generation doesn't match the current server generation

    • write a single page's reMarkable lines (.rm) drawing

      Parameters

      • ref: ItemRef

        a reference to the document

      • pageId: string

        the id of the page, from the document's .content page list

      • page: RmPage

        the drawing to write, replacing any already there

      • refresh: boolean = false

      Returns Promise<ItemRef>

      a reference to the updated document, with its new hash

      GenerationError if the generation doesn't match the current server generation

      if pageId is not a page of the document

    • write several pages' reMarkable lines (.rm) drawings in one commit

      Parameters

      • ref: ItemRef

        a reference to the document

      • pages: ReadonlyMap<string, RmPage>

        the drawings to write, keyed by page id, replacing any already on those pages and leaving every other page alone

      • refresh: boolean = false

      Returns Promise<ItemRef>

      a reference to the updated document, with its new hash

      GenerationError if the generation doesn't match the current server generation

      if any key is not a page of the document

    • attach a template to an item as a .template sidecar

      Parameters

      • ref: ItemRef

        a reference to the item

      • template: TemplateContent

        the template to attach, replacing any already there

      • refresh: boolean = false

      Returns Promise<ItemRef>

      a reference to the updated item, with its new hash

      GenerationError if the generation doesn't match the current server generation

    • rename an entry

      Parameters

      • ref: ItemRef

        a reference to the entry to rename

      • visibleName: string

        the new name to assign

      • refresh: boolean = false

      Returns Promise<ItemRef>

      a reference to the renamed entry, with its new hash

      const next = await api.rename(file, "new name");
      
    • star or unstar an entry

      Parameters

      • ref: ItemRef

        a reference to the entry to star

      • starred: boolean

        whether the entry should be starred or not

      • refresh: boolean = false

      Returns Promise<ItemRef>

      a reference to the updated entry, with its new hash

      const next = await api.star(file, true);
      
    • update content metadata for a collection

      Parameters

      • ref: ItemRef

        a reference to the collection to update

      • content: Partial<CollectionContent>

        the fields of content to update

      • refresh: boolean = false

      Returns Promise<ItemRef>

      a reference to the updated entry, with its new hash

      const next = await api.updateCollection(dir, { textAlignment: "left" });
      
    • update content metadata for a document

      Parameters

      • ref: ItemRef

        a reference to the file to update

      • content: Partial<DocumentContent>

        the fields of content to update

      • refresh: boolean = false

      Returns Promise<ItemRef>

      a reference to the updated entry, with its new hash

      const next = await api.updateDocument(doc, { textAlignment: "left" });
      
    • update content metadata for a template

      Parameters

      • ref: ItemRef

        a reference to the template to update

      • content: Partial<TemplateContent>

        the fields of content to update

      • refresh: boolean = false

      Returns Promise<ItemRef>

      a reference to the updated entry, with its new hash

      const next = await api.updateTemplate(tmpl, { textAlignment: "left" });
      
    • upload an epub

      Parameters

      • visibleName: string

        the name to show for the uploaded epub

      • buffer: Uint8Array

        the epub contents

      Returns Promise<ItemRef>

      await api.uploadEpub("My EPub", ...);
      

      this uses a simpler api that works even with schema version 4.

    • create a folder using the simple api

      Parameters

      • visibleName: string

      Returns Promise<ItemRef>

    • upload a pdf

      Parameters

      • visibleName: string

        the name to show for the uploaded epub

      • buffer: Uint8Array

        the epub contents

      Returns Promise<ItemRef>

      await api.uploadPdf("My PDF", ...);
      

      this uses a simpler api that works even with schema version 4.