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 all media of library
Retrieves a list of all general media data for this library.
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\GetAllMediaLibraryRequest(
sectionKey: 9518,
type: Operations\GetAllMediaLibraryQueryParamType::TvShow,
);
$response = $sdk->library->getAllMediaLibrary(
request: $request
);
if ($response->object !== null) {
// handle response
}
{
"MediaContainer": {
"size": 50,
"totalSize": 50,
"offset": 0,
"allowSync": false,
"art": "/:/resources/show-fanart.jpg",
"content": "secondary",
"identifier": "com.plexapp.plugins.library",
"librarySectionID": 2,
"librarySectionTitle": "TV Series",
"librarySectionUUID": "e69655a2-ef48-4aba-bb19-0cc34d1e7d36",
"mediaTagPrefix": "/system/bundle/media/flags/",
"mediaTagVersion": 1734362201,
"thumb": "/:/resources/show.png",
"nocache": true,
"title1": "TV Series",
"title2": "By Starring Actor",
"viewGroup": "secondary",
"Meta": {
"Type": [
{
"key": "/library/sections/2/all?type=2",
"type": "filter",
"subtype": "clip",
"title": "TV Shows",
"active": false,
"Filter": [
{
"filter": "genre",
"filterType": "string",
"key": "/library/sections/2/genre?type=2",
"title": "Genre",
"type": "filter",
"advanced": true
}
],
"Sort": [
{
"default": "asc",
"active": false,
"activeDirection": "asc",
"defaultDirection": "asc",
"descKey": "titleSort:desc",
"firstCharacterKey": "/library/sections/2/firstCharacter",
"key": "titleSort",
"title": "Title"
}
],
"Field": [
{
"key": "show.title",
"title": "Show Title",
"type": "string",
"subType": "rating"
}
]
}
],
"FieldType": [
{
"type": "tag",
"Operator": [
{
"key": "=",
"title": "is"
}
]
}
]
},
"Metadata": [
{
"ratingKey": "58683",
"key": "/library/metadata/58683",
"guid": "plex://movie/5d7768ba96b655001fdc0408",
"slug": "4-for-texas",
"studio": "20th Century Studios",
"type": "movie",
"title": "Avatar: The Way of Water",
"titleSort": "Whale",
"contentRating": "PG-13",
"summary": "Jake Sully lives with his newfound family formed on the extrasolar moon Pandora.\nOnce a familiar threat returns to finish what was previously started, Jake must\nwork with Neytiri and the army of the Na'vi race to protect their home.\n",
"rating": 7.6,
"audienceRating": 9.2,
"year": 2022,
"tagline": "Return to Pandora.",
"thumb": "/library/metadata/58683/thumb/1703239236",
"art": "/library/metadata/58683/art/1703239236",
"theme": "/library/metadata/1/theme/1705636920",
"index": 1,
"leafCount": 14,
"viewedLeafCount": 0,
"childCount": 1,
"seasonCount": 2022,
"duration": 11558112,
"originallyAvailableAt": "2022-12-14",
"addedAt": 1556281940,
"updatedAt": 1556281940,
"audienceRatingImage": "rottentomatoes://image.rating.upright",
"chapterSource": "media",
"primaryExtraKey": "/library/metadata/58684",
"originalTitle": "映画 ブラッククローバー 魔法帝の剣",
"parentRatingKey": "66",
"grandparentRatingKey": "66",
"parentGuid": "plex://show/5d9c081b170e24001f2a7be4",
"grandparentGuid": "plex://show/5d9c081b170e24001f2a7be4",
"grandparentSlug": "alice-in-borderland-2020",
"grandparentKey": "/library/metadata/66",
"parentKey": "/library/metadata/66",
"grandparentTitle": "Caprica",
"grandparentThumb": "/library/metadata/66/thumb/1705716261",
"grandparentTheme": "/library/metadata/66/theme/1705716261",
"grandparentArt": "/library/metadata/66/art/1705716261",
"parentTitle": "Caprica",
"parentIndex": 1,
"parentThumb": "/library/metadata/66/thumb/1705716261",
"ratingImage": "rottentomatoes://image.rating.ripe",
"viewCount": 1,
"viewOffset": 5222500,
"skipCount": 1,
"subtype": "clip",
"lastRatedAt": 1721813113,
"createdAtAccuracy": "epoch,local",
"createdAtTZOffset": "0",
"lastViewedAt": 1682752242,
"userRating": 10,
"Image": [
{
"alt": "Episode 1",
"type": "background",
"url": "/library/metadata/45521/thumb/1644710589"
}
],
"UltraBlurColors": {
"topLeft": "11333b",
"topRight": "0a232d",
"bottomRight": 73958,
"bottomLeft": "1f5066"
},
"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"
}
]
}
]
}
],
"Genre": [
{
"tag": "United States of America"
}
],
"Country": [
{
"tag": "United States of America"
}
],
"Director": [
{
"tag": "Danny Boyle"
}
],
"Writer": [
{
"tag": "Danny Boyle"
}
],
"Role": [
{
"tag": "Danny Boyle"
}
],
"Guid": [
{
"id": "tvdb://2337"
}
],
"Collection": [
{
"tag": "My Awesome Collection"
}
]
}
]
}
}
Authorizations
Plex Authentication Token
Headers
application/json
, application/xml
"application/json"
Path Parameters
The unique key of the Plex library. Note: This is unique in the context of the Plex server.
9518
Query Parameters
The type of media to retrieve or filter by. 1 = movie 2 = show 3 = season 4 = episode E.g. A movie library will not return anything with type 3 as there are no seasons for movie libraries
1
, 2
, 3
, 4
, 8
, 9
, 10
2
Adds the Meta object to the response
0
, 1
1
Adds the Guid object to the response
0
, 1
1
0
, 1
1
0
, 1
1
0
, 1
1
The index of the first item to return. If not specified, the first item will be returned. If the number of items exceeds the limit, the response will be paginated. By default this is 0
0
The number of items to return. If not specified, all items will be returned. If the number of items exceeds the limit, the response will be paginated. By default this is 50
50
Response
Number of media items returned in this response.
50
Total number of media items in the library.
50
Offset value for pagination.
0
Indicates whether syncing is allowed.
false
URL for the background artwork of the media container.
"/:/resources/show-fanart.jpg"
The content type or mode.
"secondary"
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
URL for the thumbnail image of the media container.
"/:/resources/show.png"
Specifies whether caching is disabled.
true
The primary title of the media container.
"TV Series"
The secondary title of the media container.
"By Starring Actor"
Identifier for the view group layout.
"secondary"
The universally unique identifier for the library section.
"e69655a2-ef48-4aba-bb19-0cc34d1e7d36"
The Meta object is only included in the response if the includeMeta
parameter is set to 1
.
"/library/sections/2/all?type=2"
"filter"
"TV Shows"
false
"clip"
"genre"
"string"
"/library/sections/2/genre?type=2"
"Genre"
"filter"
true
The direction of the sort. Can be either asc
or desc
.
asc
, desc
"asc"
"titleSort"
"Title"
"asc"
false
The direction of the sort. Can be either asc
or desc
.
asc
, desc
"asc"
"titleSort:desc"
"/library/sections/2/firstCharacter"
An array of metadata items.
Unknown
The rating key (Media ID) of this media item. Note: Although this is always an integer, it is represented as a string in the API.
"58683"
The unique key for the media item.
"/library/metadata/58683"
The globally unique identifier for the media item.
"plex://movie/5d7768ba96b655001fdc0408"
A URL‐friendly version of the media title.
"4-for-texas"
The type of media content
movie
, show
, season
, episode
, artist
, album
"movie"
The title of the media item.
"Avatar: The Way of Water"
The sort title used for ordering media items.
"Whale"
A synopsis of the media item.
"Jake Sully lives with his newfound family formed on the extrasolar moon Pandora.\nOnce a familiar threat returns to finish what was previously started, Jake must\nwork with Neytiri and the army of the Na'vi race to protect their home.\n"
The critic rating for the media item.
7.6
The audience rating for the media item.
9.2
The release year of the media item.
2022
A brief tagline for the media item.
"Return to Pandora."
The thumbnail image URL for the media item.
"/library/metadata/58683/thumb/1703239236"
The art image URL for the media item.
"/library/metadata/58683/art/1703239236"
The theme URL for the media item.
"/library/metadata/1/theme/1705636920"
The index position of the media item.
1
The number of child items associated with this media item.
1
The total number of seasons (for TV shows).
2022
The duration of the media item in milliseconds.
11558112
The original release date of the media item.
"2022-12-14"
Unix timestamp when the item was added.
1556281940
The studio that produced the media item.
"20th Century Studios"
The content rating for the media item.
"PG-13"
The number of leaf items (end nodes) under this media item.
14
The number of leaf items that have been viewed.
0
Unix epoch datetime in seconds
1556281940
The URL for the audience rating image.
"rottentomatoes://image.rating.upright"
The source from which chapter data is derived.
"media"
The primary extra key associated with this media item.
"/library/metadata/58684"
The original title of the media item (if different).
"映画 ブラッククローバー 魔法帝の剣"
The rating key of the parent media item.
"66"
The rating key of the grandparent media item.
"66"
The GUID of the parent media item.
"plex://show/5d9c081b170e24001f2a7be4"
The GUID of the grandparent media item.
"plex://show/5d9c081b170e24001f2a7be4"
The slug for the grandparent media item.
"alice-in-borderland-2020"
The key of the grandparent media item.
"/library/metadata/66"
The key of the parent media item.
"/library/metadata/66"
The title of the grandparent media item.
"Caprica"
The thumbnail URL for the grandparent media item.
"/library/metadata/66/thumb/1705716261"
The theme URL for the grandparent media item.
"/library/metadata/66/theme/1705716261"
The art URL for the grandparent media item.
"/library/metadata/66/art/1705716261"
The title of the parent media item.
"Caprica"
The index position of the parent media item.
1
The thumbnail URL for the parent media item.
"/library/metadata/66/thumb/1705716261"
The URL for the rating image.
"rottentomatoes://image.rating.ripe"
The number of times this media item has been viewed.
1
The current playback offset (in milliseconds).
5222500
The number of times this media item has been skipped.
1
A classification that further describes the type of media item. For example, 'clip' indicates that the item is a short video clip.
"clip"
The Unix timestamp representing the last time the item was rated.
1721813113
The accuracy of the creation timestamp. This value indicates the format(s) provided (for example, 'epoch,local' means both epoch and local time formats are available).
"epoch,local"
The time zone offset for the creation timestamp, represented as a string. This offset indicates the difference from UTC.
"0"
Unix timestamp for when the media item was last viewed.
1682752242
The rating provided by a user for the item. This value is expressed as a decimal number.
10
"Episode 1"
coverPoster
, background
, snapshot
, clearLogo
"background"
"/library/metadata/45521/thumb/1644710589"
"11333b"
"0a232d"
73958
"1f5066"
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
The country of origin of this media item
"United States of America"
The country of origin of this media item
"United States of America"
The role of Director
"Danny Boyle"
The role of Writer
"Danny Boyle"
The name of the actor for this role
"Danny Boyle"
The unique identifier for the Guid. Can be imdb://tt0286347, tmdb://1763, tvdb://2337
"tvdb://2337"
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\GetAllMediaLibraryRequest(
sectionKey: 9518,
type: Operations\GetAllMediaLibraryQueryParamType::TvShow,
);
$response = $sdk->library->getAllMediaLibrary(
request: $request
);
if ($response->object !== null) {
// handle response
}
{
"MediaContainer": {
"size": 50,
"totalSize": 50,
"offset": 0,
"allowSync": false,
"art": "/:/resources/show-fanart.jpg",
"content": "secondary",
"identifier": "com.plexapp.plugins.library",
"librarySectionID": 2,
"librarySectionTitle": "TV Series",
"librarySectionUUID": "e69655a2-ef48-4aba-bb19-0cc34d1e7d36",
"mediaTagPrefix": "/system/bundle/media/flags/",
"mediaTagVersion": 1734362201,
"thumb": "/:/resources/show.png",
"nocache": true,
"title1": "TV Series",
"title2": "By Starring Actor",
"viewGroup": "secondary",
"Meta": {
"Type": [
{
"key": "/library/sections/2/all?type=2",
"type": "filter",
"subtype": "clip",
"title": "TV Shows",
"active": false,
"Filter": [
{
"filter": "genre",
"filterType": "string",
"key": "/library/sections/2/genre?type=2",
"title": "Genre",
"type": "filter",
"advanced": true
}
],
"Sort": [
{
"default": "asc",
"active": false,
"activeDirection": "asc",
"defaultDirection": "asc",
"descKey": "titleSort:desc",
"firstCharacterKey": "/library/sections/2/firstCharacter",
"key": "titleSort",
"title": "Title"
}
],
"Field": [
{
"key": "show.title",
"title": "Show Title",
"type": "string",
"subType": "rating"
}
]
}
],
"FieldType": [
{
"type": "tag",
"Operator": [
{
"key": "=",
"title": "is"
}
]
}
]
},
"Metadata": [
{
"ratingKey": "58683",
"key": "/library/metadata/58683",
"guid": "plex://movie/5d7768ba96b655001fdc0408",
"slug": "4-for-texas",
"studio": "20th Century Studios",
"type": "movie",
"title": "Avatar: The Way of Water",
"titleSort": "Whale",
"contentRating": "PG-13",
"summary": "Jake Sully lives with his newfound family formed on the extrasolar moon Pandora.\nOnce a familiar threat returns to finish what was previously started, Jake must\nwork with Neytiri and the army of the Na'vi race to protect their home.\n",
"rating": 7.6,
"audienceRating": 9.2,
"year": 2022,
"tagline": "Return to Pandora.",
"thumb": "/library/metadata/58683/thumb/1703239236",
"art": "/library/metadata/58683/art/1703239236",
"theme": "/library/metadata/1/theme/1705636920",
"index": 1,
"leafCount": 14,
"viewedLeafCount": 0,
"childCount": 1,
"seasonCount": 2022,
"duration": 11558112,
"originallyAvailableAt": "2022-12-14",
"addedAt": 1556281940,
"updatedAt": 1556281940,
"audienceRatingImage": "rottentomatoes://image.rating.upright",
"chapterSource": "media",
"primaryExtraKey": "/library/metadata/58684",
"originalTitle": "映画 ブラッククローバー 魔法帝の剣",
"parentRatingKey": "66",
"grandparentRatingKey": "66",
"parentGuid": "plex://show/5d9c081b170e24001f2a7be4",
"grandparentGuid": "plex://show/5d9c081b170e24001f2a7be4",
"grandparentSlug": "alice-in-borderland-2020",
"grandparentKey": "/library/metadata/66",
"parentKey": "/library/metadata/66",
"grandparentTitle": "Caprica",
"grandparentThumb": "/library/metadata/66/thumb/1705716261",
"grandparentTheme": "/library/metadata/66/theme/1705716261",
"grandparentArt": "/library/metadata/66/art/1705716261",
"parentTitle": "Caprica",
"parentIndex": 1,
"parentThumb": "/library/metadata/66/thumb/1705716261",
"ratingImage": "rottentomatoes://image.rating.ripe",
"viewCount": 1,
"viewOffset": 5222500,
"skipCount": 1,
"subtype": "clip",
"lastRatedAt": 1721813113,
"createdAtAccuracy": "epoch,local",
"createdAtTZOffset": "0",
"lastViewedAt": 1682752242,
"userRating": 10,
"Image": [
{
"alt": "Episode 1",
"type": "background",
"url": "/library/metadata/45521/thumb/1644710589"
}
],
"UltraBlurColors": {
"topLeft": "11333b",
"topRight": "0a232d",
"bottomRight": 73958,
"bottomLeft": "1f5066"
},
"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"
}
]
}
]
}
],
"Genre": [
{
"tag": "United States of America"
}
],
"Country": [
{
"tag": "United States of America"
}
],
"Director": [
{
"tag": "Danny Boyle"
}
],
"Writer": [
{
"tag": "Danny Boyle"
}
],
"Role": [
{
"tag": "Danny Boyle"
}
],
"Guid": [
{
"id": "tvdb://2337"
}
],
"Collection": [
{
"tag": "My Awesome Collection"
}
]
}
]
}
}