pixiv Unofficial API Library for TypeScript
This is NOT a fork of @ibaraki-douji/pixivts. However, it is used as a reference.
- Zero runtime dependencies — no axios, no zod at runtime; uses native
fetch - Result-typed API — every method returns
Result<T, PixivError>; no thrown exceptions for API errors - Automatic token refresh — exchanges the refresh token for an access token on startup, and retries on 401
- ESM + CJS dual output — works in Node.js ESM/CJS and edge runtimes
- Paginated results —
PaginatedResultAsyncwith.pages()/.items()async generators for multi-page iteration - Resource-based namespaces —
illusts,novels,users,manga,ugoira,images - Optional MySQL recorder —
@book000/pixivts-db-mysqlpersists every API response via Drizzle ORM
| Package | Description |
|---|---|
@book000/pixivts |
Core API client — zero runtime dependencies, Result-typed, ESM + CJS |
@book000/pixivts-db-mysql |
Optional MySQL recorder using Drizzle ORM |
npm install @book000/pixivtsimport { PixivClient } from '@book000/pixivts'
const client = await PixivClient.of(process.env.PIXIV_REFRESH_TOKEN!)
const result = await client.illusts.detail({ illustId: 12345 })
if (result.isOk) {
console.log(result.value.illust.title)
}- Getting Started — authentication, Result type, error handling
- Pagination —
.items()/.pages(), cursor-based resume - Option Constants — enum-like
BookmarkRestrict.PUBLICetc. - MySQL Recorder —
@book000/pixivts-db-mysqlsetup and query helpers - Migration Guide — migrating from ≤ 0.55.1 to ≥ 0.56.2
- API Reference — full TypeDoc reference
This project is licensed under the MIT License