Search limit parameter returning random number of objects

In initial call to search/channels endpoint i get 8 objects when i have set limit = 9. Then when using the _next and _prev links for pagination i get seemingly random amounts of objects returned while the offset holds steady at 9.
Here is my call. Any reason for this behavior? What can be done to fix it if possible?
Thanks.

var params = {'q': searchTerm, 'limit': 9};
var url = "https://api.twitch.tv/kraken/search/" + searchType + "?";

$.ajax({
                url: url,
                data: params,
                success: function(response) {
                    next = response._links.next;
                    prev = response._links.prev;
                    console.log(response);
                    callback(response);
                },
                error: ...

Here it is in action https://github.com/Adoyle2014/FCC-TwitchAPIApp/tree/gh-pages

Correct me if I’m wrong but you are saying when you first make a call to the API, you get 8 objects but then after going next/previous u have 9 objects?

I was getting the same kind of results using the search/streams endpoint. I did some testing and I believe what is happening is that when streams are ending, what would’ve been that 9th object is removed but the rest of the objects in the array in the server are still in place until the server reorders them. The same goes for the _total property in the response. One possible solution is to increase the limit, store the objects, and use your own pagination functionality instead of making a request for each new page. But this comes at the cost of accuracy of what streams are actually still live.

the first part is right but the next doesn’t always give 9 objects either. The offset=9 in the url but sometimes it only gives 8 and even 7 when there are of course thousands to go through.

this makes sense for the streams but i am using the channels endpoint. They shouldn’t change, correct.
The local pagination might end up being the workaround. Thanks

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.