Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

YouTube Api v3 - topic channel videos

So how do I get posted videos from a channel that is "auto-generated by YouTube" (topic)? https://www.youtube.com/channel/UCSkJDgBGvNOEXSQl4YNjDtQ/videos

I can get topic ids from channel call but when I search by this topic ids I get a completely different results.

And if I run search api call with:

{
  'part':'snippet',
  'channelId':'UCSkJDgBGvNOEXSQl4YNjDtQ',
  'topicId':'/m/03lty'
} 

I get only playlists and channels. No video results.

like image 744
Gapipro Avatar asked Nov 10 '22 18:11

Gapipro


1 Answers

You have to do this way:

  • get the channel id in your case 'UCSkJDgBGvNOEXSQl4YNjDtQ'
  • call playlists endpoint and retrieve the id

    GET https://www.googleapis.com/youtube/v3/playlists?part=id&channelId=UCSkJDgBGvNOEXSQl4YNjDtQ&maxResults=1&key={YOUR_API_KEY}

  • call playlistitems using the retrieved id

    GET https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId={RETRIEVED_ID_COMES_HERE}&key={YOUR_API_KEY}

This works like a charm to me.

-- editing on March 27, 2016. You can also scrapy how search engine does. Just check the ToS and Policy.

like image 93
Fernanda Fentili Avatar answered Jan 04 '23 02:01

Fernanda Fentili