Get Recently Added TV Shows

This API command is used to get all recently added TV show episodes to a library.

URL

GET http://{ip_address}:32400/library/sections/{id}/recentlyAdded?X-Plex-Token={plex_token}

Parameters

NameDescription
ip_addressThe IP address of the Plex Media server.
plex_tokenThe Plex token.
idThe key associated with a TV show library. This key can be found by calling the Libraries API command and using the value of the key attribute associated with the TV show library.

Return Status

HTTP CodeDescription
200Success - The request was successful.
401Unauthorized - The Plex token provided was not valid.
404Not Found - The URL path is incorrect. See Remarks below.

Response

XML string value that lists the all the recently added TV shows in the library. An example of the XML returned from the request is shown below:

<?xml version="1.0" encoding="UTF-8"?>
<MediaContainer size="99" allowSync="1" art="/:/resources/show-fanart.jpg" identifier="com.plexapp.plugins.library" librarySectionID="4" librarySectionTitle="TV Shows" librarySectionUUID="3bbbe6f7-628f-4983-ae5d-7c05779c4c28" mediaTagPrefix="/system/bundle/media/flags/" mediaTagVersion="1710434120" mixedParents="1" nocache="1" sortAsc="1" thumb="/:/resources/show.png" title1="TV Shows" title2="Recently Added" viewGroup="episode" viewMode="131133">
    <Video ratingKey="284997" key="/library/metadata/284997" skipParent="1" parentRatingKey="284996" grandparentRatingKey="284995" guid="plex://episode/5ee7425070a20200424dcd66" parentGuid="plex://season/602e7afac96042002d09cdaa" grandparentGuid="plex://show/5ee7425070a20200424dcd49" grandparentSlug="men-in-kilts-a-roadtrip-with-sam-and-graham" type="episode" title="Food and Drink" grandparentKey="/library/metadata/284995" parentKey="/library/metadata/284996" grandparentTitle="Men in Kilts: A Roadtrip with Sam and Graham" parentTitle="Season 1" contentRating="TV-PG" summary="Scotland's cuisine and whisky are renown throughout the world, for different reasons. In this episode, Sam and Graham explore the world's finest whisky and dishes like Haggis." index="1" parentIndex="1" viewCount="1" lastViewedAt="1660701675" thumb="/library/metadata/284997/thumb/1660697962" art="/library/metadata/284995/art/1710311992" parentThumb="/library/metadata/284996/thumb/1660697962" grandparentThumb="/library/metadata/284995/thumb/1710311992" grandparentArt="/library/metadata/284995/art/1710311992" duration="1745792" originallyAvailableAt="2021-02-14" addedAt="1660697959" updatedAt="1660697962">
        <Media id="347530" duration="1745792" bitrate="9847" width="1920" height="1080" aspectRatio="1.78" audioChannels="6" audioCodec="eac3" videoCodec="h264" videoResolution="1080" container="mkv" videoFrameRate="24p" videoProfile="high">
            <Part id="347884" key="/library/parts/347884/1660602452/file.mkv" duration="1745792" file="M:\Media\TV Shows\Men in Kilts - A Roadtrip with Sam and Graham\Season 1\Men.in.Kilts.A.Roadtrip.with.Sam.and.Graham.S01E01.Food.and.Drink.1080p.AMZN.WEB-DL.DDP.5.1.H.264-FLUX[eztv.re].mkv" size="2149536961" container="mkv" videoProfile="high" />
        </Media>
    </Video>
    ...
</MediaContainer>

The XML returned provides a list of the all TV shows in a library have been recently added to the Plex server. The root is the MediaContainer element. This element contains a few attributes that provide overall information about the TV shows on the server.

