@book000/pixivts 0.60.0 → 0.60.1
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/dist/index.cjs +1529 -1448
- package/dist/index.d.cts +1272 -1327
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +1272 -1327
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1530 -1446
- package/dist/index.js.map +1 -0
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/result.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Zero-dependency Result / ResultAsync implementation.
|
|
3
4
|
*
|
|
@@ -17,41 +18,41 @@
|
|
|
17
18
|
*/
|
|
18
19
|
/** Successful result carrying `value`. */
|
|
19
20
|
interface OkResult<T> {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
21
|
+
/** Always `true` — use this to narrow the union to `OkResult<T>`. */
|
|
22
|
+
readonly isOk: true;
|
|
23
|
+
/** Always `false` — use this to narrow the union to `OkResult<T>`. */
|
|
24
|
+
readonly isErr: false;
|
|
25
|
+
/** The success value. */
|
|
26
|
+
readonly value: T;
|
|
27
|
+
/** Returns an `OkResult` with `fn(value)`. */
|
|
28
|
+
map<U>(fn: (value: T) => U): OkResult<U>;
|
|
29
|
+
/** Returns `this` unchanged. */
|
|
30
|
+
mapErr<F>(_fn: (error: never) => F): OkResult<T>;
|
|
31
|
+
/** Calls `fn(value)` and returns its Result. */
|
|
32
|
+
andThen<U, F>(fn: (value: T) => Result<U, F>): Result<U, F>;
|
|
33
|
+
/** Calls `onOk` and returns its result. */
|
|
34
|
+
match<U>(onOk: (value: T) => U, _onErr: (error: never) => U): U;
|
|
35
|
+
/** Returns `value`. */
|
|
36
|
+
unwrapOr(_fallback: T): T;
|
|
36
37
|
}
|
|
37
38
|
/** Failed result carrying `error`. */
|
|
38
39
|
interface ErrResult<E> {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
40
|
+
/** Always `false` — use this to narrow the union to `ErrResult<E>`. */
|
|
41
|
+
readonly isOk: false;
|
|
42
|
+
/** Always `true` — use this to narrow the union to `ErrResult<E>`. */
|
|
43
|
+
readonly isErr: true;
|
|
44
|
+
/** The error value. */
|
|
45
|
+
readonly error: E;
|
|
46
|
+
/** Returns `this` unchanged. */
|
|
47
|
+
map<U>(_fn: (value: never) => U): ErrResult<E>;
|
|
48
|
+
/** Returns an `ErrResult` with `fn(error)`. */
|
|
49
|
+
mapErr<F>(fn: (error: E) => F): ErrResult<F>;
|
|
50
|
+
/** Returns `this` unchanged. */
|
|
51
|
+
andThen<U, F>(_fn: (value: never) => Result<U, F>): ErrResult<E>;
|
|
52
|
+
/** Calls `onErr` and returns its result. */
|
|
53
|
+
match<U>(_onOk: (value: never) => U, onErr: (error: E) => U): U;
|
|
54
|
+
/** Returns `fallback`. */
|
|
55
|
+
unwrapOr<T>(fallback: T): T;
|
|
55
56
|
}
|
|
56
57
|
/** A value that is either `OkResult<T>` or `ErrResult<E>`. */
|
|
57
58
|
type Result<T, E> = OkResult<T> | ErrResult<E>;
|
|
@@ -80,64 +81,65 @@ declare function err<E>(error: E): ErrResult<E>;
|
|
|
80
81
|
* ```
|
|
81
82
|
*/
|
|
82
83
|
declare class ResultAsync<T, E> implements PromiseLike<Result<T, E>> {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
|
|
84
|
+
private readonly _promise;
|
|
85
|
+
constructor(promise: Promise<Result<T, E>>);
|
|
86
|
+
then<TResult1 = Result<T, E>, TResult2 = never>(onfulfilled?: ((value: Result<T, E>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
|
|
87
|
+
/**
|
|
88
|
+
* Wraps a `Promise<T>` into a `ResultAsync<T, E>`.
|
|
89
|
+
*
|
|
90
|
+
* If the promise rejects, `onError` maps the rejection reason to `E`.
|
|
91
|
+
*
|
|
92
|
+
* @param promise - The promise to wrap
|
|
93
|
+
* @param onError - Error mapper
|
|
94
|
+
*/
|
|
95
|
+
static fromPromise<T, E>(promise: Promise<T>, onError: (reason: unknown) => E): ResultAsync<T, E>;
|
|
96
|
+
/**
|
|
97
|
+
* Wraps an already-resolved `Result<T, E>` into a `ResultAsync<T, E>`.
|
|
98
|
+
*
|
|
99
|
+
* @param result - The result to wrap
|
|
100
|
+
*/
|
|
101
|
+
static fromResult<T, E>(result: Result<T, E>): ResultAsync<T, E>;
|
|
102
|
+
/**
|
|
103
|
+
* Transforms the success value.
|
|
104
|
+
*
|
|
105
|
+
* If the inner result is `Err`, `fn` is not called.
|
|
106
|
+
*
|
|
107
|
+
* @param fn - Synchronous mapper
|
|
108
|
+
*/
|
|
109
|
+
map<U>(fn: (value: T) => U): ResultAsync<U, E>;
|
|
110
|
+
/**
|
|
111
|
+
* Transforms the error value.
|
|
112
|
+
*
|
|
113
|
+
* If the inner result is `Ok`, `fn` is not called.
|
|
114
|
+
*
|
|
115
|
+
* @param fn - Synchronous error mapper
|
|
116
|
+
*/
|
|
117
|
+
mapErr<F>(fn: (error: E) => F): ResultAsync<T, F>;
|
|
118
|
+
/**
|
|
119
|
+
* Chains another async operation that may fail.
|
|
120
|
+
*
|
|
121
|
+
* If the inner result is `Err`, `fn` is not called.
|
|
122
|
+
*
|
|
123
|
+
* @param fn - Async mapper that returns a `ResultAsync<U, F>`
|
|
124
|
+
*/
|
|
125
|
+
andThen<U, F>(fn: (value: T) => ResultAsync<U, F> | Result<U, F>): ResultAsync<U, E | F>;
|
|
126
|
+
/**
|
|
127
|
+
* Pattern-matches on success / failure.
|
|
128
|
+
*
|
|
129
|
+
* @param onOk - Called with the success value
|
|
130
|
+
* @param onErr - Called with the error value
|
|
131
|
+
* @returns A `Promise<U>`
|
|
132
|
+
*/
|
|
133
|
+
match<U>(onOk: (value: T) => U | Promise<U>, onErr: (error: E) => U | Promise<U>): Promise<U>;
|
|
134
|
+
/**
|
|
135
|
+
* Returns the success value, or `fallback` if the result is `Err`.
|
|
136
|
+
*
|
|
137
|
+
* @param fallback - The fallback value
|
|
138
|
+
*/
|
|
139
|
+
unwrapOr(fallback: T): Promise<T>;
|
|
140
|
+
}
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/auth.d.ts
|
|
141
143
|
/**
|
|
142
144
|
* Authentication manager for the pixiv API.
|
|
143
145
|
*
|
|
@@ -150,12 +152,12 @@ declare class ResultAsync<T, E> implements PromiseLike<Result<T, E>> {
|
|
|
150
152
|
*/
|
|
151
153
|
/** Auth credentials returned by the pixiv token endpoint. */
|
|
152
154
|
interface AuthCredentials {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
/** Numeric user ID returned as a string by the token endpoint. */
|
|
156
|
+
userId: string;
|
|
157
|
+
/** Short-lived bearer token for API requests. */
|
|
158
|
+
accessToken: string;
|
|
159
|
+
/** Long-lived token used to obtain new access tokens. */
|
|
160
|
+
refreshToken: string;
|
|
159
161
|
}
|
|
160
162
|
/**
|
|
161
163
|
* Manages access tokens for the pixiv API.
|
|
@@ -165,29 +167,30 @@ interface AuthCredentials {
|
|
|
165
167
|
* via the pixiv OAuth endpoint.
|
|
166
168
|
*/
|
|
167
169
|
declare class AuthManager {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
|
|
170
|
+
#private;
|
|
171
|
+
userId: string;
|
|
172
|
+
constructor(credentials: AuthCredentials);
|
|
173
|
+
/** Returns the current access token. */
|
|
174
|
+
get accessToken(): string;
|
|
175
|
+
/** Returns the current refresh token. */
|
|
176
|
+
get refreshToken(): string;
|
|
177
|
+
/**
|
|
178
|
+
* Exchanges the stored refresh token for a fresh access token.
|
|
179
|
+
*
|
|
180
|
+
* Updates the internal credentials on success.
|
|
181
|
+
* Throws if the token endpoint returns a non-200 response.
|
|
182
|
+
*/
|
|
183
|
+
refresh(): Promise<void>;
|
|
184
|
+
/**
|
|
185
|
+
* Creates an `AuthManager` by performing the initial token refresh.
|
|
186
|
+
*
|
|
187
|
+
* @param refreshToken - Pixiv refresh token
|
|
188
|
+
* @returns Initialized `AuthManager`
|
|
189
|
+
*/
|
|
190
|
+
static login(refreshToken: string): Promise<AuthManager>;
|
|
191
|
+
}
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region src/interceptor.d.ts
|
|
191
194
|
/**
|
|
192
195
|
* Response interceptor types for the pixiv API client.
|
|
193
196
|
*
|
|
@@ -209,24 +212,24 @@ type HttpMethod = 'GET' | 'POST';
|
|
|
209
212
|
* HTTP call made by the pixiv client.
|
|
210
213
|
*/
|
|
211
214
|
interface ResponseRecord {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
215
|
+
/** HTTP method used for the request. */
|
|
216
|
+
method: HttpMethod;
|
|
217
|
+
/** API endpoint path (e.g. "/v1/illust/detail"). */
|
|
218
|
+
endpoint: string;
|
|
219
|
+
/** Full request URL including query string (null if unavailable). */
|
|
220
|
+
url: string | null;
|
|
221
|
+
/** JSON-serialized request headers (null if unavailable). */
|
|
222
|
+
requestHeaders: string | null;
|
|
223
|
+
/** URL-encoded request body for POST requests (null for GET). */
|
|
224
|
+
requestBody: string | null;
|
|
225
|
+
/** Whether the response body was parsed as JSON or left as plain text. */
|
|
226
|
+
responseType: 'JSON' | 'TEXT';
|
|
227
|
+
/** HTTP response status code. */
|
|
228
|
+
statusCode: number;
|
|
229
|
+
/** JSON-serialized response headers (null if unavailable). */
|
|
230
|
+
responseHeaders: string | null;
|
|
231
|
+
/** Serialized response body. */
|
|
232
|
+
responseBody: string;
|
|
230
233
|
}
|
|
231
234
|
/**
|
|
232
235
|
* A callback invoked after every successful API response.
|
|
@@ -236,7 +239,8 @@ interface ResponseRecord {
|
|
|
236
239
|
* asynchronously if persistence latency matters.
|
|
237
240
|
*/
|
|
238
241
|
type ResponseInterceptor = (record: ResponseRecord) => void | Promise<void>;
|
|
239
|
-
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region src/errors.d.ts
|
|
240
244
|
/**
|
|
241
245
|
* Discriminated union of all errors that can occur when using the pixiv API client.
|
|
242
246
|
*
|
|
@@ -249,27 +253,18 @@ type ResponseInterceptor = (record: ResponseRecord) => void | Promise<void>;
|
|
|
249
253
|
* ```
|
|
250
254
|
*/
|
|
251
255
|
type PixivError = {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
/** Retry-After duration parsed from the last 429 response (milliseconds). */
|
|
255
|
-
retryAfter: number;
|
|
256
|
+
/** The request hit the rate limit and exhausted all retries. */type: 'rate_limit'; /** Retry-After duration parsed from the last 429 response (milliseconds). */
|
|
257
|
+
retryAfter: number;
|
|
256
258
|
} | {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
/** HTTP status code (always 401). */
|
|
260
|
-
status: number;
|
|
259
|
+
/** Authentication failed (401 response that could not be refreshed). */type: 'auth_failed'; /** HTTP status code (always 401). */
|
|
260
|
+
status: number;
|
|
261
261
|
} | {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
/** The underlying error thrown by fetch. */
|
|
265
|
-
cause: unknown;
|
|
262
|
+
/** A network-level error occurred (fetch threw). */type: 'network'; /** The underlying error thrown by fetch. */
|
|
263
|
+
cause: unknown;
|
|
266
264
|
} | {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
status: number;
|
|
271
|
-
/** Parsed response body (object if JSON, string otherwise). */
|
|
272
|
-
body: unknown;
|
|
265
|
+
/** The API returned a non-2xx status code other than 401/429. */type: 'api_error'; /** HTTP status code. */
|
|
266
|
+
status: number; /** Parsed response body (object if JSON, string otherwise). */
|
|
267
|
+
body: unknown;
|
|
273
268
|
};
|
|
274
269
|
/**
|
|
275
270
|
* An `Error` subclass that wraps a `PixivError` for use in thrown contexts
|
|
@@ -290,9 +285,9 @@ type PixivError = {
|
|
|
290
285
|
* ```
|
|
291
286
|
*/
|
|
292
287
|
declare class PixivFetchError extends Error {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
288
|
+
/** The underlying structured `PixivError`. */
|
|
289
|
+
readonly pixivError: PixivError;
|
|
290
|
+
constructor(pixivError: PixivError);
|
|
296
291
|
}
|
|
297
292
|
/** Creates a rate-limit error. */
|
|
298
293
|
declare function rateLimitError(retryAfter: number): PixivError;
|
|
@@ -302,23 +297,14 @@ declare function authFailedError(status: number): PixivError;
|
|
|
302
297
|
declare function networkError(cause: unknown): PixivError;
|
|
303
298
|
/** Creates an API error. */
|
|
304
299
|
declare function apiError(status: number, body: unknown): PixivError;
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
* HTTP client for the pixiv API.
|
|
308
|
-
*
|
|
309
|
-
* Wraps the global `fetch` API and adds:
|
|
310
|
-
* - 429 retry with Retry-After header parsing
|
|
311
|
-
* - 401 → token refresh → single retry
|
|
312
|
-
* - Response interceptor hook (for optional DB recording)
|
|
313
|
-
* - Image fetch helper (browser UA, Referer, no auth)
|
|
314
|
-
*/
|
|
315
|
-
|
|
300
|
+
//#endregion
|
|
301
|
+
//#region src/http.d.ts
|
|
316
302
|
/** Options for controlling retry behaviour on rate-limited requests. */
|
|
317
303
|
interface RateLimitRetryOptions {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
304
|
+
/** Maximum number of retries when a 429 response is received. Defaults to 3. */
|
|
305
|
+
maxRetries: number;
|
|
306
|
+
/** Default wait time (ms) used when no Retry-After header is present. Defaults to 10_000. */
|
|
307
|
+
waitMs: number;
|
|
322
308
|
}
|
|
323
309
|
/**
|
|
324
310
|
* HTTP client for the pixiv API.
|
|
@@ -327,69 +313,57 @@ interface RateLimitRetryOptions {
|
|
|
327
313
|
* A 429 → retry loop and a 401 → refresh → retry are handled internally.
|
|
328
314
|
*/
|
|
329
315
|
declare class HttpClient {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
* PaginatedResultAsync — pagination support for the pixiv API.
|
|
374
|
-
*
|
|
375
|
-
* Extends `ResultAsync<TPage, PixivError>` so that:
|
|
376
|
-
* - `await paginated` returns the first-page `Result<TPage, PixivError>` directly
|
|
377
|
-
* - `.pages()` is an async generator that yields each page
|
|
378
|
-
* - `.items()` is an async generator that yields individual items across all pages
|
|
379
|
-
*
|
|
380
|
-
* Pagination uses the `nextUrl` field returned by list endpoints. The URL is
|
|
381
|
-
* fetched via `HttpClient.getAbsolute()` which reuses the same auth / retry /
|
|
382
|
-
* interceptor pipeline as regular requests.
|
|
383
|
-
*/
|
|
384
|
-
|
|
316
|
+
#private;
|
|
317
|
+
constructor(auth: AuthManager, options?: {
|
|
318
|
+
retry?: Partial<RateLimitRetryOptions>;
|
|
319
|
+
onResponse?: ResponseInterceptor;
|
|
320
|
+
});
|
|
321
|
+
/**
|
|
322
|
+
* Sends a GET request to the pixiv API.
|
|
323
|
+
*
|
|
324
|
+
* @param path - API endpoint path (e.g. "/v1/illust/detail")
|
|
325
|
+
* @param params - Query parameters as a URLSearchParams instance
|
|
326
|
+
* @returns `ResultAsync<T, PixivError>`
|
|
327
|
+
*/
|
|
328
|
+
get<T>(path: string, params?: URLSearchParams): ResultAsync<T, PixivError>;
|
|
329
|
+
/**
|
|
330
|
+
* Sends a POST request to the pixiv API.
|
|
331
|
+
*
|
|
332
|
+
* @param path - API endpoint path (e.g. "/v2/illust/bookmark/add")
|
|
333
|
+
* @param body - URL-encoded request body string
|
|
334
|
+
* @returns `ResultAsync<T, PixivError>`
|
|
335
|
+
*/
|
|
336
|
+
post<T>(path: string, body: string): ResultAsync<T, PixivError>;
|
|
337
|
+
/**
|
|
338
|
+
* Fetches a pixiv image URL without an Authorization header.
|
|
339
|
+
*
|
|
340
|
+
* Uses a browser User-Agent and the pixiv Referer, which are required for
|
|
341
|
+
* image CDN access. Retry and interceptor are not applied here.
|
|
342
|
+
*
|
|
343
|
+
* @param imageUrl - Full image URL
|
|
344
|
+
* @returns `ResultAsync<Response, PixivError>`
|
|
345
|
+
*/
|
|
346
|
+
fetchImage(imageUrl: string): ResultAsync<Response, PixivError>;
|
|
347
|
+
/**
|
|
348
|
+
* Sends a request to an absolute URL returned in a `next_url` field.
|
|
349
|
+
*
|
|
350
|
+
* Applies the same retry / interceptor / auth logic as `get()`.
|
|
351
|
+
*
|
|
352
|
+
* @param absoluteUrl - Full URL including query string
|
|
353
|
+
* @returns `ResultAsync<T, PixivError>`
|
|
354
|
+
*/
|
|
355
|
+
getAbsolute<T>(absoluteUrl: string): ResultAsync<T, PixivError>;
|
|
356
|
+
}
|
|
357
|
+
//#endregion
|
|
358
|
+
//#region src/paginated.d.ts
|
|
385
359
|
/**
|
|
386
360
|
* A page returned by a pixiv list endpoint.
|
|
387
361
|
*
|
|
388
362
|
* Must have a `nextUrl` field (null when there are no more pages).
|
|
389
363
|
*/
|
|
390
364
|
interface PagedResponse {
|
|
391
|
-
|
|
392
|
-
|
|
365
|
+
/** URL to the next page, or `null` when there are no more pages. */
|
|
366
|
+
nextUrl: string | null;
|
|
393
367
|
}
|
|
394
368
|
/**
|
|
395
369
|
* A `ResultAsync<TPage, PixivError>` with additional `.pages()` / `.items()`
|
|
@@ -398,42 +372,42 @@ interface PagedResponse {
|
|
|
398
372
|
* Returned by all resource methods that produce a `nextUrl` field.
|
|
399
373
|
*/
|
|
400
374
|
declare class PaginatedResultAsync<TPage extends PagedResponse, TItem> extends ResultAsync<TPage, PixivError> {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
375
|
+
#private;
|
|
376
|
+
constructor(promise: Promise<Result<TPage, PixivError>>, http: HttpClient, getItems: (page: TPage) => TItem[]);
|
|
377
|
+
/**
|
|
378
|
+
* Creates a `PaginatedResultAsync` from a `ResultAsync`.
|
|
379
|
+
*
|
|
380
|
+
* @param inner - The first-page result
|
|
381
|
+
* @param http - HTTP client for fetching subsequent pages
|
|
382
|
+
* @param getItems - Extracts item array from a page
|
|
383
|
+
*/
|
|
384
|
+
static fromResultAsync<TPage extends PagedResponse, TItem>(inner: ResultAsync<TPage, PixivError>, http: HttpClient, getItems: (page: TPage) => TItem[]): PaginatedResultAsync<TPage, TItem>;
|
|
385
|
+
/**
|
|
386
|
+
* Async generator that yields each page starting from the first.
|
|
387
|
+
*
|
|
388
|
+
* If any page fetch fails, the generator throws a `PixivFetchError`.
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* ```ts
|
|
392
|
+
* for await (const page of client.illusts.search({ word: 'cat' }).pages()) {
|
|
393
|
+
* console.log(page.illusts.length)
|
|
394
|
+
* }
|
|
395
|
+
* ```
|
|
396
|
+
*/
|
|
397
|
+
pages(): AsyncGenerator<TPage, void, unknown>;
|
|
398
|
+
/**
|
|
399
|
+
* Async generator that yields individual items across all pages.
|
|
400
|
+
*
|
|
401
|
+
* If any page fetch fails, the generator throws a `PixivFetchError`.
|
|
402
|
+
*
|
|
403
|
+
* @example
|
|
404
|
+
* ```ts
|
|
405
|
+
* for await (const illust of client.illusts.search({ word: 'cat' }).items()) {
|
|
406
|
+
* console.log(illust.title)
|
|
407
|
+
* }
|
|
408
|
+
* ```
|
|
409
|
+
*/
|
|
410
|
+
items(): AsyncGenerator<TItem, void, unknown>;
|
|
437
411
|
}
|
|
438
412
|
/**
|
|
439
413
|
* Creates an immediately-failed `PaginatedResultAsync`.
|
|
@@ -445,7 +419,8 @@ declare class PaginatedResultAsync<TPage extends PagedResponse, TItem> extends R
|
|
|
445
419
|
* @param getItems - Item extractor (used for signature compatibility)
|
|
446
420
|
*/
|
|
447
421
|
declare function failedPaginated<TPage extends PagedResponse, TItem>(error: PixivError, http: HttpClient, getItems: (page: TPage) => TItem[]): PaginatedResultAsync<TPage, TItem>;
|
|
448
|
-
|
|
422
|
+
//#endregion
|
|
423
|
+
//#region src/params.d.ts
|
|
449
424
|
/**
|
|
450
425
|
* Typed cursor parameters extracted from a pixiv `next_url`.
|
|
451
426
|
*
|
|
@@ -461,16 +436,16 @@ declare function failedPaginated<TPage extends PagedResponse, TItem>(error: Pixi
|
|
|
461
436
|
* | `lastOrder` | `GET /v2/novel/series` |
|
|
462
437
|
*/
|
|
463
438
|
interface ParsedNextUrl {
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
439
|
+
/** Cursor for `GET /v1/user/bookmarks/illust`. */
|
|
440
|
+
maxBookmarkId?: number;
|
|
441
|
+
/** Cursor for `GET /v1/illust/recommended` and `GET /v1/novel/recommended`. */
|
|
442
|
+
maxBookmarkIdForRecommend?: number;
|
|
443
|
+
/** Secondary cursor for `GET /v1/illust/recommended`. */
|
|
444
|
+
minBookmarkIdForRecentIllust?: number;
|
|
445
|
+
/** Zero-based offset for general list endpoints. */
|
|
446
|
+
offset?: number;
|
|
447
|
+
/** Cursor for `GET /v2/novel/series`. */
|
|
448
|
+
lastOrder?: number;
|
|
474
449
|
}
|
|
475
450
|
/**
|
|
476
451
|
* Parses a pixiv `next_url` into a typed cursor object.
|
|
@@ -495,7 +470,8 @@ interface ParsedNextUrl {
|
|
|
495
470
|
* @returns Typed cursor parameters; fields absent in the URL are `undefined`
|
|
496
471
|
*/
|
|
497
472
|
declare function parseNextUrl(url: string): ParsedNextUrl;
|
|
498
|
-
|
|
473
|
+
//#endregion
|
|
474
|
+
//#region src/options.d.ts
|
|
499
475
|
/**
|
|
500
476
|
* Public option constants for @book000/pixivts.
|
|
501
477
|
*
|
|
@@ -521,10 +497,10 @@ declare function parseNextUrl(url: string): ParsedNextUrl;
|
|
|
521
497
|
* - `keyword` — general keyword search (novel only)
|
|
522
498
|
*/
|
|
523
499
|
declare const SearchTarget: {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
500
|
+
readonly PARTIAL_MATCH_FOR_TAGS: "partial_match_for_tags";
|
|
501
|
+
readonly EXACT_MATCH_FOR_TAGS: "exact_match_for_tags";
|
|
502
|
+
readonly TITLE_AND_CAPTION: "title_and_caption";
|
|
503
|
+
readonly KEYWORD: "keyword";
|
|
528
504
|
};
|
|
529
505
|
/**
|
|
530
506
|
* Sort order for search results.
|
|
@@ -534,9 +510,9 @@ declare const SearchTarget: {
|
|
|
534
510
|
* - `popular_desc` — most bookmarks first (premium only)
|
|
535
511
|
*/
|
|
536
512
|
declare const SearchSort: {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
513
|
+
readonly DATE_DESC: "date_desc";
|
|
514
|
+
readonly DATE_ASC: "date_asc";
|
|
515
|
+
readonly POPULAR_DESC: "popular_desc";
|
|
540
516
|
};
|
|
541
517
|
/**
|
|
542
518
|
* Date range filter for search results.
|
|
@@ -546,9 +522,9 @@ declare const SearchSort: {
|
|
|
546
522
|
* - `within_last_month` — past 30 days
|
|
547
523
|
*/
|
|
548
524
|
declare const SearchDuration: {
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
525
|
+
readonly WITHIN_LAST_DAY: "within_last_day";
|
|
526
|
+
readonly WITHIN_LAST_WEEK: "within_last_week";
|
|
527
|
+
readonly WITHIN_LAST_MONTH: "within_last_month";
|
|
552
528
|
};
|
|
553
529
|
/**
|
|
554
530
|
* Ranking mode for illust rankings.
|
|
@@ -556,19 +532,19 @@ declare const SearchDuration: {
|
|
|
556
532
|
* R-18 modes require a premium account with R-18 content enabled.
|
|
557
533
|
*/
|
|
558
534
|
declare const RankingMode: {
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
535
|
+
readonly DAY: "day";
|
|
536
|
+
readonly DAY_MALE: "day_male";
|
|
537
|
+
readonly DAY_FEMALE: "day_female";
|
|
538
|
+
readonly WEEK_ORIGINAL: "week_original";
|
|
539
|
+
readonly WEEK_ROOKIE: "week_rookie";
|
|
540
|
+
readonly WEEK: "week";
|
|
541
|
+
readonly MONTH: "month";
|
|
542
|
+
readonly DAY_AI: "day_ai";
|
|
543
|
+
readonly DAY_R18: "day_r18";
|
|
544
|
+
readonly WEEK_R18: "week_r18";
|
|
545
|
+
readonly DAY_MALE_R18: "day_male_r18";
|
|
546
|
+
readonly DAY_FEMALE_R18: "day_female_r18";
|
|
547
|
+
readonly DAY_R18_AI: "day_r18_ai";
|
|
572
548
|
};
|
|
573
549
|
/**
|
|
574
550
|
* Ranking mode for novel rankings.
|
|
@@ -576,14 +552,14 @@ declare const RankingMode: {
|
|
|
576
552
|
* R-18 modes require a premium account with R-18 content enabled.
|
|
577
553
|
*/
|
|
578
554
|
declare const NovelRankingMode: {
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
555
|
+
readonly DAY: "day";
|
|
556
|
+
readonly WEEK: "week";
|
|
557
|
+
readonly DAY_MALE: "day_male";
|
|
558
|
+
readonly DAY_FEMALE: "day_female";
|
|
559
|
+
readonly WEEK_ROOKIE: "week_rookie";
|
|
560
|
+
readonly DAY_R18: "day_r18";
|
|
561
|
+
readonly WEEK_R18: "week_r18";
|
|
562
|
+
readonly DAY_R18_AI: "day_r18_ai";
|
|
587
563
|
};
|
|
588
564
|
/**
|
|
589
565
|
* Visibility restriction for bookmarks.
|
|
@@ -592,8 +568,8 @@ declare const NovelRankingMode: {
|
|
|
592
568
|
* - `private` — visible only to the owner
|
|
593
569
|
*/
|
|
594
570
|
declare const BookmarkRestrict: {
|
|
595
|
-
|
|
596
|
-
|
|
571
|
+
readonly PUBLIC: "public";
|
|
572
|
+
readonly PRIVATE: "private";
|
|
597
573
|
};
|
|
598
574
|
/**
|
|
599
575
|
* Visibility restriction for follows.
|
|
@@ -602,8 +578,8 @@ declare const BookmarkRestrict: {
|
|
|
602
578
|
* - `private` — visible only to the owner
|
|
603
579
|
*/
|
|
604
580
|
declare const FollowRestrict: {
|
|
605
|
-
|
|
606
|
-
|
|
581
|
+
readonly PUBLIC: "public";
|
|
582
|
+
readonly PRIVATE: "private";
|
|
607
583
|
};
|
|
608
584
|
/**
|
|
609
585
|
* OS filter used to request works compatible with the given platform.
|
|
@@ -612,8 +588,8 @@ declare const FollowRestrict: {
|
|
|
612
588
|
* - `for_android` — Android-compatible works
|
|
613
589
|
*/
|
|
614
590
|
declare const OSFilter: {
|
|
615
|
-
|
|
616
|
-
|
|
591
|
+
readonly FOR_IOS: "for_ios";
|
|
592
|
+
readonly FOR_ANDROID: "for_android";
|
|
617
593
|
};
|
|
618
594
|
/**
|
|
619
595
|
* Work type filter for user illust listings.
|
|
@@ -622,10 +598,11 @@ declare const OSFilter: {
|
|
|
622
598
|
* - `manga` — manga only
|
|
623
599
|
*/
|
|
624
600
|
declare const UserIllustType: {
|
|
625
|
-
|
|
626
|
-
|
|
601
|
+
readonly ILLUST: "illust";
|
|
602
|
+
readonly MANGA: "manga";
|
|
627
603
|
};
|
|
628
|
-
|
|
604
|
+
//#endregion
|
|
605
|
+
//#region src/types.d.ts
|
|
629
606
|
/**
|
|
630
607
|
* Public types for @book000/pixivts.
|
|
631
608
|
*
|
|
@@ -642,19 +619,19 @@ declare const UserIllustType: {
|
|
|
642
619
|
* Accessing these URLs requires setting an appropriate `Referer` header.
|
|
643
620
|
*/
|
|
644
621
|
interface ImageUrls {
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
622
|
+
/** 360×360 thumbnail */
|
|
623
|
+
squareMedium: string;
|
|
624
|
+
/** Long side ≤ 540 px */
|
|
625
|
+
medium: string;
|
|
626
|
+
/** Width ≤ 600 px, height ≤ 1200 px */
|
|
627
|
+
large: string;
|
|
628
|
+
/** Original image (present in `metaPages` entries only) */
|
|
629
|
+
original?: string;
|
|
653
630
|
}
|
|
654
631
|
/** Profile image URLs for a user. */
|
|
655
632
|
interface ProfileImageUrls {
|
|
656
|
-
|
|
657
|
-
|
|
633
|
+
/** Medium-size profile image URL. */
|
|
634
|
+
medium: string;
|
|
658
635
|
}
|
|
659
636
|
/**
|
|
660
637
|
* Minimal user info embedded in works, search results, and preview lists.
|
|
@@ -662,60 +639,60 @@ interface ProfileImageUrls {
|
|
|
662
639
|
* Full profile data is returned by GET /v1/user/detail.
|
|
663
640
|
*/
|
|
664
641
|
interface PixivUser {
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
642
|
+
/**
|
|
643
|
+
* Internal numeric user ID.
|
|
644
|
+
*
|
|
645
|
+
* NOTE: certain API endpoints return this as a string. The core library
|
|
646
|
+
* normalises it to `number` before returning it to callers.
|
|
647
|
+
*/
|
|
648
|
+
id: number;
|
|
649
|
+
/** Display name shown on the user's profile. */
|
|
650
|
+
name: string;
|
|
651
|
+
/** Login account name (distinct from the display `name`). */
|
|
652
|
+
account: string;
|
|
653
|
+
/** Set of profile image URLs at different sizes. */
|
|
654
|
+
profileImageUrls: ProfileImageUrls;
|
|
655
|
+
/** Whether the authenticated user follows this user. */
|
|
656
|
+
isFollowed?: boolean;
|
|
657
|
+
/** Whether this user has blocked access by the authenticated user. */
|
|
658
|
+
isAccessBlockingUser?: boolean;
|
|
659
|
+
/** Whether this user accepts illustration commission requests. */
|
|
660
|
+
isAcceptRequest?: boolean;
|
|
684
661
|
}
|
|
685
662
|
/** Tag on a work. */
|
|
686
663
|
interface Tag {
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
664
|
+
/** Tag name in Japanese. */
|
|
665
|
+
name: string;
|
|
666
|
+
/** Translated tag name, or `null` if no translation is available. */
|
|
667
|
+
translatedName: string | null;
|
|
668
|
+
/** Whether the tag was added by the work's uploader. */
|
|
669
|
+
addedByUploadedUser?: boolean;
|
|
693
670
|
}
|
|
694
671
|
/** Series information embedded in a work item. */
|
|
695
672
|
interface Series {
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
673
|
+
/** Series ID. */
|
|
674
|
+
id: number;
|
|
675
|
+
/** Series title. */
|
|
676
|
+
title: string;
|
|
700
677
|
}
|
|
701
678
|
/** Privacy-policy blurb returned by recommended endpoints. */
|
|
702
679
|
interface PrivacyPolicy {
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
680
|
+
/** Policy version string. */
|
|
681
|
+
version?: string;
|
|
682
|
+
/** Human-readable policy notice. */
|
|
683
|
+
message?: string;
|
|
684
|
+
/** URL to the full privacy-policy page. */
|
|
685
|
+
url?: string;
|
|
709
686
|
}
|
|
710
687
|
/** Original-image URL for a single-page illust. */
|
|
711
688
|
interface MetaSinglePage {
|
|
712
|
-
|
|
713
|
-
|
|
689
|
+
/** Direct URL to the original-resolution image. */
|
|
690
|
+
originalImageUrl: string;
|
|
714
691
|
}
|
|
715
692
|
/** Per-page image URLs for a multi-page work (manga). */
|
|
716
693
|
interface MetaPages {
|
|
717
|
-
|
|
718
|
-
|
|
694
|
+
/** Full set of image URLs for this page, including the original. */
|
|
695
|
+
imageUrls: Required<ImageUrls>;
|
|
719
696
|
}
|
|
720
697
|
/**
|
|
721
698
|
* A pixiv illust or manga work item as returned by the API.
|
|
@@ -724,95 +701,95 @@ interface MetaPages {
|
|
|
724
701
|
* GET /v1/illust/ranking, GET /v1/illust/recommended, etc.
|
|
725
702
|
*/
|
|
726
703
|
interface PixivIllustItem {
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
704
|
+
/**
|
|
705
|
+
* Work ID.
|
|
706
|
+
*
|
|
707
|
+
* Illusts and novels are numbered in separate sequences — the same ID
|
|
708
|
+
* can appear in both.
|
|
709
|
+
*/
|
|
710
|
+
id: number;
|
|
711
|
+
/** Title of the work. */
|
|
712
|
+
title: string;
|
|
713
|
+
/** Work category: illustration, manga, or animated illustration. */
|
|
714
|
+
type: 'illust' | 'manga' | 'ugoira';
|
|
715
|
+
/** Thumbnail image URLs at various sizes. */
|
|
716
|
+
imageUrls: ImageUrls;
|
|
717
|
+
/** Work caption / description (may contain HTML). */
|
|
718
|
+
caption: string;
|
|
719
|
+
/** Content restriction level (0 = public, 1 = mypixiv-only, 2 = private). */
|
|
720
|
+
restrict: number;
|
|
721
|
+
/** Author of the work. */
|
|
722
|
+
user: PixivUser;
|
|
723
|
+
/** Tags attached to the work. */
|
|
724
|
+
tags: Tag[];
|
|
725
|
+
/** Creation tools listed by the author (e.g. "Photoshop"). */
|
|
726
|
+
tools: string[];
|
|
727
|
+
/** ISO 8601 date-time string of when the work was posted. */
|
|
728
|
+
createDate: string;
|
|
729
|
+
/** Number of images in a multi-page work (1 for single-page). */
|
|
730
|
+
pageCount: number;
|
|
731
|
+
/** Canvas width in pixels. */
|
|
732
|
+
width: number;
|
|
733
|
+
/** Canvas height in pixels. */
|
|
734
|
+
height: number;
|
|
735
|
+
/** Sanity / sensitivity level assigned by the pixiv content filter. */
|
|
736
|
+
sanityLevel: number;
|
|
737
|
+
/** Age restriction: 0 = all-ages, 1 = R-18, 2 = R-18G */
|
|
738
|
+
xRestrict: number;
|
|
739
|
+
/** Series this work belongs to, or `null` if not part of a series. */
|
|
740
|
+
series: Series | null;
|
|
741
|
+
/**
|
|
742
|
+
* For single-page works: `{ originalImageUrl: string }`.
|
|
743
|
+
* For multi-page works: `{}` (empty object).
|
|
744
|
+
*/
|
|
745
|
+
metaSinglePage: MetaSinglePage | Record<string, never>;
|
|
746
|
+
/** Per-page image URLs for multi-page works (empty array for single-page). */
|
|
747
|
+
metaPages: MetaPages[];
|
|
748
|
+
/** Total number of views. */
|
|
749
|
+
totalView: number;
|
|
750
|
+
/** Total number of bookmarks. */
|
|
751
|
+
totalBookmarks: number;
|
|
752
|
+
/** Whether the authenticated user has bookmarked this work. */
|
|
753
|
+
isBookmarked: boolean;
|
|
754
|
+
/** Whether the work is publicly visible. */
|
|
755
|
+
visible: boolean;
|
|
756
|
+
/** Whether the work is muted for the authenticated user. */
|
|
757
|
+
isMuted: boolean;
|
|
758
|
+
/** Total number of comments (may be absent on some endpoints). */
|
|
759
|
+
totalComments?: number;
|
|
760
|
+
/** AI-generated content flag: 0 = no AI, 1 = partial AI, 2 = fully AI */
|
|
761
|
+
illustAiType: number;
|
|
762
|
+
/** Book-style rendering flag (0 = normal, 1 = book). */
|
|
763
|
+
illustBookStyle: number;
|
|
764
|
+
/** Controls who can post comments (may be absent). */
|
|
765
|
+
commentAccessControl?: number;
|
|
766
|
+
/** Additional access-restriction attributes (may be absent). */
|
|
767
|
+
restrictionAttributes?: string[];
|
|
791
768
|
}
|
|
792
769
|
/** Illust series metadata returned by GET /v1/illust/series. */
|
|
793
770
|
interface IllustSeriesDetail {
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
771
|
+
/** Series ID. */
|
|
772
|
+
id: number;
|
|
773
|
+
/** Series title. */
|
|
774
|
+
title: string;
|
|
775
|
+
/** Series description / caption. */
|
|
776
|
+
caption: string;
|
|
777
|
+
/** Cover image URLs. */
|
|
778
|
+
coverImageUrls: {
|
|
779
|
+
medium: string;
|
|
780
|
+
};
|
|
781
|
+
/** Number of works in the series. */
|
|
782
|
+
seriesWorkCount: number;
|
|
783
|
+
/** ISO 8601 date-time string of when the series was created. */
|
|
784
|
+
createDate: string;
|
|
785
|
+
/** Canvas width of the cover image in pixels. */
|
|
786
|
+
width: number;
|
|
787
|
+
/** Canvas height of the cover image in pixels. */
|
|
788
|
+
height: number;
|
|
789
|
+
/** Author of the series. */
|
|
790
|
+
user: PixivUser;
|
|
791
|
+
/** Whether the authenticated user has added this series to their watchlist. */
|
|
792
|
+
watchlistAdded: boolean;
|
|
816
793
|
}
|
|
817
794
|
/**
|
|
818
795
|
* A pixiv novel work item as returned by the API.
|
|
@@ -820,188 +797,187 @@ interface IllustSeriesDetail {
|
|
|
820
797
|
* Returned by GET /v2/novel/detail, GET /v1/search/novel, etc.
|
|
821
798
|
*/
|
|
822
799
|
interface PixivNovelItem {
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
800
|
+
/**
|
|
801
|
+
* Work ID.
|
|
802
|
+
*
|
|
803
|
+
* Novels and illusts are numbered in separate sequences — the same ID
|
|
804
|
+
* can appear in both.
|
|
805
|
+
*/
|
|
806
|
+
id: number;
|
|
807
|
+
/** Title of the novel. */
|
|
808
|
+
title: string;
|
|
809
|
+
/** Synopsis / caption (may contain HTML). */
|
|
810
|
+
caption: string;
|
|
811
|
+
/** Content restriction level (0 = public, 1 = mypixiv-only, 2 = private). */
|
|
812
|
+
restrict: number;
|
|
813
|
+
/** Age restriction: 0 = all-ages, 1 = R-18, 2 = R-18G */
|
|
814
|
+
xRestrict: number;
|
|
815
|
+
/** Whether the novel is an original work (not fan fiction). */
|
|
816
|
+
isOriginal: boolean;
|
|
817
|
+
/** Cover image URLs. */
|
|
818
|
+
imageUrls: ImageUrls;
|
|
819
|
+
/** ISO 8601 date-time string of when the novel was posted. */
|
|
820
|
+
createDate: string;
|
|
821
|
+
/** Tags attached to the novel. */
|
|
822
|
+
tags: Tag[];
|
|
823
|
+
/** Number of pages (word-count chunks). */
|
|
824
|
+
pageCount: number;
|
|
825
|
+
/** Total character count of the novel body. */
|
|
826
|
+
textLength: number;
|
|
827
|
+
/** Author of the novel. */
|
|
828
|
+
user: PixivUser;
|
|
829
|
+
/**
|
|
830
|
+
* Series information.
|
|
831
|
+
*
|
|
832
|
+
* `{}` (empty object) if the novel does not belong to a series.
|
|
833
|
+
*/
|
|
834
|
+
series: Series | Record<string, never>;
|
|
835
|
+
/** Whether the authenticated user has bookmarked this novel. */
|
|
836
|
+
isBookmarked: boolean;
|
|
837
|
+
/** Total number of bookmarks. */
|
|
838
|
+
totalBookmarks: number;
|
|
839
|
+
/** Total number of views. */
|
|
840
|
+
totalView: number;
|
|
841
|
+
/** Whether the novel is publicly visible. */
|
|
842
|
+
visible: boolean;
|
|
843
|
+
/** Total number of comments. */
|
|
844
|
+
totalComments: number;
|
|
845
|
+
/** Whether the novel is muted for the authenticated user. */
|
|
846
|
+
isMuted: boolean;
|
|
847
|
+
/** Whether the novel is restricted to mutual followers (mypixiv). */
|
|
848
|
+
isMypixivOnly: boolean;
|
|
849
|
+
/** Whether the novel contains explicit content beyond the `xRestrict` flag. */
|
|
850
|
+
isXRestricted: boolean;
|
|
851
|
+
/** AI-generated content flag: 0 = no AI, 1 = partial AI, 2 = fully AI */
|
|
852
|
+
novelAiType: number;
|
|
853
|
+
/** Controls who can post comments (may be absent). */
|
|
854
|
+
commentAccessControl?: number;
|
|
878
855
|
}
|
|
879
856
|
/** Novel series details returned by GET /v2/novel/series. */
|
|
880
857
|
interface NovelSeriesDetail {
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
858
|
+
/** Series ID. */
|
|
859
|
+
id: number;
|
|
860
|
+
/** Series title. */
|
|
861
|
+
title: string;
|
|
862
|
+
/** Series description / caption. */
|
|
863
|
+
caption: string;
|
|
864
|
+
/** Whether every novel in the series is original (not fan fiction). */
|
|
865
|
+
isOriginal: boolean;
|
|
866
|
+
/** Whether the series has been marked as concluded by the author. */
|
|
867
|
+
isConcluded: boolean;
|
|
868
|
+
/** Number of novels in the series. */
|
|
869
|
+
contentCount: number;
|
|
870
|
+
/** Total character count across all novels in the series. */
|
|
871
|
+
totalCharacterCount: number;
|
|
872
|
+
/** Author of the series. */
|
|
873
|
+
user: PixivUser;
|
|
874
|
+
/** Human-readable series label / tagline. */
|
|
875
|
+
displayText: string;
|
|
876
|
+
/** AI-generated content flag: 0 = no AI, 1 = partial AI, 2 = fully AI */
|
|
877
|
+
novelAiType: number;
|
|
878
|
+
/** Whether the authenticated user has added this series to their watchlist. */
|
|
879
|
+
watchlistAdded: boolean;
|
|
903
880
|
}
|
|
904
881
|
/** User item with self-introduction; embedded in GET /v1/user/detail. */
|
|
905
882
|
type PixivUserItem = PixivUser & {
|
|
906
|
-
|
|
907
|
-
comment: string;
|
|
883
|
+
/** Self-introduction text (line endings are \r\n) */comment: string;
|
|
908
884
|
};
|
|
909
885
|
/** Visibility setting for a user profile field. */
|
|
910
886
|
type Publicity = 'public' | 'private' | 'mypixiv';
|
|
911
887
|
/** Detailed profile information for a user. */
|
|
912
888
|
interface PixivUserProfile {
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
889
|
+
/** Personal website URL, or `null` if not set. */
|
|
890
|
+
webpage: string | null;
|
|
891
|
+
/** Disclosed gender. */
|
|
892
|
+
gender: 'male' | 'female' | 'unknown';
|
|
893
|
+
/** Birth date string (YYYY-MM-DD format, may be partial). */
|
|
894
|
+
birth: string;
|
|
895
|
+
/** Birth day portion (MM-DD format). */
|
|
896
|
+
birthDay: string;
|
|
897
|
+
/** Birth year. */
|
|
898
|
+
birthYear: number;
|
|
899
|
+
/** Region / prefecture. */
|
|
900
|
+
region: string;
|
|
901
|
+
/** Internal address ID. */
|
|
902
|
+
addressId: number;
|
|
903
|
+
/** Two-letter country code (ISO 3166-1 alpha-2). */
|
|
904
|
+
countryCode: string;
|
|
905
|
+
/** Occupation / job description. */
|
|
906
|
+
job: string;
|
|
907
|
+
/** Internal job category ID. */
|
|
908
|
+
jobId: number;
|
|
909
|
+
/** Number of users this user follows. */
|
|
910
|
+
totalFollowUsers: number;
|
|
911
|
+
/** Number of mutual-follow (mypixiv) connections. */
|
|
912
|
+
totalMypixivUsers: number;
|
|
913
|
+
/** Total number of public illusts. */
|
|
914
|
+
totalIllusts: number;
|
|
915
|
+
/** Total number of public manga works. */
|
|
916
|
+
totalManga: number;
|
|
917
|
+
/** Total number of public novels. */
|
|
918
|
+
totalNovels: number;
|
|
919
|
+
/** Total number of publicly bookmarked illusts. */
|
|
920
|
+
totalIllustBookmarksPublic: number;
|
|
921
|
+
/** Total number of illust series. */
|
|
922
|
+
totalIllustSeries: number;
|
|
923
|
+
/** Total number of novel series. */
|
|
924
|
+
totalNovelSeries: number;
|
|
925
|
+
/** Profile background image URL, or `null` if not set. */
|
|
926
|
+
backgroundImageUrl: string | null;
|
|
927
|
+
/** Linked Twitter/X account name (without @). */
|
|
928
|
+
twitterAccount: string;
|
|
929
|
+
/** Twitter/X profile URL, or `null` if not set. */
|
|
930
|
+
twitterUrl: string | null;
|
|
931
|
+
/** Pawoo profile URL, or `null` if not set. */
|
|
932
|
+
pawooUrl: string | null;
|
|
933
|
+
/** Whether the user has a premium (paid) account. */
|
|
934
|
+
isPremium: boolean;
|
|
935
|
+
/** Whether the user has set a custom profile image. */
|
|
936
|
+
isUsingCustomProfileImage: boolean;
|
|
961
937
|
}
|
|
962
938
|
/** Visibility settings for a user's profile fields. */
|
|
963
939
|
interface PixivUserProfilePublicity {
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
940
|
+
/** Visibility of the gender field. */
|
|
941
|
+
gender: Publicity;
|
|
942
|
+
/** Visibility of the region field. */
|
|
943
|
+
region: Publicity;
|
|
944
|
+
/** Visibility of the birth-day field. */
|
|
945
|
+
birthDay: Publicity;
|
|
946
|
+
/** Visibility of the birth-year field. */
|
|
947
|
+
birthYear: Publicity;
|
|
948
|
+
/** Visibility of the job field. */
|
|
949
|
+
job: Publicity;
|
|
950
|
+
/** Whether the Pawoo account link is visible. */
|
|
951
|
+
pawoo: boolean;
|
|
976
952
|
}
|
|
977
953
|
/** Workspace / desk setup information from a user's profile. */
|
|
978
954
|
interface PixivUserProfileWorkspace {
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
955
|
+
/** PC / computer specs. */
|
|
956
|
+
pc: string;
|
|
957
|
+
/** Monitor model. */
|
|
958
|
+
monitor: string;
|
|
959
|
+
/** Drawing software / tool. */
|
|
960
|
+
tool: string;
|
|
961
|
+
/** Scanner model. */
|
|
962
|
+
scanner: string;
|
|
963
|
+
/** Tablet model. */
|
|
964
|
+
tablet: string;
|
|
965
|
+
/** Mouse model. */
|
|
966
|
+
mouse: string;
|
|
967
|
+
/** Printer model. */
|
|
968
|
+
printer: string;
|
|
969
|
+
/** Desktop wallpaper or environment description. */
|
|
970
|
+
desktop: string;
|
|
971
|
+
/** Music / background audio description. */
|
|
972
|
+
music: string;
|
|
973
|
+
/** Desk description. */
|
|
974
|
+
desk: string;
|
|
975
|
+
/** Chair description. */
|
|
976
|
+
chair: string;
|
|
977
|
+
/** Free-text comment about the workspace. */
|
|
978
|
+
comment: string;
|
|
979
|
+
/** Workspace image URL, or `null` if not set. */
|
|
980
|
+
workspaceImageUrl: string | null;
|
|
1005
981
|
}
|
|
1006
982
|
/**
|
|
1007
983
|
* Preview item for a user in the GET /v1/user/following response.
|
|
@@ -1009,33 +985,33 @@ interface PixivUserProfileWorkspace {
|
|
|
1009
985
|
* Contains a few sample illusts and novels from that user.
|
|
1010
986
|
*/
|
|
1011
987
|
interface PixivUserPreviewItem {
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
988
|
+
/** The user being previewed. */
|
|
989
|
+
user: PixivUser;
|
|
990
|
+
/** A small sample of the user's recent illusts. */
|
|
991
|
+
illusts: PixivIllustItem[];
|
|
992
|
+
/** A small sample of the user's recent novels. */
|
|
993
|
+
novels: PixivNovelItem[];
|
|
994
|
+
/** Whether this user is muted by the authenticated user. */
|
|
995
|
+
isMuted: boolean;
|
|
1020
996
|
}
|
|
1021
997
|
/** URLs for ugoira frame archives (ZIP files). */
|
|
1022
998
|
interface ZipUrls {
|
|
1023
|
-
|
|
1024
|
-
|
|
999
|
+
/** URL for the 600 px-long-side archive. */
|
|
1000
|
+
medium: string;
|
|
1025
1001
|
}
|
|
1026
1002
|
/** Timing info for a single ugoira frame. */
|
|
1027
1003
|
interface Frame {
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1004
|
+
/** File name within the ZIP archive */
|
|
1005
|
+
file: string;
|
|
1006
|
+
/** Display duration in milliseconds */
|
|
1007
|
+
delay: number;
|
|
1032
1008
|
}
|
|
1033
1009
|
/** Ugoira metadata as returned by GET /v1/ugoira/metadata. */
|
|
1034
1010
|
interface PixivUgoiraItem {
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1011
|
+
/** Archive URLs for the frame ZIP. */
|
|
1012
|
+
zipUrls: ZipUrls;
|
|
1013
|
+
/** Per-frame timing data (in order). */
|
|
1014
|
+
frames: Frame[];
|
|
1039
1015
|
}
|
|
1040
1016
|
/**
|
|
1041
1017
|
* Camelized shape of the JSON error body returned by the pixiv API.
|
|
@@ -1045,785 +1021,753 @@ interface PixivUgoiraItem {
|
|
|
1045
1021
|
* are `lowerCamelCase`.
|
|
1046
1022
|
*/
|
|
1047
1023
|
interface PixivApiErrorBody {
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
reason: string;
|
|
1056
|
-
/** Additional details for the user-facing message (may be absent). */
|
|
1057
|
-
userMessageDetails?: Record<string, unknown>;
|
|
1058
|
-
};
|
|
1024
|
+
/** Error payload returned by the pixiv API (keys camelized). */
|
|
1025
|
+
error: {
|
|
1026
|
+
/** Localised error message intended for end users. */userMessage: string; /** Internal error message. */
|
|
1027
|
+
message: string; /** Short error reason / code. */
|
|
1028
|
+
reason: string; /** Additional details for the user-facing message (may be absent). */
|
|
1029
|
+
userMessageDetails?: Record<string, unknown>;
|
|
1030
|
+
};
|
|
1059
1031
|
}
|
|
1060
1032
|
/** Response shape for GET /v1/illust/detail. */
|
|
1061
1033
|
interface IllustDetailResponse {
|
|
1062
|
-
|
|
1063
|
-
|
|
1034
|
+
/** The requested illust. */
|
|
1035
|
+
illust: PixivIllustItem;
|
|
1064
1036
|
}
|
|
1065
1037
|
/** Page response for illust list endpoints (search, related, ranking, etc.). */
|
|
1066
1038
|
interface IllustListPage {
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1039
|
+
/** Illusts on this page. */
|
|
1040
|
+
illusts: PixivIllustItem[];
|
|
1041
|
+
/**
|
|
1042
|
+
* Whether AI-generated works are shown in the results.
|
|
1043
|
+
*
|
|
1044
|
+
* Only present on search responses; absent on related/ranking/recommended endpoints.
|
|
1045
|
+
*/
|
|
1046
|
+
showAi?: boolean;
|
|
1047
|
+
/** URL to the next page, or `null` when this is the last page. */
|
|
1048
|
+
nextUrl: string | null;
|
|
1077
1049
|
}
|
|
1078
1050
|
/** Page response for GET /v1/illust/recommended. */
|
|
1079
1051
|
interface IllustRecommendedPage {
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1052
|
+
/** Recommended illusts. */
|
|
1053
|
+
illusts: PixivIllustItem[];
|
|
1054
|
+
/** Ranking illusts included alongside recommendations. */
|
|
1055
|
+
rankingIllusts: PixivIllustItem[];
|
|
1056
|
+
/** Whether an ongoing contest exists. */
|
|
1057
|
+
contestExists: boolean;
|
|
1058
|
+
/** Privacy-policy notice (present on the first page). */
|
|
1059
|
+
privacyPolicy?: PrivacyPolicy;
|
|
1060
|
+
/** URL to the next page, or `null` when this is the last page. */
|
|
1061
|
+
nextUrl: string | null;
|
|
1090
1062
|
}
|
|
1091
1063
|
/** Page response for GET /v1/illust/series. */
|
|
1092
1064
|
interface IllustSeriesPage {
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1065
|
+
/** Metadata for the series. */
|
|
1066
|
+
illustSeriesDetail: IllustSeriesDetail;
|
|
1067
|
+
/** First illust in the series. */
|
|
1068
|
+
illustSeriesFirstIllust: PixivIllustItem;
|
|
1069
|
+
/** Illusts on this page. */
|
|
1070
|
+
illusts: PixivIllustItem[];
|
|
1071
|
+
/** URL to the next page, or `null` when this is the last page. */
|
|
1072
|
+
nextUrl: string | null;
|
|
1101
1073
|
}
|
|
1102
1074
|
/** Page response for GET /v1/manga/recommended. */
|
|
1103
1075
|
interface MangaRecommendedPage {
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1076
|
+
/** Recommended manga works. */
|
|
1077
|
+
illusts: PixivIllustItem[];
|
|
1078
|
+
/** Ranking manga works included alongside recommendations. */
|
|
1079
|
+
rankingIllusts: PixivIllustItem[];
|
|
1080
|
+
/** Privacy-policy notice (present on the first page). */
|
|
1081
|
+
privacyPolicy?: PrivacyPolicy;
|
|
1082
|
+
/** URL to the next page, or `null` when this is the last page. */
|
|
1083
|
+
nextUrl: string | null;
|
|
1112
1084
|
}
|
|
1113
1085
|
/** Response shape for GET /v1/ugoira/metadata. */
|
|
1114
1086
|
interface UgoiraMetadataResponse {
|
|
1115
|
-
|
|
1116
|
-
|
|
1087
|
+
/** Ugoira metadata (ZIP URLs and per-frame timings). */
|
|
1088
|
+
ugoiraMetadata: PixivUgoiraItem;
|
|
1117
1089
|
}
|
|
1118
1090
|
/** Response shape for GET /v2/novel/detail. */
|
|
1119
1091
|
interface NovelDetailResponse {
|
|
1120
|
-
|
|
1121
|
-
|
|
1092
|
+
/** The requested novel. */
|
|
1093
|
+
novel: PixivNovelItem;
|
|
1122
1094
|
}
|
|
1123
1095
|
/** Page response for novel list endpoints (search, related, ranking, etc.). */
|
|
1124
1096
|
interface NovelListPage {
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1097
|
+
/** Novels on this page. */
|
|
1098
|
+
novels: PixivNovelItem[];
|
|
1099
|
+
/**
|
|
1100
|
+
* Whether AI-generated works are shown in the results.
|
|
1101
|
+
*
|
|
1102
|
+
* Only present on search responses; absent on related/ranking/recommended endpoints.
|
|
1103
|
+
*/
|
|
1104
|
+
showAi?: boolean;
|
|
1105
|
+
/** URL to the next page, or `null` when this is the last page. */
|
|
1106
|
+
nextUrl: string | null;
|
|
1135
1107
|
}
|
|
1136
1108
|
/** Page response for GET /v1/novel/recommended. */
|
|
1137
1109
|
interface NovelRecommendedPage {
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1110
|
+
/** Recommended novels. */
|
|
1111
|
+
novels: PixivNovelItem[];
|
|
1112
|
+
/** Ranking novels included alongside recommendations. */
|
|
1113
|
+
rankingNovels: PixivNovelItem[];
|
|
1114
|
+
/** Privacy-policy notice (present on the first page). */
|
|
1115
|
+
privacyPolicy?: PrivacyPolicy;
|
|
1116
|
+
/** URL to the next page, or `null` when this is the last page. */
|
|
1117
|
+
nextUrl: string | null;
|
|
1146
1118
|
}
|
|
1147
1119
|
/** Page response for GET /v2/novel/series. */
|
|
1148
1120
|
interface NovelSeriesPage {
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1121
|
+
/** Metadata for the series. */
|
|
1122
|
+
novelSeriesDetail: NovelSeriesDetail;
|
|
1123
|
+
/** First novel in the series. */
|
|
1124
|
+
novelSeriesFirstNovel: PixivNovelItem;
|
|
1125
|
+
/** Most recently published novel in the series. */
|
|
1126
|
+
novelSeriesLatestNovel: PixivNovelItem;
|
|
1127
|
+
/** Novels on this page. */
|
|
1128
|
+
novels: PixivNovelItem[];
|
|
1129
|
+
/** URL to the next page, or `null` when this is the last page. */
|
|
1130
|
+
nextUrl: string | null;
|
|
1159
1131
|
}
|
|
1160
1132
|
/** Response shape for GET /v1/user/detail. */
|
|
1161
1133
|
interface UserDetailResponse {
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1134
|
+
/** Basic user info with self-introduction. */
|
|
1135
|
+
user: PixivUserItem;
|
|
1136
|
+
/** Detailed profile data. */
|
|
1137
|
+
profile: PixivUserProfile;
|
|
1138
|
+
/** Visibility settings for profile fields. */
|
|
1139
|
+
profilePublicity: PixivUserProfilePublicity;
|
|
1140
|
+
/** Workspace / desk-setup information. */
|
|
1141
|
+
workspace: PixivUserProfileWorkspace;
|
|
1170
1142
|
}
|
|
1171
1143
|
/** Page response for GET /v1/user/illusts. */
|
|
1172
1144
|
interface UserIllustsPage {
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1145
|
+
/** The user whose illusts are listed. */
|
|
1146
|
+
user: PixivUser;
|
|
1147
|
+
/** Illusts on this page. */
|
|
1148
|
+
illusts: PixivIllustItem[];
|
|
1149
|
+
/** URL to the next page, or `null` when this is the last page. */
|
|
1150
|
+
nextUrl: string | null;
|
|
1179
1151
|
}
|
|
1180
1152
|
/** Page response for GET /v1/user/novels. */
|
|
1181
1153
|
interface UserNovelsPage {
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1154
|
+
/** The user whose novels are listed. */
|
|
1155
|
+
user: PixivUser;
|
|
1156
|
+
/** Novels on this page. */
|
|
1157
|
+
novels: PixivNovelItem[];
|
|
1158
|
+
/** URL to the next page, or `null` when this is the last page. */
|
|
1159
|
+
nextUrl: string | null;
|
|
1188
1160
|
}
|
|
1189
1161
|
/** Page response for GET /v1/user/bookmarks/illust. */
|
|
1190
1162
|
interface UserBookmarksIllustPage {
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1163
|
+
/** Bookmarked illusts on this page. */
|
|
1164
|
+
illusts: PixivIllustItem[];
|
|
1165
|
+
/** URL to the next page, or `null` when this is the last page. */
|
|
1166
|
+
nextUrl: string | null;
|
|
1195
1167
|
}
|
|
1196
1168
|
/** Page response for GET /v1/user/bookmarks/novel. */
|
|
1197
1169
|
interface UserBookmarksNovelPage {
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1170
|
+
/** Bookmarked novels on this page. */
|
|
1171
|
+
novels: PixivNovelItem[];
|
|
1172
|
+
/** URL to the next page, or `null` when this is the last page. */
|
|
1173
|
+
nextUrl: string | null;
|
|
1202
1174
|
}
|
|
1203
1175
|
/** Page response for GET /v1/user/following. */
|
|
1204
1176
|
interface UserFollowingPage {
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1177
|
+
/** User preview items on this page. */
|
|
1178
|
+
userPreviews: PixivUserPreviewItem[];
|
|
1179
|
+
/** URL to the next page, or `null` when this is the last page. */
|
|
1180
|
+
nextUrl: string | null;
|
|
1209
1181
|
}
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
* IllustResource — methods for the illust API namespace.
|
|
1213
|
-
*/
|
|
1214
|
-
|
|
1182
|
+
//#endregion
|
|
1183
|
+
//#region src/resources/illusts.d.ts
|
|
1215
1184
|
/** Parameters for fetching a single illust by ID. */
|
|
1216
1185
|
interface IllustDetailParams {
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1186
|
+
/** ID of the illust to fetch. */
|
|
1187
|
+
illustId: number;
|
|
1188
|
+
/** OS filter to apply (default: `"for_ios"`). */
|
|
1189
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1221
1190
|
}
|
|
1222
1191
|
/** Parameters for fetching related illusts. */
|
|
1223
1192
|
interface IllustRelatedParams {
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1193
|
+
/** ID of the illust for which to fetch related works. */
|
|
1194
|
+
illustId: number;
|
|
1195
|
+
/** Additional seed illust IDs to influence recommendations. */
|
|
1196
|
+
seedIllustIds?: number[];
|
|
1197
|
+
/** OS filter to apply (default: `"for_ios"`). */
|
|
1198
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1230
1199
|
}
|
|
1231
1200
|
/** Parameters for searching illusts. */
|
|
1232
1201
|
interface IllustSearchParams {
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1202
|
+
/** Search keyword. */
|
|
1203
|
+
word: string;
|
|
1204
|
+
/** How to match the keyword against works (default: `"partial_match_for_tags"`). */
|
|
1205
|
+
searchTarget?: (typeof SearchTarget)[keyof typeof SearchTarget];
|
|
1206
|
+
/** Sort order for results (default: `"date_desc"`). */
|
|
1207
|
+
sort?: (typeof SearchSort)[keyof typeof SearchSort];
|
|
1208
|
+
/** Date range preset filter (omit for no restriction). */
|
|
1209
|
+
duration?: (typeof SearchDuration)[keyof typeof SearchDuration];
|
|
1210
|
+
/** Start date for a custom date range (YYYY-MM-DD; requires `endDate`). */
|
|
1211
|
+
startDate?: string;
|
|
1212
|
+
/** End date for a custom date range (YYYY-MM-DD; requires `startDate`). */
|
|
1213
|
+
endDate?: string;
|
|
1214
|
+
/** OS filter to apply (default: `"for_ios"`). */
|
|
1215
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1216
|
+
/** AI-generated content filter: `0` = hide AI works, `1` = show only AI works. */
|
|
1217
|
+
searchAiType?: 0 | 1;
|
|
1218
|
+
/** Zero-based offset for pagination. */
|
|
1219
|
+
offset?: number;
|
|
1251
1220
|
}
|
|
1252
1221
|
/** Parameters for fetching the illust ranking. */
|
|
1253
1222
|
interface IllustRankingParams {
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1223
|
+
/** Ranking category (default: `"day"`). */
|
|
1224
|
+
mode?: (typeof RankingMode)[keyof typeof RankingMode];
|
|
1225
|
+
/** OS filter to apply (default: `"for_ios"`). */
|
|
1226
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1227
|
+
/** Specific date to fetch rankings for (YYYY-MM-DD; omit for the latest). */
|
|
1228
|
+
date?: string;
|
|
1229
|
+
/** Zero-based offset for pagination. */
|
|
1230
|
+
offset?: number;
|
|
1262
1231
|
}
|
|
1263
1232
|
/** Parameters for fetching recommended illusts. */
|
|
1264
1233
|
interface IllustRecommendedParams {
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1234
|
+
/** OS filter to apply (default: `"for_ios"`). */
|
|
1235
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1236
|
+
/** Zero-based offset for pagination. */
|
|
1237
|
+
offset?: number;
|
|
1238
|
+
/**
|
|
1239
|
+
* Cursor for resuming pagination: the `maxBookmarkIdForRecommend` value
|
|
1240
|
+
* extracted from a previous page's `next_url` via {@link parseNextUrl}.
|
|
1241
|
+
*/
|
|
1242
|
+
maxBookmarkIdForRecommend?: number;
|
|
1243
|
+
/**
|
|
1244
|
+
* Secondary cursor for resuming pagination: the `minBookmarkIdForRecentIllust`
|
|
1245
|
+
* value extracted from a previous page's `next_url` via {@link parseNextUrl}.
|
|
1246
|
+
*/
|
|
1247
|
+
minBookmarkIdForRecentIllust?: number;
|
|
1279
1248
|
}
|
|
1280
1249
|
/** Parameters for fetching an illust series. */
|
|
1281
1250
|
interface IllustSeriesParams {
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1251
|
+
/** ID of the illust series to fetch. */
|
|
1252
|
+
illustSeriesId: number;
|
|
1253
|
+
/** OS filter to apply (default: `"for_ios"`). */
|
|
1254
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1286
1255
|
}
|
|
1287
1256
|
/** Parameters for adding an illust bookmark. */
|
|
1288
1257
|
interface IllustBookmarkAddParams {
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1258
|
+
/** ID of the illust to bookmark. */
|
|
1259
|
+
illustId: number;
|
|
1260
|
+
/** Bookmark visibility (default: `"public"`). */
|
|
1261
|
+
restrict?: (typeof BookmarkRestrict)[keyof typeof BookmarkRestrict];
|
|
1262
|
+
/** Tags to attach to the bookmark. */
|
|
1263
|
+
tags?: string[];
|
|
1295
1264
|
}
|
|
1296
1265
|
/** Parameters for removing an illust bookmark. */
|
|
1297
1266
|
interface IllustBookmarkDeleteParams {
|
|
1298
|
-
|
|
1299
|
-
|
|
1267
|
+
/** ID of the illust to remove from bookmarks. */
|
|
1268
|
+
illustId: number;
|
|
1300
1269
|
}
|
|
1301
1270
|
/** Methods for the illust API namespace. */
|
|
1302
1271
|
declare class IllustResource {
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
* NovelResource — methods for the novel API namespace.
|
|
1389
|
-
*/
|
|
1390
|
-
|
|
1272
|
+
#private;
|
|
1273
|
+
constructor(http: HttpClient);
|
|
1274
|
+
/**
|
|
1275
|
+
* Fetches a single illust by ID.
|
|
1276
|
+
* GET /v1/illust/detail
|
|
1277
|
+
*
|
|
1278
|
+
* @param params - Request parameters
|
|
1279
|
+
*
|
|
1280
|
+
* @example
|
|
1281
|
+
* ```ts
|
|
1282
|
+
* const result = await client.illusts.detail({ illustId: 12345 })
|
|
1283
|
+
* if (result.isOk) {
|
|
1284
|
+
* console.log(result.value.illust.title)
|
|
1285
|
+
* } else {
|
|
1286
|
+
* console.error(result.error)
|
|
1287
|
+
* }
|
|
1288
|
+
* ```
|
|
1289
|
+
*/
|
|
1290
|
+
detail(params: IllustDetailParams): ResultAsync<IllustDetailResponse, PixivError>;
|
|
1291
|
+
/**
|
|
1292
|
+
* Fetches related illusts for a given illust.
|
|
1293
|
+
* GET /v2/illust/related
|
|
1294
|
+
*
|
|
1295
|
+
* @param params - Request parameters
|
|
1296
|
+
*/
|
|
1297
|
+
related(params: IllustRelatedParams): PaginatedResultAsync<IllustListPage, IllustListPage['illusts'][number]>;
|
|
1298
|
+
/**
|
|
1299
|
+
* Searches for illusts.
|
|
1300
|
+
* GET /v1/search/illust
|
|
1301
|
+
*
|
|
1302
|
+
* @param params - Request parameters
|
|
1303
|
+
*
|
|
1304
|
+
* @example
|
|
1305
|
+
* ```ts
|
|
1306
|
+
* // Iterate all results across pages
|
|
1307
|
+
* for await (const illust of client.illusts.search({ word: 'cat' }).items()) {
|
|
1308
|
+
* console.log(illust.title)
|
|
1309
|
+
* }
|
|
1310
|
+
*
|
|
1311
|
+
* // Fetch only the first page
|
|
1312
|
+
* const page = await client.illusts.search({ word: 'cat' })
|
|
1313
|
+
* if (page.isOk) {
|
|
1314
|
+
* console.log(page.value.illusts.length)
|
|
1315
|
+
* }
|
|
1316
|
+
* ```
|
|
1317
|
+
*/
|
|
1318
|
+
search(params: IllustSearchParams): PaginatedResultAsync<IllustListPage, IllustListPage['illusts'][number]>;
|
|
1319
|
+
/**
|
|
1320
|
+
* Fetches the illust ranking.
|
|
1321
|
+
* GET /v1/illust/ranking
|
|
1322
|
+
*
|
|
1323
|
+
* @param params - Request parameters
|
|
1324
|
+
*/
|
|
1325
|
+
ranking(params?: IllustRankingParams): PaginatedResultAsync<IllustListPage, IllustListPage['illusts'][number]>;
|
|
1326
|
+
/**
|
|
1327
|
+
* Fetches recommended illusts.
|
|
1328
|
+
* GET /v1/illust/recommended
|
|
1329
|
+
*
|
|
1330
|
+
* @param params - Request parameters
|
|
1331
|
+
*/
|
|
1332
|
+
recommended(params?: IllustRecommendedParams): PaginatedResultAsync<IllustRecommendedPage, IllustRecommendedPage['illusts'][number]>;
|
|
1333
|
+
/**
|
|
1334
|
+
* Fetches an illust series.
|
|
1335
|
+
* GET /v1/illust/series
|
|
1336
|
+
*
|
|
1337
|
+
* @param params - Request parameters
|
|
1338
|
+
*/
|
|
1339
|
+
series(params: IllustSeriesParams): PaginatedResultAsync<IllustSeriesPage, IllustSeriesPage['illusts'][number]>;
|
|
1340
|
+
/**
|
|
1341
|
+
* Adds an illust bookmark.
|
|
1342
|
+
* POST /v2/illust/bookmark/add
|
|
1343
|
+
*
|
|
1344
|
+
* @param params - Request parameters
|
|
1345
|
+
*/
|
|
1346
|
+
bookmarkAdd(params: IllustBookmarkAddParams): ResultAsync<Record<string, never>, PixivError>;
|
|
1347
|
+
/**
|
|
1348
|
+
* Removes an illust bookmark.
|
|
1349
|
+
* POST /v1/illust/bookmark/delete
|
|
1350
|
+
*
|
|
1351
|
+
* @param params - Request parameters
|
|
1352
|
+
*/
|
|
1353
|
+
bookmarkDelete(params: IllustBookmarkDeleteParams): ResultAsync<Record<string, never>, PixivError>;
|
|
1354
|
+
}
|
|
1355
|
+
//#endregion
|
|
1356
|
+
//#region src/resources/novels.d.ts
|
|
1391
1357
|
/** Parameters for fetching a single novel by ID. */
|
|
1392
1358
|
interface NovelDetailParams {
|
|
1393
|
-
|
|
1394
|
-
|
|
1359
|
+
/** ID of the novel to fetch. */
|
|
1360
|
+
novelId: number;
|
|
1395
1361
|
}
|
|
1396
1362
|
/** Parameters for fetching the WebView HTML of a novel. */
|
|
1397
1363
|
interface NovelTextParams {
|
|
1398
|
-
|
|
1399
|
-
|
|
1364
|
+
/** ID of the novel whose WebView HTML to fetch. */
|
|
1365
|
+
novelId: number;
|
|
1400
1366
|
}
|
|
1401
1367
|
/** Parameters for fetching related novels. */
|
|
1402
1368
|
interface NovelRelatedParams {
|
|
1403
|
-
|
|
1404
|
-
|
|
1369
|
+
/** ID of the novel for which to fetch related works. */
|
|
1370
|
+
novelId: number;
|
|
1405
1371
|
}
|
|
1406
1372
|
/** Parameters for searching novels. */
|
|
1407
1373
|
interface NovelSearchParams {
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1374
|
+
/** Search keyword. */
|
|
1375
|
+
word: string;
|
|
1376
|
+
/** How to match the keyword against works (default: `"partial_match_for_tags"`). */
|
|
1377
|
+
searchTarget?: (typeof SearchTarget)[keyof typeof SearchTarget];
|
|
1378
|
+
/** Sort order for results (default: `"date_desc"`). */
|
|
1379
|
+
sort?: (typeof SearchSort)[keyof typeof SearchSort];
|
|
1380
|
+
/** OS filter to apply (default: `"for_ios"`). */
|
|
1381
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1382
|
+
/** Date range preset filter (omit for no restriction). */
|
|
1383
|
+
duration?: (typeof SearchDuration)[keyof typeof SearchDuration];
|
|
1384
|
+
/** Start date for a custom date range (YYYY-MM-DD; requires `endDate`). */
|
|
1385
|
+
startDate?: string;
|
|
1386
|
+
/** End date for a custom date range (YYYY-MM-DD; requires `startDate`). */
|
|
1387
|
+
endDate?: string;
|
|
1388
|
+
/** AI-generated content filter: `0` = hide AI works, `1` = show only AI works. */
|
|
1389
|
+
searchAiType?: 0 | 1;
|
|
1390
|
+
/** Zero-based offset for pagination. */
|
|
1391
|
+
offset?: number;
|
|
1426
1392
|
}
|
|
1427
1393
|
/** Parameters for fetching the novel ranking. */
|
|
1428
1394
|
interface NovelRankingParams {
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1395
|
+
/** Ranking category (default: `"day"`). */
|
|
1396
|
+
mode?: (typeof NovelRankingMode)[keyof typeof NovelRankingMode];
|
|
1397
|
+
/** OS filter to apply (default: `"for_ios"`). */
|
|
1398
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1399
|
+
/** Specific date to fetch rankings for (YYYY-MM-DD; omit for the latest). */
|
|
1400
|
+
date?: string;
|
|
1401
|
+
/** Zero-based offset for pagination. */
|
|
1402
|
+
offset?: number;
|
|
1437
1403
|
}
|
|
1438
1404
|
/** Parameters for fetching recommended novels. */
|
|
1439
1405
|
interface NovelRecommendedParams {
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1406
|
+
/** OS filter to apply (default: `"for_ios"`). */
|
|
1407
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1408
|
+
/** Zero-based offset for pagination. */
|
|
1409
|
+
offset?: number;
|
|
1410
|
+
/**
|
|
1411
|
+
* Cursor for resuming pagination: the `maxBookmarkIdForRecommend` value
|
|
1412
|
+
* extracted from a previous page's `next_url` via {@link parseNextUrl}.
|
|
1413
|
+
*/
|
|
1414
|
+
maxBookmarkIdForRecommend?: number;
|
|
1449
1415
|
}
|
|
1450
1416
|
/** Parameters for fetching a novel series. */
|
|
1451
1417
|
interface NovelSeriesParams {
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1418
|
+
/** ID of the novel series to fetch. */
|
|
1419
|
+
seriesId: number;
|
|
1420
|
+
/** Order of the last novel already seen; used for cursor-based pagination. */
|
|
1421
|
+
lastOrder?: number;
|
|
1456
1422
|
}
|
|
1457
1423
|
/** Parameters for adding a novel bookmark. */
|
|
1458
1424
|
interface NovelBookmarkAddParams {
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1425
|
+
/** ID of the novel to bookmark. */
|
|
1426
|
+
novelId: number;
|
|
1427
|
+
/** Bookmark visibility (default: `"public"`). */
|
|
1428
|
+
restrict?: (typeof BookmarkRestrict)[keyof typeof BookmarkRestrict];
|
|
1429
|
+
/** Tags to attach to the bookmark. */
|
|
1430
|
+
tags?: string[];
|
|
1465
1431
|
}
|
|
1466
1432
|
/** Parameters for removing a novel bookmark. */
|
|
1467
1433
|
interface NovelBookmarkDeleteParams {
|
|
1468
|
-
|
|
1469
|
-
|
|
1434
|
+
/** ID of the novel to remove from bookmarks. */
|
|
1435
|
+
novelId: number;
|
|
1470
1436
|
}
|
|
1471
1437
|
/** Methods for the novel API namespace. */
|
|
1472
1438
|
declare class NovelResource {
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
}
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
* UserResource — methods for the user API namespace.
|
|
1569
|
-
*/
|
|
1570
|
-
|
|
1439
|
+
#private;
|
|
1440
|
+
constructor(http: HttpClient);
|
|
1441
|
+
/**
|
|
1442
|
+
* Fetches a single novel by ID.
|
|
1443
|
+
* GET /v2/novel/detail
|
|
1444
|
+
*
|
|
1445
|
+
* @param params - Request parameters
|
|
1446
|
+
*
|
|
1447
|
+
* @example
|
|
1448
|
+
* ```ts
|
|
1449
|
+
* const result = await client.novels.detail({ novelId: 67890 })
|
|
1450
|
+
* if (result.isOk) {
|
|
1451
|
+
* console.log(result.value.novel.title)
|
|
1452
|
+
* } else {
|
|
1453
|
+
* console.error(result.error)
|
|
1454
|
+
* }
|
|
1455
|
+
* ```
|
|
1456
|
+
*/
|
|
1457
|
+
detail(params: NovelDetailParams): ResultAsync<NovelDetailResponse, PixivError>;
|
|
1458
|
+
/**
|
|
1459
|
+
* Fetches the WebView HTML for a novel.
|
|
1460
|
+
* GET /webview/v2/novel
|
|
1461
|
+
*
|
|
1462
|
+
* Returns the raw HTML page that the pixiv app renders in a WebView.
|
|
1463
|
+
* To extract the plain text, parse the returned HTML (e.g. strip tags).
|
|
1464
|
+
*
|
|
1465
|
+
* @param params - Request parameters
|
|
1466
|
+
*/
|
|
1467
|
+
text(params: NovelTextParams): ResultAsync<string, PixivError>;
|
|
1468
|
+
/**
|
|
1469
|
+
* Fetches related novels for a given novel.
|
|
1470
|
+
* GET /v1/novel/related
|
|
1471
|
+
*
|
|
1472
|
+
* @param params - Request parameters
|
|
1473
|
+
*/
|
|
1474
|
+
related(params: NovelRelatedParams): PaginatedResultAsync<NovelListPage, PixivNovelItem>;
|
|
1475
|
+
/**
|
|
1476
|
+
* Searches for novels.
|
|
1477
|
+
* GET /v1/search/novel
|
|
1478
|
+
*
|
|
1479
|
+
* @param params - Request parameters
|
|
1480
|
+
*
|
|
1481
|
+
* @example
|
|
1482
|
+
* ```ts
|
|
1483
|
+
* // Iterate all results across pages
|
|
1484
|
+
* for await (const novel of client.novels.search({ word: 'fantasy' }).items()) {
|
|
1485
|
+
* console.log(novel.title)
|
|
1486
|
+
* }
|
|
1487
|
+
*
|
|
1488
|
+
* // Fetch only the first page
|
|
1489
|
+
* const page = await client.novels.search({ word: 'fantasy' })
|
|
1490
|
+
* if (page.isOk) {
|
|
1491
|
+
* console.log(page.value.novels.length)
|
|
1492
|
+
* }
|
|
1493
|
+
* ```
|
|
1494
|
+
*/
|
|
1495
|
+
search(params: NovelSearchParams): PaginatedResultAsync<NovelListPage, PixivNovelItem>;
|
|
1496
|
+
/**
|
|
1497
|
+
* Fetches the novel ranking.
|
|
1498
|
+
* GET /v1/novel/ranking
|
|
1499
|
+
*
|
|
1500
|
+
* @param params - Request parameters
|
|
1501
|
+
*/
|
|
1502
|
+
ranking(params?: NovelRankingParams): PaginatedResultAsync<NovelListPage, PixivNovelItem>;
|
|
1503
|
+
/**
|
|
1504
|
+
* Fetches recommended novels.
|
|
1505
|
+
* GET /v1/novel/recommended
|
|
1506
|
+
*
|
|
1507
|
+
* @param params - Request parameters
|
|
1508
|
+
*/
|
|
1509
|
+
recommended(params?: NovelRecommendedParams): PaginatedResultAsync<NovelRecommendedPage, PixivNovelItem>;
|
|
1510
|
+
/**
|
|
1511
|
+
* Fetches a novel series.
|
|
1512
|
+
* GET /v2/novel/series
|
|
1513
|
+
*
|
|
1514
|
+
* @param params - Request parameters
|
|
1515
|
+
*/
|
|
1516
|
+
series(params: NovelSeriesParams): PaginatedResultAsync<NovelSeriesPage, PixivNovelItem>;
|
|
1517
|
+
/**
|
|
1518
|
+
* Adds a novel bookmark.
|
|
1519
|
+
* POST /v2/novel/bookmark/add
|
|
1520
|
+
*
|
|
1521
|
+
* @param params - Request parameters
|
|
1522
|
+
*/
|
|
1523
|
+
bookmarkAdd(params: NovelBookmarkAddParams): ResultAsync<Record<string, never>, PixivError>;
|
|
1524
|
+
/**
|
|
1525
|
+
* Removes a novel bookmark.
|
|
1526
|
+
* POST /v1/novel/bookmark/delete
|
|
1527
|
+
*
|
|
1528
|
+
* @param params - Request parameters
|
|
1529
|
+
*/
|
|
1530
|
+
bookmarkDelete(params: NovelBookmarkDeleteParams): ResultAsync<Record<string, never>, PixivError>;
|
|
1531
|
+
}
|
|
1532
|
+
//#endregion
|
|
1533
|
+
//#region src/resources/users.d.ts
|
|
1571
1534
|
/** Parameters for fetching a user's bookmarked illusts. */
|
|
1572
1535
|
interface UserBookmarksIllustParams {
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1536
|
+
/** ID of the user whose bookmarks to fetch. */
|
|
1537
|
+
userId: number;
|
|
1538
|
+
/** Visibility of the bookmarks to return (default: `"public"`). */
|
|
1539
|
+
restrict?: (typeof BookmarkRestrict)[keyof typeof BookmarkRestrict];
|
|
1540
|
+
/** OS filter to apply (default: `"for_ios"`). */
|
|
1541
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1542
|
+
/** Limit results to bookmarks with this tag. */
|
|
1543
|
+
tag?: string;
|
|
1544
|
+
/** Fetch bookmarks older than this bookmark ID (cursor-based pagination). */
|
|
1545
|
+
maxBookmarkId?: number;
|
|
1546
|
+
/** Zero-based offset for pagination. */
|
|
1547
|
+
offset?: number;
|
|
1585
1548
|
}
|
|
1586
1549
|
/** Parameters for fetching a user's bookmarked novels. */
|
|
1587
1550
|
interface UserBookmarksNovelParams {
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1551
|
+
/** ID of the user whose bookmarks to fetch. */
|
|
1552
|
+
userId: number;
|
|
1553
|
+
/** Visibility of the bookmarks to return (default: `"public"`). */
|
|
1554
|
+
restrict?: (typeof BookmarkRestrict)[keyof typeof BookmarkRestrict];
|
|
1555
|
+
/** OS filter to apply (default: `"for_ios"`). */
|
|
1556
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1557
|
+
/** Limit results to bookmarks with this tag. */
|
|
1558
|
+
tag?: string;
|
|
1559
|
+
/** Fetch bookmarks older than this bookmark ID (cursor-based pagination). */
|
|
1560
|
+
maxBookmarkId?: number;
|
|
1561
|
+
/** Zero-based offset for pagination. */
|
|
1562
|
+
offset?: number;
|
|
1600
1563
|
}
|
|
1601
1564
|
/** Parameters for fetching a user's detail. */
|
|
1602
1565
|
interface UserDetailParams {
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1566
|
+
/** ID of the user to fetch. */
|
|
1567
|
+
userId: number;
|
|
1568
|
+
/** OS filter to apply (default: `"for_ios"`). */
|
|
1569
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1607
1570
|
}
|
|
1608
1571
|
/** Parameters for fetching a user's illusts. */
|
|
1609
1572
|
interface UserIllustsParams {
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1573
|
+
/** ID of the user whose illusts to fetch. */
|
|
1574
|
+
userId: number;
|
|
1575
|
+
/** Work type to filter by (omit to return both illusts and manga). */
|
|
1576
|
+
type?: (typeof UserIllustType)[keyof typeof UserIllustType];
|
|
1577
|
+
/** OS filter to apply (default: `"for_ios"`). */
|
|
1578
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1579
|
+
/** Zero-based offset for pagination. */
|
|
1580
|
+
offset?: number;
|
|
1618
1581
|
}
|
|
1619
1582
|
/** Parameters for fetching a user's novels. */
|
|
1620
1583
|
interface UserNovelsParams {
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1584
|
+
/** ID of the user whose novels to fetch. */
|
|
1585
|
+
userId: number;
|
|
1586
|
+
/** OS filter to apply (default: `"for_ios"`). */
|
|
1587
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1588
|
+
/** Zero-based offset for pagination. */
|
|
1589
|
+
offset?: number;
|
|
1627
1590
|
}
|
|
1628
1591
|
/** Parameters for fetching a user's following list. */
|
|
1629
1592
|
interface UserFollowingParams {
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1593
|
+
/** ID of the user whose following list to fetch. */
|
|
1594
|
+
userId: number;
|
|
1595
|
+
/** Visibility of the follows to return (default: `"public"`). */
|
|
1596
|
+
restrict?: (typeof FollowRestrict)[keyof typeof FollowRestrict];
|
|
1597
|
+
/** Zero-based offset for pagination. */
|
|
1598
|
+
offset?: number;
|
|
1636
1599
|
}
|
|
1637
1600
|
/** Parameters for following a user. */
|
|
1638
1601
|
interface UserFollowAddParams {
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1602
|
+
/** ID of the user to follow. */
|
|
1603
|
+
userId: number;
|
|
1604
|
+
/** Visibility of the follow (default: `"public"`). */
|
|
1605
|
+
restrict?: (typeof FollowRestrict)[keyof typeof FollowRestrict];
|
|
1643
1606
|
}
|
|
1644
1607
|
/** Parameters for unfollowing a user. */
|
|
1645
1608
|
interface UserFollowDeleteParams {
|
|
1646
|
-
|
|
1647
|
-
|
|
1609
|
+
/** ID of the user to unfollow. */
|
|
1610
|
+
userId: number;
|
|
1648
1611
|
}
|
|
1649
1612
|
/** Methods for the user bookmarks sub-namespace. */
|
|
1650
1613
|
declare class UserBookmarksResource {
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1614
|
+
#private;
|
|
1615
|
+
constructor(http: HttpClient);
|
|
1616
|
+
/**
|
|
1617
|
+
* Fetches a user's bookmarked illusts.
|
|
1618
|
+
* GET /v1/user/bookmarks/illust
|
|
1619
|
+
*
|
|
1620
|
+
* @param params - Request parameters
|
|
1621
|
+
*
|
|
1622
|
+
* @example
|
|
1623
|
+
* ```ts
|
|
1624
|
+
* // Iterate all bookmarked illusts across pages
|
|
1625
|
+
* for await (const illust of client.users.bookmarks.illusts({ userId: client.userId }).items()) {
|
|
1626
|
+
* console.log(illust.title)
|
|
1627
|
+
* }
|
|
1628
|
+
*
|
|
1629
|
+
* // Resume from a saved cursor
|
|
1630
|
+
* import { parseNextUrl } from '@book000/pixivts'
|
|
1631
|
+
* const page = await client.users.bookmarks.illusts({ userId: client.userId })
|
|
1632
|
+
* if (page.isOk && page.value.nextUrl) {
|
|
1633
|
+
* const cursor = parseNextUrl(page.value.nextUrl)
|
|
1634
|
+
* const next = await client.users.bookmarks.illusts({
|
|
1635
|
+
* userId: client.userId,
|
|
1636
|
+
* maxBookmarkId: cursor.maxBookmarkId,
|
|
1637
|
+
* })
|
|
1638
|
+
* }
|
|
1639
|
+
* ```
|
|
1640
|
+
*/
|
|
1641
|
+
illusts(params: UserBookmarksIllustParams): PaginatedResultAsync<UserBookmarksIllustPage, PixivIllustItem>;
|
|
1642
|
+
/**
|
|
1643
|
+
* Fetches a user's bookmarked novels.
|
|
1644
|
+
* GET /v1/user/bookmarks/novel
|
|
1645
|
+
*
|
|
1646
|
+
* @param params - Request parameters
|
|
1647
|
+
*
|
|
1648
|
+
* @example
|
|
1649
|
+
* ```ts
|
|
1650
|
+
* // Iterate all bookmarked novels across pages
|
|
1651
|
+
* for await (const novel of client.users.bookmarks.novels({ userId: client.userId }).items()) {
|
|
1652
|
+
* console.log(novel.title)
|
|
1653
|
+
* }
|
|
1654
|
+
* ```
|
|
1655
|
+
*/
|
|
1656
|
+
novels(params: UserBookmarksNovelParams): PaginatedResultAsync<UserBookmarksNovelPage, PixivNovelItem>;
|
|
1694
1657
|
}
|
|
1695
1658
|
/** Methods for the user API namespace. */
|
|
1696
1659
|
declare class UserResource {
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
}
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
* MangaResource — methods for the manga API namespace.
|
|
1747
|
-
*/
|
|
1748
|
-
|
|
1660
|
+
#private;
|
|
1661
|
+
/** User bookmarks sub-namespace. */
|
|
1662
|
+
readonly bookmarks: UserBookmarksResource;
|
|
1663
|
+
constructor(http: HttpClient);
|
|
1664
|
+
/**
|
|
1665
|
+
* Fetches detailed profile information for a user.
|
|
1666
|
+
* GET /v1/user/detail
|
|
1667
|
+
*
|
|
1668
|
+
* @param params - Request parameters
|
|
1669
|
+
*/
|
|
1670
|
+
detail(params: UserDetailParams): ResultAsync<UserDetailResponse, PixivError>;
|
|
1671
|
+
/**
|
|
1672
|
+
* Fetches illusts posted by a user.
|
|
1673
|
+
* GET /v1/user/illusts
|
|
1674
|
+
*
|
|
1675
|
+
* @param params - Request parameters
|
|
1676
|
+
*/
|
|
1677
|
+
illusts(params: UserIllustsParams): PaginatedResultAsync<UserIllustsPage, PixivIllustItem>;
|
|
1678
|
+
/**
|
|
1679
|
+
* Fetches novels posted by a user.
|
|
1680
|
+
* GET /v1/user/novels
|
|
1681
|
+
*
|
|
1682
|
+
* @param params - Request parameters
|
|
1683
|
+
*/
|
|
1684
|
+
novels(params: UserNovelsParams): PaginatedResultAsync<UserNovelsPage, PixivNovelItem>;
|
|
1685
|
+
/**
|
|
1686
|
+
* Fetches the list of users that a user is following.
|
|
1687
|
+
* GET /v1/user/following
|
|
1688
|
+
*
|
|
1689
|
+
* @param params - Request parameters
|
|
1690
|
+
*/
|
|
1691
|
+
following(params: UserFollowingParams): PaginatedResultAsync<UserFollowingPage, PixivUserPreviewItem>;
|
|
1692
|
+
/**
|
|
1693
|
+
* Follows a user.
|
|
1694
|
+
* POST /v1/user/follow/add
|
|
1695
|
+
*
|
|
1696
|
+
* @param params - Request parameters
|
|
1697
|
+
*/
|
|
1698
|
+
followAdd(params: UserFollowAddParams): ResultAsync<Record<string, never>, PixivError>;
|
|
1699
|
+
/**
|
|
1700
|
+
* Unfollows a user.
|
|
1701
|
+
* POST /v1/user/follow/delete
|
|
1702
|
+
*
|
|
1703
|
+
* @param params - Request parameters
|
|
1704
|
+
*/
|
|
1705
|
+
followDelete(params: UserFollowDeleteParams): ResultAsync<Record<string, never>, PixivError>;
|
|
1706
|
+
}
|
|
1707
|
+
//#endregion
|
|
1708
|
+
//#region src/resources/manga.d.ts
|
|
1749
1709
|
/** Parameters for fetching recommended manga. */
|
|
1750
1710
|
interface MangaRecommendedParams {
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1711
|
+
/** OS filter to apply (default: `"for_ios"`). */
|
|
1712
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1713
|
+
/** Zero-based offset for pagination. */
|
|
1714
|
+
offset?: number;
|
|
1755
1715
|
}
|
|
1756
1716
|
/** Methods for the manga API namespace. */
|
|
1757
1717
|
declare class MangaResource {
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
}
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
* UgoiraResource — methods for the ugoira API namespace.
|
|
1771
|
-
*/
|
|
1772
|
-
|
|
1718
|
+
#private;
|
|
1719
|
+
constructor(http: HttpClient);
|
|
1720
|
+
/**
|
|
1721
|
+
* Fetches recommended manga.
|
|
1722
|
+
* GET /v1/manga/recommended
|
|
1723
|
+
*
|
|
1724
|
+
* @param params - Request parameters
|
|
1725
|
+
*/
|
|
1726
|
+
recommended(params?: MangaRecommendedParams): PaginatedResultAsync<MangaRecommendedPage, PixivIllustItem>;
|
|
1727
|
+
}
|
|
1728
|
+
//#endregion
|
|
1729
|
+
//#region src/resources/ugoira.d.ts
|
|
1773
1730
|
/** Parameters for fetching ugoira metadata. */
|
|
1774
1731
|
interface UgoiraMetadataParams {
|
|
1775
|
-
|
|
1776
|
-
|
|
1732
|
+
/** ID of the ugoira illust whose metadata to fetch. */
|
|
1733
|
+
illustId: number;
|
|
1777
1734
|
}
|
|
1778
1735
|
/** Methods for the ugoira API namespace. */
|
|
1779
1736
|
declare class UgoiraResource {
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
}
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
* ImageResource — helpers for fetching pixiv CDN images.
|
|
1793
|
-
*/
|
|
1794
|
-
|
|
1737
|
+
#private;
|
|
1738
|
+
constructor(http: HttpClient);
|
|
1739
|
+
/**
|
|
1740
|
+
* Fetches ugoira metadata (ZIP URL and per-frame timings).
|
|
1741
|
+
* GET /v1/ugoira/metadata
|
|
1742
|
+
*
|
|
1743
|
+
* @param params - Request parameters
|
|
1744
|
+
*/
|
|
1745
|
+
metadata(params: UgoiraMetadataParams): ResultAsync<UgoiraMetadataResponse, PixivError>;
|
|
1746
|
+
}
|
|
1747
|
+
//#endregion
|
|
1748
|
+
//#region src/resources/images.d.ts
|
|
1795
1749
|
/** Methods for fetching pixiv images. */
|
|
1796
1750
|
declare class ImageResource {
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
}
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
* PixivClient — main entry point for the @book000/pixivts library.
|
|
1812
|
-
*
|
|
1813
|
-
* @example
|
|
1814
|
-
* ```ts
|
|
1815
|
-
* const client = await PixivClient.of(process.env.PIXIV_REFRESH_TOKEN!)
|
|
1816
|
-
* const result = await client.illusts.detail({ illustId: 12345 })
|
|
1817
|
-
* if (result.isOk) console.log(result.value.illust.title)
|
|
1818
|
-
* ```
|
|
1819
|
-
*/
|
|
1820
|
-
|
|
1751
|
+
#private;
|
|
1752
|
+
constructor(http: HttpClient);
|
|
1753
|
+
/**
|
|
1754
|
+
* Fetches a pixiv image.
|
|
1755
|
+
*
|
|
1756
|
+
* Uses a browser User-Agent and Referer (required for pixiv CDN).
|
|
1757
|
+
* No Authorization header is sent.
|
|
1758
|
+
*
|
|
1759
|
+
* @param imageUrl - Full CDN image URL
|
|
1760
|
+
*/
|
|
1761
|
+
fetch(imageUrl: string): ResultAsync<Response, PixivError>;
|
|
1762
|
+
}
|
|
1763
|
+
//#endregion
|
|
1764
|
+
//#region src/client.d.ts
|
|
1821
1765
|
/** Options for constructing a {@link PixivClient}. */
|
|
1822
1766
|
interface PixivClientOptions {
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1767
|
+
/** Rate-limit retry configuration. */
|
|
1768
|
+
retry?: Partial<RateLimitRetryOptions>;
|
|
1769
|
+
/** Optional interceptor called after each successful response (DB seam). */
|
|
1770
|
+
onResponse?: ResponseInterceptor;
|
|
1827
1771
|
}
|
|
1828
1772
|
/**
|
|
1829
1773
|
* Main client for the pixiv API.
|
|
@@ -1832,62 +1776,63 @@ interface PixivClientOptions {
|
|
|
1832
1776
|
* because initialisation requires an async token refresh.
|
|
1833
1777
|
*/
|
|
1834
1778
|
declare class PixivClient {
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
}
|
|
1892
|
-
|
|
1779
|
+
#private;
|
|
1780
|
+
/** Illust API namespace. */
|
|
1781
|
+
readonly illusts: IllustResource;
|
|
1782
|
+
/** Novel API namespace. */
|
|
1783
|
+
readonly novels: NovelResource;
|
|
1784
|
+
/** User API namespace. */
|
|
1785
|
+
readonly users: UserResource;
|
|
1786
|
+
/** Manga API namespace. */
|
|
1787
|
+
readonly manga: MangaResource;
|
|
1788
|
+
/** Ugoira API namespace. */
|
|
1789
|
+
readonly ugoira: UgoiraResource;
|
|
1790
|
+
/** Image fetch helpers. */
|
|
1791
|
+
readonly images: ImageResource;
|
|
1792
|
+
private constructor();
|
|
1793
|
+
/**
|
|
1794
|
+
* Numeric user ID of the authenticated account.
|
|
1795
|
+
*
|
|
1796
|
+
* Available immediately after {@link PixivClient.of} resolves.
|
|
1797
|
+
* The pixiv OAuth endpoint returns the ID as a string; this getter
|
|
1798
|
+
* normalises it to `number` for consistency with resource method params
|
|
1799
|
+
* (e.g. `UserBookmarksIllustParams.userId`).
|
|
1800
|
+
*
|
|
1801
|
+
* @example
|
|
1802
|
+
* ```ts
|
|
1803
|
+
* const client = await PixivClient.of(refreshToken)
|
|
1804
|
+
* const bookmarks = await client.users.bookmarks.illusts({ userId: client.userId })
|
|
1805
|
+
* ```
|
|
1806
|
+
*/
|
|
1807
|
+
get userId(): number;
|
|
1808
|
+
/**
|
|
1809
|
+
* Returns the current OAuth access token.
|
|
1810
|
+
*
|
|
1811
|
+
* The access token is short-lived and changes after each call to
|
|
1812
|
+
* {@link PixivClient.of} and after each automatic token refresh triggered
|
|
1813
|
+
* by a 401 response.
|
|
1814
|
+
*
|
|
1815
|
+
* @returns The current bearer access token string
|
|
1816
|
+
*/
|
|
1817
|
+
getAccessToken(): string;
|
|
1818
|
+
/**
|
|
1819
|
+
* Returns the current OAuth refresh token.
|
|
1820
|
+
*
|
|
1821
|
+
* The refresh token is long-lived and is used to obtain new access tokens.
|
|
1822
|
+
* It may rotate after a successful token refresh.
|
|
1823
|
+
*
|
|
1824
|
+
* @returns The current refresh token string
|
|
1825
|
+
*/
|
|
1826
|
+
getRefreshToken(): string;
|
|
1827
|
+
/**
|
|
1828
|
+
* Creates a PixivClient by refreshing the given token.
|
|
1829
|
+
*
|
|
1830
|
+
* @param refreshToken - Pixiv refresh token
|
|
1831
|
+
* @param options - Optional retry and response interceptor configuration
|
|
1832
|
+
* @returns A fully initialised {@link PixivClient}
|
|
1833
|
+
*/
|
|
1834
|
+
static of(refreshToken: string, options?: PixivClientOptions): Promise<PixivClient>;
|
|
1835
|
+
}
|
|
1836
|
+
//#endregion
|
|
1893
1837
|
export { BookmarkRestrict, type ErrResult, FollowRestrict, type Frame, type HttpMethod, type IllustBookmarkAddParams, type IllustBookmarkDeleteParams, type IllustDetailParams, type IllustDetailResponse, type IllustListPage, type IllustRankingParams, type IllustRecommendedPage, type IllustRecommendedParams, type IllustRelatedParams, type IllustSearchParams, type IllustSeriesDetail, type IllustSeriesPage, type IllustSeriesParams, type ImageUrls, type MangaRecommendedPage, type MetaPages, type MetaSinglePage, type NovelBookmarkAddParams, type NovelBookmarkDeleteParams, type NovelDetailParams, type NovelDetailResponse, type NovelListPage, NovelRankingMode, type NovelRankingParams, type NovelRecommendedPage, type NovelRecommendedParams, type NovelRelatedParams, type NovelSearchParams, type NovelSeriesDetail, type NovelSeriesPage, type NovelSeriesParams, type NovelTextParams, OSFilter, type OkResult, type PagedResponse, PaginatedResultAsync, type ParsedNextUrl, type PixivApiErrorBody, PixivClient, type PixivClientOptions, type PixivError, PixivFetchError, type PixivIllustItem, type PixivNovelItem, type PixivUgoiraItem, type PixivUser, type PixivUserItem, type PixivUserPreviewItem, type PixivUserProfile, type PixivUserProfilePublicity, type PixivUserProfileWorkspace, type PrivacyPolicy, type ProfileImageUrls, RankingMode, type ResponseInterceptor, type ResponseRecord, type Result, ResultAsync, SearchDuration, SearchSort, SearchTarget, type Series, type Tag, type UgoiraMetadataResponse, type UserBookmarksIllustPage, type UserBookmarksIllustParams, type UserBookmarksNovelPage, type UserBookmarksNovelParams, type UserDetailParams, type UserDetailResponse, type UserFollowAddParams, type UserFollowDeleteParams, type UserFollowingPage, type UserFollowingParams, UserIllustType, type UserIllustsPage, type UserIllustsParams, type UserNovelsPage, type UserNovelsParams, type ZipUrls, apiError, authFailedError, err, failedPaginated, networkError, ok, parseNextUrl, rateLimitError };
|
|
1838
|
+
//# sourceMappingURL=index.d.ts.map
|