...
/Delete Videos with the playlists and playlistItems Resources
Delete Videos with the playlists and playlistItems Resources
Learn to delete videos by using the playlist and playlistItems resources.
We'll cover the following...
Both the playlists and playlistItems resources offer a DELETE method. The playlistItems resource helps users in removing a specific video from the playlist. On the other hand, the playlists resource allows users to remove the entire playlist from the channel.
Delete individual videos
In this part of the lesson, we’ll delete a specific video from the playlist by sending a DELETE request to the following URL:
https://www.googleapis.com/youtube/v3/playlistItems
Request parameters
The DELETE request only requires one parameter to delete the playlist item, which is the ID of the playlist item that the user wants to delete.
Let’s take a look at the following code explanation for the above code:
Line 5: We define the
endpointUrlvariable in which we pass the endpoint URL.Lines 12–14: We define a
queryParametersvariable in which we pass the playlist item ID we want to delete.
Response
In the case of successful execution of the above code, it returns the response code 204.
Delete a playlist
In this part of the lesson, we’ll delete a specific playlist by sending a DELETE request to the following URL:
https://www.googleapis.com/youtube/v3/playlist
Request parameters
The delete request only requires one parameter to delete the playlist, which is the ID of the playlist that the user wants to delete.
Let’s take a look at the following code explanation for the above code:
Line 5: We define the
endpointUrlvariable in which we pass the endpoint URL.Lines 12–14: We define a
queryParametersvariable in which we pass the playlist item ID that we want to delete.
Response
In the case of successful execution of the above code, it returns the response code 204.