Retrieving all the new subscription videos in YouTube v3 API

SARose picture SARose · Oct 28, 2013 · Viewed 11.3k times · Source

I need to know the equivalent request in YouTube Data API v3 as this v2 request for retrieving all the new subscription videos.

https://gdata.youtube.com/feeds/api/users/default/newsubscriptionvideos

I have not seen any simple and clean requests that are as simple as the v2 version of the reques

Answer

Alistair Buxton picture Alistair Buxton · May 13, 2014

You can retrieve this information with the Youtube V3 API but it is incredibly inefficient:

  • First get the channel ID from the username (one request).
  • Now get the subscriptions for the channel (batchable - one request per 50 subs).
  • Now get the playlists for each subscribed channel (batchable - one request per 50 subs).
  • Get the most recent playlistItems for the "uploads" system playlist of each channel. (one request per sub).
  • Get the video related to each playlistItem (batchable - one request 50 playlistItems).

You can now sort the videos by publishing date and print the most recent.

If you have 100 subscriptions and fetch 5 videos from each channel this will result in 114 API requests and use around 500 quota units (the daily limit is 50 million units). It will also take about 2 minutes to run if you don't parallelize the API calls.

This method does have a couple of benefits over using activites though:

  • You can do it for any user with public account settings, not just the authenticated user, so it works like the V2 API in that respect.
  • It won't randomly lose videos like the Youtube homepage does.

A full Python implementation is available: https://github.com/ali1234/ytsubs