{"_id":"@dorakika/weread-api","name":"@dorakika/weread-api","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@dorakika/weread-api","version":"0.1.0","description":"Type-safe WeRead (微信读书) API client — search, shelf, notes, reviews, reading stats & more","type":"module","license":"MIT","author":{"name":"dorakika"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","engines":{"node":">=18"},"scripts":{"build":"tsc -p tsconfig.build.json","test":"vitest run","test:watch":"vitest","typecheck":"tsc --noEmit","prepublishOnly":"npm run build && npm run test"},"devDependencies":{"@types/node":"^22.0.0","typescript":"^5.7.0","vitest":"^3.0.0"},"keywords":["weread","wechat-reading","微信读书","api-client","typescript"],"gitHead":"c4a5dbe54db994e23b18c27b3d85a74984bd8739","_id":"@dorakika/weread-api@0.1.0","_nodeVersion":"24.11.1","_npmVersion":"11.6.2","dist":{"integrity":"sha512-5baUrWP/jup706bB449r90bzY2TGrfRYDY6juAWKlDWKkreWQUrV7XnAMFhgn4BeMF/acgSLq7t+lYYaicmHsg==","shasum":"3e4308aa8cf73497dfe7751898d96fd0927d5e4c","tarball":"https://registry.npmjs.org/@dorakika/weread-api/-/weread-api-0.1.0.tgz","fileCount":134,"unpackedSize":116057,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIBltu0xqwmeF6tjLnU1AJ5ytSWTw4mds6yZKvceobr/fAiEAn4gUdl6q+dFtPXcRi+tT/L3ZucUYQZsnp5i6p6ysye4="}]},"_npmUser":{"name":"dorakika","email":"dorakika@163.com"},"directories":{},"maintainers":[{"name":"dorakika","email":"dorakika@163.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/weread-api_0.1.0_1781425579624_0.13097834575114486"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-14T08:26:19.390Z","0.1.0":"2026-06-14T08:26:19.768Z","modified":"2026-06-14T08:26:20.051Z"},"maintainers":[{"name":"dorakika","email":"dorakika@163.com"}],"description":"Type-safe WeRead (微信读书) API client — search, shelf, notes, reviews, reading stats & more","keywords":["weread","wechat-reading","微信读书","api-client","typescript"],"author":{"name":"dorakika"},"license":"MIT","readme":"# @dorakika/weread-api\n\nType-safe WeRead (微信读书) API client for Node.js & browsers.\n\n## Install\n\n```bash\nnpm install @dorakika/weread-api\n```\n\n## Quick start\n\n```ts\nimport { WereadClient, formatDate, formatDuration } from '@dorakika/weread-api'\n\nconst client = new WereadClient({ apiKey: 'wrk-xxxxxxxx' })\n\n// Search books\nconst { results } = await client.search.books({ keyword: '三体', count: 5 })\nfor (const group of results) {\n  console.log(`— ${group.title} —`)\n  for (const { bookInfo } of group.books) {\n    console.log(`  ${bookInfo.title} — ${bookInfo.author}`)\n  }\n}\n\n// Bookshelf\nconst shelf = await client.shelf.sync()\nconsole.log(`${shelf.books.length} books on shelf`)\n\n// Reading stats this month\nconst stats = await client.readdata.detail({ mode: 'monthly' })\nconsole.log(`Read ${formatDuration(stats.totalReadTime)} across ${stats.readDays} days`)\n\n// Iterate all notebooks (auto-paginated)\nfor await (const nb of client.notebook.all({ pageSize: 50 })) {\n  console.log(`${nb.book.title}: ${nb.noteCount} highlights`)\n}\n```\n\n## API namespaces\n\n| Namespace | Method | Description |\n|-----------|--------|-------------|\n| `client.search` | `.books(params)` | Search bookstore |\n| `client.search` | `.all(params)` | Async generator over all search results |\n| `client.book` | `.info({bookId})` | Book details |\n| `client.book` | `.chapters({bookId})` | Table of contents |\n| `client.book` | `.progress({bookId})` | Reading progress |\n| `client.shelf` | `.sync()` | Full bookshelf |\n| `client.notebook` | `.list(params?)` | Notebooks page |\n| `client.notebook` | `.all(options?)` | Async generator over all notebooks |\n| `client.bookmark` | `.list({bookId})` | Highlights for a book |\n| `client.bestbookmarks` | `.all({bookId})` | Popular highlights |\n| `client.underlines` | `.stats({bookId, chapterUid})` | Highlight popularity per chapter |\n| `client.readreviews` | `.forRange(params)` | Thoughts under highlights |\n| `client.readreviews` | `.single({reviewId})` | Single thought detail |\n| `client.review` | `.list({bookId})` | Public reviews |\n| `client.review` | `.all({bookId})` | Async generator over all reviews |\n| `client.review` | `.mine({bookid})` | My thoughts/reviews |\n| `client.review` | `.single({reviewId})` | Single review detail |\n| `client.readdata` | `.detail({mode})` | Reading statistics |\n| `client.discover` | `.recommend(params?)` | Personalized recommendations |\n| `client.discover` | `.recommendAll(params?)` | Async generator over all recs |\n| `client.discover` | `.similar({bookId})` | Similar books |\n| `client.discover` | `.similarAll({bookId})` | Async generator over all similar |\n| `client.profile` | `.summary()` | Shelf + progress summary |\n\n## Utilities\n\n```ts\nimport { formatDate, formatDuration, toDate } from '@dorakika/weread-api'\nimport { bookLink, chapterLink, highlightLink } from '@dorakika/weread-api'\n\nformatDate(1715678901)    // → '2024-05-14'\nformatDuration(3661)       // → '1小时1分钟'\nbookLink('abc123')         // → 'weread://reading?bId=abc123'\n```\n\n## Error handling\n\n```ts\nimport { WereadError, WereadAuthError, WereadHttpError } from '@dorakika/weread-api'\n\ntry {\n  await client.search.books({ keyword: '三体' })\n} catch (err) {\n  if (err instanceof WereadAuthError) {\n    console.error('Set WEREAD_API_KEY')\n  } else if (err instanceof WereadError) {\n    if (err.upgradeInfo) console.warn('Upgrade:', err.upgradeInfo.message)\n    console.error(`API error [${err.errcode}]: ${err.message}`)\n  }\n}\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-a68a6066150d2f0f25dc82aa49b7f374"}