Get All Videos
A library, such as movies or TV shows, can contain many items. This API command will return all other videos for a specific library that is available on the Plex server. These videos can be media files that aren't standard movies, such as home videos.
URL
GET http://{ip_address}:32400/library/sections/{id}/all?X-Plex-Token={plex_token}&{filter}
Parameters
Name | Description |
---|---|
ip_address | The IP address of the Plex Media server. |
plex_token | The Plex token. |
id | The key associated with a videos library. This key can be found by calling the Libraries API command and looking for a videos library. |
filter | (Optional) The filter to apply to the response. |
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 all the videos in the library. An example of the XML returned from the request is shown below:
<?xml version="1.0" encoding="UTF-8"?> <MediaContainer size="443" allowSync="1" art="/:/resources/movie-fanart.jpg" identifier="com.plexapp.plugins.library" librarySectionID="7" librarySectionTitle="Home Videos" librarySectionUUID="1704f844-5d35-474d-84d2-3f398c4a1684" mediaTagPrefix="/system/bundle/media/flags/" mediaTagVersion="1641342384" sortAsc="1" thumb="/:/resources/video.png" title1="Home Videos" title2="All Home Videos" viewGroup="movie" viewMode="131624"> <Video ratingKey="77963" key="/library/metadata/77963" guid="com.plexapp.agents.none://a186aa7249d7043eeb16e5b45ffbf2601d0590c0?lang=xn" type="movie" title="00000" contentRating="G" subtype="clip" summary="" viewCount="1" lastViewedAt="1640720544" year="2010" thumb="/library/metadata/77963/thumb/1597469053" art="/library/metadata/77963/art/1597469053" duration="32032" originallyAvailableAt="2010-12-12" addedAt="1450725246" updatedAt="1597469053" createdAtAccuracy="epoch" createdAtTZOffset="-14400"> <Media id="86785" duration="32032" bitrate="23866" width="1920" height="1080" aspectRatio="1.78" audioChannels="2" audioCodec="ac3" videoCodec="h264" videoResolution="1080" container="mpegts" videoFrameRate="NTSC" videoProfile="high" title="Original"> <Part id="86918" key="/library/parts/86918/1292187170/file.MTS" duration="32032" file="I:\Videos\2010\Christmas Tree\00000.MTS" size="95557632" container="mpegts" packetLength="192" timeStamp="1" videoProfile="high" /> </Media> <Media id="277883" duration="32032" bitrate="3543" width="1280" height="720" aspectRatio="1.78" audioChannels="2" audioCodec="aac" videoCodec="h264" videoResolution="720" container="mp4" videoFrameRate="NTSC" optimizedForStreaming="1" proxyType="42" audioProfile="lc" has64bitOffsets="0" target="Optimized for Mobile" targetTagID="6207" videoProfile="high" title="Optimized for Mobile"> <Part id="278213" key="/library/parts/278213/1597255970/file.mp4" duration="32032" file="I:\Videos\2010\Christmas Tree\Plex Versions\Optimized for Mobile\00000 (2010).mp4" size="14223890" audioProfile="lc" container="mp4" has64bitOffsets="0" optimizedForStreaming="1" videoProfile="high" /> </Media> </Video> ... </MediaContainer>
The XML returned provides a list of the all videos in a library 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 videos on the server.
Attribute | Description |
---|---|
size | The number of videos. |
allowSync | 1 - allow syncing content. 0 - don't allow syncing content. |
art | Background artwork used to represent the video. |
identifier | The type of item. |
librarySectionID | The unique key associated with the library. |
librarySectionTitle | The title of the library. |
librarySectionUUID | Unique GUID identifier for the library. |
mediaTagPrefix | Prefix for the media tag. |
mediaTagVersion | Media tag version. Note: This could be a date and time value. |
sortAsc | 1 - the library is sorted in ascending order. 0 - the library is sorted in descending order. |
thumb | The thumbnail for the video. |
title1 | The title of the video. Note: This appears to be internally created, and can't be changed by the server owner. |
title2 | A descriptive title for the video. |
viewGroup | The group type used to view the video. |
viewMode | Unknown integer value. |
Within the MediaContainer
there are one or more Video
child elements. Each Video
element represents one video available on the Plex server.
Attribute | Description |
---|---|
ratingKey | A key associated with the video. |
key | The relative URL of the video information. |
guid | The unique identifier comprised of the Plex agent and video identifier for the agent. |
type | The type of media. |
title | The title of the video. |
contentRating | The content rating associated with the video. |
subtype | The subtype of the video. |
summary | A summary of the video. |
viewCount | The number of times the video has been viewed. |
lastViewedAt | The date and time for the last time the video was viewed. |
year | The year the video was released. |
thumb | The thumbnail for the video. |
art | The background artwork used to represent the video. |
duration | The length of the video in milliseconds. |
originallyAvailableAt | The original release date of the video. |
addedAt | The date and time, in Unix time, the video was added to the library. |
updatedAt | The date and time in epoch time, the video was updated in the library. |
createdAtAccuracy | The accuracy of the created date. |
createdAtTZOffset | The time zone offset to GMT in seconds. |
Within the Video
there are one or more Media
child elements. Each Media
element represents one media file of the video available on the Plex server.
If there are two video files associated with the video, such as a 1080p and 480p version, then there would be two Media
child elements in the Video
element.
Attribute | Description |
---|---|
id | Unique ID associated with the video. |
duration | The length of the video in milliseconds. |
bitrate | The bitrate of the video. |
width | The width of the video. |
height | The height of the video. |
aspectRatio | The aspect ratio of the video. |
audioChannels | The number of audio channels. |
audioCodec | The audio codec used to encode the audio. |
videoCodec | The video codec used to encode the video. |
videoResolution | The video resolution. |
container | The video container. |
videoFrameRate | The framerate standard used for the video. |
videoProfile | The video profile of the media. |
title | The title of the video. |
Within the Media
there are one or more Part
child elements. Each Part
element represents one part of the video. If the video has been added to the Plex server as a multi-part video, then each of those parts will be represented by one Part
child element.
Attribute | Description |
---|---|
key | The unique relative path for the part that is used at its key. |
duration | The length of the part in milliseconds. |
file | The file associated with the part. |
size | The file size of the part. |
container | The type of media container. |
packetLength | The packet length. |
timeStamp | 1 - the video contains a timestamp. 0 - the video doesn't contain a timestamp. |
videoProfile | The video profile associated with the video part. |
Remarks
To reduce the number of items returned, you can filter the API response to only return items that meet a specific criteria.
For more information, check out the Filter page.
Examples
curl -X GET http://{ip_address}:32400/library/sections/{id}/all?X-Plex-Token={plex_token}
import requests plex_url = http://{ip_address}:32400/library/sections/{id}/all?X-Plex-Token={plex_token} response = requests.get(plex_url) print(response.text)
$response = Invoke-RestMethod 'http://{ip_address}:32400/library/sections/{id}/all?X-Plex-Token={plex_token}' -Method 'GET' Write-Output $response