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;
        bulkDelete(refs: readonly ItemRef[], refresh?: boolean): Promise<ItemRef[]>;
        bulkMove(
            refs: readonly ItemRef[],
            parent: string,
            refresh?: boolean,
        ): Promise<ItemRef[]>;
        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>>;
        getMetadata(ref: ItemRef): Promise<Metadata>;
        getPdf(ref: ItemRef): Promise<Uint8Array<ArrayBufferLike>>;
        getRmPage(ref: ItemRef, pageId: string): Promise<RmPage | undefined>;
        getRmPages(ref: ItemRef): Promise<Map<string, RmPage>>;
        listIds(refresh?: boolean): Promise<ItemRef[]>;
        listItems(refresh?: boolean): Promise<Entry[]>;
        move(ref: ItemRef, parent: string, refresh?: boolean): Promise<ItemRef>;
        pruneCache(refresh?: boolean): Promise<void>;
        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>;
        putPdf(
            visibleName: string,
            buffer: Uint8Array,
            opts?: PutOptions,
        ): 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

    Properties

    scoped access to the raw low-level api

    Methods

    • 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);
      
    • 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 listIds)

      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 the metadata for an item

      Parameters

      • ref: ItemRef

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

      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 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

    • similar to listItems but backed by the low level api

      Parameters

      • refresh: boolean = false

        if true, refresh the root hash before listing

      Returns Promise<ItemRef[]>

    • 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.

    • 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.

    • 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, visible name, and id

      Returns Promise<ItemRef>

      This is an experimental feature. By default a fresh document id is generated so re-uploading to the same account doesn't collide with the original; pass id to keep the original id. 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>

    • 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

    • 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.