Get Libraries
A Plex server can have many different libraries setup for various media. You can easily retrieve the information about all libraries that are available on a Plex server using this API command.
URL
GET http://[IP address]:32400/library/sections/?X-Plex-Token=[PlexToken]
Parameters
Name | Description |
---|---|
IP address | The IP address of the Plex Media server. |
PlexToken | The temporary authentication Plex token. |
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 lists the libraries that have been created 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="4" allowSync="0" identifier="com.plexapp.plugins.library" mediaTagPrefix="/system/bundle/media/flags/" mediaTagVersion="1638961228" title1="Plex Library"> <Directory allowSync="1" art="/:/resources/movie-fanart.jpg" composite="/library/sections/2/composite/1640879224" filters="1" refreshing="0" thumb="/:/resources/movie.png" key="2" type="movie" title="Movies" agent="com.plexapp.agents.imdb" scanner="Plex Movie Scanner" language="en" uuid="493a64e7-b541-4667-b050-d702beebf2f6" updatedAt="1595491662" createdAt="1419621957" scannedAt="1640879224" content="1" directory="1" contentChangedAt="87188911" hidden="0"> <Location id="9" path="M:\Media\Movies" /> </Directory> <Directory allowSync="1" art="/:/resources/show-fanart.jpg" composite="/library/sections/4/composite/1640879304" filters="1" refreshing="0" thumb="/:/resources/show.png" key="4" type="show" title="TV Shows" agent="com.plexapp.agents.thetvdb" scanner="Plex Series Scanner" language="en" uuid="3bbbe6f7-628f-4983-ae5d-7c05779c4c28" updatedAt="1595493250" createdAt="1419642504" scannedAt="1640879304" content="1" directory="1" contentChangedAt="5613493" hidden="0"> <Location id="11" path="M:\Media\TV Shows" /> </Directory> <Directory allowSync="1" art="/:/resources/artist-fanart.jpg" composite="/library/sections/8/composite/1640879225" filters="1" refreshing="0" thumb="/:/resources/artist.png" key="8" type="artist" title="Music" agent="tv.plex.agents.music" scanner="Plex Music" language="en" uuid="b6031749-2969-4027-afee-64172b72b77d" updatedAt="1598392667" createdAt="1430573735" scannedAt="1640879225" content="1" directory="1" contentChangedAt="59913170" hidden="0"> <Location id="16" path="M:\Media\Music" /> </Directory> <Directory allowSync="1" art="/:/resources/photo-fanart.jpg" composite="/library/sections/1/composite/1640879303" filters="1" refreshing="0" thumb="/:/resources/photo.png" key="1" type="photo" title="Photos" agent="com.plexapp.agents.none" scanner="Plex Photo Scanner" language="xn" uuid="fc948ea9-3fad-45e2-99ef-b461b2d746d2" updatedAt="1600821139" createdAt="1419611117" scannedAt="1640879303" enableAutoPhotoTags="0" content="1" directory="1" contentChangedAt="115673999" hidden="0"> <Location id="10" path="M:\Media\Pictures" /> </Directory> </MediaContainer>
Remarks
The XML returned provides a list of the libraries that are available on the Plex server. The root is the MediaContainer
element. This element contains a few attributes that provide overall information about the libraries on the server.
Attribute | Description |
---|---|
size | The number of libraries added to the Plex server. |
allowSync | 1 - allow syncing. 0 - do not allow syncing. Note: Not sure how this attribute works as the server and libraries can have allowsync = 1, and this value can be 0. |
identifier | The identifier for this type of item in Plex. |
mediaTagPrefix | Prefix for the media tag. |
mediaTagVersion | Media tag version. Note: This could be a date and time value. |
title1 | The title of the library item. Note: This appears to be internally created, and can't be changed by the server owner. |
Within the MediaContainer
there are one or more Directory
child elements. Each Directory
element represents one library on the Plex server.
Attribute | Description |
---|---|
allowSync | 1 - allow the items in the library to be synced. 0 - do not allow the items in the library to be synced. |
art | Location of the image file used for the library artwork. |
composite | The relative URL of the composite artwork for the library. |
filters | 1 - allow library filters. 0 - do no allow library filters. |
refreshing | 1 - the library is refreshing the metadata. 0 - the library is not refreshing the metadata. |
thumb | Location of the thumbnail for the library. |
key | The unique key value for the library. |
type | The type of library. |
title | The title of library that was specified when the library was created. |
agent | The agent used to set the metadata for the items in the library. |
scanner | The name of the scanner used to scan the library. |
language | The two-character language for the library. |
uuid | Unique identifier for the library. |
updatedAt | The date and time when the library was last updated. |
createdAt | The date and time when the library was created. |
scannedAt | The date and time when the library was last scanned. |
content | Unknown |
directory | Unknown |
contentChangedAt | The date and time when the library content was last changed. |
hidden | 1 - the library is hidden. 0 - the library is not hidden. |
Within each of the Directory
elements can be one or more Location
child elements. These child elements specify the folder path of the files associated with each library.
The attributes of the Location
elements are:
Attribute | Description |
---|---|
id | Unique integer value used as the location identifier. |
path | The full path to the folder containing the files for the library. This value was specified when the library was added to the Plex server. |
Examples
Example 1
Get the library information for the Plex Media Server located at the IP address of 192.168.1.4:
GET http://192.168.1.4:32400/library/sections/?X-Plex-Token=L6vkd7JtLHjsH5987vYY