@lorenzopant/tmdb 1.18.1 → 1.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -542,6 +542,20 @@ declare class TMDBLogger {
542
542
  private static defaultLogger;
543
543
  }
544
544
  //#endregion
545
+ //#region src/utils/rate-limiter.d.ts
546
+ type RateLimitOptions = {
547
+ /**
548
+ * Maximum number of requests allowed within the window.
549
+ * @default 40
550
+ */
551
+ max_requests?: number;
552
+ /**
553
+ * Window size in milliseconds.
554
+ * @default 1_000
555
+ */
556
+ per_ms?: number;
557
+ };
558
+ //#endregion
545
559
  //#region src/types/config/timezones.d.ts
546
560
  type Timezone = TimezoneTuple[number];
547
561
  type TimezoneTuple = (typeof TIMEZONE_DATA)[number]["zones"];
@@ -1439,6 +1453,27 @@ type TMDBOptions = {
1439
1453
  onError?: ResponseErrorInterceptor;
1440
1454
  };
1441
1455
  };
1456
+ /**
1457
+ * When enabled, outgoing requests are queued to stay within TMDB's API rate limits.
1458
+ *
1459
+ * - `true` — uses the default limits (approximately 40 requests per second).
1460
+ * - Pass a {@link RateLimitOptions} object to customize `max_requests` and/or `per_ms`.
1461
+ *
1462
+ * Requests that exceed the budget are held in a FIFO queue and dispatched as
1463
+ * slots become available. This is especially useful for bulk data-fetching scripts.
1464
+ *
1465
+ * @default false (disabled)
1466
+ *
1467
+ * @example
1468
+ * ```ts
1469
+ * // Enable with defaults (~40 req / s)
1470
+ * const tmdb = new TMDB(token, { rate_limit: true });
1471
+ *
1472
+ * // Custom budget
1473
+ * const tmdb = new TMDB(token, { rate_limit: { max_requests: 30, per_ms: 1_000 } });
1474
+ * ```
1475
+ */
1476
+ rate_limit?: boolean | RateLimitOptions;
1442
1477
  };
1443
1478
  //#endregion
1444
1479
  //#region src/types/common/certifications.d.ts
@@ -3359,6 +3394,278 @@ type PersonImagesParams = PersonBaseParam;
3359
3394
  type PersonTranslationsParams = PersonBaseParam;
3360
3395
  type PersonTaggedImagesParams = Prettify<PersonBaseParam & WithPage>;
3361
3396
  //#endregion
3397
+ //#region src/types/v4/auth.d.ts
3398
+ /** Optional request body for POST /4/auth/request_token. */
3399
+ type V4AuthCreateRequestTokenBody = {
3400
+ /** URL to redirect the user back to after they approve the request token on TMDB. */redirect_to?: string;
3401
+ };
3402
+ /**
3403
+ * Response from POST /4/auth/request_token.
3404
+ * Contains a short-lived request token the user must approve at the TMDB website.
3405
+ */
3406
+ type V4AuthRequestTokenResponse = {
3407
+ /** Always `true` on success. */success: boolean;
3408
+ /** The generated request token. Redirect the user to:
3409
+ * `https://www.themoviedb.org/auth/access?request_token={request_token}` to approve it. */
3410
+ request_token: string;
3411
+ };
3412
+ /** Request body for POST /4/auth/access_token. */
3413
+ type V4AuthCreateAccessTokenBody = {
3414
+ /** The request token that the user has approved at the TMDB website. */request_token: string;
3415
+ };
3416
+ /**
3417
+ * Response from POST /4/auth/access_token.
3418
+ * Contains the permanent user access token and the TMDB account ID.
3419
+ */
3420
+ type V4AuthAccessTokenResponse = {
3421
+ /** Always `true` on success. */success: boolean; /** The permanent user access token (Bearer token). Store this securely — treat it like a password. */
3422
+ access_token: string; /** The TMDB account ID associated with this access token. Used by v4 account endpoints. */
3423
+ account_id: string;
3424
+ };
3425
+ /** Request body for DELETE /4/auth/access_token. */
3426
+ type V4AuthDeleteAccessTokenBody = {
3427
+ /** The access token to invalidate. */access_token: string;
3428
+ };
3429
+ /**
3430
+ * Response from DELETE /4/auth/access_token.
3431
+ */
3432
+ type V4AuthDeleteAccessTokenResponse = {
3433
+ /** `true` if the access token was successfully deleted. */success: boolean; /** TMDB internal status code. */
3434
+ status_code: number; /** Human-readable status message. */
3435
+ status_message: string;
3436
+ };
3437
+ //#endregion
3438
+ //#region src/types/v4/lists.d.ts
3439
+ /** A media type used in v4 list items. */
3440
+ type V4ListMediaType = "movie" | "tv";
3441
+ /**
3442
+ * A single item reference used when adding, updating, or removing items from a v4 list.
3443
+ */
3444
+ type V4ListItemInput = {
3445
+ /** The TMDB media type. */media_type: V4ListMediaType; /** The TMDB media ID. */
3446
+ media_id: number; /** Optional per-item comment. */
3447
+ comment?: string;
3448
+ };
3449
+ /** Standard status/success response returned by mutating v4 list endpoints. */
3450
+ type V4ListStatusResponse = {
3451
+ /** Always `true` on success. */success: boolean; /** TMDB internal status code. */
3452
+ status_code: number; /** Human-readable status message. */
3453
+ status_message: string;
3454
+ };
3455
+ /** Request body for POST /4/list. */
3456
+ type V4CreateListBody = {
3457
+ /** The name of the list. */name: string; /** ISO 639-1 language code (e.g. `"en"`). */
3458
+ iso_639_1: string; /** Optional description for the list. */
3459
+ description?: string; /** Whether the list is public. Defaults to `true`. */
3460
+ public?: boolean;
3461
+ };
3462
+ /**
3463
+ * Response from POST /4/list.
3464
+ * Returns the new list's ID alongside a standard status payload.
3465
+ */
3466
+ type V4CreateListResponse = V4ListStatusResponse & {
3467
+ /** The TMDB ID of the newly created list. */id: number;
3468
+ };
3469
+ /** Parameters for GET /4/list/{list_id}. */
3470
+ type V4ListDetailsParams = {
3471
+ /** The TMDB list ID. */list_id: number; /** Language for localized fields. Defaults to `en-US`. */
3472
+ language?: Language; /** Page number. Defaults to `1`. */
3473
+ page?: number;
3474
+ };
3475
+ /**
3476
+ * A single media item returned inside a v4 list's results array.
3477
+ * Fields vary slightly between movie and TV show entries; common fields are listed here.
3478
+ */
3479
+ type V4ListResult = {
3480
+ /** Whether the item is adult-only content. */adult: boolean; /** Backdrop image path, or `null` if unavailable. */
3481
+ backdrop_path?: string; /** TMDB ID. */
3482
+ id: number; /** The media type. */
3483
+ media_type: V4ListMediaType; /** Original language. */
3484
+ original_language: string; /** Poster image path, or `null` if unavailable. */
3485
+ poster_path?: string; /** Popularity score. */
3486
+ popularity: number; /** Vote average. */
3487
+ vote_average: number; /** Total vote count. */
3488
+ vote_count: number; /** Movie: original title. */
3489
+ original_title?: string; /** Movie: release date (YYYY-MM-DD). */
3490
+ release_date?: string; /** Movie: title. */
3491
+ title?: string; /** Movie: whether the movie has a video. */
3492
+ video?: boolean; /** TV: original name. */
3493
+ original_name?: string; /** TV: first air date (YYYY-MM-DD). */
3494
+ first_air_date?: string; /** TV: name. */
3495
+ name?: string; /** TV: origin countries. */
3496
+ origin_country?: string[];
3497
+ };
3498
+ /**
3499
+ * Full list detail response from GET /4/list/{list_id}.
3500
+ * Includes paginated results.
3501
+ */
3502
+ type V4ListDetails = {
3503
+ /** The TMDB list ID. */id: number; /** Display name. */
3504
+ name: string; /** Description text. */
3505
+ description: string; /** Username of the list creator. */
3506
+ created_by: string; /** Backdrop image path, or `null`. */
3507
+ backdrop_path?: string; /** Cover poster image path, or `null`. */
3508
+ poster_path?: string; /** Whether the list is publicly visible. */
3509
+ public: boolean; /** ISO 639-1 language code. */
3510
+ iso_639_1: string; /** ISO 3166-1 country code. */
3511
+ iso_3166_1: string; /** Total number of items in the list. */
3512
+ item_count: number; /** Average rating across all rated items. */
3513
+ average_rating: number; /** Total combined runtime of all items (minutes). */
3514
+ runtime: number; /** Active sort_by mode. */
3515
+ sort_by: string; /** Total revenue of items in the list. */
3516
+ revenue: number; /** Per-item comments keyed by `"movie:{id}"` or `"tv:{id}"`. */
3517
+ comments: Record<string, string | null>; /** Internal TMDB object IDs. */
3518
+ object_ids: Record<string, string>; /** Current page of results. */
3519
+ page: number; /** Total number of pages. */
3520
+ total_pages: number; /** Total number of items. */
3521
+ total_results: number; /** Paginated media items. */
3522
+ results: V4ListResult[];
3523
+ };
3524
+ /** Request body for PUT /4/list/{list_id}. */
3525
+ type V4UpdateListBody = {
3526
+ /** The TMDB list ID. */list_id: number; /** New display name. */
3527
+ name?: string; /** New description. */
3528
+ description?: string; /** Change visibility. */
3529
+ public?: boolean; /** Sort field (e.g. `"original_order.asc"`, `"vote_average.desc"`). */
3530
+ sort_by?: string;
3531
+ };
3532
+ /** Parameters for DELETE /4/list/{list_id}. */
3533
+ type V4DeleteListParams = {
3534
+ /** The TMDB list ID. */list_id: number;
3535
+ };
3536
+ /** Request body for POST /4/list/{list_id}/items. */
3537
+ type V4AddListItemsBody = {
3538
+ /** Array of items to add. */items: V4ListItemInput[];
3539
+ };
3540
+ /** Per-item result within an add/update items response. */
3541
+ type V4ListItemResult = {
3542
+ /** Whether this individual item was successfully processed. */success: boolean; /** The media type. */
3543
+ media_type: V4ListMediaType; /** The TMDB media ID. */
3544
+ media_id: number;
3545
+ };
3546
+ /** Response from POST /4/list/{list_id}/items (add) and PUT /4/list/{list_id}/items (update). */
3547
+ type V4AddListItemsResponse = V4ListStatusResponse & {
3548
+ /** Per-item success status. */results: V4ListItemResult[];
3549
+ };
3550
+ /** Request body for PUT /4/list/{list_id}/items (update comments). */
3551
+ type V4UpdateListItemsBody = V4AddListItemsBody;
3552
+ /** Response from PUT /4/list/{list_id}/items. */
3553
+ type V4UpdateListItemsResponse = V4AddListItemsResponse;
3554
+ /** Request body for DELETE /4/list/{list_id}/items. */
3555
+ type V4RemoveListItemsBody = {
3556
+ /** Array of items to remove. */items: Pick<V4ListItemInput, "media_type" | "media_id">[];
3557
+ };
3558
+ /** Parameters for GET /4/list/{list_id}/item_status. */
3559
+ type V4ListItemStatusParams = {
3560
+ /** The TMDB list ID. */list_id: number; /** The media type to check. */
3561
+ media_type: V4ListMediaType; /** The TMDB media ID to check. */
3562
+ media_id: number;
3563
+ };
3564
+ /**
3565
+ * Response from GET /4/list/{list_id}/item_status.
3566
+ */
3567
+ type V4ListItemStatusResponse = {
3568
+ /** The TMDB list ID. */id: number; /** The media type. */
3569
+ media_type: V4ListMediaType; /** The TMDB media ID. */
3570
+ media_id: number;
3571
+ };
3572
+ //#endregion
3573
+ //#region src/types/guest_sessions.d.ts
3574
+ /** Common query params for paginated guest session rated lists. */
3575
+ type GuestSessionRatedParams = {
3576
+ /** The guest session ID. */guest_session_id: string; /** Sort direction for the results. */
3577
+ sort_by?: AccountSortBy;
3578
+ } & WithLanguage & WithPage;
3579
+ /** Paginated response of rated movies for a guest session. */
3580
+ type GuestSessionRatedMoviesResponse = PaginatedResponse<AccountRatedMovieItem>;
3581
+ /** Paginated response of rated TV shows for a guest session. */
3582
+ type GuestSessionRatedTVResponse = PaginatedResponse<AccountRatedTVItem>;
3583
+ /** Paginated response of rated TV episodes for a guest session. */
3584
+ type GuestSessionRatedEpisodesResponse = PaginatedResponse<AccountRatedEpisodeItem>;
3585
+ //#endregion
3586
+ //#region src/types/lists.d.ts
3587
+ /** Standard mutation response returned by add_movie, remove_movie, clear, and delete. */
3588
+ type ListMutationResponse = {
3589
+ /** TMDB internal status code. */status_code: number; /** Human-readable status message. */
3590
+ status_message: string;
3591
+ };
3592
+ /** Query params for list mutation endpoints that require a session and a list ID. */
3593
+ type ListMutationParams = {
3594
+ /** TMDB list ID. */list_id: number; /** v3 session ID (required). */
3595
+ session_id: string;
3596
+ };
3597
+ /** A single item inside a TMDB v3 list (movie with media_type). */
3598
+ type ListItem = {
3599
+ /** Whether the item is adult content. */adult: boolean; /** Path to the backdrop image, if available. */
3600
+ backdrop_path?: string; /** Array of genre IDs. */
3601
+ genre_ids: number[]; /** Unique TMDB ID of the item. */
3602
+ id: number; /** Media type — always `"movie"` for v3 lists. */
3603
+ media_type: string; /** ISO 639-1 original language code. */
3604
+ original_language: string; /** Original title. */
3605
+ original_title: string; /** Plot overview. */
3606
+ overview: string; /** Popularity score. */
3607
+ popularity: number; /** Path to the poster image, if available. */
3608
+ poster_path?: string; /** Release date (YYYY-MM-DD). */
3609
+ release_date: string; /** Localized title. */
3610
+ title: string; /** Whether the item has a video. */
3611
+ video: boolean; /** Average TMDB vote score. */
3612
+ vote_average: number; /** Total number of TMDB votes. */
3613
+ vote_count: number;
3614
+ };
3615
+ /** Full details of a TMDB v3 list. */
3616
+ type ListDetails = {
3617
+ /** Display name of the list creator. */created_by: string; /** Description of the list. */
3618
+ description: string; /** Number of users who have favorited this list. */
3619
+ favorite_count: number; /** Unique TMDB list ID (returned as a string by the API). */
3620
+ id: string; /** Array of items in the list. */
3621
+ items: ListItem[]; /** Total number of items in the list. */
3622
+ item_count: number; /** ISO 639-1 language the list is written in. */
3623
+ iso_639_1: string; /** Display name of the list. */
3624
+ name: string; /** Path to the list's poster image, if set. */
3625
+ poster_path?: string;
3626
+ };
3627
+ /** Query params for the list details endpoint. */
3628
+ type ListDetailsParams = {
3629
+ /** TMDB list ID. */list_id: number;
3630
+ } & WithLanguage & WithPage;
3631
+ /** Request body for creating a new list. */
3632
+ type ListCreateBody = {
3633
+ /** Display name of the list. */name: string; /** Description of the list. */
3634
+ description: string; /** ISO 639-1 language code for the list. */
3635
+ language: string;
3636
+ };
3637
+ /** Query params for the create list endpoint. */
3638
+ type ListCreateParams = {
3639
+ /** v3 session ID (required). */session_id: string;
3640
+ };
3641
+ /** Response from creating a new list. */
3642
+ type ListCreateResponse = {
3643
+ /** Human-readable status message. */status_message: string; /** Whether the list was created successfully. */
3644
+ success: boolean; /** TMDB internal status code. */
3645
+ status_code: number; /** The ID of the newly created list. */
3646
+ list_id: number;
3647
+ };
3648
+ /** Request body for add_movie and remove_movie. */
3649
+ type ListMovieBody = {
3650
+ /** TMDB movie ID to add or remove. */media_id: number;
3651
+ };
3652
+ /** Query params for clearing all items from a list. */
3653
+ type ListClearParams = {
3654
+ /** TMDB list ID. */list_id: number; /** v3 session ID (required). */
3655
+ session_id: string; /** Must be `true` to confirm the operation. */
3656
+ confirm: boolean;
3657
+ };
3658
+ /** Query params for the check item status endpoint. */
3659
+ type ListItemStatusParams = {
3660
+ /** TMDB list ID. */list_id: number; /** TMDB movie ID to check. */
3661
+ movie_id?: number;
3662
+ } & WithLanguage;
3663
+ /** Response from the check item status endpoint. */
3664
+ type ListItemStatusResponse = {
3665
+ /** The TMDB list ID. */id: number; /** Whether the movie is present in the list. */
3666
+ item_present: boolean;
3667
+ };
3668
+ //#endregion
3362
3669
  //#region src/client.d.ts
