### Add Function Simplified Usage Example Source: https://ctrl-plex.vercel.app/classes/Library Provides a simplified example of the 'add' function for common use cases. This function is designed to streamline the process of adding libraries by allowing users to specify essential parameters. ```typescript add( "My Library", "movie", "com.plexapp.agents.imdb", "Plex Movie Scanner", "/path/to/movies" ); ``` -------------------------------- ### Install @ctrl/plex Package Source: https://ctrl-plex.vercel.app/index Installs the @ctrl/plex package using npm. This is the first step to using the Plex API client in your project. ```bash npm install @ctrl/plex ``` -------------------------------- ### Utility Methods Source: https://ctrl-plex.vercel.app/classes/Show Utility methods for getting web URLs and checking object relationships. ```APIDOC ## Utility Methods ### getWebURL * **Description**: Retrieves the web URL for the media item. * **Method**: GET * **Endpoint**: N/A (Method call) * **Parameters**: * **__namedParameters** (object) - Optional * **base** (string) - Optional - The base URL to use. * **Returns**: string ### isChildOf * **Description**: Returns true if this object is a child of the given class. * **Method**: GET * **Endpoint**: N/A (Method call) * **Parameters**: * **cls** (any) - Required - The class to check against. * **Returns**: boolean ``` -------------------------------- ### GET /get Source: https://ctrl-plex.vercel.app/classes/LibrarySection Retrieves a media item by its title. ```APIDOC ## GET /get ### Description Retrieves a media item by its title. ### Method GET ### Endpoint /get ### Parameters #### Query Parameters - **title** (string) - Required - The title of the media item to retrieve. ### Request Example None ### Response #### Success Response (200) - **mediaItem** (SType) - The media item object with the specified title. #### Response Example ```json { "title": "Example Movie", "year": 2023, "type": "movie" } ``` ``` -------------------------------- ### Get Section Source: https://ctrl-plex.vercel.app/classes/Show Retrieves the Section object for a given media item. ```javascript video.section() ``` -------------------------------- ### Get Available Posters Source: https://ctrl-plex.vercel.app/classes/Show Retrieves a list of available Poster objects for a given media item. ```javascript video.posters() ``` -------------------------------- ### GET /getWebURL Source: https://ctrl-plex.vercel.app/classes/LibrarySection Generates the Plex Web URL for the library, with optional parameters for customization. ```APIDOC ## GET /getWebURL ### Description Generates the Plex Web URL for the library, with optional parameters for customization. ### Method GET ### Endpoint /getWebURL ### Parameters #### Query Parameters - **base** (object) - Optional - Configuration for the base URL. - **base** (string) - Optional - The base URL before the fragment (`#!`). Default is `https://app.plex.tv/desktop`. - **key** (string) - Optional - A hub key. - **tab** (string) - Optional - The library tab (e.g., `library`, `collections`, `playlists`, `timeline`). ### Request Example None ### Response #### Success Response (200) - **url** (string) - The generated Plex Web URL. #### Response Example ``` https://app.plex.tv/desktop#!/server/YOUR_SERVER_ID/section/YOUR_SECTION_ID/tab/library ``` ``` -------------------------------- ### Get Section Source: https://ctrl-plex.vercel.app/classes/Collections Retrieves information about the current section. ```APIDOC ## GET /section ### Description Retrieves information about the current section. ### Method GET ### Endpoint /section ### Response #### Success Response (200) - **Section** - Information about the section. #### Response Example { "id": "1", "name": "Movies", "type": "movie" } ``` -------------------------------- ### GET /api/media/all Source: https://ctrl-plex.vercel.app/classes/Library Retrieves a list of all media from all library sections. Be aware that this can return a very large dataset. ```APIDOC ## GET /api/media/all ### Description Retrieves a list of all media items from all library sections. This operation may return a large dataset. ### Method GET ### Endpoint /api/media/all ### Parameters None ### Request Example None ### Response #### Success Response (200) - **mediaItems** (any[]) - An array containing all media items. #### Response Example ```json [ { "id": "media1", "title": "Sample Image", "type": "image" }, { "id": "media2", "title": "Sample Video", "type": "video" } ] ``` ``` -------------------------------- ### video.setPoster() Source: https://ctrl-plex.vercel.app/classes/Show Sets the poster for a Plex media object. ```APIDOC ## PUT /video/poster ### Description Sets the poster for a Plex media object. ### Method PUT ### Endpoint /video/poster ### Parameters #### Request Body - **poster** (Poster) - Required - The poster object to select. ### Request Example ```json { "example": "{ "id": "poster123", "url": "/library/metadata/1/poster" }" } ``` ### Response #### Success Response (200) - **Show** (object) - The updated media object. #### Response Example ```json { "example": "{ "id": "movie1", "title": "Example Movie" }" } ``` ``` -------------------------------- ### Get Track by GUID (Python Example) Source: https://ctrl-plex.vercel.app/classes/MusicSection Retrieves a media item using its external GUID (IMDB, TMDB, TVDB). The example demonstrates both direct retrieval (potentially slow) and an optimized approach using a lookup dictionary for multiple GUIDs. This function returns a Promise resolving to a Track object. ```python # This will retrieve all items in the entire library 3 times result1 = library.getGuid('imdb://tt0944947') result2 = library.getGuid('tmdb://1399') result3 = library.getGuid('tvdb://121361') # This will only retrieve all items in the library once to create a lookup dictionary guidLookup = {guid.id: item for item in library.all() for guid in item.guids} result1 = guidLookup['imdb://tt0944947'] result2 = guidLookup['tmdb://1399'] result3 = guidLookup['tvdb://121361'] ``` -------------------------------- ### video.section() Source: https://ctrl-plex.vercel.app/classes/Show Retrieves information about the current media section. ```APIDOC ## GET /video/section ### Description Retrieves information about the current media section. ### Method GET ### Endpoint /video/section ### Parameters No parameters required. ### Request Example ```json { "example": "/video/section" } ``` ### Response #### Success Response (200) - **Section** (object) - An object containing section details. #### Response Example ```json { "example": "{ "id": "movies", "name": "Movies" }" } ``` ``` -------------------------------- ### Get Movie by GUID Source: https://ctrl-plex.vercel.app/classes/MovieSection Retrieves a media item using its external GUID (IMDB, TMDB, or TVDB). Note: This search can be slow as it may retrieve all items in the library. ```APIDOC ## GET /api/media/guid ### Description Retrieves the media item with the specified external IMDB, TMDB, or TVDB ID. Performance may be slow due to library-wide search. ### Method GET ### Endpoint /api/media/guid ### Parameters #### Query Parameters - **guid** (string) - Required - The external GUID of the item (e.g., `imdb://tt0944947`, `tmdb://1399`, `tvdb://121361`). ### Response #### Success Response (200) - **Movie** (object) - The media item corresponding to the provided GUID. #### Response Example ```json { "title": "Example Media", "guid": "imdb://tt0944947" } ``` ``` -------------------------------- ### Get Thumbnail URL Source: https://ctrl-plex.vercel.app/classes/Season Retrieves the most specific thumbnail URL for an item, starting from the most specific available thumbnail. ```typescript /** * Get the first first thumbnail url starting on the most specific thumbnail for that item. * @returns The thumbnail URL. */ get thumbUrl(): URL ``` -------------------------------- ### video.matches() Source: https://ctrl-plex.vercel.app/classes/Show Matches media items with available metadata. Supports filtering by title and year, with optional agent and language parameters automatically handled. ```APIDOC ## GET /video/matches ### Description Matches media items with available metadata. Supports filtering by title and year, with optional agent and language parameters automatically handled. ### Method GET ### Endpoint /video/matches ### Parameters #### Query Parameters - **title** (string) - Optional - The title of the media to match. - **year** (string) - Optional - The release year of the media to match. - **agent** (string) - Optional - The agent to use for matching (automatically filled). - **language** (string) - Optional - The language for matching (automatically filled). ### Request Example ```json { "example": "/video/matches?title=something&year=2020" } ``` ### Response #### Success Response (200) - **SearchResult[]** (array) - An array of search results. #### Response Example ```json { "example": "[ { "title": "Example Movie", "year": 2020, "id": "tt1234567" } ]" } ``` ``` -------------------------------- ### PlexServer Initialization Source: https://ctrl-plex.vercel.app/classes/PlexServer Initializes a new PlexServer instance to interact with your Plex Media Server. You can connect using the server's base URL and authentication token. ```APIDOC ## Constructor PlexServer ### Description Initializes a new PlexServer instance. ### Method `new PlexServer(baseurl: string, token: string, timeout?: number): PlexServer` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "baseurl": "http://192.168.1.100:32400", "token": "YOUR_PLEX_TOKEN", "timeout": 30000 } ``` ### Response #### Success Response (200) Returns a `PlexServer` object. #### Response Example ```json { "instance": "PlexServer" } ``` ``` -------------------------------- ### GET /getGuid Source: https://ctrl-plex.vercel.app/classes/LibrarySection Retrieves a media item by its external GUID (IMDB, TMDB, TVDB). Note: This can be slow as it searches the entire library. ```APIDOC ## GET /getGuid ### Description Retrieves a media item by its external GUID (IMDB, TMDB, TVDB). Note: This can be slow as it searches the entire library. ### Method GET ### Endpoint /getGuid ### Parameters #### Query Parameters - **guid** (string) - Required - The external GUID of the item to return. Examples: `imdb://tt0944947`, `tmdb://1399`, `tvdb://121361`. ### Request Example None ### Response #### Success Response (200) - **mediaItem** (SType) - The media item object corresponding to the provided GUID. #### Response Example ```json { "title": "Game of Thrones", "guid": "tvdb://121361", "type": "show" } ``` ``` -------------------------------- ### Get Media Item by GUID Source: https://ctrl-plex.vercel.app/classes/LibrarySection Retrieves a media item using its external GUID (IMDB, TMDB, TVDB). This operation can be slow as it may require retrieving all items from the library. For frequent lookups, creating a local lookup dictionary is recommended. Returns a Promise resolving to the media item of type SType. ```python result1 = library.getGuid('imdb://tt0944947') result2 = library.getGuid('tmdb://1399') result3 = library.getGuid('tvdb://1399') # Recommended approach for multiple lookups: guidLookup = {guid.id: item for item in library.all() for guid in item.guids} result1 = guidLookup['imdb://tt0944947'] result2 = guidLookup['tmdb://1399'] result3 = guidLookup['tvdb://1399'] ``` -------------------------------- ### Create a Play Queue Source: https://ctrl-plex.vercel.app/classes/Artist Asynchronously creates and returns a new PlayQueue instance from the current media item. Optional configuration options can be provided to customize the PlayQueue. ```typescript createPlayQueue(options?: CreatePlayQueueOptions): Promise ``` -------------------------------- ### Playback and PlayQueue Source: https://ctrl-plex.vercel.app/classes/Show Methods related to playback control and creating play queues. ```APIDOC ## Playback and PlayQueue ### createPlayQueue * **Description**: Returns a new PlayQueue from this media item. * **Method**: POST * **Endpoint**: N/A (Method call) * **Parameters**: * **options** (CreatePlayQueueOptions) - Optional - Options for creating the PlayQueue. * **Returns**: Promise ### markUnwatched * **Description**: Marks the video as unwatched. * **Method**: POST * **Endpoint**: N/A (Method call) * **Returns**: Promise ### markWatched * **Description**: Marks the video as watched. * **Method**: POST * **Endpoint**: N/A (Method call) * **Returns**: Promise ``` -------------------------------- ### Get Media Item by GUID Source: https://ctrl-plex.vercel.app/classes/MovieSection Retrieves a media item using its external GUID (IMDB, TMDB, or TVDB). Note that this operation can be slow as it may retrieve all items in the library. It's recommended to build a lookup dictionary for frequent searches. Returns a Promise resolving to a Movie object. ```python import asyncio # Assuming 'library' is an instance of your library object async def get_media_by_guid(library): # This will retrieve all items in the entire library 3 times result1 = await library.getGuid('imdb://tt0944947') result2 = await library.getGuid('tmdb://1399') result3 = await library.getGuid('tvdb://121361') print(f"Result 1: {result1}") print(f"Result 2: {result2}") print(f"Result 3: {result3}") # This will only retrieve all items in the library once to create a lookup dictionary all_items = await library.all() guidLookup = {guid.id: item for item in all_items for guid in item.guids} result1_lookup = guidLookup.get('imdb://tt0944947') result2_lookup = guidLookup.get('tmdb://1399') result3_lookup = guidLookup.get('tvdb://121361') print(f"Result 1 (lookup): {result1_lookup}") print(f"Result 2 (lookup): {result2_lookup}") print(f"Result 3 (lookup): {result3_lookup}") # Example usage (assuming you have an initialized library object): # asyncio.run(get_media_by_guid(your_library_instance)) ``` -------------------------------- ### Get Media Item by GUID Source: https://ctrl-plex.vercel.app/classes/ShowSection Retrieves a media item using its external identifier (IMDB, TMDB, or TVDB). Note: This search can be slow as it may iterate through the entire library. ```APIDOC ## GET /api/media/guid ### Description Retrieves the media item with the specified external IMDB, TMDB, or TVDB ID. This search uses a PlexAPI operator, so performance may be slow. It is recommended to create your own lookup dictionary if searching for many external GUIDs. ### Method GET ### Endpoint /api/media/guid ### Parameters #### Query Parameters - **guid** (string) - Required - The external guid of the item to return. Examples: IMDB `imdb://tt0944947`, TMDB `tmdb://1399`, TVDB `tvdb://121361`. ### Request Example ``` GET /api/media/guid?guid=imdb://tt0944947 ``` ### Response #### Success Response (200) - **Show** - The media item with the specified GUID. #### Response Example ```json { "title": "Example Show", "guid": "imdb://tt0944947", "year": 2023 } ``` ``` -------------------------------- ### Get Claim Token for Server Registration Source: https://ctrl-plex.vercel.app/classes/MyPlexAccount Retrieves a new claim token that can be used to register a Plex Media Server instance with a Plex account. This is useful for automating server setup. ```typescript import { MyPlexAccount } from "@ctrl/plex"; async function getClaimToken() { const plexAccount = new MyPlexAccount(); // Or instantiate with options const token = await plexAccount.claimToken(); console.log("Claim Token:", token); return token; } ``` -------------------------------- ### video.rate() Source: https://ctrl-plex.vercel.app/classes/Show Sets the rating for a media item. ```APIDOC ## PUT /video/rate ### Description Sets the rating for a media item. ### Method PUT ### Endpoint /video/rate ### Parameters #### Query Parameters - **rate** (number) - Required - The rating to set (e.g., 1-10). ### Request Example ```json { "example": "/video/rate?rate=8" } ``` ### Response #### Success Response (200) - **void** - Indicates successful rating update. #### Response Example ```json { "example": "" } ``` ``` -------------------------------- ### Get Media Item by GUID Source: https://ctrl-plex.vercel.app/classes/ShowSection Retrieves a media item using its external identifier (IMDB, TMDB, or TVDB). Performance can be slow as it may scan the entire library. Consider creating a lookup dictionary for frequent searches. ```python # This will retrieve all items in the entire library 3 times result1 = library.getGuid('imdb://tt0944947') result2 = library.getGuid('tmdb://1399') result3 = library.getGuid('tvdb://121361') # This will only retrieve all items in the library once to create a lookup dictionary guidLookup = {guid.id: item for item in library.all() for guid in item.guids} result1 = guidLookup['imdb://tt0944947'] result2 = guidLookup['tmdb://1399'] result3 = guidLookup['tvdb://121361'] ``` -------------------------------- ### video.unmatch() Source: https://ctrl-plex.vercel.app/classes/Show Unmatches the metadata match from a media object. ```APIDOC ## DELETE /video/unmatch ### Description Unmatches the metadata match from a media object. ### Method DELETE ### Endpoint /video/unmatch ### Parameters No parameters required. ### Request Example ```json { "example": "/video/unmatch" } ``` ### Response #### Success Response (200) - **any** - Indicates successful unmatching. #### Response Example ```json { "example": "" } ``` ``` -------------------------------- ### List Available Filters Source: https://ctrl-plex.vercel.app/classes/LibrarySection Returns a list of available filters for a specified library type. This function helps in identifying the options available in the custom filter dropdown menu for different media categories. The example shows how to map the results to get just the filter names. ```typescript listFilters(libtype?: "movie" | "show" | "season" | "episode" | "trailer" | "comic" | "person" | "artist" | "album" | "track" | "picture" | "clip" | "photo" | "photoalbum" | "playlist" | "playlistFolder" | "collection" | "optimizedVersion" | "userPlaylistItem"): Promise // Example usage: const availableFilters = (await library.listFilters()).map(f => f.filter) ``` -------------------------------- ### video.posters() Source: https://ctrl-plex.vercel.app/classes/Show Retrieves a list of available poster objects for a media item. ```APIDOC ## GET /video/posters ### Description Retrieves a list of available poster objects for a media item. ### Method GET ### Endpoint /video/posters ### Parameters No parameters required. ### Request Example ```json { "example": "/video/posters" } ``` ### Response #### Success Response (200) - **Poster[]** (array) - An array of poster objects. #### Response Example ```json { "example": "[ { "id": "poster123", "url": "/library/metadata/1/poster" } ]" } ``` ``` -------------------------------- ### video.uploadPoster() Source: https://ctrl-plex.vercel.app/classes/Show Uploads a new poster for a media item. This method is experimental and may not function correctly. ```APIDOC ## POST /video/poster/upload ### Description Uploads a new poster for a media item. This method is experimental and may not function correctly. ### Method POST ### Endpoint /video/poster/upload ### Parameters #### Request Body - **__namedParameters** (object) - Optional - Contains the poster data. - **file** (Uint8Array) - Optional - The poster image data as a byte array. - **url** (string) - Optional - The URL of the poster image to upload. ### Request Example ```json { "example": "POST /video/poster/upload with body { "file": "" }" } ``` ### Response #### Success Response (200) - **void** - Indicates successful poster upload. #### Response Example ```json { "example": "" } ``` ``` -------------------------------- ### Guid Constructor Source: https://ctrl-plex.vercel.app/classes/Guid Initializes a new Guid object. It requires a PlexServer instance and data, with optional parameters for initialization path and parent object. This constructor is fundamental for creating Guid instances to represent external metadata. ```typescript new Guid( server: PlexServer, data: any, initpath?: string, parent?: PlexObject, ): Guid ``` -------------------------------- ### Guid Methods: reload Source: https://ctrl-plex.vercel.app/classes/Guid Asynchronously reloads the data for the Guid object from its associated key. An optional 'ekey' parameter can be provided for specific reload targets. ```typescript reload(ekey?: string): Promise ``` -------------------------------- ### video.refresh() Source: https://ctrl-plex.vercel.app/classes/Show Refreshes the metadata for a library or individual media item. ```APIDOC ## POST /video/refresh ### Description Refreshes the metadata for a library or individual media item. This action updates the metadata even if it already exists. ### Method POST ### Endpoint /video/refresh ### Parameters No parameters required. ### Request Example ```json { "example": "/video/refresh" } ``` ### Response #### Success Response (200) - **void** - Indicates successful metadata refresh. #### Response Example ```json { "example": "" } ``` ``` -------------------------------- ### Guid Methods: isChildOf Source: https://ctrl-plex.vercel.app/classes/Guid Checks if the current Guid object is a child of a specified class. This method is useful for verifying hierarchical relationships within the Plex object structure. ```typescript isChildOf(cls: any): boolean ``` -------------------------------- ### Bootstrap Plex Server with Test Media Source: https://ctrl-plex.vercel.app/index Initializes the Plex server with test media content. This script requires the PLEX_PASSWORD and PLEX_USERNAME environment variables to be set and can be run with or without Docker. ```bash npx tsx scripts/bootstraptest.ts --no-docker --server-name=orbstack --password=$PLEX_PASSWORD --username=$PLEX_USERNAME ``` -------------------------------- ### Guid Properties Source: https://ctrl-plex.vercel.app/classes/Guid Details the properties of the Guid class, including 'id' for external metadata identifiers (like IMDB), 'key' for Plex URLs, optional 'parent' as a WeakRef, and static properties 'TAG' and 'TYPE' for XML element identification. These properties provide essential information about the Guid's context and origin. ```typescript id: string key: string parent?: WeakRef server: PlexServer TAG: "Guid" = ... TYPE: string = null ``` -------------------------------- ### section Source: https://ctrl-plex.vercel.app/classes/Audio Fetches all sections available on the Plex server. ```APIDOC ## GET /sections ### Description Fetches all sections available on the Plex server. ### Method GET ### Endpoint /sections ### Response #### Success Response (200) - **Section** (object[]) - An array of section objects, each representing a library section. #### Response Example ```json [ { "id": "1", "name": "Movies", "type": "movie" }, { "id": "2", "name": "TV Shows", "type": "show" } ] ``` ``` -------------------------------- ### PlexClient Constructor Source: https://ctrl-plex.vercel.app/classes/PlexClient Initializes a new instance of the PlexClient class. This client can connect directly to a Plex device or proxy commands through a Plex Server. ```APIDOC ## Constructor PlexClient ### Description Initializes a new instance of the PlexClient class. ### Method constructor ### Parameters - **options** (PlexOptions) - Optional - Configuration options for the Plex client. ### Returns PlexClient - A new instance of the PlexClient. ### Request Example ```json { "options": {} } ``` ### Response Example ```json { "instance": "PlexClient" } ``` ``` -------------------------------- ### Guid Methods: refresh Source: https://ctrl-plex.vercel.app/classes/Guid Asynchronously refreshes the metadata for a library or individual item, even if metadata already exists. This is crucial for ensuring the latest metadata is available for Plex objects. ```typescript refresh(): Promise ``` -------------------------------- ### Media Management Methods Source: https://ctrl-plex.vercel.app/classes/Show Methods for managing media collections, genres, labels, and performing server analysis. ```APIDOC ## Media Management Methods ### addCollection * **Description**: Adds one or more collections to the media item. * **Method**: POST * **Endpoint**: N/A (Method call) * **Parameters**: * **collections** (string[]) - Required - The collections to add. * **Returns**: Promise ### addGenre * **Description**: Adds one or more genres to the media item. * **Method**: POST * **Endpoint**: N/A (Method call) * **Parameters**: * **genres** (string[]) - Required - The genres to add. * **Returns**: Promise ### addLabel * **Description**: Adds one or more labels to the media item. * **Method**: POST * **Endpoint**: N/A (Method call) * **Parameters**: * **labels** (string[]) - Required - The labels to add. * **Returns**: Promise ### analyze * **Description**: Tells Plex Media Server to perform analysis on this item to gather information. Analysis includes gathering media properties, generating default artwork, generating video preview thumbnails, and generating intro video markers. * **Method**: POST * **Endpoint**: N/A (Method call) * **Returns**: Promise ``` -------------------------------- ### GET /history Source: https://ctrl-plex.vercel.app/classes/Episode Retrieves the history of the object. ```APIDOC ## GET /history ### Description Retrieves the history of the object. ### Method GET ### Endpoint /history ### Parameters None ### Request Example N/A ### Response #### Success Response (200) - **HistoryResult[]** - An array of history results. #### Response Example N/A ``` -------------------------------- ### PlayQueue Methods: Get, IsChildOf Source: https://ctrl-plex.vercel.app/classes/PlayQueue Methods to retrieve specific items or check relationships. `getItem` gets an item by index, `getQueueItem` finds a similar object within the queue, and `isChildOf` checks class hierarchy. ```typescript getItem(index: number): Playable getQueueItem(item: Playable): Playable isChildOf(cls: any): boolean ``` -------------------------------- ### url Source: https://ctrl-plex.vercel.app/classes/Audio Returns the full URL for a given part relative to the item's key, including the authentication token. ```APIDOC ## GET /url ### Description Returns the full URL for a given part (like a media stream) relative to the item's key. Includes the authentication token. ### Method GET ### Endpoint /url ### Parameters #### Query Parameters - **part** (string) - Required - The relative path or resource identifier. ### Response #### Success Response (200) - **string** - The full URL string including the server address and token, or undefined if part is empty. #### Response Example ```json "https://your-plex-server.com/library/parts/123/file.mp4?X-Plex-Token=YOUR_TOKEN" ``` ``` -------------------------------- ### Library Constructor Source: https://ctrl-plex.vercel.app/classes/Library Initializes a new Library instance. It requires a PlexServer object and LibraryRootResponse data. This constructor is fundamental for creating and managing library objects within the Plex ecosystem. ```typescript new Library(server: PlexServer, data: LibraryRootResponse): Library ``` -------------------------------- ### GET /section Source: https://ctrl-plex.vercel.app/classes/Season Retrieves information about the current section. ```APIDOC ## GET /section ### Description Returns information about the current section. ### Method GET ### Endpoint /section ### Parameters #### Query Parameters None ### Request Example ```json {} ``` ### Response #### Success Response (200) - **section** (Section) - The Section object. #### Response Example ```json { "section": { "id": "movies_1", "name": "Movies" } } ``` ``` -------------------------------- ### Connect API Source: https://ctrl-plex.vercel.app/classes/PlexServer Establishes a connection to the Plex server. ```APIDOC ## POST /connect ### Description Establishes a connection to the Plex server. ### Method POST ### Endpoint /connect ### Parameters #### Query Parameters - **None** ### Request Example ``` POST /connect ``` ### Response #### Success Response (200) - **message** (string) - Indicates a successful connection. #### Response Example ```json { "message": "Successfully connected to Plex server." } ``` ``` -------------------------------- ### MediaPart Constructor - TypeScript Source: https://ctrl-plex.vercel.app/classes/MediaPart Initializes a new MediaPart object. Requires a PlexServer instance and data, with optional initpath and parent parameters. Returns a MediaPart instance. ```typescript new MediaPart( server: PlexServer, data: any, initpath?: string, parent?: PlexObject ): MediaPart ``` -------------------------------- ### GET /hubs Source: https://ctrl-plex.vercel.app/classes/LibrarySection Retrieves a list of hubs available in the Plex library. ```APIDOC ## GET /hubs ### Description Retrieves a list of hubs available in the Plex library. ### Method GET ### Endpoint /hubs ### Parameters #### Query Parameters None ### Request Example None ### Response #### Success Response (200) - **hubs** (Hub[]) - A list of available hubs. #### Response Example ```json [ { "title": "Recently Added Movies", "type": "hub" } ] ``` ``` -------------------------------- ### Media Properties Source: https://ctrl-plex.vercel.app/classes/Show Retrieve various properties and metadata associated with media items. ```APIDOC ## Media Properties ### actors * **Description**: Alias of Show.roles. Retrieves the actors associated with the media. * **Method**: GET * **Endpoint**: N/A (Property getter) * **Returns**: Role[] ### artUrl * **Description**: Retrieves the URL for the artwork of the media item. * **Method**: GET * **Endpoint**: N/A (Property getter) * **Returns**: URL ### isFullObject * **Description**: Returns true if this is already a full object, meaning all attributes were populated from the API path representing only this item. For example, the search result for a movie often only contains a portion of the attributes a full object (main URL) for that movie would contain. * **Method**: GET * **Endpoint**: N/A (Property getter) * **Returns**: boolean ### isWatched * **Description**: Returns true if this show is fully watched. * **Method**: GET * **Endpoint**: N/A (Property getter) * **Returns**: boolean ### thumbUrl * **Description**: Returns the first thumbnail URL, starting with the most specific thumbnail for that item. * **Method**: GET * **Endpoint**: N/A (Property getter) * **Returns**: URL ``` -------------------------------- ### GET /getFilterType Source: https://ctrl-plex.vercel.app/classes/LibrarySection Retrieves filtering options for a specified library type. ```APIDOC ## GET /getFilterType ### Description Retrieves filtering options for a specified library type. ### Method GET ### Endpoint /getFilterType ### Parameters #### Query Parameters - **libtype** (string) - Optional - The library type to get filters for (e.g., movie, show, season, episode, artist, album, track, photoalbum, photo, collection). ### Request Example None ### Response #### Success Response (200) - **filteringType** (FilteringType) - An object containing available filters for the specified library type. #### Response Example ```json { "filters": [ { "id": "genre", "key": "genre", "type": "tag" } ] } ``` ``` -------------------------------- ### GET /genres Source: https://ctrl-plex.vercel.app/classes/LibrarySection Retrieves a list of available genres from the Plex library. ```APIDOC ## GET /genres ### Description Retrieves a list of available genres from the Plex library. ### Method GET ### Endpoint /genres ### Parameters #### Query Parameters None ### Request Example None ### Response #### Success Response (200) - **genres** (FilterChoice[]) - A list of available genre filter choices. #### Response Example ```json [ { "id": "1", "key": "action", "tag": "Action" } ] ``` ``` -------------------------------- ### Show Class Constructor - Python Source: https://ctrl-plex.vercel.app/classes/Show Initializes a new Show object. It requires a PlexServer instance and data, with optional parameters for initialization path and parent object. This constructor is fundamental for creating and managing show objects within the Plex ecosystem. ```python def __init__(self, server: PlexServer, data: any, initpath?: string, parent?: PlexObject): Show ``` -------------------------------- ### Create Play Queue Source: https://ctrl-plex.vercel.app/classes/Clip Creates a new PlayQueue for a given media item, with optional configuration. ```APIDOC ## POST /createPlayQueue ### Description Returns a new PlayQueue from this media item. PlayQueues allow for managing playback order and options. ### Method POST ### Endpoint /createPlayQueue ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **options** (object) - Optional - Options for creating the PlayQueue. Defaults to an empty object. - **shuffle** (boolean) - Optional - Whether to shuffle the play queue. - **repeat** (boolean) - Optional - Whether to repeat the play queue. ### Request Example ```json { "options": { "shuffle": true, "repeat": false } } ``` ### Response #### Success Response (200) - **PlayQueue** (object) - A new PlayQueue instance. - **key** (string) - The unique identifier for the PlayQueue. - **items** (array) - An array of media items in the PlayQueue. #### Response Example ```json { "PlayQueue": { "key": "/playqueues/12345", "items": [ { "title": "Media Item 1" }, { "title": "Media Item 2" } ] } } ``` ``` -------------------------------- ### Get Web URL Source: https://ctrl-plex.vercel.app/classes/Extra Retrieves the web URL for the media item. ```APIDOC ## GET /getWebURL ### Description Retrieves the web URL for the media item. ### Method GET ### Endpoint /getWebURL ### Parameters #### Query Parameters * **__namedParameters** (object) - Optional - Named parameters. * **base** (string) - Optional - The base URL to use. ### Request Example ```json { "__namedParameters": { "base": "https://app.plex.tv" } } ``` ### Response #### Success Response (200) - **string** - The web URL for the media item. #### Response Example ```json "https://app.plex.tv/desktop#!/server/abcdef1234567890/item/12345" ``` ``` -------------------------------- ### Get Filtering Type by Library Type Source: https://ctrl-plex.vercel.app/classes/MovieSection Retrieves filtering types based on the specified library type. This function can be used to get available filters for different media categories like movies, shows, etc. It returns a Promise that resolves to a FilteringType object. ```typescript /** * Retrieves filtering types for a given library type. * @param libtype The library type (movie, show, season, episode, etc.). * @returns A Promise that resolves to the FilteringType. */ async getFilterType(libtype?: "movie" | "show" | "season" | "episode" | "trailer" | "comic" | "person" | "artist" | "album" | "track" | "picture" | "clip" | "photo" | "photoalbum" | "playlist" | "playlistFolder" | "collection" | "optimizedVersion" | "userPlaylistItem"): Promise ``` -------------------------------- ### Run Plex Docker Container for Testing Source: https://ctrl-plex.vercel.app/index Starts a Plex Media Server instance in a Docker container for testing. This command maps necessary ports, sets up volumes for configuration and media, and uses the claim token for authorization. ```bash docker run -d \ --name=plex \ --net=host \ -h orbstack \ -p 32400:32400/tcp \ -p 32400:32400 \ -p 1900:1900/udp \ -p 5353:5353/udp \ -p 8324:8324 \ -p 32410:32410/udp \ -p 32412:32412/udp \ -p 32413:32413/udp \ -p 32414:32414/udp \ -p 32469:32469 \ -e PUID=1000 \ -e PGID=1000 \ -e TZ=Etc/UTC \ -e VERSION=docker \ -e PLEX_CLAIM=$PLEX_CLAIM_TOKEN \ -v /Users/scooper/gh/plex/plex/media/db:/config \ -v /Users/scooper/gh/plex/plex/media/transcode:/transcode \ -v /Users/scooper/gh/plex/plex/media:/data \ --restart unless-stopped \ lscr.io/linuxserver/plex:latest ``` -------------------------------- ### GET /listFilters Source: https://ctrl-plex.vercel.app/classes/LibrarySection Returns a list of available filters for a specified library type. ```APIDOC ## GET /listFilters ### Description Returns a list of available filters for a specified library type. ### Method GET ### Endpoint /listFilters ### Parameters #### Query Parameters - **libtype** (string) - Optional - The library type to filter (e.g., movie, show, season, episode, artist, album, track, photoalbum, photo, collection). ### Request Example ```javascript const availableFilters = (await library.listFilters()).map(f => f.filter) ``` ### Response #### Success Response (200) - **filters** (FilteringFilter[]) - A list of available filters. #### Response Example ```json [ { "filter": { "id": "genre", "key": "genre", "type": "tag" } } ] ``` ``` -------------------------------- ### Create Playlist using PlexServer Source: https://ctrl-plex.vercel.app/classes/Playlist Creates a new playlist on a Plex server. Requires the PlexServer instance, a title, and playlist creation options. Returns the created Playlist object. ```typescript static create( server: PlexServer, title: string, options: CreatePlaylistOptions, ): Promise ``` -------------------------------- ### unmatch Source: https://ctrl-plex.vercel.app/classes/Audio Unmatches metadata match from an object. ```APIDOC ## POST /unmatch ### Description Unmatches metadata match from object. ### Method POST ### Endpoint /unmatch ### Response #### Success Response (200) - **any** - This endpoint returns a promise that resolves to any type upon successful execution. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### GET /getFieldType Source: https://ctrl-plex.vercel.app/classes/LibrarySection Retrieves information about a specific field type used for filtering. ```APIDOC ## GET /getFieldType ### Description Retrieves information about a specific field type used for filtering. ### Method GET ### Endpoint /getFieldType ### Parameters #### Query Parameters - **fieldType** (string) - Required - The data type for the field (e.g., tag, integer, string, boolean, date, subtitleLanguage, audioLanguage, resolution). ### Request Example None ### Response #### Success Response (200) - **filteringFieldType** (FilteringFieldType) - Information about the specified field type. #### Response Example ```json { "type": "tag", "label": "Genre" } ``` ``` -------------------------------- ### Get Posters Source: https://ctrl-plex.vercel.app/classes/Extra Retrieves a list of available Poster objects for a media item. ```APIDOC ## GET /posters ### Description Returns list of available Poster objects. ### Method GET ### Endpoint /posters ### Parameters *None* ### Request Example ```json // No request body needed for GET operation. ``` ### Response #### Success Response (200) - **Poster[]** - An array of Poster objects. #### Response Example ```json [ { "id": "poster1", "key": "/library/metadata/123/poster.jpg", "url": "http://localhost:32400/library/metadata/123/poster.jpg" } ] ``` ``` -------------------------------- ### Get Extras Source: https://ctrl-plex.vercel.app/classes/Extra Retrieves a list of available Extra objects for a media item. ```APIDOC ## GET /extras ### Description Returns list of available Extra objects. ### Method GET ### Endpoint /extras ### Parameters *None* ### Request Example ```json // No request body needed for GET operation. ``` ### Response #### Success Response (200) - **Extra[]** - An array of Extra objects. #### Response Example ```json [ { "id": "1", "title": "Behind the Scenes", "type": "featurette" } ] ``` ``` -------------------------------- ### Create Play Queue Source: https://ctrl-plex.vercel.app/classes/Playlist Creates a new PlayQueue from a given media item, with optional configuration. ```APIDOC ## POST /createPlayQueue ### Description Returns a new PlayQueue from this media item. Options can be provided to configure the PlayQueue. ### Method POST ### Endpoint /createPlayQueue ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **options** (object) - Optional - Options for creating the PlayQueue. - **Example**: `{}` ### Request Example ```json { "options": {} } ``` ### Response #### Success Response (200) - **PlayQueue** (object) - A new PlayQueue instance. #### Response Example ```json { "example": "{\"playQueue\": {\"items\": [...], \"playNext\": [...]}}" } ``` ``` -------------------------------- ### Get Default Sync Title Source: https://ctrl-plex.vercel.app/classes/Album Returns the default title for a synchronized item. ```typescript _defaultSyncTitle(): string ``` -------------------------------- ### Get List Type Source: https://ctrl-plex.vercel.app/classes/Album Returns the hardcoded list type for filtering, which is 'audio'. ```typescript get listType(): "audio" ```