I am trying to use the YouTube Data API to fetch channel data for particular channels. According to the documentation, I can use list (by channel ID) or list (by YouTube username)
Search by channel ID
https://youtube.googleapis.com/youtube/v3/channels?part=snippet&id={ChannelID}&key={APIKey}
// Get channel by YouTube username
https://youtube.googleapis.com/youtube/v3/channels?part=snippet&forUsername={Username}&key={APIKey}
The channel ID can be retrieved by going to YouTube in a browser and search for the channel by name and then when you select the channel; the channel ID is part of the URL like this:
https://www.youtube.com/channel/UCbTw29mcP12YlTt1EpUaVJw
.
This particular channel is for Sean Allen and his YouTube URL is:
https://www.youtube.com/SeanAllen
.
I would have thought that the YouTube username would be SeanAllen
, but it is not because, when I use that term in the API request, I get 0 results.
However, in my own case, my channel ID is UCOWdR4sFkmolWkU2fg669Gg
and the search by channel ID works to fetch my channel data. My YouTube URL is:
https://wwww.youtube.com/StewartLynch
and, if I use StewartLynch
as the username, I can use that 2nd API request to fetch the same data.
So, my question is, how does one find the correct YouTube username for a channel? Apparently it is not what is used in the channel URL.