0

Since the old feed on http://gdata.youtube.com/feeds/api/videos?author=[channel]&start-index=[index] is no longer available, I had to switch to the official YouTube API to get a list of all videos present on a channel. However, I've ran into the issue that this API does not return the right videocount on a channel. This also leads to being unable to use the pageToken, as none is returned.

The expected result is to have a an amount of 159 videos in total, however, at around 50% the API tells me there are only 16 videos.

I'm using the following url:

https://www.googleapis.com/youtube/v3/search?key=*****&channelId=UCsuBLfTDK4Hjn9Q6AYPwGqQ&part=snippet,id&order=date&maxResults=25

As 16 is lower than the max amount of results per request, I wont have a nextPageToken half of the time which I need to paginate and get a list of every record, making this API completely useless in production..

Is there anything I can do to resolve this issue, or is this a problem that lies on the YouTube side? Or is there anything else I can use as an alternative? All I need is the video IDs of every video on a certain channel.

Deltanic
  • 1,009
  • 4
  • 11
  • 17
  • A few links you might like http://stackoverflow.com/questions/25918405/youtube-api-v3-page-tokens/25928207#25928207 https://code.google.com/p/gdata-issues/issues/detail?id=4282 http://stackoverflow.com/questions/30867855/listing-large-amount-of-subscriptions-of-a-youtube-channel/30868645#30868645 – Linda Lawton - DaImTo Jun 30 '15 at 14:06
  • @DaImTo Unfortunately these links don't provide useful information. My dataset is much, much smaller, and doesnt return consistent data. Every request may return 16 OR 159 results, and I'm unable to navigate over the 159 results when 16 is returned as no page tokens are returned either. – Deltanic Jun 30 '15 at 14:36

1 Answers1

3

First, get the ID for your uploads playlist:

GET https://www.googleapis.com/youtube/v3/channels?part=contentDetails&id=CHANNEL_ID&key=API_KEY

The ID should be under 'uploads'.

Then, you can use the playlistItems list method:

GET https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=PLAYLIST_ID&key=API_KEY

and get the number of videos from totalResults.

Alternatively, you can use the code from the playlistItems documentation to get a list of the uploaded videos.

not_a_bot
  • 2,332
  • 2
  • 19
  • 33