MediaContainer Attributes
AttributeDescription
sizeThe number of episodes.
allowSync1 - allow syncing content.
0 - don't allow syncing content.
artBackground artwork used to represent the episode.
identifierThe type of item.
librarySectionIDThe unique key associated with the library.
librarySectionTitleThe title of the library.
librarySectionUUIDUnique GUID identifier for the library.
mediaTagPrefixPrefix for the media tag.
mediaTagVersionMedia tag version.
Note: This could be a date and time value.
mixedParentsMedia items returned contain multiple parents.
nocache1 - cache the library.
0 - do not cache the library.
sortAsc1 - the library is sorted in ascending order.
0 - the library is sorted in descending order.
thumbThe thumbnail for the episode.
title1The title of the episode.
Note: This appears to be internally created, and can't be changed by the server owner.
title2A descriptive title for the episode.
viewGroupThe group type used to view the episode.
viewModeUnknown integer value.

Within the MediaContainer there are one or more Video child elements. Each Video element represents one TV show available on the Plex server.

Video Attributes
AttributeDescription
ratingKeyA key associated with the episode.
keyThe relative URL of the episode information.
skipParentFlag indicate how to display the seasons. 0 - show the season.
1 - hide for single-season series.
2 - hide all seasons.
parentRatingKeyThe relative URL of the information for the season.
grandparentRatingKeyThe relative URL of the information for the TV show.
guidThe unique identifier comprised of the Plex agent and episode identifier for the agent.
parentGuidThe GUID for the season.
grandparentGuidThe GUID for the TV show.
grandparentSlugThe short path name for the TV show.
typeThe type of media.
titleThe title of the episode.
grandparentKeyThe unique identifier for the TV show.
parentKeyThe unique identifier for the season.
grandparentTitleThe title of the TV show.
parentTitleThe title of the season.
contentRatingThe content rating associated with the episode.
summaryA summary of the episode.
indexThe index of the episode.
parentIndexThe index of the season.
viewCountThe number of times the episode has been viewed.
lastViewedAtThe date and time for the last time the episode was viewed.
thumbThe thumbnail for the episode.
artThe background artwork used to represent the episode.
parentThumbThe thumbnail for the season.
grandparentThumbThe thumbnail for the TV show.
grandparentArtThe background artwork used to represent the TV show.
durationThe length of the episode in milliseconds.
originallyAvailableAtThe original release date of the episode.
addedAtThe date and time, in Unix time, the episode was added to the library.
updatedAtThe date and time in epoch time, the episode was updated in the library.

Within the Video there are one or more Media child elements. Each Media element represents one media file of the episode available on the Plex server.

If there are two media files associated with the episode, such as a 1080p and 480p version, then there would be two Media child elements in the Video element.

Media Attributes
AttributeDescription
idUnique ID associated with the episode.
durationThe length of the episode in milliseconds.
bitrateThe bitrate of the episode.
widthThe width of the episode.
heightThe height of the episode.
aspectRatioThe aspect ratio of the episode.
audioChannelsThe number of audio channels.
audioCodecThe audio codec used to encode the audio.
videoCodecThe video codec used to encode the video.
videoResolutionThe video resolution.
containerThe episode container.
videoFrameRateThe framerate standard used for the video.
videoProfileThe video profile of the media.

Within the Media there are one or more Part child elements. Each Part element represents one part of the TV show episode.

Part Attributes
AttributeDescription
idUnique ID associated with the part.
keyThe unique relative path for the part that is used at its key.
durationThe length of the part in milliseconds.
fileThe file associated with the part.
sizeThe file size of the part.
containerThe type of media container.
videoProfileThe video profile associated with the video part.

Remarks

When using the command ensure that the 'A' in 'recentlyAdded' is in uppercase. A lowercase 'A' will return a 404 status code.

Examples

curl -X GET http://{ip_address}:32400/library/sections/{id}/recentlyAdded?X-Plex-Token={plex_token}
import requests
plex_url = http://{ip_address}:32400/library/sections/{id}/recentlyAdded?X-Plex-Token={plex_token}
response = requests.get(plex_url)
print(response.text)
$response = Invoke-RestMethod 'http://{ip_address}:32400/library/sections/{id}/recentlyAdded?X-Plex-Token={plex_token}' -Method 'GET'
Write-Output $response
Subscribe
Display