Delete All Items from a Playlist
Each playlist that is created on a Plex server contains different media files. Each playlist can contain only one type of file, but can contain hundreds of the same media type.
This API command will delete all items from a playlist.
URL
DELETE http://{ip_address}:32400/playlists/{id}/items?X-Plex-Token={plex_token}
Parameters
Name | Description |
---|---|
ip_address | The IP address of the Plex Media server. |
plex_token | The Plex user token. |
id | The key associated with a playlist. This key can be found by calling the view playlists for a user API command and getting the value in the ratingsKey attribute. |
Return Status
HTTP Code | Description |
---|---|
200 | Success - The request was successful. |
401 | Unauthorized - The Plex token provided was not valid. |
404 | Not Found - The playlist associated with the ID was not found. |
Response
XML string value that lists the all the items in a playlist. The XML return is dependent on the type of media that is contained in the playlist.
For movie playlists, an example XML returned is:
<?xml version="1.0" encoding="UTF-8"?> <MediaContainer size="1"> <Playlist ratingKey="892" key="/playlists/892/items" guid="com.plexapp.agents.none://80f382aa-89eb-4a3d-bf9d-54dff7912b4b" type="playlist" title="1990s Movie" titleSort="1990s Movies" summary="Movies from the 1990s" smart="0" playlistType="video" thumb="/library/metadata/892/thumb/1710508894" art="/library/metadata/892/art/1710508894" leafCount="0" addedAt="1710506337" updatedAt="1710508894"> <Field locked="1" name="thumb" /> <Field locked="1" name="art" /> </Playlist> </MediaContainer>
The XML returned provides information about the items associated with the specified playlist ID. The root is the MediaContainer
element. This element contains an attribute that indicates the number of playlists returned - in this case it would be one.
Attribute | Description |
---|---|
size | The number of playlists returned from the request. |
Playlist
Within the MediaContainer
there is one Playlist
child element that contains the details about the playlist.
Attribute | Description |
---|---|
ratingKey | A key associated with the playlist. |
key | The relative URL of the playlist information. |
guid | The unique identifier comprised of the Plex agent and playlist identifier for the agent. |
type | The type of media. |
title | The title of the playlist. |
titleSort | The title of the playlist used to sort the playlists in a collection or list. |
summary | A summary of the playlist. |
smart | 1 - playlist is a smart playlist. 0 - playlist is not a smart playlist. |
playlistType | video - playlist contains videos/movies. audio - playlist contains audio/music. photo - playlist contains photos. |
thumb | The thumbnail for the playlist. |
art | The background artwork used to represent the playlist. |
leafCount | Number of items in the playlist. |
addedAt | The date and time, in Unix time, the playlist was added to the library. |
updatedAt | The date and time in epoch time, the playlist was updated in the library. |
Field
Within the Playlist
there are one or more Field
child elements. Each Field
element represents one field associated with the playlist.
Attribute | Description |
---|---|
locked | The field is locked. |
name | The name of the field. |
Remarks
A playlist is specific to a user on the Plex server. Only that user can request information about a playlist.
When using a device Plex authentication token, the administrative user playlists will be returned by the Plex server. This means that the administrator's Plex token and any device token will return the same XML response.
Examples
curl -X DELETE http://{ip_address}:32400/playlists/{id}/items?X-Plex-Token={plex_token}
import requests plex_url = http://{ip_address}:32400/playlists/{id}/items?X-Plex-Token={plex_token} response = requests.delete(plex_url) print(response.text)
$response = Invoke-RestMethod 'http://{ip_address}:32400/playlists/{id}/items?X-Plex-Token={plex_token}' -Method 'DELETE' Write-Output $response