Is there any way to find playlist ID of youtube video using API, like through videoID? I looked into /playlistItems endpoint but I'm not sure where I can find the playlist item ID? I've tried to look this over everywhere but I'm at lost.
Get playlist ID from youtube video
803 Views Asked by Afifa At
2
There are 2 best solutions below
1
On
An alternative could be:
- Since you have the
video_id, get the title of the video as well. - With the title of the video, use the search:list endpoint for search playlists that matches with the query/criteria - that is, the title of the video.
- Loop the results from the search request and use the code I show in my answer for check if the
video_idis on the playlist.
Example:
video_id:
eJjbnFZ6yA8title:
FULL MATCH - The Rock vs. Mankind – WWE Championship Match: Raw, Jan. 4, 1999
Make search to get playlists that matches the search term: "FULL MATCH - The Rock vs. Mankind – WWE Championship Match: Raw, Jan. 4, 1999"
URL:
https://youtube.googleapis.com/youtube/v3/search?part=id%2Csnippet&maxResults=50&q=FULL%20MATCH%20-%20The%20Rock%20vs.%20Mankind%20%E2%80%93%20WWE%20Championship%20Match%3A%20Raw%2C%20Jan.%204%2C%201999&type=playlist&key=[YOUR_API_KEY]
From the results of the search, get the playlist - for this example I took the first result I got from the search, then, I check if the video_id eJjbnFZ6yA8 is on the playlist PLAamU2iv-fSuxZrVqQIBcrrZMTCMbBt2W
URL:
https://youtube.googleapis.com/youtube/v3/playlistItems?part=id%2Csnippet&playlistId=PLAamU2iv-fSuxZrVqQIBcrrZMTCMbBt2W&videoId=eJjbnFZ6yA8&key=[YOUR_API_KEY]
Try-it here for check the results.
Keep in mind that the search:list endpoint consumes 100 quota points, so, the quota might be drain rather quickly - depending of the intensity of the search.
I looked a bit, and the only method I can find would be limited to your own playlists and playlists on the video's channel (or other channels that you specify):
It's a bit ugly, and limited of course - maybe someone else will share a better method with us.