# Library (*Library*) ## Overview API Calls interacting with Plex Media Server Libraries ### Available Operations * [GetFileHash](#getfilehash) - Get Hash Value * [GetRecentlyAdded](#getrecentlyadded) - Get Recently Added * [GetLibraries](#getlibraries) - Get All Libraries * [GetLibrary](#getlibrary) - Get Library Details * [DeleteLibrary](#deletelibrary) - Delete Library Section * [GetLibraryItems](#getlibraryitems) - Get Library Items * [RefreshLibrary](#refreshlibrary) - Refresh Library * [GetMetadata](#getmetadata) - Get Items Metadata * [GetMetadataChildren](#getmetadatachildren) - Get Items Children * [GetOnDeck](#getondeck) - Get On Deck ## GetFileHash This resource returns hash values for local files ### Example Usage ```csharp using PlexAPI; using PlexAPI.Models.Components; using PlexAPI.Models.Requests; var sdk = new PlexAPISDK( security: new Models.Components.Security() { AccessToken = "", }); var res = await sdk.Library.GetFileHashAsync(Url: "file://C:\Image.png&type=13", Type: 4462.17D); // handle response ``` ### Parameters | Parameter | Type | Required | Description | Example | | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | | `Url` | *string* | :heavy_check_mark: | This is the path to the local file, must be prefixed by `file://` | file://C:\Image.png&type=13 | | `Type` | *double* | :heavy_minus_sign: | Item type | | ### Response **[GetFileHashResponse](../../Models/Requests/GetFileHashResponse.md)** ## GetRecentlyAdded This endpoint will return the recently added content. ### Example Usage ```csharp using PlexAPI; using PlexAPI.Models.Components; var sdk = new PlexAPISDK( security: new Models.Components.Security() { AccessToken = "", }); var res = await sdk.Library.GetRecentlyAddedAsync(); // handle response ``` ### Response **[GetRecentlyAddedResponse](../../Models/Requests/GetRecentlyAddedResponse.md)** ## GetLibraries A library section (commonly referred to as just a library) is a collection of media. Libraries are typed, and depending on their type provide either a flat or a hierarchical view of the media. For example, a music library has an artist > albums > tracks structure, whereas a movie library is flat. Libraries have features beyond just being a collection of media; for starters, they include information about supported types, filters and sorts. This allows a client to provide a rich interface around the media (e.g. allow sorting movies by release year). ### Example Usage ```csharp using PlexAPI; using PlexAPI.Models.Components; var sdk = new PlexAPISDK( security: new Models.Components.Security() { AccessToken = "", }); var res = await sdk.Library.GetLibrariesAsync(); // handle response ``` ### Response **[GetLibrariesResponse](../../Models/Requests/GetLibrariesResponse.md)** ## GetLibrary ## Library Details Endpoint This endpoint provides comprehensive details about the library, focusing on organizational aspects rather than the content itself. The details include: ### Directories Organized into three categories: - **Primary Directories**: - Used in some clients for quick access to media subsets (e.g., "All", "On Deck"). - Most can be replicated via media queries. - Customizable by users. - **Secondary Directories**: - Marked with `secondary="1"`. - Used in older clients for structured navigation. - **Special Directories**: - Includes a "By Folder" entry for filesystem-based browsing. - Contains an obsolete `search="1"` entry for on-the-fly search dialog creation. ### Types Each type in the library comes with a set of filters and sorts, aiding in building dynamic media controls: - **Type Object Attributes**: - `key`: Endpoint for the media list of this type. - `type`: Metadata type (if standard Plex type). - `title`: Title for this content type (e.g., "Movies"). - **Filter Objects**: - Subset of the media query language. - Attributes include `filter` (name), `filterType` (data type), `key` (endpoint for value range), and `title`. - **Sort Objects**: - Description of sort fields. - Attributes include `defaultDirection` (asc/desc), `descKey` and `key` (sort parameters), and `title`. > **Note**: Filters and sorts are optional; without them, no filtering controls are rendered. ### Example Usage ```csharp using PlexAPI; using PlexAPI.Models.Components; using PlexAPI.Models.Requests; var sdk = new PlexAPISDK( security: new Models.Components.Security() { AccessToken = "", }); var res = await sdk.Library.GetLibraryAsync(SectionId: 1000D, IncludeDetails: IncludeDetails.Zero); // handle response ``` ### Parameters | Parameter | Type | Required | Description | Example | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `SectionId` | *double* | :heavy_check_mark: | the Id of the library to query | 1000 | | `IncludeDetails` | [IncludeDetails](../../Models/Requests/IncludeDetails.md) | :heavy_minus_sign: | Whether or not to include details for a section (types, filters, and sorts).
Only exists for backwards compatibility, media providers other than the server libraries have it on always.
| | ### Response **[GetLibraryResponse](../../Models/Requests/GetLibraryResponse.md)** ## DeleteLibrary Delate a library using a specific section ### Example Usage ```csharp using PlexAPI; using PlexAPI.Models.Components; using PlexAPI.Models.Requests; var sdk = new PlexAPISDK( security: new Models.Components.Security() { AccessToken = "", }); var res = await sdk.Library.DeleteLibraryAsync(SectionId: 1000D); // handle response ``` ### Parameters | Parameter | Type | Required | Description | Example | | ------------------------------ | ------------------------------ | ------------------------------ | ------------------------------ | ------------------------------ | | `SectionId` | *double* | :heavy_check_mark: | the Id of the library to query | 1000 | ### Response **[DeleteLibraryResponse](../../Models/Requests/DeleteLibraryResponse.md)** ## GetLibraryItems Fetches details from a specific section of the library identified by a section key and a tag. The tag parameter accepts the following values: - `all`: All items in the section. - `unwatched`: Items that have not been played. - `newest`: Items that are recently released. - `recentlyAdded`: Items that are recently added to the library. - `recentlyViewed`: Items that were recently viewed. - `onDeck`: Items to continue watching. - `collection`: Items categorized by collection. - `edition`: Items categorized by edition. - `genre`: Items categorized by genre. - `year`: Items categorized by year of release. - `decade`: Items categorized by decade. - `director`: Items categorized by director. - `actor`: Items categorized by starring actor. - `country`: Items categorized by country of origin. - `contentRating`: Items categorized by content rating. - `rating`: Items categorized by rating. - `resolution`: Items categorized by resolution. - `firstCharacter`: Items categorized by the first letter. - `folder`: Items categorized by folder. - `search?type=1`: Search functionality within the section. ### Example Usage ```csharp using PlexAPI; using PlexAPI.Models.Components; using PlexAPI.Models.Requests; var sdk = new PlexAPISDK( security: new Models.Components.Security() { AccessToken = "", }); var res = await sdk.Library.GetLibraryItemsAsync(SectionId: 451092, Tag: Tag.Unwatched); // handle response ``` ### Parameters | Parameter | Type | Required | Description | | ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- | | `SectionId` | *long* | :heavy_check_mark: | the Id of the library to query | | `Tag` | [Tag](../../Models/Requests/Tag.md) | :heavy_check_mark: | A key representing a specific tag within the section. | ### Response **[GetLibraryItemsResponse](../../Models/Requests/GetLibraryItemsResponse.md)** ## RefreshLibrary This endpoint Refreshes the library. ### Example Usage ```csharp using PlexAPI; using PlexAPI.Models.Components; using PlexAPI.Models.Requests; var sdk = new PlexAPISDK( security: new Models.Components.Security() { AccessToken = "", }); var res = await sdk.Library.RefreshLibraryAsync(SectionId: 934.16D); // handle response ``` ### Parameters | Parameter | Type | Required | Description | | -------------------------------- | -------------------------------- | -------------------------------- | -------------------------------- | | `SectionId` | *double* | :heavy_check_mark: | the Id of the library to refresh | ### Response **[RefreshLibraryResponse](../../Models/Requests/RefreshLibraryResponse.md)** ## GetMetadata This endpoint will return the metadata of a library item specified with the ratingKey. ### Example Usage ```csharp using PlexAPI; using PlexAPI.Models.Components; using PlexAPI.Models.Requests; var sdk = new PlexAPISDK( security: new Models.Components.Security() { AccessToken = "", }); var res = await sdk.Library.GetMetadataAsync(RatingKey: 8382.31D); // handle response ``` ### Parameters | Parameter | Type | Required | Description | | ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- | | `RatingKey` | *double* | :heavy_check_mark: | the id of the library item to return the children of. | ### Response **[GetMetadataResponse](../../Models/Requests/GetMetadataResponse.md)** ## GetMetadataChildren This endpoint will return the children of of a library item specified with the ratingKey. ### Example Usage ```csharp using PlexAPI; using PlexAPI.Models.Components; using PlexAPI.Models.Requests; var sdk = new PlexAPISDK( security: new Models.Components.Security() { AccessToken = "", }); var res = await sdk.Library.GetMetadataChildrenAsync(RatingKey: 1539.14D); // handle response ``` ### Parameters | Parameter | Type | Required | Description | | ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- | | `RatingKey` | *double* | :heavy_check_mark: | the id of the library item to return the children of. | ### Response **[GetMetadataChildrenResponse](../../Models/Requests/GetMetadataChildrenResponse.md)** ## GetOnDeck This endpoint will return the on deck content. ### Example Usage ```csharp using PlexAPI; using PlexAPI.Models.Components; var sdk = new PlexAPISDK( security: new Models.Components.Security() { AccessToken = "", }); var res = await sdk.Library.GetOnDeckAsync(); // handle response ``` ### Response **[GetOnDeckResponse](../../Models/Requests/GetOnDeckResponse.md)**