3363
3670
  declare class ApiClient {
3364
3671
  private accessToken;
@@ -3372,14 +3679,17 @@ declare class ApiClient {
3372
3679
  */
3373
3680
  private inflightRequests;
3374
3681
  private deduplication;
3682
+ private rateLimiter?;
3375
3683
  private requestInterceptors;
3376
3684
  private onSuccessInterceptor?;
3377
3685
  private onErrorInterceptor?;
3378
3686
  private imageApi?;
3379
3687
  constructor(accessToken: string, options?: {
3688
+ /** @internal API version to target. Used by TMDBv4 — not exposed in TMDBOptions. */version?: 3 | 4;
3380
3689
  logger?: boolean | TMDBLoggerFn;
3381
3690
  deduplication?: boolean;
3382
3691
  images?: ImagesConfig;
3692
+ rate_limit?: boolean | RateLimitOptions;
3383
3693
  interceptors?: {
3384
3694
  request?: RequestInterceptor | RequestInterceptor[];
3385
3695
  response?: {
@@ -3426,15 +3736,19 @@ declare class ApiClient {
3426
3736
  private sanitizeNulls;
3427
3737
  private handleError;
3428
3738
  /**
3429
- * Makes an authenticated mutation request (POST, PUT, or DELETE) to the TMDB API.
3430
- * Unlike `request()`, mutations are never deduplicated since they change server state.
3739
+ * Makes an authenticated mutation request to the TMDB API.
3740
+ * Unlike `request()`, mutations are **never deduplicated** since they change server state.
3741
+ *
3742
+ * Accepts `"GET"` in addition to the standard mutation verbs for the rare TMDB endpoints
3743
+ * (e.g. `GET /4/list/{id}/clear`) that are specified as GET but carry side effects and
3744
+ * must therefore not be collapsed by the deduplication layer.
3431
3745
  *
3432
3746
  * @param method - HTTP method to use
3433
3747
  * @param endpoint - API path (e.g. "/account/123/favorite")
3434
- * @param body - JSON body to send (omit for DELETE requests without a body)
3748
+ * @param body - JSON body to send (omit for DELETE/GET requests without a body)
3435
3749
  * @param params - Optional query string parameters (e.g. session_id)
3436
3750
  */
3437
- mutate<T>(method: "POST" | "PUT" | "DELETE", endpoint: string, body?: Record<string, unknown>, params?: Record<string, unknown | undefined>): Promise<T>;
3751
+ mutate<T>(method: "GET" | "POST" | "PUT" | "DELETE", endpoint: string, body?: Record<string, unknown>, params?: Record<string, unknown | undefined>): Promise<T>;
3438
3752
  /**
3439
3753
  * Shared fetch + response-parsing pipeline used by both `request` and `mutate`.
3440
3754
  * Handles URL construction, auth, logging, error mapping, and null sanitisation.
@@ -5109,9 +5423,292 @@ declare class AuthenticationAPI extends TMDBAPIBase {
5109
5423
  delete_session(body: AuthDeleteSessionBody): Promise<AuthDeleteSessionResponse>;
5110
5424
  }
5111
5425
  //#endregion
5426
+ //#region src/endpoints/guest_sessions.d.ts
5427
+ declare class GuestSessionsAPI extends TMDBAPIBase {
5428
+ private guestSessionPath;
5429
+ private guestSessionSubPath;
5430
+ /**
5431
+ * Rated Movies
5432
+ * GET - https://api.themoviedb.org/3/guest_session/{guest_session_id}/rated/movies
5433
+ *
5434
+ * Get the rated movies for a guest session.
5435
+ * @param params Guest session ID, optional language, page, and sort_by.
5436
+ * @reference https://developer.themoviedb.org/reference/guest-session-rated-movies
5437
+ */
5438
+ rated_movies(params: GuestSessionRatedParams): Promise<GuestSessionRatedMoviesResponse>;
5439
+ /**
5440
+ * Rated TV
5441
+ * GET - https://api.themoviedb.org/3/guest_session/{guest_session_id}/rated/tv
5442
+ *
5443
+ * Get the rated TV shows for a guest session.
5444
+ * @param params Guest session ID, optional language, page, and sort_by.
5445
+ * @reference https://developer.themoviedb.org/reference/guest-session-rated-tv
5446
+ */
5447
+ rated_tv(params: GuestSessionRatedParams): Promise<GuestSessionRatedTVResponse>;
5448
+ /**
5449
+ * Rated TV Episodes
5450
+ * GET - https://api.themoviedb.org/3/guest_session/{guest_session_id}/rated/tv/episodes
5451
+ *
5452
+ * Get the rated TV episodes for a guest session.
5453
+ * @param params Guest session ID, optional language, page, and sort_by.
5454
+ * @reference https://developer.themoviedb.org/reference/guest-session-rated-tv-episodes
5455
+ */
5456
+ rated_tv_episodes(params: GuestSessionRatedParams): Promise<GuestSessionRatedEpisodesResponse>;
5457
+ }
5458
+ //#endregion
5459
+ //#region src/endpoints/lists.d.ts
5460
+ declare class ListsAPI extends TMDBAPIBase {
5461
+ private listPath;
5462
+ private listSubPath;
5463
+ /**
5464
+ * Details
5465
+ * GET - https://api.themoviedb.org/3/list/{list_id}
5466
+ *
5467
+ * Get the details of a list.
5468
+ * @param params List ID and optional language and page.
5469
+ * @reference https://developer.themoviedb.org/reference/list-details
5470
+ */
5471
+ details(params: ListDetailsParams): Promise<ListDetails>;
5472
+ /**
5473
+ * Create
5474
+ * POST - https://api.themoviedb.org/3/list
5475
+ *
5476
+ * Create a new list.
5477
+ * @param params session_id query param (required).
5478
+ * @param body name, description, and language for the new list.
5479
+ * @reference https://developer.themoviedb.org/reference/list-create
5480
+ */
5481
+ create(params: ListCreateParams, body: ListCreateBody): Promise<ListCreateResponse>;
5482
+ /**
5483
+ * Delete
5484
+ * DELETE - https://api.themoviedb.org/3/list/{list_id}
5485
+ *
5486
+ * Delete a list.
5487
+ * @param params List ID and session_id (required).
5488
+ * @reference https://developer.themoviedb.org/reference/list-delete
5489
+ */
5490
+ delete(params: ListMutationParams): Promise<ListMutationResponse>;
5491
+ /**
5492
+ * Add Movie
5493
+ * POST - https://api.themoviedb.org/3/list/{list_id}/add_item
5494
+ *
5495
+ * Add a movie to a list.
5496
+ * @param params List ID and session_id (required).
5497
+ * @param body media_id of the movie to add.
5498
+ * @reference https://developer.themoviedb.org/reference/list-add-movie
5499
+ */
5500
+ add_movie(params: ListMutationParams, body: ListMovieBody): Promise<ListMutationResponse>;
5501
+ /**
5502
+ * Remove Movie
5503
+ * POST - https://api.themoviedb.org/3/list/{list_id}/remove_item
5504
+ *
5505
+ * Remove a movie from a list.
5506
+ * @param params List ID and session_id (required).
5507
+ * @param body media_id of the movie to remove.
5508
+ * @reference https://developer.themoviedb.org/reference/list-remove-movie
5509
+ */
5510
+ remove_movie(params: ListMutationParams, body: ListMovieBody): Promise<ListMutationResponse>;
5511
+ /**
5512
+ * Check Item Status
5513
+ * GET - https://api.themoviedb.org/3/list/{list_id}/item_status
5514
+ *
5515
+ * Check if a movie has already been added to a list.
5516
+ * @param params List ID and optional movie_id and language.
5517
+ * @reference https://developer.themoviedb.org/reference/list-check-item-status
5518
+ */
5519
+ check_item_status(params: ListItemStatusParams): Promise<ListItemStatusResponse>;
5520
+ /**
5521
+ * Clear
5522
+ * POST - https://api.themoviedb.org/3/list/{list_id}/clear
5523
+ *
5524
+ * Clear all items from a list. Pass `confirm: true` to confirm the operation.
5525
+ * @param params List ID, session_id, and confirm flag (required).
5526
+ * @reference https://developer.themoviedb.org/reference/list-clear
5527
+ */
5528
+ clear(params: ListClearParams): Promise<ListMutationResponse>;
5529
+ }
5530
+ //#endregion
5531
+ //#region src/endpoints/v4/auth.d.ts
5532
+ declare class V4AuthAPI extends TMDBAPIBase {
5533
+ /**
5534
+ * Create Request Token
5535
+ * POST - https://api.themoviedb.org/4/auth/request_token
5536
+ *
5537
+ * Generate a request token that the user must approve at the TMDB website to begin
5538
+ * the v4 OAuth-style flow. Redirect the user to:
5539
+ * `https://www.themoviedb.org/auth/access?request_token={request_token}`
5540
+ *
5541
+ * Once approved, exchange the token for an access token using `create_access_token`.
5542
+ * @param body Optional body with a `redirect_to` URL for post-approval redirect.
5543
+ * @reference https://developer.themoviedb.org/reference/create-request-token
5544
+ */
5545
+ create_request_token(body?: V4AuthCreateRequestTokenBody): Promise<V4AuthRequestTokenResponse>;
5546
+ /**
5547
+ * Create Access Token
5548
+ * POST - https://api.themoviedb.org/4/auth/access_token
5549
+ *
5550
+ * Exchange a user-approved request token for a permanent user access token and
5551
+ * TMDB account ID. Store the returned `access_token` securely — it is valid
5552
+ * indefinitely until explicitly deleted with `delete_access_token`.
5553
+ * @param body An object containing the approved `request_token`.
5554
+ * @reference https://developer.themoviedb.org/reference/create-access-token
5555
+ */
5556
+ create_access_token(body: V4AuthCreateAccessTokenBody): Promise<V4AuthAccessTokenResponse>;
5557
+ /**
5558
+ * Delete Access Token (Logout)
5559
+ * DELETE - https://api.themoviedb.org/4/auth/access_token
5560
+ *
5561
+ * Invalidate a user access token. Use this to log a user out of your application.
5562
+ * @param body An object containing the `access_token` to delete.
5563
+ * @reference https://developer.themoviedb.org/reference/delete-access-token
5564
+ */
5565
+ delete_access_token(body: V4AuthDeleteAccessTokenBody): Promise<V4AuthDeleteAccessTokenResponse>;
5566
+ }
5567
+ //#endregion
5568
+ //#region src/endpoints/v4/account.d.ts
5569
+ declare class V4AccountAPI extends TMDBAPIBase {}
5570
+ //#endregion
5571
+ //#region src/endpoints/v4/lists.d.ts
5572
+ declare class V4ListsAPI extends TMDBAPIBase {
5573
+ private listPath;
5574
+ /**
5575
+ * Create List
5576
+ * POST - https://api.themoviedb.org/4/list
5577
+ *
5578
+ * Create a new v4 list. The authenticated user becomes the owner.
5579
+ * @param body List name and ISO 639-1 language code are required.
5580
+ * @reference https://developer.themoviedb.org/reference/list-create
5581
+ */
5582
+ create(body: V4CreateListBody): Promise<V4CreateListResponse>;
5583
+ /**
5584
+ * List Details
5585
+ * GET - https://api.themoviedb.org/4/list/{list_id}
5586
+ *
5587
+ * Retrieve the details and paginated items of a specific list.
5588
+ * @param params `list_id` is required. Optionally pass `language` and `page`.
5589
+ * @reference https://developer.themoviedb.org/reference/list-details
5590
+ */
5591
+ details({
5592
+ list_id,
5593
+ ...params
5594
+ }: V4ListDetailsParams): Promise<V4ListDetails>;
5595
+ /**
5596
+ * Update List
5597
+ * PUT - https://api.themoviedb.org/4/list/{list_id}
5598
+ *
5599
+ * Update the metadata (name, description, visibility, sort order) of an existing list.
5600
+ * @param body `list_id` plus any fields to change.
5601
+ * @reference https://developer.themoviedb.org/reference/list-update
5602
+ */
5603
+ update({
5604
+ list_id,
5605
+ ...body
5606
+ }: V4UpdateListBody): Promise<V4ListStatusResponse>;
5607
+ /**
5608
+ * Delete List
5609
+ * DELETE - https://api.themoviedb.org/4/list/{list_id}
5610
+ *
5611
+ * Permanently delete a list. This action cannot be undone.
5612
+ * @param params.list_id The TMDB list ID to delete.
5613
+ * @reference https://developer.themoviedb.org/reference/list-delete
5614
+ */
5615
+ delete({
5616
+ list_id
5617
+ }: V4DeleteListParams): Promise<V4ListStatusResponse>;
5618
+ /**
5619
+ * Add Items
5620
+ * POST - https://api.themoviedb.org/4/list/{list_id}/items
5621
+ *
5622
+ * Add one or more movies or TV shows to a list. For each item the response
5623
+ * includes whether it was added successfully.
5624
+ * @param list_id The TMDB list ID.
5625
+ * @param body Array of `{ media_type, media_id }` objects to add.
5626
+ * @reference https://developer.themoviedb.org/reference/list-add-items
5627
+ */
5628
+ add_items(list_id: number, body: V4AddListItemsBody): Promise<V4AddListItemsResponse>;
5629
+ /**
5630
+ * Update Items
5631
+ * PUT - https://api.themoviedb.org/4/list/{list_id}/items
5632
+ *
5633
+ * Update per-item comments for items already in the list.
5634
+ * @param list_id The TMDB list ID.
5635
+ * @param body Array of `{ media_type, media_id, comment }` objects.
5636
+ * @reference https://developer.themoviedb.org/reference/list-update-items
5637
+ */
5638
+ update_items(list_id: number, body: V4UpdateListItemsBody): Promise<V4UpdateListItemsResponse>;
5639
+ /**
5640
+ * Remove Items
5641
+ * DELETE - https://api.themoviedb.org/4/list/{list_id}/items
5642
+ *
5643
+ * Remove one or more items from the list.
5644
+ * @param list_id The TMDB list ID.
5645
+ * @param body Array of `{ media_type, media_id }` objects to remove.
5646
+ * @reference https://developer.themoviedb.org/reference/list-remove-items
5647
+ */
5648
+ remove_items(list_id: number, body: V4RemoveListItemsBody): Promise<V4ListStatusResponse>;
5649
+ /**
5650
+ * Check Item Status
5651
+ * GET - https://api.themoviedb.org/4/list/{list_id}/item_status
5652
+ *
5653
+ * Check whether a specific movie or TV show is already present in the list.
5654
+ * @param params `list_id`, `media_type`, and `media_id` are all required.
5655
+ * @reference https://developer.themoviedb.org/reference/list-item-status
5656
+ */
5657
+ item_status({
5658
+ list_id,
5659
+ ...params
5660
+ }: V4ListItemStatusParams): Promise<V4ListItemStatusResponse>;
5661
+ /**
5662
+ * Clear List
5663
+ * GET - https://api.themoviedb.org/4/list/{list_id}/clear
5664
+ *
5665
+ * Remove all items from the list without deleting the list itself.
5666
+ * @param list_id The TMDB list ID to clear.
5667
+ * @reference https://developer.themoviedb.org/reference/list-clear
5668
+ */
5669
+ clear(list_id: number): Promise<V4ListStatusResponse>;
5670
+ }
5671
+ //#endregion
5672
+ //#region src/tmdb.v4.d.ts
5673
+ /**
5674
+ * Aggregator for all TMDB API v4 namespaces.
5675
+ *
5676
+ * Access via `tmdb.v4` — the v4 client is backed by `https://api.themoviedb.org/4`
5677
+ * and inherits the same access token and options as the parent TMDB instance.
5678
+ *
5679
+ * @example
5680
+ * ```ts
5681
+ * const tmdb = new TMDB(accessToken);
5682
+ *
5683
+ * // v4 auth flow
5684
+ * const { request_token } = await tmdb.v4.auth.create_request_token();
5685
+ * // ... user approves at https://www.themoviedb.org/auth/access?request_token=...
5686
+ * const { access_token, account_id } = await tmdb.v4.auth.create_access_token({ request_token });
5687
+ *
5688
+ * // v4 account (account_id is a string from the access token response)
5689
+ * const profile = await tmdb.v4.account.details(account_id);
5690
+ * const favorites = await tmdb.v4.account.favorite_movies({ account_id, page: 1 });
5691
+ *
5692
+ * // v4 lists (full CRUD)
5693
+ * const list = await tmdb.v4.lists.create({ name: "My list", iso_639_1: "en" });
5694
+ * await tmdb.v4.lists.add_items(list.id, { items: [{ media_type: "movie", media_id: 550 }] });
5695
+ * ```
5696
+ */
5697
+ declare class TMDBv4 {
5698
+ private client;
5699
+ /** v4 authentication — request token → access token → logout. */
5700
+ auth: V4AuthAPI;
5701
+ /** v4 account — details, lists, favorites, watchlist, rated. */
5702
+ account: V4AccountAPI;
5703
+ /** v4 lists — full CRUD for user-created lists. */
5704
+ lists: V4ListsAPI;
5705
+ constructor(accessToken: string, options?: TMDBOptions);
5706
+ }
5707
+ //#endregion
5112
5708
  //#region src/tmdb.d.ts
5113
5709
  declare class TMDB {
5114
5710
  private client;
5711
+ private accessToken;
5115
5712
  private options;
5116
5713
  movies: MoviesAPI;
5117
5714
  movie_lists: MovieListsAPI;
@@ -5140,6 +5737,14 @@ declare class TMDB {
5140
5737
  people: PeopleAPI;
5141
5738
  account: AccountAPI;
5142
5739
  authentication: AuthenticationAPI;
5740
+ guest_sessions: GuestSessionsAPI;
5741
+ lists: ListsAPI;
5742
+ /**
5743
+ * TMDB API v4 namespaces. Access via `tmdb.v4.auth`, `tmdb.v4.account`, `tmdb.v4.lists`.
5744
+ * Requires a Bearer (JWT) access token — throws if the instance was created with an API key.
5745
+ */
5746
+ get v4(): TMDBv4;
5747
+ private _v4;
5143
5748
  /**
5144
5749
  * Creates a new TMDB instance.
5145
5750
  * @param accessToken The TMDB API access token.
@@ -5184,4 +5789,4 @@ declare function hasLogoPath(data: unknown): data is {
5184
5789
  logo_path: string;
5185
5790
  };
5186
5791
  //#endregion
5187
- export { AccountAPI, AccountAddFavoriteBody, AccountAddToWatchlistBody, AccountAvatar, AccountDetails, AccountDetailsParams, AccountListItem, AccountListsParams, AccountListsResponse, AccountMediaListParams, AccountMovieItem, AccountMovieListResponse, AccountMutationParams, AccountMutationResponse, AccountRatedEpisodeItem, AccountRatedEpisodesResponse, AccountRatedMovieItem, AccountRatedMoviesResponse, AccountRatedTVItem, AccountRatedTVResponse, AccountSortBy, AccountTVItem, AccountTVListResponse, AlternativeName, AlternativeNamesResult, AlternativeTitle, AuthCreateSessionBody, AuthCreateSessionResponse, AuthCreateSessionWithLoginBody, AuthDeleteSessionBody, AuthDeleteSessionResponse, AuthGuestSessionResponse, AuthRequestTokenResponse, AuthValidateKeyResponse, AuthenticationAPI, BACKDROP_SIZES, BackdropSize, Cast, CertificationItem, Certifications, CertificationsAPI, Change, ChangeItem, ChangeResultItem, Changes, ChangesAPI, Collection, CollectionBaseParam, CollectionDetailsParams, CollectionImages, CollectionImagesParams, CollectionItem, CollectionResultItem, CollectionTranslationData, CollectionTranslations, CollectionsAPI, CompaniesAPI, Company, CompanyAlternativeName, CompanyAlternativeNames, CompanyAlternativeNamesParams, CompanyBaseParam, CompanyDetailsParams, CompanyImages, CompanyImagesParams, CompanyResultItem, CompanySummary, ConfigurationAPI, ConfigurationCountriesParams, ConfigurationCountry, ConfigurationJob, ConfigurationLanguage, ConfigurationResponse, ConfigurationTimezone, ContentRating, CountryISO3166_1, Credit, CreditBaseParam, CreditDetails, CreditDetailsMedia, CreditDetailsMovieMedia, CreditDetailsParams, CreditDetailsPerson, CreditDetailsTVEpisode, CreditDetailsTVMedia, CreditDetailsTVSeason, CreditsAPI, Crew, DateRange, DefaultImageSizesConfig, DiscoverAPI, DiscoverFilterExpression, DiscoverMovieParams, DiscoverMovieSortBy, DiscoverTVParams, DiscoverTVResultItem, DiscoverTVSortBy, DiscoverTVStatus, DiscoverTVType, FileType, FindAPI, FindByIDParams, FindExternalSource, FindMovieResultItem, FindPersonResultItem, FindResults, FindTVEpisodeResultItem, FindTVResultItem, FindTVSeasonResultItem, Genre, GenresAPI, GenresResponse, IMAGE_BASE_URL, IMAGE_SECURE_BASE_URL, ImageCollectionKey, ImageConfiguration, ImageItem, ImageSize, ImageSizeTypes, ImagesConfig, ImagesResult, Keyword, KeywordBaseParam, KeywordDetailsParams, KeywordMoviesParams, KeywordResultItem, KeywordsAPI, KnownForItem, KnownForMovie, KnownForTV, LOGO_SIZES, Language, LanguageISO6391, LiteralUnion, LogoSize, MediaType, MediaWatchProviders, MovieAlternativeTitles, MovieAlternativeTitlesParams, MovieAppendToResponseNamespace, MovieAppendableMap, MovieChanges, MovieChangesParams, MovieCollection, MovieCredits, MovieCreditsParams, MovieDetails, MovieDetailsParams, MovieDetailsWithAppends, MovieExternalIDs, MovieExternalIDsParams, MovieImages, MovieImagesParams, MovieKeywords, MovieKeywordsParams, MovieListParams, MovieListsAPI, MovieRecommendations, MovieRecommendationsParams, MovieReleaseDate, MovieReleaseDateResult, MovieReleaseDates, MovieReleaseDatesParams, MovieResultItem, MovieReviews, MovieReviewsParams, MovieSimilar, MovieSimilarParams, MovieTranslationData, MovieTranslations, MovieTranslationsParams, MovieVideos, MovieVideosParams, MovieWatchProvidersParams, MoviesAPI, MultiSearchResultItem, Network, NetworkBaseParams, NetworkImages, NetworkItem, NetworksAPI, OrganizationImage, POSTER_SIZES, PROFILE_SIZES, PaginatedResponse, PeopleAPI, PeopleListParams, PeopleListsAPI, PersonAppendToResponseNamespace, PersonAppendableMap, PersonBaseParam, PersonChanges, PersonChangesParams, PersonCombinedCastCredit, PersonCombinedCredits, PersonCombinedCrewCredit, PersonCreditsParams, PersonDetails, PersonDetailsParams, PersonDetailsWithAppends, PersonExternalIDs, PersonExternalIDsParams, PersonImages, PersonImagesParams, PersonMovieCastCredit, PersonMovieCredits, PersonMovieCrewCredit, PersonResultItem, PersonTVCastCredit, PersonTVCredits, PersonTVCrewCredit, PersonTaggedImage, PersonTaggedImageMedia, PersonTaggedImages, PersonTaggedImagesParams, PersonTranslationData, PersonTranslations, PersonTranslationsParams, PosterSize, Prettify, PrimaryTranslations, ProductionCompany, ProductionCountry, ProfileSize, RequestInterceptor, RequestInterceptorContext, ResponseErrorInterceptor, ResponseSuccessInterceptor, Review, ReviewAuthorDetails, ReviewDetails, ReviewDetailsParams, ReviewsAPI, STILL_SIZES, SearchAPI, SearchCollectionsParams, SearchCompanyParams, SearchKeywordsParams, SearchMoviesParams, SearchMultiParams, SearchPersonParams, SearchTVSeriesParams, SpokenLanguage, StillSize, TMDB, TMDBCountries, TMDBError, TMDBLogger, TMDBLoggerEntry, TMDBLoggerFn, TMDBOptions, TMDBQueryParams, TVAggregateCredits, TVAggregateCreditsCastItem, TVAggregateCreditsCrewItem, TVAggregateCreditsParams, TVAlternativeTitles, TVAppendToResponseNamespace, TVAppendableMap, TVBaseParam, TVChangeParams, TVContentRatings, TVCreditJob, TVCreditRole, TVCredits, TVCreditsParams, TVDetailsParams, TVDetailsWithAppends, TVEpisode, TVEpisodeAppendToResponseNamespace, TVEpisodeAppendableMap, TVEpisodeBaseParams, TVEpisodeCredits, TVEpisodeCreditsParams, TVEpisodeDetailsParams, TVEpisodeDetailsWithAppends, TVEpisodeExternalIDs, TVEpisodeGroupDetails, TVEpisodeGroupDetailsItem, TVEpisodeGroupEpisode, TVEpisodeGroupItem, TVEpisodeGroupParams, TVEpisodeGroupType, TVEpisodeGroups, TVEpisodeGroupsAPI, TVEpisodeId, TVEpisodeImages, TVEpisodeImagesParams, TVEpisodeItem, TVEpisodeTranslationData, TVEpisodeTranslations, TVEpisodeVideos, TVEpisodesAPI, TVExternalIDs, TVImageItem, TVImages, TVImagesParams, TVKeywords, TVRecommendations, TVRecommendationsParams, TVReviews, TVReviewsParams, TVScreenedTheatrically, TVScreeningItem, TVSeason, TVSeasonAggregateCredits, TVSeasonAggregateCreditsParams, TVSeasonAppendToResponseNamespace, TVSeasonAppendableMap, TVSeasonBaseParams, TVSeasonChanges, TVSeasonChangesParams, TVSeasonCredits, TVSeasonCreditsParams, TVSeasonDetailsParams, TVSeasonDetailsWithAppends, TVSeasonEpisode, TVSeasonExternalIDs, TVSeasonId, TVSeasonImages, TVSeasonImagesParams, TVSeasonItem, TVSeasonTranslationData, TVSeasonTranslations, TVSeasonVideos, TVSeasonVideosParams, TVSeasonWatchProvidersParams, TVSeasonsAPI, TVSeriesAPI, TVSeriesChanges, TVSeriesDetails, TVSeriesListItem, TVSeriesListParams, TVSeriesLists, TVSeriesListsAPI, TVSeriesListsParams, TVSeriesResultItem, TVSimilar, TVSimilarParams, TVTranslationData, TVTranslations, TVVideos, Timezone, Translation, TranslationResults, TrendingAPI, TrendingAllResult, TrendingMovieResult, TrendingParams, TrendingPersonResult, TrendingTVResult, TrendingTimeWindow, VideoItem, VideoResults, WatchMonetizationType, WatchProvider, WatchProviderDisplayPriorities, WatchProviderItem, WatchProviderListItem, WatchProviderListParams, WatchProviderListResponse, WatchProviderRegionsParams, WatchProviderRegionsResponse, WatchProvidersAPI, WithLanguage, WithLanguagePage, WithPage, WithPageAndDateRange, WithParams, WithRegion, hasBackdropPath, hasLogoPath, hasPosterPath, hasProfilePath, hasStillPath, isJwt, isKnownForMovie, isKnownForTV, isPlainObject, isRecord };
5792
+ export { AccountAPI, AccountAddFavoriteBody, AccountAddToWatchlistBody, AccountAvatar, AccountDetails, AccountDetailsParams, AccountListItem, AccountListsParams, AccountListsResponse, AccountMediaListParams, AccountMovieItem, AccountMovieListResponse, AccountMutationParams, AccountMutationResponse, AccountRatedEpisodeItem, AccountRatedEpisodesResponse, AccountRatedMovieItem, AccountRatedMoviesResponse, AccountRatedTVItem, AccountRatedTVResponse, AccountSortBy, AccountTVItem, AccountTVListResponse, AlternativeName, AlternativeNamesResult, AlternativeTitle, AuthCreateSessionBody, AuthCreateSessionResponse, AuthCreateSessionWithLoginBody, AuthDeleteSessionBody, AuthDeleteSessionResponse, AuthGuestSessionResponse, AuthRequestTokenResponse, AuthValidateKeyResponse, AuthenticationAPI, BACKDROP_SIZES, BackdropSize, Cast, CertificationItem, Certifications, CertificationsAPI, Change, ChangeItem, ChangeResultItem, Changes, ChangesAPI, Collection, CollectionBaseParam, CollectionDetailsParams, CollectionImages, CollectionImagesParams, CollectionItem, CollectionResultItem, CollectionTranslationData, CollectionTranslations, CollectionsAPI, CompaniesAPI, Company, CompanyAlternativeName, CompanyAlternativeNames, CompanyAlternativeNamesParams, CompanyBaseParam, CompanyDetailsParams, CompanyImages, CompanyImagesParams, CompanyResultItem, CompanySummary, ConfigurationAPI, ConfigurationCountriesParams, ConfigurationCountry, ConfigurationJob, ConfigurationLanguage, ConfigurationResponse, ConfigurationTimezone, ContentRating, CountryISO3166_1, Credit, CreditBaseParam, CreditDetails, CreditDetailsMedia, CreditDetailsMovieMedia, CreditDetailsParams, CreditDetailsPerson, CreditDetailsTVEpisode, CreditDetailsTVMedia, CreditDetailsTVSeason, CreditsAPI, Crew, DateRange, DefaultImageSizesConfig, DiscoverAPI, DiscoverFilterExpression, DiscoverMovieParams, DiscoverMovieSortBy, DiscoverTVParams, DiscoverTVResultItem, DiscoverTVSortBy, DiscoverTVStatus, DiscoverTVType, FileType, FindAPI, FindByIDParams, FindExternalSource, FindMovieResultItem, FindPersonResultItem, FindResults, FindTVEpisodeResultItem, FindTVResultItem, FindTVSeasonResultItem, Genre, GenresAPI, GenresResponse, GuestSessionRatedEpisodesResponse, GuestSessionRatedMoviesResponse, GuestSessionRatedParams, GuestSessionRatedTVResponse, GuestSessionsAPI, IMAGE_BASE_URL, IMAGE_SECURE_BASE_URL, ImageCollectionKey, ImageConfiguration, ImageItem, ImageSize, ImageSizeTypes, ImagesConfig, ImagesResult, Keyword, KeywordBaseParam, KeywordDetailsParams, KeywordMoviesParams, KeywordResultItem, KeywordsAPI, KnownForItem, KnownForMovie, KnownForTV, LOGO_SIZES, Language, LanguageISO6391, ListClearParams, ListCreateBody, ListCreateParams, ListCreateResponse, ListDetails, ListDetailsParams, ListItem, ListItemStatusParams, ListItemStatusResponse, ListMovieBody, ListMutationParams, ListMutationResponse, ListsAPI, LiteralUnion, LogoSize, MediaType, MediaWatchProviders, MovieAlternativeTitles, MovieAlternativeTitlesParams, MovieAppendToResponseNamespace, MovieAppendableMap, MovieChanges, MovieChangesParams, MovieCollection, MovieCredits, MovieCreditsParams, MovieDetails, MovieDetailsParams, MovieDetailsWithAppends, MovieExternalIDs, MovieExternalIDsParams, MovieImages, MovieImagesParams, MovieKeywords, MovieKeywordsParams, MovieListParams, MovieListsAPI, MovieRecommendations, MovieRecommendationsParams, MovieReleaseDate, MovieReleaseDateResult, MovieReleaseDates, MovieReleaseDatesParams, MovieResultItem, MovieReviews, MovieReviewsParams, MovieSimilar, MovieSimilarParams, MovieTranslationData, MovieTranslations, MovieTranslationsParams, MovieVideos, MovieVideosParams, MovieWatchProvidersParams, MoviesAPI, MultiSearchResultItem, Network, NetworkBaseParams, NetworkImages, NetworkItem, NetworksAPI, OrganizationImage, POSTER_SIZES, PROFILE_SIZES, PaginatedResponse, PeopleAPI, PeopleListParams, PeopleListsAPI, PersonAppendToResponseNamespace, PersonAppendableMap, PersonBaseParam, PersonChanges, PersonChangesParams, PersonCombinedCastCredit, PersonCombinedCredits, PersonCombinedCrewCredit, PersonCreditsParams, PersonDetails, PersonDetailsParams, PersonDetailsWithAppends, PersonExternalIDs, PersonExternalIDsParams, PersonImages, PersonImagesParams, PersonMovieCastCredit, PersonMovieCredits, PersonMovieCrewCredit, PersonResultItem, PersonTVCastCredit, PersonTVCredits, PersonTVCrewCredit, PersonTaggedImage, PersonTaggedImageMedia, PersonTaggedImages, PersonTaggedImagesParams, PersonTranslationData, PersonTranslations, PersonTranslationsParams, PosterSize, Prettify, PrimaryTranslations, ProductionCompany, ProductionCountry, ProfileSize, RequestInterceptor, RequestInterceptorContext, ResponseErrorInterceptor, ResponseSuccessInterceptor, Review, ReviewAuthorDetails, ReviewDetails, ReviewDetailsParams, ReviewsAPI, STILL_SIZES, SearchAPI, SearchCollectionsParams, SearchCompanyParams, SearchKeywordsParams, SearchMoviesParams, SearchMultiParams, SearchPersonParams, SearchTVSeriesParams, SpokenLanguage, StillSize, TMDB, TMDBCountries, TMDBError, TMDBLogger, TMDBLoggerEntry, TMDBLoggerFn, TMDBOptions, TMDBQueryParams, TMDBv4, TVAggregateCredits, TVAggregateCreditsCastItem, TVAggregateCreditsCrewItem, TVAggregateCreditsParams, TVAlternativeTitles, TVAppendToResponseNamespace, TVAppendableMap, TVBaseParam, TVChangeParams, TVContentRatings, TVCreditJob, TVCreditRole, TVCredits, TVCreditsParams, TVDetailsParams, TVDetailsWithAppends, TVEpisode, TVEpisodeAppendToResponseNamespace, TVEpisodeAppendableMap, TVEpisodeBaseParams, TVEpisodeCredits, TVEpisodeCreditsParams, TVEpisodeDetailsParams, TVEpisodeDetailsWithAppends, TVEpisodeExternalIDs, TVEpisodeGroupDetails, TVEpisodeGroupDetailsItem, TVEpisodeGroupEpisode, TVEpisodeGroupItem, TVEpisodeGroupParams, TVEpisodeGroupType, TVEpisodeGroups, TVEpisodeGroupsAPI, TVEpisodeId, TVEpisodeImages, TVEpisodeImagesParams, TVEpisodeItem, TVEpisodeTranslationData, TVEpisodeTranslations, TVEpisodeVideos, TVEpisodesAPI, TVExternalIDs, TVImageItem, TVImages, TVImagesParams, TVKeywords, TVRecommendations, TVRecommendationsParams, TVReviews, TVReviewsParams, TVScreenedTheatrically, TVScreeningItem, TVSeason, TVSeasonAggregateCredits, TVSeasonAggregateCreditsParams, TVSeasonAppendToResponseNamespace, TVSeasonAppendableMap, TVSeasonBaseParams, TVSeasonChanges, TVSeasonChangesParams, TVSeasonCredits, TVSeasonCreditsParams, TVSeasonDetailsParams, TVSeasonDetailsWithAppends, TVSeasonEpisode, TVSeasonExternalIDs, TVSeasonId, TVSeasonImages, TVSeasonImagesParams, TVSeasonItem, TVSeasonTranslationData, TVSeasonTranslations, TVSeasonVideos, TVSeasonVideosParams, TVSeasonWatchProvidersParams, TVSeasonsAPI, TVSeriesAPI, TVSeriesChanges, TVSeriesDetails, TVSeriesListItem, TVSeriesListParams, TVSeriesLists, TVSeriesListsAPI, TVSeriesListsParams, TVSeriesResultItem, TVSimilar, TVSimilarParams, TVTranslationData, TVTranslations, TVVideos, Timezone, Translation, TranslationResults, TrendingAPI, TrendingAllResult, TrendingMovieResult, TrendingParams, TrendingPersonResult, TrendingTVResult, TrendingTimeWindow, V4AccountAPI, V4AddListItemsBody, V4AddListItemsResponse, V4AuthAPI, V4AuthAccessTokenResponse, V4AuthCreateAccessTokenBody, V4AuthCreateRequestTokenBody, V4AuthDeleteAccessTokenBody, V4AuthDeleteAccessTokenResponse, V4AuthRequestTokenResponse, V4CreateListBody, V4CreateListResponse, V4DeleteListParams, V4ListDetails, V4ListDetailsParams, V4ListItemInput, V4ListItemResult, V4ListItemStatusParams, V4ListItemStatusResponse, V4ListMediaType, V4ListResult, V4ListStatusResponse, V4ListsAPI, V4RemoveListItemsBody, V4UpdateListBody, V4UpdateListItemsBody, V4UpdateListItemsResponse, VideoItem, VideoResults, WatchMonetizationType, WatchProvider, WatchProviderDisplayPriorities, WatchProviderItem, WatchProviderListItem, WatchProviderListParams, WatchProviderListResponse, WatchProviderRegionsParams, WatchProviderRegionsResponse, WatchProvidersAPI, WithLanguage, WithLanguagePage, WithPage, WithPageAndDateRange, WithParams, WithRegion, hasBackdropPath, hasLogoPath, hasPosterPath, hasProfilePath, hasStillPath, isJwt, isKnownForMovie, isKnownForTV, isPlainObject, isRecord };
package/dist/index.mjs CHANGED
@@ -296,10 +296,64 @@ var ImageAPI = class {
296
296
  }
297
297
  };
298
298
  //#endregion
299
+ //#region src/utils/rate-limiter.ts
300
+ /**
301
+ * A sliding-window rate limiter that queues callers when the request budget is exhausted.
302
+ *
303
+ * Callers `await acquire()` before dispatching a fetch. If the number of requests made
304
+ * within the last `per_ms` milliseconds is below `max_requests`, the caller is released
305
+ * immediately. Otherwise it waits until enough time has passed for older timestamps to
306
+ * leave the window, then proceeds.
307
+ *
308
+ * The internal queue is processed serially by a single `process()` loop so there are no
309
+ * race conditions between concurrent callers.
310
+ */
311
+ var RateLimiter = class {
312
+ maxRequests;
313
+ windowMs;
314
+ timestamps = [];
315
+ queue = [];
316
+ processing = false;
317
+ constructor(options = {}) {
318
+ const maxRequests = options.max_requests ?? 40;
319
+ const perMs = options.per_ms ?? 1e3;
320
+ if (!Number.isFinite(maxRequests) || !Number.isInteger(maxRequests) || maxRequests < 1) throw new RangeError(`rate_limit.max_requests must be a finite integer >= 1 (got ${maxRequests})`);
321
+ if (!Number.isFinite(perMs) || !Number.isInteger(perMs) || perMs < 1) throw new RangeError(`rate_limit.per_ms must be a finite integer >= 1 (got ${perMs})`);
322
+ this.maxRequests = maxRequests;
323
+ this.windowMs = perMs;
324
+ }
325
+ /**
326
+ * Resolves when a request slot is available within the current window.
327
+ * Requests that cannot be dispatched immediately are queued in FIFO order.
328
+ */
329
+ acquire() {
330
+ return new Promise((resolve) => {
331
+ this.queue.push(resolve);
332
+ if (!this.processing) this.process();
333
+ });
334
+ }
335
+ async process() {
336
+ this.processing = true;
337
+ while (this.queue.length > 0) {
338
+ const now = Date.now();
339
+ this.timestamps = this.timestamps.filter((t) => now - t < this.windowMs);
340
+ if (this.timestamps.length < this.maxRequests) {
341
+ this.timestamps.push(Date.now());
342
+ this.queue.shift()();
343
+ } else {
344
+ const oldest = this.timestamps[0];
345
+ const waitMs = this.windowMs - (Date.now() - oldest) + 1;
346
+ await new Promise((r) => setTimeout(r, waitMs));
347
+ }
348
+ }
349
+ this.processing = false;
350
+ }
351
+ };
352
+ //#endregion
299
353
  //#region src/client.ts
300
354
  var ApiClient = class {
301
355
  accessToken;
302
- baseUrl = "https://api.themoviedb.org/3";
356
+ baseUrl;
303
357
  logger;
304
358
  /**
305
359
  * Tracks in-flight requests keyed by a deterministic string derived from the endpoint
@@ -309,14 +363,17 @@ var ApiClient = class {
309
363
  */
310
364
  inflightRequests = /* @__PURE__ */ new Map();
311
365
  deduplication;
366
+ rateLimiter;
312
367
  requestInterceptors;
313
368
  onSuccessInterceptor;
314
369
  onErrorInterceptor;
315
370
  imageApi;
316
371
  constructor(accessToken, options = {}) {
317
372
  this.accessToken = accessToken;
373
+ this.baseUrl = `https://api.themoviedb.org/${options.version ?? 3}`;
318
374
  this.logger = TMDBLogger.from(options.logger);
319
375
  this.deduplication = options.deduplication !== false;
376
+ if (options.rate_limit) this.rateLimiter = new RateLimiter(options.rate_limit === true ? {} : options.rate_limit);
320
377
  const raw = options.interceptors?.request;
321
378
  this.requestInterceptors = raw == null ? [] : Array.isArray(raw) ? raw : [raw];
322
379
  this.onSuccessInterceptor = options.interceptors?.response?.onSuccess;
@@ -418,12 +475,16 @@ var ApiClient = class {
418
475
  throw error;
419
476
  }
420
477
  /**
421
- * Makes an authenticated mutation request (POST, PUT, or DELETE) to the TMDB API.
422
- * Unlike `request()`, mutations are never deduplicated since they change server state.
478
+ * Makes an authenticated mutation request to the TMDB API.
479
+ * Unlike `request()`, mutations are **never deduplicated** since they change server state.
480
+ *
481
+ * Accepts `"GET"` in addition to the standard mutation verbs for the rare TMDB endpoints
482
+ * (e.g. `GET /4/list/{id}/clear`) that are specified as GET but carry side effects and
483
+ * must therefore not be collapsed by the deduplication layer.
423
484
  *
424
485
  * @param method - HTTP method to use
425
486
  * @param endpoint - API path (e.g. "/account/123/favorite")
426
- * @param body - JSON body to send (omit for DELETE requests without a body)
487
+ * @param body - JSON body to send (omit for DELETE/GET requests without a body)
427
488
  * @param params - Optional query string parameters (e.g. session_id)
428
489
  */
429
490
  async mutate(method, endpoint, body, params = {}) {
@@ -434,6 +495,7 @@ var ApiClient = class {
434
495
  * Handles URL construction, auth, logging, error mapping, and null sanitisation.
435
496
  */
436
497
  async execute(method, endpoint, params, body) {
498
+ const bodyJson = body !== void 0 ? JSON.stringify(body) : void 0;
437
499
  const ctx = await this.runRequestInterceptors({
438
500
  endpoint,
439
501
  params,
@@ -451,6 +513,7 @@ var ApiClient = class {
451
513
  method,
452
514
  endpoint: effectiveEndpoint
453
515
  });
516
+ if (this.rateLimiter) await this.rateLimiter.acquire();
454
517
  let res;
455
518
  try {
456
519
  res = await fetch(url.toString(), {
@@ -459,7 +522,7 @@ var ApiClient = class {
459
522
  Authorization: `Bearer ${this.accessToken}`,
460
523
  "Content-Type": "application/json;charset=utf-8"
461
524
  } : { "Content-Type": "application/json;charset=utf-8" },
462
- ...body !== void 0 ? { body: JSON.stringify(body) } : {}
525
+ ...bodyJson !== void 0 ? { body: bodyJson } : {}
463
526
  });
464
527
  } catch (error) {
465
528
  this.logger?.log({
@@ -660,7 +723,46 @@ const ENDPOINTS = {
660
723
  PERSON: "/trending/person"
661
724
  },
662
725
  REVIEWS: { DETAILS: "/review" },
663
- PEOPLE_LISTS: { POPULAR: "/person/popular" }
726
+ PEOPLE_LISTS: { POPULAR: "/person/popular" },
727
+ LISTS: {
728
+ DETAILS: "/list",
729
+ ADD_ITEM: "/add_item",
730
+ ITEM_STATUS: "/item_status",
731
+ CLEAR: "/clear",
732
+ REMOVE_ITEM: "/remove_item"
733
+ },
734
+ GUEST_SESSIONS: {
735
+ DETAILS: "/guest_session",
736
+ RATED_MOVIES: "/rated/movies",
737
+ RATED_TV: "/rated/tv",
738
+ RATED_TV_EPISODES: "/rated/tv/episodes"
739
+ }
740
+ };
741
+ /**
742
+ * TMDB API v4 endpoint fragments.
743
+ * These are combined with `https://api.themoviedb.org/4` by the v4 ApiClient.
744
+ */
745
+ const ENDPOINTS_V4 = {
746
+ AUTH: {
747
+ REQUEST_TOKEN: "/auth/request_token",
748
+ ACCESS_TOKEN: "/auth/access_token"
749
+ },
750
+ ACCOUNT: {
751
+ DETAILS: "/account",
752
+ LISTS: "/lists",
753
+ FAVORITE_MOVIES: "/favorite/movies",
754
+ FAVORITE_TV: "/favorite/tv",
755
+ WATCHLIST_MOVIES: "/watchlist/movies",
756
+ WATCHLIST_TV: "/watchlist/tv",
757
+ RATED_MOVIES: "/rated/movies",
758
+ RATED_TV: "/rated/tv"
759
+ },
760
+ LISTS: {
761
+ DETAILS: "/list",
762
+ ITEMS: "/items",
763
+ ITEM_STATUS: "/item_status",
764
+ CLEAR: "/clear"
765
+ }
664
766
  };
665
767
  //#endregion
666
768
  //#region src/errors/messages.ts
@@ -670,7 +772,8 @@ const ENDPOINTS = {
670
772
  */
671
773
  const Errors = {
672
774
  NO_ACCESS_TOKEN: "TMDB requires a valid access token, please provide one.",
673
- INVALID_CLIENT: "TMDB received an invalid ApiClient instance. Pass a valid ApiClient or an access token string."
775
+ INVALID_CLIENT: "TMDB received an invalid ApiClient instance. Pass a valid ApiClient or an access token string.",
776
+ V4_REQUIRES_JWT: "TMDB v4 requires a Bearer (JWT) access token. API key strings are not supported for v4 endpoints."
674
777
  };
675
778
  //#endregion
676
779
  //#region src/endpoints/base.ts
@@ -683,6 +786,7 @@ var TMDBAPIBase = class {
683
786
  this.client = new ApiClient(accessTokenOrClient, {
684
787
  logger: defaultOptions.logger,
685
788
  deduplication: defaultOptions.deduplication,
789
+ rate_limit: defaultOptions.rate_limit,
686
790
  interceptors: defaultOptions.interceptors
687
791
  });
688
792
  } else if (accessTokenOrClient instanceof ApiClient) this.client = accessTokenOrClient;
@@ -2882,9 +2986,372 @@ var AuthenticationAPI = class extends TMDBAPIBase {
2882
2986
  }
2883
2987
  };
2884
2988
  //#endregion
2989
+ //#region src/endpoints/guest_sessions.ts
2990
+ var GuestSessionsAPI = class extends TMDBAPIBase {
2991
+ guestSessionPath(guest_session_id) {
2992
+ return `${ENDPOINTS.GUEST_SESSIONS.DETAILS}/${guest_session_id}`;
2993
+ }
2994
+ guestSessionSubPath(guest_session_id, route) {
2995
+ return `${this.guestSessionPath(guest_session_id)}${route}`;
2996
+ }
2997
+ /**
2998
+ * Rated Movies
2999
+ * GET - https://api.themoviedb.org/3/guest_session/{guest_session_id}/rated/movies
3000
+ *
3001
+ * Get the rated movies for a guest session.
3002
+ * @param params Guest session ID, optional language, page, and sort_by.
3003
+ * @reference https://developer.themoviedb.org/reference/guest-session-rated-movies
3004
+ */
3005
+ async rated_movies(params) {
3006
+ const { guest_session_id, language = this.defaultOptions.language, ...rest } = params;
3007
+ return this.client.request(this.guestSessionSubPath(guest_session_id, ENDPOINTS.GUEST_SESSIONS.RATED_MOVIES), {
3008
+ language,
3009
+ ...rest
3010
+ });
3011
+ }
3012
+ /**
3013
+ * Rated TV
3014
+ * GET - https://api.themoviedb.org/3/guest_session/{guest_session_id}/rated/tv
3015
+ *
3016
+ * Get the rated TV shows for a guest session.
3017
+ * @param params Guest session ID, optional language, page, and sort_by.
3018
+ * @reference https://developer.themoviedb.org/reference/guest-session-rated-tv
3019
+ */
3020
+ async rated_tv(params) {
3021
+ const { guest_session_id, language = this.defaultOptions.language, ...rest } = params;
3022
+ return this.client.request(this.guestSessionSubPath(guest_session_id, ENDPOINTS.GUEST_SESSIONS.RATED_TV), {
3023
+ language,
3024
+ ...rest
3025
+ });
3026
+ }
3027
+ /**
3028
+ * Rated TV Episodes
3029
+ * GET - https://api.themoviedb.org/3/guest_session/{guest_session_id}/rated/tv/episodes
3030
+ *
3031
+ * Get the rated TV episodes for a guest session.
3032
+ * @param params Guest session ID, optional language, page, and sort_by.
3033
+ * @reference https://developer.themoviedb.org/reference/guest-session-rated-tv-episodes
3034
+ */
3035
+ async rated_tv_episodes(params) {
3036
+ const { guest_session_id, language = this.defaultOptions.language, ...rest } = params;
3037
+ return this.client.request(this.guestSessionSubPath(guest_session_id, ENDPOINTS.GUEST_SESSIONS.RATED_TV_EPISODES), {
3038
+ language,
3039
+ ...rest
3040
+ });
3041
+ }
3042
+ };
3043
+ //#endregion
3044
+ //#region src/endpoints/lists.ts
3045
+ var ListsAPI = class extends TMDBAPIBase {
3046
+ listPath(list_id) {
3047
+ return `${ENDPOINTS.LISTS.DETAILS}/${list_id}`;
3048
+ }
3049
+ listSubPath(list_id, route) {
3050
+ return `${this.listPath(list_id)}${route}`;
3051
+ }
3052
+ /**
3053
+ * Details
3054
+ * GET - https://api.themoviedb.org/3/list/{list_id}
3055
+ *
3056
+ * Get the details of a list.
3057
+ * @param params List ID and optional language and page.
3058
+ * @reference https://developer.themoviedb.org/reference/list-details
3059
+ */
3060
+ async details(params) {
3061
+ const { list_id, language = this.defaultOptions.language, ...rest } = params;
3062
+ return this.client.request(this.listPath(list_id), {
3063
+ language,
3064
+ ...rest
3065
+ });
3066
+ }
3067
+ /**
3068
+ * Create
3069
+ * POST - https://api.themoviedb.org/3/list
3070
+ *
3071
+ * Create a new list.
3072
+ * @param params session_id query param (required).
3073
+ * @param body name, description, and language for the new list.
3074
+ * @reference https://developer.themoviedb.org/reference/list-create
3075
+ */
3076
+ async create(params, body) {
3077
+ return this.client.mutate("POST", ENDPOINTS.LISTS.DETAILS, body, params);
3078
+ }
3079
+ /**
3080
+ * Delete
3081
+ * DELETE - https://api.themoviedb.org/3/list/{list_id}
3082
+ *
3083
+ * Delete a list.
3084
+ * @param params List ID and session_id (required).
3085
+ * @reference https://developer.themoviedb.org/reference/list-delete
3086
+ */
3087
+ async delete(params) {
3088
+ const { list_id, ...queryParams } = params;
3089
+ return this.client.mutate("DELETE", this.listPath(list_id), void 0, queryParams);
3090
+ }
3091
+ /**
3092
+ * Add Movie
3093
+ * POST - https://api.themoviedb.org/3/list/{list_id}/add_item
3094
+ *
3095
+ * Add a movie to a list.
3096
+ * @param params List ID and session_id (required).
3097
+ * @param body media_id of the movie to add.
3098
+ * @reference https://developer.themoviedb.org/reference/list-add-movie
3099
+ */
3100
+ async add_movie(params, body) {
3101
+ const { list_id, ...queryParams } = params;
3102
+ return this.client.mutate("POST", this.listSubPath(list_id, ENDPOINTS.LISTS.ADD_ITEM), body, queryParams);
3103
+ }
3104
+ /**
3105
+ * Remove Movie
3106
+ * POST - https://api.themoviedb.org/3/list/{list_id}/remove_item
3107
+ *
3108
+ * Remove a movie from a list.
3109
+ * @param params List ID and session_id (required).
3110
+ * @param body media_id of the movie to remove.
3111
+ * @reference https://developer.themoviedb.org/reference/list-remove-movie
3112
+ */
3113
+ async remove_movie(params, body) {
3114
+ const { list_id, ...queryParams } = params;
3115
+ return this.client.mutate("POST", this.listSubPath(list_id, ENDPOINTS.LISTS.REMOVE_ITEM), body, queryParams);
3116
+ }
3117
+ /**
3118
+ * Check Item Status
3119
+ * GET - https://api.themoviedb.org/3/list/{list_id}/item_status
3120
+ *
3121
+ * Check if a movie has already been added to a list.
3122
+ * @param params List ID and optional movie_id and language.
3123
+ * @reference https://developer.themoviedb.org/reference/list-check-item-status
3124
+ */
3125
+ async check_item_status(params) {
3126
+ const { list_id, language = this.defaultOptions.language, ...rest } = params;
3127
+ return this.client.request(this.listSubPath(list_id, ENDPOINTS.LISTS.ITEM_STATUS), {
3128
+ language,
3129
+ ...rest
3130
+ });
3131
+ }
3132
+ /**
3133
+ * Clear
3134
+ * POST - https://api.themoviedb.org/3/list/{list_id}/clear
3135
+ *
3136
+ * Clear all items from a list. Pass `confirm: true` to confirm the operation.
3137
+ * @param params List ID, session_id, and confirm flag (required).
3138
+ * @reference https://developer.themoviedb.org/reference/list-clear
3139
+ */
3140
+ async clear(params) {
3141
+ const { list_id, ...queryParams } = params;
3142
+ return this.client.mutate("POST", this.listSubPath(list_id, ENDPOINTS.LISTS.CLEAR), void 0, queryParams);
3143
+ }
3144
+ };
3145
+ //#endregion
3146
+ //#region src/endpoints/v4/auth.ts
3147
+ var V4AuthAPI = class extends TMDBAPIBase {
3148
+ /**
3149
+ * Create Request Token
3150
+ * POST - https://api.themoviedb.org/4/auth/request_token
3151
+ *
3152
+ * Generate a request token that the user must approve at the TMDB website to begin
3153
+ * the v4 OAuth-style flow. Redirect the user to:
3154
+ * `https://www.themoviedb.org/auth/access?request_token={request_token}`
3155
+ *
3156
+ * Once approved, exchange the token for an access token using `create_access_token`.
3157
+ * @param body Optional body with a `redirect_to` URL for post-approval redirect.
3158
+ * @reference https://developer.themoviedb.org/reference/create-request-token
3159
+ */
3160
+ async create_request_token(body) {
3161
+ return this.client.mutate("POST", ENDPOINTS_V4.AUTH.REQUEST_TOKEN, body ?? {});
3162
+ }
3163
+ /**
3164
+ * Create Access Token
3165
+ * POST - https://api.themoviedb.org/4/auth/access_token
3166
+ *
3167
+ * Exchange a user-approved request token for a permanent user access token and
3168
+ * TMDB account ID. Store the returned `access_token` securely — it is valid
3169
+ * indefinitely until explicitly deleted with `delete_access_token`.
3170
+ * @param body An object containing the approved `request_token`.
3171
+ * @reference https://developer.themoviedb.org/reference/create-access-token
3172
+ */
3173
+ async create_access_token(body) {
3174
+ return this.client.mutate("POST", ENDPOINTS_V4.AUTH.ACCESS_TOKEN, body);
3175
+ }
3176
+ /**
3177
+ * Delete Access Token (Logout)
3178
+ * DELETE - https://api.themoviedb.org/4/auth/access_token
3179
+ *
3180
+ * Invalidate a user access token. Use this to log a user out of your application.
3181
+ * @param body An object containing the `access_token` to delete.
3182
+ * @reference https://developer.themoviedb.org/reference/delete-access-token
3183
+ */
3184
+ async delete_access_token(body) {
3185
+ return this.client.mutate("DELETE", ENDPOINTS_V4.AUTH.ACCESS_TOKEN, body);
3186
+ }
3187
+ };
3188
+ //#endregion
3189
+ //#region src/endpoints/v4/account.ts
3190
+ var V4AccountAPI = class extends TMDBAPIBase {};
3191
+ //#endregion
3192
+ //#region src/endpoints/v4/lists.ts
3193
+ var V4ListsAPI = class extends TMDBAPIBase {
3194
+ listPath(list_id) {
3195
+ return `${ENDPOINTS_V4.LISTS.DETAILS}/${list_id}`;
3196
+ }
3197
+ /**
3198
+ * Create List
3199
+ * POST - https://api.themoviedb.org/4/list
3200
+ *
3201
+ * Create a new v4 list. The authenticated user becomes the owner.
3202
+ * @param body List name and ISO 639-1 language code are required.
3203
+ * @reference https://developer.themoviedb.org/reference/list-create
3204
+ */
3205
+ async create(body) {
3206
+ return this.client.mutate("POST", ENDPOINTS_V4.LISTS.DETAILS, body);
3207
+ }
3208
+ /**
3209
+ * List Details
3210
+ * GET - https://api.themoviedb.org/4/list/{list_id}
3211
+ *
3212
+ * Retrieve the details and paginated items of a specific list.
3213
+ * @param params `list_id` is required. Optionally pass `language` and `page`.
3214
+ * @reference https://developer.themoviedb.org/reference/list-details
3215
+ */
3216
+ async details({ list_id, ...params }) {
3217
+ return this.client.request(this.listPath(list_id), this.withLanguage(params));
3218
+ }
3219
+ /**
3220
+ * Update List
3221
+ * PUT - https://api.themoviedb.org/4/list/{list_id}
3222
+ *
3223
+ * Update the metadata (name, description, visibility, sort order) of an existing list.
3224
+ * @param body `list_id` plus any fields to change.
3225
+ * @reference https://developer.themoviedb.org/reference/list-update
3226
+ */
3227
+ async update({ list_id, ...body }) {
3228
+ return this.client.mutate("PUT", this.listPath(list_id), body);
3229
+ }
3230
+ /**
3231
+ * Delete List
3232
+ * DELETE - https://api.themoviedb.org/4/list/{list_id}
3233
+ *
3234
+ * Permanently delete a list. This action cannot be undone.
3235
+ * @param params.list_id The TMDB list ID to delete.
3236
+ * @reference https://developer.themoviedb.org/reference/list-delete
3237
+ */
3238
+ async delete({ list_id }) {
3239
+ return this.client.mutate("DELETE", this.listPath(list_id), {});
3240
+ }
3241
+ /**
3242
+ * Add Items
3243
+ * POST - https://api.themoviedb.org/4/list/{list_id}/items
3244
+ *
3245
+ * Add one or more movies or TV shows to a list. For each item the response
3246
+ * includes whether it was added successfully.
3247
+ * @param list_id The TMDB list ID.
3248
+ * @param body Array of `{ media_type, media_id }` objects to add.
3249
+ * @reference https://developer.themoviedb.org/reference/list-add-items
3250
+ */
3251
+ async add_items(list_id, body) {
3252
+ return this.client.mutate("POST", `${this.listPath(list_id)}${ENDPOINTS_V4.LISTS.ITEMS}`, body);
3253
+ }
3254
+ /**
3255
+ * Update Items
3256
+ * PUT - https://api.themoviedb.org/4/list/{list_id}/items
3257
+ *
3258
+ * Update per-item comments for items already in the list.
3259
+ * @param list_id The TMDB list ID.
3260
+ * @param body Array of `{ media_type, media_id, comment }` objects.
3261
+ * @reference https://developer.themoviedb.org/reference/list-update-items
3262
+ */
3263
+ async update_items(list_id, body) {
3264
+ return this.client.mutate("PUT", `${this.listPath(list_id)}${ENDPOINTS_V4.LISTS.ITEMS}`, body);
3265
+ }
3266
+ /**
3267
+ * Remove Items
3268
+ * DELETE - https://api.themoviedb.org/4/list/{list_id}/items
3269
+ *
3270
+ * Remove one or more items from the list.
3271
+ * @param list_id The TMDB list ID.
3272
+ * @param body Array of `{ media_type, media_id }` objects to remove.
3273
+ * @reference https://developer.themoviedb.org/reference/list-remove-items
3274
+ */
3275
+ async remove_items(list_id, body) {
3276
+ return this.client.mutate("DELETE", `${this.listPath(list_id)}${ENDPOINTS_V4.LISTS.ITEMS}`, body);
3277
+ }
3278
+ /**
3279
+ * Check Item Status
3280
+ * GET - https://api.themoviedb.org/4/list/{list_id}/item_status
3281
+ *
3282
+ * Check whether a specific movie or TV show is already present in the list.
3283
+ * @param params `list_id`, `media_type`, and `media_id` are all required.
3284
+ * @reference https://developer.themoviedb.org/reference/list-item-status
3285
+ */
3286
+ async item_status({ list_id, ...params }) {
3287
+ return this.client.request(`${this.listPath(list_id)}${ENDPOINTS_V4.LISTS.ITEM_STATUS}`, params);
3288
+ }
3289
+ /**
3290
+ * Clear List
3291
+ * GET - https://api.themoviedb.org/4/list/{list_id}/clear
3292
+ *
3293
+ * Remove all items from the list without deleting the list itself.
3294
+ * @param list_id The TMDB list ID to clear.
3295
+ * @reference https://developer.themoviedb.org/reference/list-clear
3296
+ */
3297
+ async clear(list_id) {
3298
+ return this.client.mutate("GET", `${this.listPath(list_id)}${ENDPOINTS_V4.LISTS.CLEAR}`);
3299
+ }
3300
+ };
3301
+ //#endregion
3302
+ //#region src/tmdb.v4.ts
3303
+ /**
3304
+ * Aggregator for all TMDB API v4 namespaces.
3305
+ *
3306
+ * Access via `tmdb.v4` — the v4 client is backed by `https://api.themoviedb.org/4`
3307
+ * and inherits the same access token and options as the parent TMDB instance.
3308
+ *
3309
+ * @example
3310
+ * ```ts
3311
+ * const tmdb = new TMDB(accessToken);
3312
+ *
3313
+ * // v4 auth flow
3314
+ * const { request_token } = await tmdb.v4.auth.create_request_token();
3315
+ * // ... user approves at https://www.themoviedb.org/auth/access?request_token=...
3316
+ * const { access_token, account_id } = await tmdb.v4.auth.create_access_token({ request_token });
3317
+ *
3318
+ * // v4 account (account_id is a string from the access token response)
3319
+ * const profile = await tmdb.v4.account.details(account_id);
3320
+ * const favorites = await tmdb.v4.account.favorite_movies({ account_id, page: 1 });
3321
+ *
3322
+ * // v4 lists (full CRUD)
3323
+ * const list = await tmdb.v4.lists.create({ name: "My list", iso_639_1: "en" });
3324
+ * await tmdb.v4.lists.add_items(list.id, { items: [{ media_type: "movie", media_id: 550 }] });
3325
+ * ```
3326
+ */
3327
+ var TMDBv4 = class {
3328
+ client;
3329
+ /** v4 authentication — request token → access token → logout. */
3330
+ auth;
3331
+ /** v4 account — details, lists, favorites, watchlist, rated. */
3332
+ account;
3333
+ /** v4 lists — full CRUD for user-created lists. */
3334
+ lists;
3335
+ constructor(accessToken, options = {}) {
3336
+ if (!accessToken) throw new Error(Errors.NO_ACCESS_TOKEN);
3337
+ this.client = new ApiClient(accessToken, {
3338
+ version: 4,
3339
+ logger: options.logger,
3340
+ deduplication: options.deduplication,
3341
+ images: options.images,
3342
+ rate_limit: options.rate_limit,
3343
+ interceptors: options.interceptors
3344
+ });
3345
+ this.auth = new V4AuthAPI(this.client, options);
3346
+ this.account = new V4AccountAPI(this.client, options);
3347
+ this.lists = new V4ListsAPI(this.client, options);
3348
+ }
3349
+ };
3350
+ //#endregion
2885
3351
  //#region src/tmdb.ts
2886
3352
  var TMDB = class {
2887
3353
  client;
3354
+ accessToken;
2888
3355
  options;
2889
3356
  movies;
2890
3357
  movie_lists;
@@ -2913,6 +3380,18 @@ var TMDB = class {
2913
3380
  people;
2914
3381
  account;
2915
3382
  authentication;
3383
+ guest_sessions;
3384
+ lists;
3385
+ /**
3386
+ * TMDB API v4 namespaces. Access via `tmdb.v4.auth`, `tmdb.v4.account`, `tmdb.v4.lists`.
3387
+ * Requires a Bearer (JWT) access token — throws if the instance was created with an API key.
3388
+ */
3389
+ get v4() {
3390
+ if (!isJwt(this.accessToken)) throw new Error(Errors.V4_REQUIRES_JWT);
3391
+ if (!this._v4) this._v4 = new TMDBv4(this.accessToken, this.options);
3392
+ return this._v4;
3393
+ }
3394
+ _v4;
2916
3395
  /**
2917
3396
  * Creates a new TMDB instance.
2918
3397
  * @param accessToken The TMDB API access token.
@@ -2920,11 +3399,13 @@ var TMDB = class {
2920
3399
  */
2921
3400
  constructor(accessToken, options = {}) {
2922
3401
  if (!accessToken) throw new Error(Errors.NO_ACCESS_TOKEN);
3402
+ this.accessToken = accessToken;
2923
3403
  this.options = options;
2924
3404
  this.client = new ApiClient(accessToken, {
2925
3405
  logger: options.logger,
2926
3406
  deduplication: options.deduplication,
2927
3407
  images: options.images,
3408
+ rate_limit: options.rate_limit,
2928
3409
  interceptors: options.interceptors
2929
3410
  });
2930
3411
  this.movies = new MoviesAPI(this.client, this.options);
@@ -2954,6 +3435,8 @@ var TMDB = class {
2954
3435
  this.people = new PeopleAPI(this.client, this.options);
2955
3436
  this.account = new AccountAPI(this.client, this.options);
2956
3437
  this.authentication = new AuthenticationAPI(this.client, this.options);
3438
+ this.guest_sessions = new GuestSessionsAPI(this.client, this.options);
3439
+ this.lists = new ListsAPI(this.client, this.options);
2957
3440
  }
2958
3441
  };
2959
3442
  //#endregion
@@ -4272,4 +4755,4 @@ let TVEpisodeGroupType = /* @__PURE__ */ function(TVEpisodeGroupType) {
4272
4755
  return TVEpisodeGroupType;
4273
4756
  }({});
4274
4757
  //#endregion
4275
- export { AccountAPI, AuthenticationAPI, BACKDROP_SIZES, CertificationsAPI, ChangesAPI, CollectionsAPI, CompaniesAPI, ConfigurationAPI, CreditsAPI, DiscoverAPI, DiscoverTVStatus, DiscoverTVType, FindAPI, GenresAPI, IMAGE_BASE_URL, IMAGE_SECURE_BASE_URL, KeywordsAPI, LOGO_SIZES, MovieListsAPI, MoviesAPI, NetworksAPI, POSTER_SIZES, PROFILE_SIZES, PeopleAPI, PeopleListsAPI, ReviewsAPI, STILL_SIZES, SearchAPI, TMDB, TMDBCountries, TMDBError, TMDBLogger, TVEpisodeGroupType, TVEpisodeGroupsAPI, TVEpisodesAPI, TVSeasonsAPI, TVSeriesAPI, TVSeriesListsAPI, TrendingAPI, WatchProvidersAPI, hasBackdropPath, hasLogoPath, hasPosterPath, hasProfilePath, hasStillPath, isJwt, isKnownForMovie, isKnownForTV, isPlainObject, isRecord };
4758
+ export { AccountAPI, AuthenticationAPI, BACKDROP_SIZES, CertificationsAPI, ChangesAPI, CollectionsAPI, CompaniesAPI, ConfigurationAPI, CreditsAPI, DiscoverAPI, DiscoverTVStatus, DiscoverTVType, FindAPI, GenresAPI, GuestSessionsAPI, IMAGE_BASE_URL, IMAGE_SECURE_BASE_URL, KeywordsAPI, LOGO_SIZES, ListsAPI, MovieListsAPI, MoviesAPI, NetworksAPI, POSTER_SIZES, PROFILE_SIZES, PeopleAPI, PeopleListsAPI, ReviewsAPI, STILL_SIZES, SearchAPI, TMDB, TMDBCountries, TMDBError, TMDBLogger, TMDBv4, TVEpisodeGroupType, TVEpisodeGroupsAPI, TVEpisodesAPI, TVSeasonsAPI, TVSeriesAPI, TVSeriesListsAPI, TrendingAPI, V4AccountAPI, V4AuthAPI, V4ListsAPI, WatchProvidersAPI, hasBackdropPath, hasLogoPath, hasPosterPath, hasProfilePath, hasStillPath, isJwt, isKnownForMovie, isKnownForTV, isPlainObject, isRecord };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lorenzopant/tmdb",
3
- "version": "1.18.1",
3
+ "version": "1.20.0",
4
4
  "description": "A completely type-safe The Movie Database (TMDB) API wrapper for typescript applications.",
5
5
  "keywords": [
6
6
  "api",