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

NameDescription
ip_addressThe IP address of the Plex Media server.
plex_tokenThe Plex token.
idThe key associated with the library. This key can be found by calling the Libraries API command and looking for the library.

Return Status

HTTP CodeDescription
200Success - The request was successful.
401Unauthorized - 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.

MediaContainer Attributes
AttributeDescription
sizeThe number of libraries.
allowSync1 - allow syncing content.
0 - don't allow syncing content.
artBackground artwork used to represent the library.
contentThe level of content associated with the library.
identifierThe type of item.
librarySectionIDThe unique key associated with the library.
mediaTagPrefixPrefix for the media tag.
mediaTagVersionMedia tag version.
Note: This could be a date and time value.
thumbThe thumbnail for the library.
title1The title of the library.
Note: This appears to be internally created, and can't be changed by the server owner.
viewGroupThe group type used to view the library.
viewModeUnknown 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.

Directory Attributes
AttributeDescription
secondaryUsed by old clients to provided nested menus allowing for structured navigation of the library.
promptThe prompt associated with the directory value.
searchFlag indicating the directory is used for searching the library.
keyThe relative URL of the information for the library.
titleThe name of the library.
keyThe relative URL of the information for the library.
titleThe 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
Subscribe
Display