Giter Site home page Giter Site logo

remarkable-typescript's Introduction

reMarkable-typescript

This project was inspired by the work of https://github.com/kevlened/remarkable-node, adding typing and new features like the upload of a document.

Unofficial reMarkable api wrapper for node.js based on these unofficial docs. This module is typed for TypeScript, but you can still use JavaScript with it.

Installation

yarn add remarkable-typescript
# OR
npm install remarkable-typescript

Then, go to reMarkable's website to genereate a code to pair your reMarkable. This code is only available 5 minutes.

Example

import { Remarkable, ItemResponse } from 'remarkable-typescript';
// const { Remarkable, ItemResponse } = require('remarkable-typescript');
const fs = require('fs');

(async () => {
    /*
    * Create the reMarkable client
    * Params: { deviceToken?: string }
    * Returns: client: Remarkable
    */
    const client = new Remarkable();

    /*
    * Register your reMarkable and generate a device token. You must do this first to pair your device if you didn't specify a token. This may take a few seconds to complete. It seems that the deviceToken never expires.
    * Params: { code: string }
    * Returns: deviceToken: string
    */
    const deviceToken = await client.register({ code: 'created code' });

    // (optional) skip registration in the future with `new Remarkable({deviceToken})`
    console.log(deviceToken);

    /*
    * (Re)generate a token from the deviceToken. You MUST call this function after creating the client. This token, used to interact with storage, is different from the deviceToken. This function is automatically called in register(). This token expires.
    * Params: none
    * Returns: token: string
    */
    await client.refreshToken();

    /*
    * List all items, files and folders.
    * Params: none
    * Returns: ItemResponse[]
    */
    const items = await client.getAllItems();

    /*
    * Get an item by id
    * Params: id: string
    * Returns: ItemResponse | null
    */
    const item = await client.getItemWithId('some uuid');

    /*
    * Delete an item by is ID and document version
    * Params: id: string, version: number
    * Returns: success: boolean
    */
    await client.deleteItem('some uuid', 1);

    const myPDF = fs.readFileSync('./my/PDF/location.pdf');
    /*
    * Upload a PDF to your reMarkable
    * Params: name: string, file: Buffer
    * Returns: id: string
    */
    const pdfUploadedId = await client.uploadPDF('name of PDF document', ID: '181a124b-bbdf-4fdd-8310-64fa87bc9c7f', pdfFileBuffer, /*optional UUID of parent folder*/);

    /*
    * Download a ZIP file to your reMarkable (with the annotations)
    * Params: id: string
    * Returns: Buffer
    */
    const zipFile = await client.downloadZip(pdfUploadedId);

    /*
    * Upload a ZIP file to your reMarkable (must be a supported reMarkable format). You can generate the ID using uuidv4.
    * Params: name: string, id: string, zipFile: Buffer
    * Returns: id: string
    */
    const zipFileId = await client.uploadZip('My document name', ID: 'f831481c-7d2d-4776-922d-36e708d9d680', zipFile);

    /*
    * Upload an ePub file to your reMarkable (must be a supported reMarkable format). You can generate the ID using uuidv4 or v5. v5 will deterministically generate a uuid based on name and namespace .
    * Params: name: string, id: string, epubFileBuffer: Buffer, parent?: string
    * Returns: id: string
    */
    const epubDocId = await client.uploadEPUB('name of ePub document', ID: '181a124b-bbdf-4fdd-8310-64fa87bc9c7f', epubFileBuffer, /*optional UUID of parent folder*/);

    /*
    * Create a directory
    * Params: name: string, id: string, epubFileBuffer: Buffer, parent?: string
    * Returns: id: string
    */
    const directoryId = await client.createDirectory('testDir2', id, ID: '702ba145-0a78-4e19-9324-6f8fb3da3c1a', /*optional UUID of parent folder*/);

})();

License

MIT

remarkable-typescript's People

Contributors

benoitsepe avatar bmccann36 avatar butanal avatar dependabot[bot] avatar seb3point0 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.