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 🙏

© 2025 – Pkg Stats / Ryan Hefner

weread-client

v0.0.6

Published

A TypeScript client library for interacting with WeRead (微信读书) API to fetch your reading notes, highlights, and book information.

Readme

WeRead Client

A TypeScript client library for interacting with WeRead (微信读书) API to fetch your reading notes, highlights, and book information.

Features

  • 📚 Fetch your WeRead notebooks and book collection
  • 🔖 Retrieve highlights and bookmarks for specific books
  • 🎯 TypeScript support with full type definitions
  • 🚀 Simple and lightweight API
  • 🔒 Cookie-based authentication support

Installation

npm install weread-client
# or
pnpm add weread-client
# or
yarn add weread-client

Usage

Basic Setup

import { WeReadClient } from 'weread-client';

// Create a client instance
const client = new WeReadClient();

// Or with custom headers (e.g., for authentication)
const client = new WeReadClient({
  headers: {
    'Cookie': 'your-weread-cookies-here'
  }
});

Get Your Notebooks

const notebooks = await client.getWeReadNotebooks();

if (notebooks.status === 200) {
  console.log(`Total books: ${notebooks.data.totalBookCount}`);
  
  notebooks.data.books.forEach(book => {
    console.log(`📖 ${book.book.title} by ${book.book.author}`);
    console.log(`   Notes: ${book.noteCount}, Bookmarks: ${book.bookmarkCount}`);
  });
}

Get Highlights for a Book

const bookId = 'your-book-id';
const highlights = await client.getWeReadHighlight(bookId);

if (highlights.status === 200) {
  console.log(`Book: ${highlights.data.book.title}`);
  
  highlights.data.updated.forEach(highlight => {
    console.log(`💡 "${highlight.markText}"`);
    console.log(`   Created: ${new Date(highlight.createTime * 1000).toLocaleDateString()}`);
  });
}

API Reference

WeReadClient

Constructor

new WeReadClient(options?: WeReadClientOptions)

Options:

  • headers?: Record<string, string> - Custom headers to include in requests

Methods

getWeReadNotebooks()

Fetches your WeRead notebook collection.

Returns: Promise<{ status: number, data: { synckey: number, totalBookCount: number, noBookReviewCount: number, books: WeReadBook[] } }>

getWeReadHighlight(bookId: string)

Fetches highlights and bookmarks for a specific book.

Parameters:

  • bookId: string - The unique identifier of the book

Returns: Promise<{ status: number, data: WeReadHighlight }>

Types

WeReadBook

type WeReadBook = {
  book: {
    author: string;
    cover: string;
    title: string;
    translator: string;
  };
  bookId: string;
  bookmarkCount: number;
  noteCount: number;
  reviewCount: number;
}

WeReadHighlight

type WeReadHighlight = {
  book: WeReadBook['book'];
  chapters: {
    chapterUid: number;
    title: string;
  }[];
  updated: {
    bookId: string;
    markText: string;
    chapterUid: number;
    createTime: number;
    range: string;
  }[];
}

Authentication

To access your personal WeRead data, you'll need to provide authentication cookies. You can obtain these by:

  1. Opening WeRead in your browser
  2. Logging in to your account
  3. Opening browser developer tools
  4. Copying the Cookie header from any WeRead API request
  5. Passing it to the client:
const client = new WeReadClient({
  headers: {
    'Cookie': 'your-cookies-here'
  }
});

Development

# Install dependencies
pnpm install

# Build the project
pnpm build

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT

Disclaimer

This is an unofficial client library for WeRead. Use it responsibly and in accordance with WeRead's terms of service.