Get Library Details
A Plex server can have many different libraries setup for various media. You can easily retrieve the information about any library that is available on a Plex server using this API command.
URL
GET http://{ip_address}:32400/library/sections/{id}?X-Plex-Token={plex_token}Parameters
| Name | Description |
|---|---|
| ip_address | The IP address of the Plex Media server. |
| plex_token | The Plex token. |
| id | The key associated with the library. This key can be found by calling the Libraries API command and looking for the library. |
Return Status
| HTTP Code | Description |
|---|---|
| 200 | Success - The request was successful. |
| 401 | Unauthorized - The Plex token provided was not valid. |
Response
XML string value that contains information about a single library on the Plex server. An example of the XML returned from the request is shown below:
<?xml version="1.0" encoding="UTF-8"?>
<MediaContainer size="20" allowSync="0" art="/:/resources/movie-fanart.jpg" content="secondary" identifier="com.plexapp.plugins.library" librarySectionID="2" mediaTagPrefix="/system/bundle/media/flags/" mediaTagVersion="1698877656" thumb="/:/resources/movie.png" title1="Movies" viewGroup="secondary" viewMode="65592">
<Directory key="all" title="All Movies" />
<Directory key="unwatched" title="Unplayed" />
<Directory key="newest" title="Recently Released" />
<Directory key="recentlyAdded" title="Recently Added" />
<Directory key="recentlyViewed" title="Recently Viewed" />
<Directory key="onDeck" title="Continue Watching" />
<Directory secondary="1" key="collection" title="By Collection" />
<Directory secondary="1" key="edition" title="By Edition" />
<Directory secondary="1" key="genre" title="By Genre" />
<Directory secondary="1" key="year" title="By Year" />
<Directory secondary="1" key="decade" title="By Decade" />
<Directory secondary="1" key="director" title="By Director" />
<Directory secondary="1" key="actor" title="By Starring Actor" />
<Directory secondary="1" key="country" title="By Country" />
<Directory secondary="1" key="contentRating" title="By Content Rating" />
<Directory secondary="1" key="rating" title="By Rating" />
<Directory secondary="1" key="resolution" title="By Resolution" />
<Directory secondary="1" key="firstCharacter" title="By First Letter" />
<Directory key="folder" title="By Folder" />
<Directory prompt="Search Movies" search="1" key="search?type=1" title="Search..." />
</MediaContainer>The root is the MediaContainer element. This element contains a few attributes that provide overall information about the library on the server.
| Attribute | Description |
|---|---|
| size | The number of libraries. |
| allowSync | 1 - allow syncing content. 0 - don't allow syncing content. |
| art | Background artwork used to represent the library. |
| content | The level of content associated with the library. |
| identifier | The type of item. |
| librarySectionID | The unique key associated with the library. |
| mediaTagPrefix | Prefix for the media tag. |
| mediaTagVersion | Media tag version. Note: This could be a date and time value. |
| thumb | The thumbnail for the library. |
| title1 | The title of the library. Note: This appears to be internally created, and can't be changed by the server owner. |
| viewGroup | The group type used to view the library. |
| viewMode | Unknown integer value. |
Within the MediaContainer there are one or more Directory child elements. Each Directory element allows you to drill down into the library to get more information. A Directory element can contain any number of the following attributes.
| Attribute | Description |
|---|---|
| secondary | Used by old clients to provided nested menus allowing for structured navigation of the library. |
| prompt | The prompt associated with the directory value. |
| search | Flag indicating the directory is used for searching the library. |
| key | The relative URL of the information for the library. |
| title | The name of the library. |
| key | The relative URL of the information for the library. |
| title | The name of the library. |
Remarks
The Plex authentication token used to make the request will determine if the user can get information on the library.
If the token used is for a non-administrative user, then only a library that the user can access will be returned.
When using a device Plex token, all libraries can be returned because libraries cannot be restricted for a device, only for users.
Examples
curl -X GET http://{ip_address}:32400/library/sections/{id}?X-Plex-Token={plex_token}
import requests
plex_url = http://{ip_address}:32400/library/sections/{id}?X-Plex-Token={plex_token}
response = requests.get(plex_url)
print(response.text)
$response = Invoke-RestMethod 'http://{ip_address}:32400/library/sections/{id}?X-Plex-Token={plex_token}' -Method GET
Write-Output $response