@book000/pixivts 0.55.0 → 0.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +115 -19
- package/dist/index.cjs +1317 -0
- package/dist/index.d.cts +1659 -0
- package/dist/index.d.ts +1659 -45
- package/dist/index.js +1304 -65
- package/package.json +35 -72
- package/dist/checks.d.ts +0 -19
- package/dist/checks.d.ts.map +0 -1
- package/dist/checks.js +0 -85
- package/dist/checks.js.map +0 -1
- package/dist/checks.test.d.ts +0 -2
- package/dist/checks.test.d.ts.map +0 -1
- package/dist/checks.test.js +0 -306
- package/dist/checks.test.js.map +0 -1
- package/dist/http-client.d.ts +0 -66
- package/dist/http-client.d.ts.map +0 -1
- package/dist/http-client.js +0 -138
- package/dist/http-client.js.map +0 -1
- package/dist/http-client.test.d.ts +0 -2
- package/dist/http-client.test.d.ts.map +0 -1
- package/dist/http-client.test.js +0 -149
- package/dist/http-client.test.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/options.d.ts +0 -317
- package/dist/options.d.ts.map +0 -1
- package/dist/options.js +0 -222
- package/dist/options.js.map +0 -1
- package/dist/options.test.d.ts +0 -2
- package/dist/options.test.d.ts.map +0 -1
- package/dist/options.test.js +0 -117
- package/dist/options.test.js.map +0 -1
- package/dist/pixiv.d.ts +0 -317
- package/dist/pixiv.d.ts.map +0 -1
- package/dist/pixiv.js +0 -810
- package/dist/pixiv.js.map +0 -1
- package/dist/pixiv.test.d.ts +0 -2
- package/dist/pixiv.test.d.ts.map +0 -1
- package/dist/pixiv.test.js +0 -883
- package/dist/pixiv.test.js.map +0 -1
- package/dist/saving-responses/index.d.ts +0 -130
- package/dist/saving-responses/index.d.ts.map +0 -1
- package/dist/saving-responses/index.js +0 -263
- package/dist/saving-responses/index.js.map +0 -1
- package/dist/saving-responses/index.test.d.ts +0 -2
- package/dist/saving-responses/index.test.d.ts.map +0 -1
- package/dist/saving-responses/index.test.js +0 -468
- package/dist/saving-responses/index.test.js.map +0 -1
- package/dist/saving-responses/response-entity.d.ts +0 -16
- package/dist/saving-responses/response-entity.d.ts.map +0 -1
- package/dist/saving-responses/response-entity.js +0 -101
- package/dist/saving-responses/response-entity.js.map +0 -1
- package/dist/types/endpoints/v1/illust/bookmark/delete.d.ts +0 -14
- package/dist/types/endpoints/v1/illust/bookmark/delete.d.ts.map +0 -1
- package/dist/types/endpoints/v1/illust/bookmark/delete.js +0 -3
- package/dist/types/endpoints/v1/illust/bookmark/delete.js.map +0 -1
- package/dist/types/endpoints/v1/illust/detail.d.ts +0 -25
- package/dist/types/endpoints/v1/illust/detail.d.ts.map +0 -1
- package/dist/types/endpoints/v1/illust/detail.js +0 -20
- package/dist/types/endpoints/v1/illust/detail.js.map +0 -1
- package/dist/types/endpoints/v1/illust/ranking.d.ts +0 -51
- package/dist/types/endpoints/v1/illust/ranking.d.ts.map +0 -1
- package/dist/types/endpoints/v1/illust/ranking.js +0 -40
- package/dist/types/endpoints/v1/illust/ranking.js.map +0 -1
- package/dist/types/endpoints/v1/illust/recommended.d.ts +0 -104
- package/dist/types/endpoints/v1/illust/recommended.d.ts.map +0 -1
- package/dist/types/endpoints/v1/illust/recommended.js +0 -44
- package/dist/types/endpoints/v1/illust/recommended.js.map +0 -1
- package/dist/types/endpoints/v1/illust/series.d.ts +0 -45
- package/dist/types/endpoints/v1/illust/series.d.ts.map +0 -1
- package/dist/types/endpoints/v1/illust/series.js +0 -31
- package/dist/types/endpoints/v1/illust/series.js.map +0 -1
- package/dist/types/endpoints/v1/illust/ugoira/metadata.d.ts +0 -25
- package/dist/types/endpoints/v1/illust/ugoira/metadata.d.ts.map +0 -1
- package/dist/types/endpoints/v1/illust/ugoira/metadata.js +0 -20
- package/dist/types/endpoints/v1/illust/ugoira/metadata.js.map +0 -1
- package/dist/types/endpoints/v1/manga/recommended.d.ts +0 -72
- package/dist/types/endpoints/v1/manga/recommended.d.ts.map +0 -1
- package/dist/types/endpoints/v1/manga/recommended.js +0 -33
- package/dist/types/endpoints/v1/manga/recommended.js.map +0 -1
- package/dist/types/endpoints/v1/novel/bookmark/delete.d.ts +0 -14
- package/dist/types/endpoints/v1/novel/bookmark/delete.d.ts.map +0 -1
- package/dist/types/endpoints/v1/novel/bookmark/delete.js +0 -3
- package/dist/types/endpoints/v1/novel/bookmark/delete.js.map +0 -1
- package/dist/types/endpoints/v1/novel/ranking.d.ts +0 -47
- package/dist/types/endpoints/v1/novel/ranking.d.ts.map +0 -1
- package/dist/types/endpoints/v1/novel/ranking.js +0 -39
- package/dist/types/endpoints/v1/novel/ranking.js.map +0 -1
- package/dist/types/endpoints/v1/novel/recommended.d.ts +0 -72
- package/dist/types/endpoints/v1/novel/recommended.d.ts.map +0 -1
- package/dist/types/endpoints/v1/novel/recommended.js +0 -32
- package/dist/types/endpoints/v1/novel/recommended.js.map +0 -1
- package/dist/types/endpoints/v1/novel/related.d.ts +0 -37
- package/dist/types/endpoints/v1/novel/related.d.ts.map +0 -1
- package/dist/types/endpoints/v1/novel/related.js +0 -24
- package/dist/types/endpoints/v1/novel/related.js.map +0 -1
- package/dist/types/endpoints/v1/search/illust.d.ts +0 -109
- package/dist/types/endpoints/v1/search/illust.d.ts.map +0 -1
- package/dist/types/endpoints/v1/search/illust.js +0 -40
- package/dist/types/endpoints/v1/search/illust.js.map +0 -1
- package/dist/types/endpoints/v1/search/novel.d.ts +0 -103
- package/dist/types/endpoints/v1/search/novel.d.ts.map +0 -1
- package/dist/types/endpoints/v1/search/novel.js +0 -38
- package/dist/types/endpoints/v1/search/novel.js.map +0 -1
- package/dist/types/endpoints/v1/user/bookmarks/illust.d.ts +0 -48
- package/dist/types/endpoints/v1/user/bookmarks/illust.d.ts.map +0 -1
- package/dist/types/endpoints/v1/user/bookmarks/illust.js +0 -31
- package/dist/types/endpoints/v1/user/bookmarks/illust.js.map +0 -1
- package/dist/types/endpoints/v1/user/bookmarks/novel.d.ts +0 -44
- package/dist/types/endpoints/v1/user/bookmarks/novel.d.ts.map +0 -1
- package/dist/types/endpoints/v1/user/bookmarks/novel.js +0 -28
- package/dist/types/endpoints/v1/user/bookmarks/novel.js.map +0 -1
- package/dist/types/endpoints/v1/user/detail.d.ts +0 -44
- package/dist/types/endpoints/v1/user/detail.d.ts.map +0 -1
- package/dist/types/endpoints/v1/user/detail.js +0 -26
- package/dist/types/endpoints/v1/user/detail.js.map +0 -1
- package/dist/types/endpoints/v1/user/follow/add.d.ts +0 -24
- package/dist/types/endpoints/v1/user/follow/add.d.ts.map +0 -1
- package/dist/types/endpoints/v1/user/follow/add.js +0 -3
- package/dist/types/endpoints/v1/user/follow/add.js.map +0 -1
- package/dist/types/endpoints/v1/user/follow/delete.d.ts +0 -14
- package/dist/types/endpoints/v1/user/follow/delete.d.ts.map +0 -1
- package/dist/types/endpoints/v1/user/follow/delete.js +0 -3
- package/dist/types/endpoints/v1/user/follow/delete.js.map +0 -1
- package/dist/types/endpoints/v1/user/following.d.ts +0 -38
- package/dist/types/endpoints/v1/user/following.d.ts.map +0 -1
- package/dist/types/endpoints/v1/user/following.js +0 -26
- package/dist/types/endpoints/v1/user/following.js.map +0 -1
- package/dist/types/endpoints/v1/user/illusts.d.ts +0 -51
- package/dist/types/endpoints/v1/user/illusts.d.ts.map +0 -1
- package/dist/types/endpoints/v1/user/illusts.js +0 -31
- package/dist/types/endpoints/v1/user/illusts.js.map +0 -1
- package/dist/types/endpoints/v1/user/novels.d.ts +0 -43
- package/dist/types/endpoints/v1/user/novels.d.ts.map +0 -1
- package/dist/types/endpoints/v1/user/novels.js +0 -29
- package/dist/types/endpoints/v1/user/novels.js.map +0 -1
- package/dist/types/endpoints/v2/illust/bookmark/add.d.ts +0 -28
- package/dist/types/endpoints/v2/illust/bookmark/add.d.ts.map +0 -1
- package/dist/types/endpoints/v2/illust/bookmark/add.js +0 -3
- package/dist/types/endpoints/v2/illust/bookmark/add.js.map +0 -1
- package/dist/types/endpoints/v2/illust/related.d.ts +0 -48
- package/dist/types/endpoints/v2/illust/related.d.ts.map +0 -1
- package/dist/types/endpoints/v2/illust/related.js +0 -32
- package/dist/types/endpoints/v2/illust/related.js.map +0 -1
- package/dist/types/endpoints/v2/novel/bookmark/add.d.ts +0 -27
- package/dist/types/endpoints/v2/novel/bookmark/add.d.ts.map +0 -1
- package/dist/types/endpoints/v2/novel/bookmark/add.js +0 -3
- package/dist/types/endpoints/v2/novel/bookmark/add.js.map +0 -1
- package/dist/types/endpoints/v2/novel/detail.d.ts +0 -25
- package/dist/types/endpoints/v2/novel/detail.d.ts.map +0 -1
- package/dist/types/endpoints/v2/novel/detail.js +0 -20
- package/dist/types/endpoints/v2/novel/detail.js.map +0 -1
- package/dist/types/endpoints/v2/novel/series.d.ts +0 -49
- package/dist/types/endpoints/v2/novel/series.d.ts.map +0 -1
- package/dist/types/endpoints/v2/novel/series.js +0 -31
- package/dist/types/endpoints/v2/novel/series.js.map +0 -1
- package/dist/types/endpoints/webview/v2/novel.d.ts +0 -21
- package/dist/types/endpoints/webview/v2/novel.d.ts.map +0 -1
- package/dist/types/endpoints/webview/v2/novel.js +0 -18
- package/dist/types/endpoints/webview/v2/novel.js.map +0 -1
- package/dist/types/error-response.d.ts +0 -31
- package/dist/types/error-response.d.ts.map +0 -1
- package/dist/types/error-response.js +0 -3
- package/dist/types/error-response.js.map +0 -1
- package/dist/types/errors.d.ts +0 -7
- package/dist/types/errors.d.ts.map +0 -1
- package/dist/types/errors.js +0 -14
- package/dist/types/errors.js.map +0 -1
- package/dist/types/pixiv-common.d.ts +0 -103
- package/dist/types/pixiv-common.d.ts.map +0 -1
- package/dist/types/pixiv-common.js +0 -68
- package/dist/types/pixiv-common.js.map +0 -1
- package/dist/types/pixiv-illust-series.d.ts +0 -56
- package/dist/types/pixiv-illust-series.d.ts.map +0 -1
- package/dist/types/pixiv-illust-series.js +0 -26
- package/dist/types/pixiv-illust-series.js.map +0 -1
- package/dist/types/pixiv-illust.d.ts +0 -180
- package/dist/types/pixiv-illust.d.ts.map +0 -1
- package/dist/types/pixiv-illust.js +0 -56
- package/dist/types/pixiv-illust.js.map +0 -1
- package/dist/types/pixiv-novel-series.d.ts +0 -84
- package/dist/types/pixiv-novel-series.d.ts.map +0 -1
- package/dist/types/pixiv-novel-series.js +0 -43
- package/dist/types/pixiv-novel-series.js.map +0 -1
- package/dist/types/pixiv-novel.d.ts +0 -131
- package/dist/types/pixiv-novel.d.ts.map +0 -1
- package/dist/types/pixiv-novel.js +0 -44
- package/dist/types/pixiv-novel.js.map +0 -1
- package/dist/types/pixiv-ugoira.d.ts +0 -50
- package/dist/types/pixiv-ugoira.d.ts.map +0 -1
- package/dist/types/pixiv-ugoira.js +0 -34
- package/dist/types/pixiv-ugoira.js.map +0 -1
- package/dist/types/pixiv-user.d.ts +0 -212
- package/dist/types/pixiv-user.d.ts.map +0 -1
- package/dist/types/pixiv-user.js +0 -118
- package/dist/types/pixiv-user.js.map +0 -1
- package/dist/utils.d.ts +0 -3
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -15
- package/dist/utils.js.map +0 -1
- package/dist/utils.test.d.ts +0 -2
- package/dist/utils.test.d.ts.map +0 -1
- package/dist/utils.test.js +0 -15
- package/dist/utils.test.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,35 +1,131 @@
|
|
|
1
|
-
# pixivts
|
|
1
|
+
# @book000/pixivts
|
|
2
2
|
|
|
3
|
-
[pixiv](https://www.pixiv.net/) Unofficial API Library for TypeScript
|
|
3
|
+
[pixiv](https://www.pixiv.net/) Unofficial API Library for TypeScript.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```shell
|
|
8
|
+
npm install @book000/pixivts
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @book000/pixivts
|
|
11
|
+
# or
|
|
12
|
+
yarn add @book000/pixivts
|
|
13
|
+
```
|
|
8
14
|
|
|
9
|
-
|
|
15
|
+
## Features
|
|
10
16
|
|
|
11
|
-
|
|
17
|
+
- **Zero runtime dependencies** — no axios, no zod at runtime; uses native `fetch`
|
|
18
|
+
- **Result-typed API** — every method returns `Result<T, PixivError>` (no thrown exceptions)
|
|
19
|
+
- **ESM + CJS dual output** — works in Node.js (ESM/CJS) and edge runtimes
|
|
20
|
+
- **Paginated results** — `PaginatedResultAsync` with async generator for multi-page iteration
|
|
21
|
+
- **Resource-based API** — `illusts`, `novels`, `users`, `manga`, `ugoira`, `images` namespaces
|
|
22
|
+
- **Token refresh** — automatic refresh-token → access-token exchange on startup and 401 retry
|
|
12
23
|
|
|
13
|
-
|
|
14
|
-
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { PixivClient } from '@book000/pixivts'
|
|
28
|
+
|
|
29
|
+
const client = await PixivClient.of(process.env.PIXIV_REFRESH_TOKEN!)
|
|
30
|
+
|
|
31
|
+
// Fetch a single illust
|
|
32
|
+
const result = await client.illusts.detail({ illustId: 12345 })
|
|
33
|
+
if (result.isOk) {
|
|
34
|
+
console.log(result.value.illust.title)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Search illusts (single page)
|
|
38
|
+
const searchResult = await client.illusts.search({ word: 'hatsune miku' })
|
|
39
|
+
if (searchResult.isOk) {
|
|
40
|
+
for (const illust of searchResult.value.illusts) {
|
|
41
|
+
console.log(illust.id, illust.title)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Iterate over all pages
|
|
46
|
+
for await (const page of client.illusts.search({ word: 'hatsune miku' }).pages()) {
|
|
47
|
+
for (const illust of page.illusts) {
|
|
48
|
+
console.log(illust.id, illust.title)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Iterate over all items across pages (async generator — throws on fetch error)
|
|
53
|
+
for await (const illust of client.illusts.search({ word: 'hatsune miku' }).items()) {
|
|
54
|
+
console.log(illust.id, illust.title)
|
|
55
|
+
}
|
|
15
56
|
```
|
|
16
57
|
|
|
17
|
-
|
|
58
|
+
## API
|
|
18
59
|
|
|
19
|
-
|
|
20
|
-
|
|
60
|
+
### `PixivClient.of(refreshToken, opts?)`
|
|
61
|
+
|
|
62
|
+
Creates a `PixivClient` by exchanging the given refresh token for an access token.
|
|
63
|
+
|
|
64
|
+
| Option | Type | Default | Description |
|
|
65
|
+
|---|---|---|---|
|
|
66
|
+
| `refreshToken` | `string` | — | pixiv OAuth refresh token |
|
|
67
|
+
| `opts.retry.maxRetries` | `number` | `3` | Max 429 retry attempts |
|
|
68
|
+
| `opts.retry.waitMs` | `number` | `10000` | Default wait (ms) when no `Retry-After` header is present |
|
|
69
|
+
| `opts.onResponse` | `ResponseInterceptor` | — | Called after every API response (used by `@book000/pixivts-db-mysql`) |
|
|
70
|
+
|
|
71
|
+
### Resources
|
|
72
|
+
|
|
73
|
+
| Namespace | Methods |
|
|
74
|
+
|---|---|
|
|
75
|
+
| `illusts` | `detail`, `related`, `search`, `ranking`, `recommended`, `series`, `bookmarkAdd`, `bookmarkDelete` |
|
|
76
|
+
| `novels` | `detail`, `text`, `related`, `search`, `ranking`, `recommended`, `series`, `bookmarkAdd`, `bookmarkDelete` |
|
|
77
|
+
| `users` | `detail`, `illusts`, `novels`, `following`, `followAdd`, `followDelete` |
|
|
78
|
+
| `users.bookmarks` | `illusts`, `novels` |
|
|
79
|
+
| `manga` | `recommended` |
|
|
80
|
+
| `ugoira` | `metadata` |
|
|
81
|
+
| `images` | `fetch` |
|
|
82
|
+
|
|
83
|
+
### Error Handling
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import type { PixivError } from '@book000/pixivts'
|
|
87
|
+
|
|
88
|
+
const result = await client.illusts.detail({ illustId: 12345 })
|
|
89
|
+
|
|
90
|
+
if (result.isErr) {
|
|
91
|
+
const err: PixivError = result.error
|
|
92
|
+
switch (err.type) {
|
|
93
|
+
case 'rate_limit':
|
|
94
|
+
console.error(`Rate limited. Retry after ${err.retryAfter}ms`)
|
|
95
|
+
break
|
|
96
|
+
case 'auth_failed':
|
|
97
|
+
console.error(`Auth failed with status ${err.status}`)
|
|
98
|
+
break
|
|
99
|
+
case 'api_error':
|
|
100
|
+
console.error(`API error ${err.status}`)
|
|
101
|
+
break
|
|
102
|
+
case 'network':
|
|
103
|
+
console.error('Network error', err.cause)
|
|
104
|
+
break
|
|
105
|
+
}
|
|
106
|
+
}
|
|
21
107
|
```
|
|
22
108
|
|
|
23
|
-
|
|
109
|
+
### Result API
|
|
24
110
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
111
|
+
```typescript
|
|
112
|
+
// Transform on success
|
|
113
|
+
const title = result.map((data) => data.illust.title)
|
|
114
|
+
|
|
115
|
+
// Provide a fallback on error
|
|
116
|
+
const titleOrFallback = result.unwrapOr('Unknown')
|
|
117
|
+
|
|
118
|
+
// Match both branches
|
|
119
|
+
const message = result.match(
|
|
120
|
+
(data) => `Title: ${data.illust.title}`,
|
|
121
|
+
(err) => `Error: ${err.type}`,
|
|
122
|
+
)
|
|
123
|
+
```
|
|
28
124
|
|
|
29
|
-
##
|
|
125
|
+
## API Documentation
|
|
30
126
|
|
|
31
|
-
|
|
127
|
+
Full API reference: <https://book000.github.io/pixivts/>
|
|
32
128
|
|
|
33
|
-
##
|
|
129
|
+
## License
|
|
34
130
|
|
|
35
|
-
This project is licensed under the [MIT License](LICENSE)
|
|
131
|
+
This project is licensed under the [MIT License](../../LICENSE)
|