2

I am trying to retrieve a complete list of the channels subscribed to the authorized user.

According to Subscriptions: list:

To retrieve a complete list of subscribers, use the mySubscribers parameter. That parameter, which does not return subscribers in a particular order, does not limit the number of subscribers that can be retrieved.

However, even with this parameter, I am limited to retrieving 1000 results.

I am using Node.js. My parameters are the following:

{'params': {
   'part': 'snippet,contentDetails,subscriberSnippet',
   'mySubscribers': true,
   'maxResults': 50
 }};

The request goes to this URL:

https://www.googleapis.com/youtube/v3/subscriptions?part=snippet%2CcontentDetails%2CsubscriberSnippet&mySubscribers=true&maxResults=50

According to the pageInfo:

"pageInfo": {
    "totalResults": 12954,
    "resultsPerPage": 50
},

I continue to request using nextPageToken:

function subscriptionsListByChannelId(auth, requestData) {
  var service = google.youtube('v3');
  var parameters = removeEmptyParameters(requestData['params']);
  parameters['auth'] = auth;
  service.subscriptions.list(parameters, function(err, response) {
    if (err) {
      console.log('The API returned an error: ' + err);
      return;
    }
    console.log(response);
    if (response.data.nextPageToken) {
        var newParams = {'params': {
        'part': 'snippet,contentDetails,subscriberSnippet',
        'mySubscribers': true,
        'maxResults': 50,
        'pageToken': response.data.nextPageToken
      }};
      authorize(content, newParams, subscriptionsListByChannelId);
    }
  });
}

response.data.nextPageToken becomes undefined after exactly 1000 subscribers, meaning it has reached the last page.

I cannot figure out why it stops at this point. According to the documentation, I should be able to retrieve all subscribers, not just 1000. I have tried every combination of parameters I can think of, but nothing changes.

EDIT: For anyone stumbling across this question in the future, I noticed Channels: list gets more than 1000 subscribers, despite the mySubscribers parameter being deprecated. By switching the API, you can retrieve more subscribers, although they are about 72% duplicates. Because of the issues of both APIs, I don't see this as the solution.

MysteryPancake
  • 1,365
  • 1
  • 18
  • 47
  • 1
    Maybe this behavior is due to recent issues with the YouTube Data API. Check [this answer](https://stackoverflow.com/a/55264616/4092887) and check the issue tracker entries about issues with the YouTube Data API. You can post an entry in [Issue Tracker](https://issuetracker.google.com/issues/new?component=186600&template=874803) with your specific problem. – Mauricio Arias Olave Mar 23 '19 at 18:36
  • @MauricioAriasOlave I reported the issue (https://issuetracker.google.com/issues/129193012). I also noticed many duplicate issues with my exact problem: https://issuetracker.google.com/issues/35176904 https://issuetracker.google.com/issues/35171978 https://issuetracker.google.com/issues/75254052 https://issuetracker.google.com/issues/111489032 https://issuetracker.google.com/issues/117105237 – MysteryPancake Mar 24 '19 at 05:21

0 Answers0