5

After finally getting the API to connect properly after a couple of hiccups I've managed to grab pretty much all of the data I need fairly easily with 2 exceptions:

I need a list of the 10 most viewed videos from a specific channel. I know with video.list you can set the chart to most popular, but setting the videoCategoryId to either the channel id or the playlist id of the channel's uploads doesn't seem to work

I also need to grab the video that is featured on the channel's home page. I think this is referred to in the API as unsubscribedTrailer and is available under brandingSettings but can't find a way to get at the value from the result of channels.list

EDIT: I've also tried adding brandingSettings to the parts string of listChannels but it returns an empty object - I assume as I'm not the owner of the channel even though I only want to read them and not update

ollie
  • 799
  • 2
  • 10
  • 24

3 Answers3

6

videos->list call is for getting details about videos you already found.

What you need is to do a channels->list with id to find properties of that channels.

The featured video is: brandingSettings.channel.unsubscribedTrailer

To get get most popular videos of that channel: you can do search->list with specifying the channelId and order = viewcount

Ibrahim Ulukaya
  • 12,767
  • 1
  • 33
  • 36
  • Cheers man, the most popular videos works perfectly - I didn't think of using the regular search API. I still can't get at the brandingSettings - I'm using the PHP library, I'm not sure if you're familiar with it, but it seems like the only methods I have access to are listChannels and update. Adding brandingSettings to the parts string of listChannels doesn't work – ollie Feb 10 '14 at 02:17
  • It is working for me. Are you using the latest php library? https://github.com/google/google-api-php-client – Ibrahim Ulukaya Feb 10 '14 at 17:59
  • I get the brandingSettingsType and brandingSettingsDataType objects returned but they're empty even though there's definitely a featured video set on the channel – ollie Feb 10 '14 at 21:55
3

Replace the and with respective values, maxResults is 50 as of now

https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=<CHANNEL_ID>&key=<API_KEY>&maxResults=50&order=viewcount
oya163
  • 1,371
  • 2
  • 16
  • 20
1

You can simply call it like below to get a channels most viewed videos for youtube api v3

https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&key={API_KEY}&playlistId={playlistId}&maxResults=50&order=viewcount
Ian Samz
  • 1,743
  • 20
  • 20
  • The order is always the same regardless of `order` query string parameter. Also, `order` parameter is not documented for PlaylistItems:list operation. – Pavel Chuchuva Feb 21 '20 at 22:24