Reputation: 2780
I am using the YouTube Analytics API (v1-rev18-1.15.0-rc). I tried to get some channel reports using video dimension. According to the API document, it has a limit of maxResults <= 10. I set the startIndex and maxResults as belwo, but the second query returns nothing for the following code.
First page returns 10 rows.
query.setMaxResults(10);
query.setStartIndex(1);
Using the same query object, the second page returns nothing (resultTable.Rows is null)
query.setStartIndex(11);
result = query.execute();
result.getRows() == null; // true
I tried to create a new query object each time or set the maxResults to a smaller number such as 3, it didn't work. In queries I tested, even for dimensions without maxResults limit such as the day dimension, it returned null rows when startIndex is > 1 even it was the first query. Did I miss anything?
I just found that the pagination works in Content Owner Reports, not in Channel Reports.
Upvotes: 0
Views: 690
Reputation: 2526
The limitation for maxResults <= 10 is only for some sort orders, like by views and watch time. When sorting on any of the dimensions, like day or country the maximum number of results is much higher.
But it seems like maxResults is actually an endIndex, when I try it out:
startIndex=1 maxResults=10 -> result: 1..10
startIndex=2 maxResults=10 -> result: 3..11
startIndex=5 maxResults=10 -> result: 9..14
startIndex=10 maxResults=10 -> result: 19
startIndex=11 maxResults=10 -> result: none
startIndex=1 maxResults=20 -> result: 1..20
startIndex=10 maxResults=20 -> result: 19..29
startIndex=20 maxResults=20 -> result: 39
startIndex=21 maxResults=20 -> result: none
startIndex also seems to be using the formula (=startIndex*2 - 1) This looks like a bug to me.
Upvotes: 2