Get All Tracks for a Music Album
Each music album on Plex can have one or more tracks associated with it. This API command will return information about all the tracks, including the full path to the file.
URL
GET http://{ip_address}:32400/library/metadata/{id}/children?X-Plex-Token={plex_token}&includeGuids={include_guids}
Parameters
Name | Description |
---|---|
ip_address | The IP address of the Plex Media server. |
plex_token | The Plex token. |
id | The key associated with a music album. This key can be found by calling the Get All Music Albums for an Artist API command and using the ratingKey attribute for the album. |
include_guids | (Optional) Returns the GUID values of the online metadata services associated to the media item. |
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 all the tracks for the album specified in the request. An example of the XML returned from the request is shown below:
<?xml version="1.0" encoding="UTF-8"?> <MediaContainer size="19" allowSync="1" art="/library/metadata/218548/art/1686115671" grandparentRatingKey="218548" grandparentThumb="/library/metadata/218548/thumb/1686115671" grandparentTitle="ABBA" identifier="com.plexapp.plugins.library" key="218549" librarySectionID="8" librarySectionTitle="Music" librarySectionUUID="b6031749-2969-4027-afee-64172b72b77d" mediaTagPrefix="/system/bundle/media/flags/" mediaTagVersion="1682076900" nocache="1" parentIndex="1" parentTitle="Gold: Greatest Hits" parentYear="1992" sortAsc="1" summary="ABBA's 19-song Gold collection was the first hits compilation prepared specifically for the CD format by the 1970s supergroup, and, appearing after a period of several years in which their music had been off the market, was a welcome addition to the catalog. It is still the simplest and most straightforward collection of the group's material that it is possible to buy. ~ Bruce Eder" thumb="/library/metadata/218549/thumb/1685475601" title1="ABBA" title2="Gold: Greatest Hits" viewGroup="track" viewMode="458810"> <Track ratingKey="218550" key="/library/metadata/218550" parentRatingKey="218549" grandparentRatingKey="218548" guid="plex://track/5d07cdc7403c640290f6a452" parentGuid="plex://album/5d07c182403c64029084e584" grandparentGuid="plex://artist/5d07bbfd403c6402904a6593" parentStudio="Polydor" type="track" title="Dancing Queen" grandparentKey="/library/metadata/218548" parentKey="/library/metadata/218549" grandparentTitle="ABBA" parentTitle="Gold: Greatest Hits" summary="" index="1" parentIndex="1" ratingCount="1448426" parentYear="1992" thumb="/library/metadata/218549/thumb/1685475601" art="/library/metadata/218548/art/1686115671" parentThumb="/library/metadata/218549/thumb/1685475601" grandparentThumb="/library/metadata/218548/thumb/1686115671" grandparentArt="/library/metadata/218548/art/1686115671" duration="231400" addedAt="1598373482" updatedAt="1686115672" musicAnalysisVersion="1"> <Media id="278042" duration="231400" bitrate="978" audioChannels="2" audioCodec="flac" container="flac"> <Part id="278372" key="/library/parts/278372/1598369723/file.flac" duration="231400" file="I:\Music\ABBA\Gold- Greatest Hits\01 Dancing Queen.flac" size="28310307" container="flac" /> </Media> </Track> <Track ratingKey="218551" key="/library/metadata/218551" parentRatingKey="218549" grandparentRatingKey="218548" guid="plex://track/5d07cdd3403c640290f7cb52" parentGuid="plex://album/5d07c182403c64029084e584" grandparentGuid="plex://artist/5d07bbfd403c6402904a6593" parentStudio="Polydor" type="track" title="Knowing Me, Knowing You" grandparentKey="/library/metadata/218548" parentKey="/library/metadata/218549" grandparentTitle="ABBA" parentTitle="Gold: Greatest Hits" summary="" index="2" parentIndex="1" ratingCount="455281" parentYear="1992" thumb="/library/metadata/218549/thumb/1685475601" art="/library/metadata/218548/art/1686115671" parentThumb="/library/metadata/218549/thumb/1685475601" grandparentThumb="/library/metadata/218548/thumb/1686115671" grandparentArt="/library/metadata/218548/art/1686115671" duration="242226" addedAt="1598373482" updatedAt="1686115672" musicAnalysisVersion="1"> <Media id="278043" duration="242226" bitrate="946" audioChannels="2" audioCodec="flac" container="flac"> <Part id="278373" key="/library/parts/278373/1598369823/file.flac" duration="242226" file="I:\Music\ABBA\Gold- Greatest Hits\02 Knowing Me, Knowing You.flac" size="28660739" container="flac" /> </Media> </Track> ... </MediaContainer>
The XML returned provides a list of the all the tracks associated with a music album 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 tracks on the server.
Attribute | Description |
---|---|
size | The number of tracks. |
allowSync | 1 - allow syncing content. 0 - don't allow syncing content. |
art | Background artwork used to represent the track. |
grandparentRatingKey | The key associated with the artist. |
grandparentThumb | The thumbnail image associated with the artist. |
grandparentTitle | The title of the artist. |
identifier | The type of item. |
key | Unique identifier for the track. |
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. |
nocache | 1 - cache the library. 0 - do not cache the library. |
parentIndex | The index of the album. |
parentTitle | The title of the album. |
parentYear | The year of the album. |
sortAsc | 1 - the library is sorted in ascending order. 0 - the library is sorted in descending order. |
summary | The summary for the track. |
thumb | The thumbnail for the track. |
title1 | The title of the track. Note: This appears to be internally created, and can't be changed by the server owner. |
title2 | A descriptive title for the track. |
viewGroup | The group type used to view the track. |
viewMode | Unknown integer value. |
Within the MediaContainer
there are one or more Track
child elements. Each Track
element represents one music track available on the Plex server.
Attribute | Description |
---|---|
ratingKey | A key associated with the track. |
key | The relative URL of the track information. |
parentRatingKey | The relative URL of the information for the album. |
grandparentRatingKey | The relative URL of the information for the artist. |
guid | The unique identifier comprised of the Plex agent and track identifier for the agent. |
parentGuid | The GUID for the album. |
grandparentGuid | The GUID for the artist. |
grandparentTitle | The title of the artist. |
parentTitle | The title of the album. |
type | The type of media. |
title | The title of the track. |
grandparentKey | The unique identifier for the artist. |
parentKey | The unique identifier for the album. |
grandparentTitle | The title of the artist. |
parentTitle | The title of the album. |
summary | A summary of the track. |
index | The index of the track. |
parentIndex | The index of the album. |
ratingCount | A count of the rating. |
parentYear | The year the album was released. |
thumb | The thumbnail for the track. |
art | The background artwork used to represent the track. |
parentThumb | The thumbnail for the album. |
grandparentThumb | The thumbnail for the artist. |
grandparentArt | The background artwork used to represent the artist. |
duration | The length of the track in milliseconds. |
addedAt | The date and time, in Unix time, the track was added to the library. |
updatedAt | The date and time in epoch time, the track was updated in the library. |
musicAnalysisVersion | The version of the music analyzer used. |
Also within the Track
element there are one or more Media
elements that represent each media item for that track. If the track has multiple file versions, then each file would be represented by one Media
element.
Each Media
element contains the following:
Attribute | Description |
---|---|
id | Unique ID associated with the track. |
duration | The length of the track in milliseconds. |
bitrate | The bitrate of the track. |
audioChannels | The number of audio channels. |
audioCodec | The audio codec used to encode the audio. |
container | The track container. |
There is at least one Part
element that contains information about the actual media file. Teh Part
element contains the following:
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. |
If the include_guids
parameter was specified with the value of 1, then there would be a Guid
element for each online metadata service associated with the item.
Examples
curl -X GET http://{ip_address}:32400/library/metadata/{id}/children?X-Plex-Token={plex_token}
import requests plex_url = http://{ip_address}:32400/library/metadata/{id}/children?X-Plex-Token={plex_token} response = requests.get(plex_url) print(response.text)
$response = Invoke-RestMethod 'http://{ip_address}:32400/library/metadata/{id}/children?X-Plex-Token={plex_token}' -Method 'GET' Write-Output $response