Server
Media
Butler
Plex
Library
- GETGet Hash Value
- GETGet Recently Added
- GETGet All Libraries
- GETGet library details
- DELDelete library section
- GETGet library items
- GETGet all media of library
- GETRefresh Metadata Of The Library
- GETSearch library
- GETGet Genres of library media
- GETGet Countries of library media
- GETGet Actors of library media
- GETSearch All Libraries
- GETGet Media Metadata
- GETGet Items Children
- GETGet Top Watched Content
- GETGet On Deck
Watchlist
Playlists
Authentication
Sessions
Get Media Metadata
This endpoint will return all the (meta)data of a library item specified with by the ratingKey.
declare(strict_types=1);
require 'vendor/autoload.php';
use LukeHagar\Plex_API;
use LukeHagar\Plex_API\Models\Operations;
$sdk = Plex_API\PlexAPI::builder()
->setSecurity(
'<YOUR_API_KEY_HERE>'
)
->build();
$request = new Operations\GetMediaMetaDataRequest(
ratingKey: 9518,
includeConcerts: true,
includeExtras: true,
includeOnDeck: true,
includePopularLeaves: true,
includePreferences: true,
includeReviews: true,
includeChapters: true,
includeStations: true,
includeExternalMedia: true,
asyncAugmentMetadata: true,
asyncCheckFiles: true,
asyncRefreshAnalysis: true,
asyncRefreshLocalMediaAgent: true,
);
$response = $sdk->library->getMediaMetaData(
request: $request
);
if ($response->object !== null) {
// handle response
}
{
"MediaContainer": {
"size": 50,
"allowSync": false,
"identifier": "com.plexapp.plugins.library",
"librarySectionID": 2,
"librarySectionTitle": "TV Series",
"librarySectionUUID": "e69655a2-ef48-4aba-bb19-0cc34d1e7d36",
"mediaTagPrefix": "/system/bundle/media/flags/",
"mediaTagVersion": 1734362201,
"Metadata": [
{
"ratingKey": "44288",
"parentRatingKey": "48047",
"grandparentRatingKey": "45520",
"parentGuid": "plex://season/618b89208dde18df707ad15c",
"grandparentGuid": "plex://show/5e16253691c20300412003a8",
"grandparentSlug": "alice-in-borderland-2020",
"grandparentKey": "/library/metadata/45520",
"parentKey": "/library/metadata/48047",
"key": "/library/metadata/44288/children",
"guid": "plex://show/5d9c08254eefaa001f5d6dcb",
"slug": "better-call-saul",
"studio": "Sony Pictures Television",
"type": "show",
"title": "Better Call Saul",
"originalTitle": "Wicked: Part I",
"librarySectionTitle": "TV Series ",
"librarySectionID": 2,
"librarySectionKey": "/library/sections/2",
"contentRating": "TV-MA",
"summary": "Before Saul Goodman, he was Jimmy McGill. And if you're calling Jimmy, you're in real trouble. The prequel to \"Breaking Bad\" follows small-time attorney, Jimmy McGill, as he transforms into Walter White's morally challenged lawyer, Saul Goodman.",
"index": 1,
"grandparentTitle": "Alice in Borderland",
"parentTitle": "Season 2",
"audienceRating": 8.7,
"viewCount": 4,
"skipCount": 1,
"lastViewedAt": 1625764795,
"year": 2015,
"rating": 6,
"ratingImage": "rottentomatoes://image.rating.ripe",
"tagline": "Make the call",
"chapterSource": "media",
"primaryExtraKey": "/library/metadata/134704",
"thumb": "/library/metadata/44288/thumb/1736487993",
"art": "/library/metadata/44288/art/1736487993",
"theme": "/library/metadata/44288/theme/1736487993",
"duration": 2700000,
"originallyAvailableAt": "2015-02-08",
"leafCount": 63,
"viewedLeafCount": 4,
"childCount": 6,
"addedAt": 1556281940,
"updatedAt": 1556281940,
"audienceRatingImage": "themoviedb://image.rating",
"parentIndex": 2,
"parentThumb": "/library/metadata/48047/thumb/1671800243",
"grandparentThumb": "/library/metadata/45520/thumb/1736488003",
"grandparentArt": "/library/metadata/45520/art/1736488003",
"Media": [
{
"id": 387322,
"duration": 9610350,
"bitrate": 25512,
"width": 3840,
"height": 1602,
"aspectRatio": 2.35,
"audioChannels": 6,
"displayOffset": 50,
"audioCodec": "eac3",
"videoCodec": "hevc",
"videoResolution": "4k",
"container": "mkv",
"videoFrameRate": "24p",
"videoProfile": "main 10",
"hasVoiceActivity": false,
"audioProfile": "dts",
"optimizedForStreaming": 0,
"has64bitOffsets": false,
"Part": [
{
"accessible": true,
"exists": true,
"id": 418385,
"key": "/library/parts/418385/1735864239/file.mkv",
"indexes": "sd",
"duration": 9610350,
"file": "/mnt/Movies_1/W/Wicked (2024).mkv",
"size": 30649952104,
"packetLength": 188,
"container": "mkv",
"videoProfile": "main 10",
"audioProfile": "dts",
"has64bitOffsets": false,
"optimizedForStreaming": 0,
"hasThumbnail": "1",
"Stream": [
{
"id": 1002625,
"streamType": 1,
"default": true,
"codec": "hevc",
"index": 0,
"bitrate": 24743,
"language": "English",
"languageTag": "en",
"languageCode": "eng",
"headerCompression": true,
"DOVIBLCompatID": 1,
"DOVIBLPresent": true,
"DOVIELPresent": false,
"DOVILevel": 6,
"DOVIPresent": true,
"DOVIProfile": 8,
"DOVIRPUPresent": true,
"DOVIVersion": "1.0",
"bitDepth": 10,
"chromaLocation": "topleft",
"chromaSubsampling": "4:2:0",
"codedHeight": 1608,
"codedWidth": 3840,
"colorPrimaries": "bt2020",
"colorRange": "tv",
"colorSpace": "bt2020nc",
"colorTrc": "smpte2084",
"frameRate": 23.976,
"height": 1602,
"level": 150,
"original": true,
"hasScalingMatrix": false,
"profile": "main 10",
"scanType": "progressive",
"refFrames": 1,
"width": 3840,
"displayTitle": "4K DoVi/HDR10 (HEVC Main 10)",
"extendedDisplayTitle": "4K DoVi/HDR10 (HEVC Main 10)",
"selected": true,
"forced": true,
"channels": 6,
"audioChannelLayout": "5.1(side)",
"samplingRate": 48000,
"canAutoSync": false,
"hearingImpaired": true,
"dub": true,
"title": "SDH"
}
]
}
]
}
],
"Image": [
{
"alt": "Better Call Saul",
"type": "coverPoster",
"url": "/library/metadata/44288/thumb/1736487993"
}
],
"UltraBlurColors": {
"topLeft": "11333a",
"topRight": "1d2721",
"bottomRight": "5c451d",
"bottomLeft": "372c10"
},
"Genre": [
{
"id": 1057,
"filter": "genre=1057",
"tag": "Crime"
}
],
"Country": [
{
"id": 58591,
"filter": "country=58591",
"tag": "United States of America"
}
],
"Guid": [
{
"id": "imdb://tt3032476"
}
],
"Rating": [
{
"image": "imdb://image.rating",
"value": 9,
"type": "audience"
}
],
"Role": [
{
"id": 109501,
"filter": "actor=109501",
"tag": "Bob Odenkirk",
"tagKey": "5d77683254f42c001f8c3f69",
"role": "Jimmy McGill",
"thumb": "https://metadata-static.plex.tv/f/people/f2ca7b474cc984efbdd5c503a096285a.jpg"
}
],
"Director": [
{
"id": 109501,
"filter": "actor=109501",
"tag": "Bob Odenkirk",
"tagKey": "5d77683254f42c001f8c3f69",
"role": "Jimmy McGill",
"thumb": "https://metadata-static.plex.tv/f/people/f2ca7b474cc984efbdd5c503a096285a.jpg"
}
],
"Writer": [
{
"id": 109501,
"filter": "actor=109501",
"tag": "Bob Odenkirk",
"tagKey": "5d77683254f42c001f8c3f69",
"role": "Jimmy McGill",
"thumb": "https://metadata-static.plex.tv/f/people/f2ca7b474cc984efbdd5c503a096285a.jpg"
}
],
"Producer": [
{
"id": 109501,
"filter": "actor=109501",
"tag": "Bob Odenkirk",
"tagKey": "5d77683254f42c001f8c3f69",
"role": "Jimmy McGill",
"thumb": "https://metadata-static.plex.tv/f/people/f2ca7b474cc984efbdd5c503a096285a.jpg"
}
],
"Similar": [
{
"id": 26,
"filter": "similar=26",
"tag": "Breaking Bad"
}
],
"Location": [
{
"path": "/TV Shows/Better Call Saul"
}
]
}
]
}
}
Authorizations
Plex Authentication Token
Path Parameters
the id of the library item to return the children of.
9518
Query Parameters
Include concerts data if set to true.
true
Include extra content (e.g. bonus features).
true
Include on-deck items.
true
Include popular leaves (episodes/chapters).
true
Include preferences information.
true
Include reviews for the content.
true
Include chapter details.
true
Include station data.
true
Include external media data.
true
Trigger asynchronous metadata augmentation.
true
Trigger asynchronous file checking.
true
Trigger asynchronous refresh of analysis.
true
Trigger asynchronous refresh of the local media agent.
true
Response
Number of media items returned in this response.
50
Indicates whether syncing is allowed.
false
An plugin identifier for the media container.
"com.plexapp.plugins.library"
The unique identifier for the library section.
2
The title of the library section.
"TV Series"
The prefix used for media tag resource paths.
"/system/bundle/media/flags/"
The version number for media tags.
1734362201
An array of metadata items.
The rating key of the metadata item.
"44288"
The API key to access metadata details.
"/library/metadata/44288/children"
The globally unique identifier for the item.
"plex://show/5d9c08254eefaa001f5d6dcb"
The type of content (e.g., show, movie).
"show"
The title of the content.
"Better Call Saul"
The title of the library section.
"TV Series "
The ID of the library section.
2
The key of the library section.
"/library/sections/2"
A summary of the content.
"Before Saul Goodman, he was Jimmy McGill. And if you're calling Jimmy, you're in real trouble. The prequel to \"Breaking Bad\" follows small-time attorney, Jimmy McGill, as he transforms into Walter White's morally challenged lawyer, Saul Goodman."
The release year.
2015
URL of the thumbnail image.
"/library/metadata/44288/thumb/1736487993"
URL of the art image.
"/library/metadata/44288/art/1736487993"
Duration of the content in milliseconds.
2700000
Unix timestamp when the item was added.
1556281940
Unix timestamp when the item was last updated.
1556281940
An array of image objects.
Alternate text for the image.
"Better Call Saul"
The type of image (e.g., coverPoster, background, clearLogo).
"coverPoster"
The URL of the image.
"/library/metadata/44288/thumb/1736487993"
The top-left color value.
"11333a"
The top-right color value.
"1d2721"
The bottom-right color value.
"5c451d"
The bottom-left color value.
"372c10"
The rating key of the parent of this metadata item.
"48047"
The rating key of the grandparent of this metadata item.
"45520"
A GUID identifying the parent entity (e.g., season) for the item.
"plex://season/618b89208dde18df707ad15c"
A GUID identifying the grandparent entity (e.g., show).
"plex://show/5e16253691c20300412003a8"
A URL-friendly identifier (slug) for the grandparent entity.
"alice-in-borderland-2020"
A key identifying the grandparent metadata in the library.
"/library/metadata/45520"
A key identifying the parent metadata in the library.
"/library/metadata/48047"
A URL-friendly identifier for the item.
"better-call-saul"
The studio that produced the content.
"Sony Pictures Television"
The original title of the content.
"Wicked: Part I"
The content rating (e.g., TV-MA).
"TV-MA"
The index or order of the item.
1
The title of the grandparent entity (typically the show's title).
"Alice in Borderland"
The title of the parent entity (typically the season's title).
"Season 2"
The audience rating for the content.
8.7
The number of times the item has been viewed.
4
The number of times the item has been skipped.
1
Unix timestamp of when the item was last viewed.
1625764795
The general rating
6
The URL or identifier for the rating image (e.g., Rotten Tomatoes rating image).
"rottentomatoes://image.rating.ripe"
The tagline of the content.
"Make the call"
"media"
"/library/metadata/134704"
URL of the theme image.
"/library/metadata/44288/theme/1736487993"
The original release date.
"2015-02-08"
The total number of episodes (or leaves).
63
The number of episodes that have been viewed.
4
The number of child items.
6
The URL for the audience rating image.
"themoviedb://image.rating"
The index number of the parent entity, which could indicate its order or position.
2
The URL of the parent's thumbnail image.
"/library/metadata/48047/thumb/1671800243"
The URL of the grandparent's thumbnail image.
"/library/metadata/45520/thumb/1736488003"
The URL of the grandparent's art image.
"/library/metadata/45520/art/1736488003"
An array of media file data items.
Unique media identifier.
387322
Indicates whether voice activity is detected.
false
An array of parts for this media item.
Unique part identifier.
418385
Key to access this part.
"/library/parts/418385/1735864239/file.mkv"
File path for the part.
"/mnt/Movies_1/W/Wicked (2024).mkv"
File size in bytes.
30649952104
Indicates if the part is accessible.
true
Indicates if the part exists.
true
"sd"
Duration of the part in milliseconds.
9610350
188
Container format of the part.
"mkv"
Video profile for the part.
"main 10"
The audio profile used for the media (e.g., DTS, Dolby Digital, etc.).
"dts"
false
Has this media been optimized for streaming. NOTE: This can be 0, 1, false or true
0
, 1
Indicates if the part has a thumbnail.
0
, 1
"1"
An array of streams for this part.
Duration of the media in milliseconds.
9610350
Bitrate in bits per second.
25512
Video width in pixels.
3840
Video height in pixels.
1602
Aspect ratio of the video.
2.35
Number of audio channels.
6
50
Audio codec used.
"eac3"
Video codec used.
"hevc"
Video resolution (e.g., 4k).
"4k"
File container type.
"mkv"
Frame rate of the video. Values found include NTSC, PAL, 24p
"24p"
Video profile (e.g., main 10).
"main 10"
The audio profile used for the media (e.g., DTS, Dolby Digital, etc.).
"dts"
Has this media been optimized for streaming. NOTE: This can be 0, 1, false or true
0
, 1
false
An array of country tags.
The unique country identifier.
58591
The filter string for the country.
"country=58591"
The country name.
"United States of America"
An array of GUID objects.
The GUID value.
"imdb://tt3032476"
An array of rating objects.
The image or reference for the rating.
"imdb://image.rating"
The rating value.
9
The type of rating (e.g., audience, critic).
"audience"
An array of Actor roles.
The unique role identifier.
109501
The filter string for the role.
"actor=109501"
The actor's name.
"Bob Odenkirk"
A key associated with the actor tag.
"5d77683254f42c001f8c3f69"
The character name or role.
"Jimmy McGill"
URL for the role thumbnail image.
"https://metadata-static.plex.tv/f/people/f2ca7b474cc984efbdd5c503a096285a.jpg"
An array of Director roles.
The unique role identifier.
109501
The filter string for the role.
"actor=109501"
The actor's name.
"Bob Odenkirk"
A key associated with the actor tag.
"5d77683254f42c001f8c3f69"
The character name or role.
"Jimmy McGill"
URL for the role thumbnail image.
"https://metadata-static.plex.tv/f/people/f2ca7b474cc984efbdd5c503a096285a.jpg"
An array of Writer roles.
The unique role identifier.
109501
The filter string for the role.
"actor=109501"
The actor's name.
"Bob Odenkirk"
A key associated with the actor tag.
"5d77683254f42c001f8c3f69"
The character name or role.
"Jimmy McGill"
URL for the role thumbnail image.
"https://metadata-static.plex.tv/f/people/f2ca7b474cc984efbdd5c503a096285a.jpg"
An array of Writer roles.
The unique role identifier.
109501
The filter string for the role.
"actor=109501"
The actor's name.
"Bob Odenkirk"
A key associated with the actor tag.
"5d77683254f42c001f8c3f69"
The character name or role.
"Jimmy McGill"
URL for the role thumbnail image.
"https://metadata-static.plex.tv/f/people/f2ca7b474cc984efbdd5c503a096285a.jpg"
An array of similar content objects.
The unique similar item identifier.
26
The filter string for similar items.
"similar=26"
The tag or title of the similar content.
"Breaking Bad"
The universally unique identifier for the library section.
"e69655a2-ef48-4aba-bb19-0cc34d1e7d36"
declare(strict_types=1);
require 'vendor/autoload.php';
use LukeHagar\Plex_API;
use LukeHagar\Plex_API\Models\Operations;
$sdk = Plex_API\PlexAPI::builder()
->setSecurity(
'<YOUR_API_KEY_HERE>'
)
->build();
$request = new Operations\GetMediaMetaDataRequest(
ratingKey: 9518,
includeConcerts: true,
includeExtras: true,
includeOnDeck: true,
includePopularLeaves: true,
includePreferences: true,
includeReviews: true,
includeChapters: true,
includeStations: true,
includeExternalMedia: true,
asyncAugmentMetadata: true,
asyncCheckFiles: true,
asyncRefreshAnalysis: true,
asyncRefreshLocalMediaAgent: true,
);
$response = $sdk->library->getMediaMetaData(
request: $request
);
if ($response->object !== null) {
// handle response
}
{
"MediaContainer": {
"size": 50,
"allowSync": false,
"identifier": "com.plexapp.plugins.library",
"librarySectionID": 2,
"librarySectionTitle": "TV Series",
"librarySectionUUID": "e69655a2-ef48-4aba-bb19-0cc34d1e7d36",
"mediaTagPrefix": "/system/bundle/media/flags/",
"mediaTagVersion": 1734362201,
"Metadata": [
{
"ratingKey": "44288",
"parentRatingKey": "48047",
"grandparentRatingKey": "45520",
"parentGuid": "plex://season/618b89208dde18df707ad15c",
"grandparentGuid": "plex://show/5e16253691c20300412003a8",
"grandparentSlug": "alice-in-borderland-2020",
"grandparentKey": "/library/metadata/45520",
"parentKey": "/library/metadata/48047",
"key": "/library/metadata/44288/children",
"guid": "plex://show/5d9c08254eefaa001f5d6dcb",
"slug": "better-call-saul",
"studio": "Sony Pictures Television",
"type": "show",
"title": "Better Call Saul",
"originalTitle": "Wicked: Part I",
"librarySectionTitle": "TV Series ",
"librarySectionID": 2,
"librarySectionKey": "/library/sections/2",
"contentRating": "TV-MA",
"summary": "Before Saul Goodman, he was Jimmy McGill. And if you're calling Jimmy, you're in real trouble. The prequel to \"Breaking Bad\" follows small-time attorney, Jimmy McGill, as he transforms into Walter White's morally challenged lawyer, Saul Goodman.",
"index": 1,
"grandparentTitle": "Alice in Borderland",
"parentTitle": "Season 2",
"audienceRating": 8.7,
"viewCount": 4,
"skipCount": 1,
"lastViewedAt": 1625764795,
"year": 2015,
"rating": 6,
"ratingImage": "rottentomatoes://image.rating.ripe",
"tagline": "Make the call",
"chapterSource": "media",
"primaryExtraKey": "/library/metadata/134704",
"thumb": "/library/metadata/44288/thumb/1736487993",
"art": "/library/metadata/44288/art/1736487993",
"theme": "/library/metadata/44288/theme/1736487993",
"duration": 2700000,
"originallyAvailableAt": "2015-02-08",
"leafCount": 63,
"viewedLeafCount": 4,
"childCount": 6,
"addedAt": 1556281940,
"updatedAt": 1556281940,
"audienceRatingImage": "themoviedb://image.rating",
"parentIndex": 2,
"parentThumb": "/library/metadata/48047/thumb/1671800243",
"grandparentThumb": "/library/metadata/45520/thumb/1736488003",
"grandparentArt": "/library/metadata/45520/art/1736488003",
"Media": [
{
"id": 387322,
"duration": 9610350,
"bitrate": 25512,
"width": 3840,
"height": 1602,
"aspectRatio": 2.35,
"audioChannels": 6,
"displayOffset": 50,
"audioCodec": "eac3",
"videoCodec": "hevc",
"videoResolution": "4k",
"container": "mkv",
"videoFrameRate": "24p",
"videoProfile": "main 10",
"hasVoiceActivity": false,
"audioProfile": "dts",
"optimizedForStreaming": 0,
"has64bitOffsets": false,
"Part": [
{
"accessible": true,
"exists": true,
"id": 418385,
"key": "/library/parts/418385/1735864239/file.mkv",
"indexes": "sd",
"duration": 9610350,
"file": "/mnt/Movies_1/W/Wicked (2024).mkv",
"size": 30649952104,
"packetLength": 188,
"container": "mkv",
"videoProfile": "main 10",
"audioProfile": "dts",
"has64bitOffsets": false,
"optimizedForStreaming": 0,
"hasThumbnail": "1",
"Stream": [
{
"id": 1002625,
"streamType": 1,
"default": true,
"codec": "hevc",
"index": 0,
"bitrate": 24743,
"language": "English",
"languageTag": "en",
"languageCode": "eng",
"headerCompression": true,
"DOVIBLCompatID": 1,
"DOVIBLPresent": true,
"DOVIELPresent": false,
"DOVILevel": 6,
"DOVIPresent": true,
"DOVIProfile": 8,
"DOVIRPUPresent": true,
"DOVIVersion": "1.0",
"bitDepth": 10,
"chromaLocation": "topleft",
"chromaSubsampling": "4:2:0",
"codedHeight": 1608,
"codedWidth": 3840,
"colorPrimaries": "bt2020",
"colorRange": "tv",
"colorSpace": "bt2020nc",
"colorTrc": "smpte2084",
"frameRate": 23.976,
"height": 1602,
"level": 150,
"original": true,
"hasScalingMatrix": false,
"profile": "main 10",
"scanType": "progressive",
"refFrames": 1,
"width": 3840,
"displayTitle": "4K DoVi/HDR10 (HEVC Main 10)",
"extendedDisplayTitle": "4K DoVi/HDR10 (HEVC Main 10)",
"selected": true,
"forced": true,
"channels": 6,
"audioChannelLayout": "5.1(side)",
"samplingRate": 48000,
"canAutoSync": false,
"hearingImpaired": true,
"dub": true,
"title": "SDH"
}
]
}
]
}
],
"Image": [
{
"alt": "Better Call Saul",
"type": "coverPoster",
"url": "/library/metadata/44288/thumb/1736487993"
}
],
"UltraBlurColors": {
"topLeft": "11333a",
"topRight": "1d2721",
"bottomRight": "5c451d",
"bottomLeft": "372c10"
},
"Genre": [
{
"id": 1057,
"filter": "genre=1057",
"tag": "Crime"
}
],
"Country": [
{
"id": 58591,
"filter": "country=58591",
"tag": "United States of America"
}
],
"Guid": [
{
"id": "imdb://tt3032476"
}
],
"Rating": [
{
"image": "imdb://image.rating",
"value": 9,
"type": "audience"
}
],
"Role": [
{
"id": 109501,
"filter": "actor=109501",
"tag": "Bob Odenkirk",
"tagKey": "5d77683254f42c001f8c3f69",
"role": "Jimmy McGill",
"thumb": "https://metadata-static.plex.tv/f/people/f2ca7b474cc984efbdd5c503a096285a.jpg"
}
],
"Director": [
{
"id": 109501,
"filter": "actor=109501",
"tag": "Bob Odenkirk",
"tagKey": "5d77683254f42c001f8c3f69",
"role": "Jimmy McGill",
"thumb": "https://metadata-static.plex.tv/f/people/f2ca7b474cc984efbdd5c503a096285a.jpg"
}
],
"Writer": [
{
"id": 109501,
"filter": "actor=109501",
"tag": "Bob Odenkirk",
"tagKey": "5d77683254f42c001f8c3f69",
"role": "Jimmy McGill",
"thumb": "https://metadata-static.plex.tv/f/people/f2ca7b474cc984efbdd5c503a096285a.jpg"
}
],
"Producer": [
{
"id": 109501,
"filter": "actor=109501",
"tag": "Bob Odenkirk",
"tagKey": "5d77683254f42c001f8c3f69",
"role": "Jimmy McGill",
"thumb": "https://metadata-static.plex.tv/f/people/f2ca7b474cc984efbdd5c503a096285a.jpg"
}
],
"Similar": [
{
"id": 26,
"filter": "similar=26",
"tag": "Breaking Bad"
}
],
"Location": [
{
"path": "/TV Shows/Better Call Saul"
}
]
}
]
}
}