Get Recently Added Media
This API command is used to get all recently added media to a Plex server.
URL
GET http://{ip_address}:32400/library/recentlyAdded?X-Plex-Token={plex_token}
Parameters
Name | Description |
---|---|
ip_address | The IP address of the Plex Media server. |
plex_token | The Plex token. |
Return Status
HTTP Code | Description |
---|---|
200 | Success - The request was successful. |
401 | Unauthorized - The Plex token provided was not valid. |
404 | Not Found - The URL path is incorrect. See Remarks below. |
Response
XML string value that lists the all the recently added media in the library. An example of the XML returned from the request is shown below:
<?xml version="1.0" encoding="UTF-8"?> <MediaContainer size="70" allowSync="1" art="/:/resources/movie-fanart.jpg" identifier="com.plexapp.plugins.library" librarySectionID="2" librarySectionTitle="Movies" librarySectionUUID="493a64e7-b541-4667-b050-d702beebf2f6" mediaTagPrefix="/system/bundle/media/flags/" mediaTagVersion="1710434120" sortAsc="1" thumb="/:/resources/movie.png" title1="Movies" title2="Recently Added" viewGroup="movie" viewMode="131624"> <Video ratingKey="293776" key="/library/metadata/293776" guid="plex://movie/5d7768257228e5001f1dccce" slug="the-godfather-part-iii" editionTitle="The Coppola Restoration" studio="Paramount" type="movie" title="The Godfather Part III" titleSort="Godfather 03" contentRating="R" summary="Follows Michael Corleone, now in his 60s, as he seeks to free his family from crime and find a suitable successor to his empire." rating="6.6" audienceRating="6.7" year="1990" tagline="All the power on earth can't change destiny." thumb="/library/metadata/293776/thumb/1710405033" art="/library/metadata/293776/art/1710405033" duration="10215285" originallyAvailableAt="1990-12-25" addedAt="1704040658" updatedAt="1710405033" audienceRatingImage="rottentomatoes://image.rating.upright" chapterSource="media" primaryExtraKey="/library/metadata/293778" ratingImage="rottentomatoes://image.rating.ripe"> <Media id="359530" duration="10215285" bitrate="15938" width="1912" height="1080" aspectRatio="1.78" audioChannels="6" audioCodec="ac3" videoCodec="h264" videoResolution="1080" container="mkv" videoFrameRate="24p" videoProfile="high"> <Part id="359932" key="/library/parts/359932/1704046025/file.mkv" duration="10215285" file="M:\Media\Movies\The Godfather Part III (1990)\The Godfather Part III (1990) [1080p h.264][AAC AC3 TrueHD]{edition-The Coppola Restoration}.mkv" size="21127533050" container="mkv" videoProfile="high" /> </Media> <Genre tag="Drama" /> <Genre tag="Thriller" /> <Country tag="United States of America" /> <Collection tag="The Godfather" /> <Director tag="Francis Ford Coppola" /> <Writer tag="Francis Ford Coppola" /> <Writer tag="Mario Puzo" /> <Role tag="Al Pacino" /> <Role tag="Diane Keaton" /> <Role tag="Talia Shire" /> </Video> ... </MediaContainer>
The XML returned provides a list of the all movies in a library that are unwatched for the user on the Plex server. The root is the MediaContainer
element. This element contains a few attributes that provide overall information about the movies 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. |
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 library. |
title1 | The title of the library. Note: This appears to be internally created, and can't be changed by the server owner. |
title2 | A descriptive title for the library. |
viewGroup | The group type used to view the library. |
viewMode | Unknown integer value. |
Video library (movies and other videos)
Within the MediaContainer
there are one or more Video
child elements. Each Video
element represents one movie 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. |
slug | The short path name for the video. |
editionTitle | The title of the video edition. |
studio | The name of the video studio. |
type | The type of media. |
title | The title of the video. |
titleSort | The title of the video used to sort the videos in a collection or list. |
contentRating | The content rating associated with the video. |
summary | A summary of the video. |
rating | The rating for the video. |
audienceRating | The audience rating for the video. |
year | The year the video was released. |
tagline | The tagline associated with the video. |
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. |
audienceRatingImage | The image associated with the audience rating. |
chapterSource | The chapter source type. |
primaryExtraKey | The extra key value. |
ratingImage | The image associated with the rating. |
Within the Video
there are one or more Media
child elements. Each Media
element represents one media file of the movie available on the Plex server.
If there are two media files associated with the movie, 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 item. |
duration | The length of the item in milliseconds. |
bitrate | The bitrate of the item. |
width | The width of the item. |
height | The height of the item. |
aspectRatio | The aspect ratio of the item. |
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 item container. |
videoFrameRate | The framerate standard used for the video. |
videoProfile | The video profile of the media. |
Within the Media
there are one or more Part
child elements. Each Part
element represents one part of the movie. If the movie has been added to the Plex server as a multi-part movie, then each of those parts will be represented by one Part
child element.
Attribute | Description |
---|---|
id | Unique ID associated with the part. |
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. |
videoProfile | The video profile associated with the video part. |
Also within the Video
element there are multiple additional child elements that provide more details about the movie. These child elements include Genre
, Director
, Writer
, Country
, Collection
, and Role
.
Within each of these child elements is a single tag
attribute that provides the information for the element. There could be multiple of the same child element within the Video
, such as multiple directors or writers.
Attribute | Description |
---|---|
tag | A genre of the movie. |
Attribute | Description |
---|---|
tag | A director of the movie. |
Attribute | Description |
---|---|
tag | A writer for the movie |
Attribute | Description |
---|---|
tag | A country of origin for the movie. |
Attribute | Description |
---|---|
tag | The name of a collection containing the movie. |
Attribute | Description |
---|---|
tag | The name of a person with a role in the movie. |
Music
For music, the command will return a Directory
element for each album.
Attribute | Description |
---|---|
allowSync | 1 - allow the items in the to be synced. 0 - do not allow the items in the album to be synced. |
librarySectionID | The ID of the library section. |
librarySectionTitle | The name of the library section where the album is located. |
librarySectionUUID | The unique GUID of the library section. |
ratingKey | A key associated with the album. |
key | The relative URL of the information for the album. |
parentRatingKey | A key associated with the parent. |
guid | The unique identifier for the album. |
parentGuid | The unique identifier associated with the parent. |
type | The type of item represented by this Directory element. |
title | The name of the album. |
titleSort | The title used to sort the seasons. |
parentKey | The key associated with the parent. |
parentTitle | The title associated with the parent. |
summary | Information about the album. |
index | Unknown. |
thumb | The thumbnail for the album. |
art | The background artwork used to represent the album. |
parentThumb | The studio associated with the parent. |
leafCount | The number of items in the album. |
viewedLeafCount | The number of the album items that have been viewed. |
Remarks
When using the command ensure that the 'A' in 'recentlyAdded' is in uppercase. A lowercase 'A' will return a 404 status code.
This API command will not return media added to a photo library. It will only return media from a movies, TV shows, music or other videos library.
Examples
curl -X GET http://{ip_address}:32400/library/recentlyAdded?X-Plex-Token={plex_token}
import requests plex_url = http://{ip_address}:32400/library/recentlyAdded?X-Plex-Token={plex_token} response = requests.get(plex_url) print(response.text)
$response = Invoke-RestMethod 'http://{ip_address}:32400/library/recentlyAdded?X-Plex-Token={plex_token}' -Method 'GET' Write-Output $response