npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

readwise-reader-api

v0.5.2

Published

An unofficial JavaScript client for the Readwise Reader API

Readme

An unofficial Readwise & Reader SDK for JavaScript

This client provides a convenient way to interact with the Readwise & Reader API, suitable for both JavaScript and TypeScript applications.

Installation

npm install readwise-reader-api

Usage

Prerequisites

  1. Obtain a Readwise API token here
  2. Store in .env file or in an environment variable.
export READWISE_TOKEN=<api_token>

Import and initialize a client (Readwise or Reader) using an access token.

import { Readwise } from "readwise-reader-api";

const readwise = new Readwise({
  auth: process.env.READWISE_TOKEN,
});

Make a request to any Readwise (or Reader) API endpoint.

See the complete list of endpoints in the API Reference:

(async () => {
  const daily_review = await readwise.review.daily();
})();

Each method returns a Promise which resolves the response.

console.log(daily_review);
{
  review_id: 104932226,
  review_url: 'https://readwise.io/reviews/104932226',
  review_completed: true,
  highlights: [
    {
      text: '“If it walks like a duck and it quacks like a duck, then it must be a duck.”',
      title: 'Practices of the Python Pro',
      author: 'Dane Hillard',
      url: null,
      source_url: 'https://read.readwise.io/read/01h65f61js5qpaycd1409e22qw',
      source_type: 'article',
      category: null,
      location_type: 'offset',
      location: 78999682,
      note: '',
      highlighted_at: '2023-09-17T15:46:42.883825Z',
      highlight_url: 'https://read.readwise.io/read/01hahx56818mje85sga832j5t2',
      image_url: 'https://readwise-assets.s3.amazonaws.com/static/images/article0.00998d930354.png',
      id: 597114893,
      api_source: null
    },
    ...
    {
      text: 'we continue along this rate of change and follow a “Large Model Moore’s Law,” then these far-fetched scenarios may just enter the realm of the possible.',
      title: 'Generative AI: A Creative New World',
      author: 'Sonya Huang',
      url: null,
      source_url: 'https://read.readwise.io/read/01h6qabyzghazrt1qsjvf9zeqa',
      source_type: 'article',
      category: null,
      location_type: 'offset',
      location: 21926,
      note: '',
      highlighted_at: '2023-08-04T15:17:58.196413Z',
      highlight_url: 'https://read.readwise.io/read/01h70j0xryxnwm3b6wcf4n6kfh',
      image_url: 'https://www.sequoiacap.com/wp-content/uploads/sites/6/2022/09/robots-1-1960.jpg',
      id: 574654751,
      api_source: null
    },
  ]
}

Client Library References

A reference for all methods and types available in Readwise and Reader Client libraries.

Readwise

EXPORT Highlights: Export all highlights after a specific date.

async function exportHighlights() {
  try {
    const highlights: ReadwiseBookHighlights[] =
      await readwise.highlights.export({
        updatedAfter: "2024-01-27T00:00:00Z",
      });
    console.log(highlights);
  } catch (error) {
    console.error("Error:", error);
  }
}

LIST Highlights: List all highlights after a specific date.

async function listHighlights() {
  try {
    const highlights: ReadwiseHighlight[] = await readwise.highlights.list({
      highlighted_at__gt: "2024-01-27T00:00:00Z",
    });
    console.log(highlights);
  } catch (error) {
    console.error("Error:", error);
  }
}

DAILY REVIEW: Returns your daily review highlights.

async function getDailyReview() {
  /** Get Daily Review */
  try {
    const review = await readwise.review.daily();
    console.log(review);
  } catch (error) {
    console.error("Error:", error);
  }
}

DETAILS Book: Get details for a book (eg Article, Blog, Tweet, Book, etc.).

async function getBookDetails() {
  try {
    const book: ReadwiseBook = await readwise.books.details({
      book_id: "35943114",
    });
    console.log(book);
  } catch (error) {
    console.error("Error:", error);
  }
}

LIST Highlights (in Book): Get all highlights for a single book (eg Article, Blog, Tweet, Book, etc.).

async function getBookHighlights() {
  try {
    const book_highlights: ReadwiseHighlight[] = await readwise.highlights.list(
      { book_id: 35943114 },
    );
    console.log(book_highlights);
  } catch (error) {
    console.error("Error:", error);
  }
}

EXPORT Highlights (in Book): Export all highlights for a single book (eg Article, Blog, Tweet, Book, etc.).

async function exportBookHighlights(): Promise<void> {
  try {
    const highlights: ReadwiseBookHighlights[] =
      await readwise.highlights.export({ ids: 35943114 });
    console.log(highlights);
  } catch (error) {
    console.error("Error:", error);
  }
}

Advanced Usage

Get all highlights for a particular category (eg "Tweets")

async function getHighlightsFromTweets() {
  const books: ReadwiseBook[] = await readwise.books.list({
    category: "tweets",
  });
  for (const book of books) {
    const highlights = await readwise.highlights.list({ book_id: book.id });
    if (highlights.length > 0) {
      console.log(book.title);
      for (const highlight of highlights) {
        console.log(highlight.text);
      }
    }
  }
}

Readwise Reader

Provides the ability to create, list, and retrieve documents.

import { Reader } from 'readwise-reader-api

const reader = new Reader({
  auth: process.env.READWISE_TOKEN,
});

CREATE Document: Create a document.

const result = await reader.document.create({
  url: url,
  title: "New Title",
});

The response will show if document already exists or not.

{
  document_already_exists: true,
  data: {
    id: '01hqeecsxa5qx6beyjvbrz37e4',
    url: 'https://read.readwise.io/read/01hqeecsxa5qx6beyjvbrz37e4'
  }
}

LIST Documents: List documents for a specific location, category and/or date.

async function listReaderDocuments() {
  try {
    console.log("Getting documents...");
    const docs = await reader.document.list(
      "new",
      "article",
      "2024-01-01T00:00:00Z",
    );
    console.log(docs);
  } catch (error) {
    console.error("Error:", error);
  }
}

GET Document by ID: Retrieve a single document.

async function getReaderDocument() {
  try {
    console.log("Getting a specific document...");
    const doc = await reader.document.id("01hkwssvj7g207daxvk5k1tc4d");
    console.log(doc);
  } catch (error) {
    console.error("Error:", error);
  }
}

Available Readwise and Reader Types

export {
  /** Readwise */
  ReadwiseBook,
  ReadwiseBookHighlights,
  ReadwiseHighlight,
  ReadwiseLibraryCategoryType,
  /** Reader */
  ReaderDocument,
  ReaderLocationType,
  ReaderCategoryType,
} from "./api-endpoints";