Kang-Kyu Lee

January 10, 2026

How to find playlist item id

Hello.

In my previous post, I talked about deleting an item from your playlists.

Before removing any item, the computer should know what to remove.
By the way, we are willing to request a computer to do something through the internet.

In case you know channel id, you can get all the playlist ids.
In case you know playlist id, then you can get all the playlist item ids.

Let's look at YouTube Data API documentation.

PlaylistItems: list

GET https://www.googleapis.com/youtube/v3/playlistItems

Yes you request with GET to this address. And the query parameters we need today is,

part=id&playlistId=...

In a Ruby code, this can be written (Do you remember the previous post?)

require 'net/http'
require 'uri'

path = "/youtube/v3/playlistItems"
host = "www.googleapis.com"
params = "part=id&playlistId=PLwjDRP5ZX_MEOE-zOuTIMOVH0VOYgG_69" # to get id

uri = URI::HTTPS.build(host: host, path: path, query: params)
http_request = Net::HTTP::Get.new(uri.request_uri)

response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
  http.request http_request
end

And then you will see a response. (This time there's a response, and the playlist item id is supposed to be found in the response)

require 'net/http'
require 'uri'

By the way this part of the code is needed because in that way we are able to use "URI::HTTPS" and "Net::HTTP" skills. The libraries ("net/http" and "uri") are required.

Ok then you will see the response!

=> #<Net::HTTPOK 200 OK readbody=true>

Oh oops,

response.body
=> "{\n  \"kind\": \"youtube#playlistItemListResponse\",\n  \"etag\": \"s6QcrvkzWWOAgqLpxGuOTwmYE-s\",\n  \"items\": [\n    {\n      \"kind\": \"youtube#playlistItem\",\n      \"etag\": \"bXmH501ZhdvFDcAuhNF1e2hnFTM\",\n      \"id\": \"UEx3akRSUDVaWF9NRU9FLXpPdVRJTU9WSDBWT1lnR182OS41NkI0NEY2RDEwNTU3Q0M2\"\n    }\n  ],\n  \"pageInfo\": {\n    \"totalResults\": 1,\n    \"resultsPerPage\": 5\n  }\n}\n"

There are 1 item in total, and the id of item is "UEx3akRSUDVaWF9NRU9FLXpPdVRJTU9WSDBWT1lnR182OS41NkI0NEY2RDEwNTU3Q0M2"

Thank you, see you next time!

About Kang-Kyu Lee

I love hamburgers. I will share my experiences with Ruby and YouTube