justintv / Twitch-API

A home for details about our API
www.twitch.tv
1.72k stars 381 forks source link

GET /search/streams endpoint doesn't return highest viewer count to lowest. #525

Closed laere closed 8 years ago

laere commented 8 years ago

Currently using the GET /search/streams endpoint for an application. I know that the GET /streams/ endpoint returns a limit of 100 streams, and returns the streams in order from highest to lowest current viewers. Was curious if the same could be done for the aforementioned endpoint in the title, /search/streams?

tadachi commented 8 years ago

https://api.twitch.tv/kraken/search/streams?q=starcraft

example: streams.channel[0].title => "RERUN: StarCraft 2 - Snute vs. Fantasy (ZvT) - IEM Katowice 2015 - EU Qualifier"

               /* Get data from 
                  https://api.twitch.tv/kraken/search/streams?q=starcraft
                  via ajax json GET call
               */

               // Compare function for title to sort
               var compare = function(a, b) {
                    //a.title b.title
                    if (a.title < b.title) {
                        return 1;
                    } else if (a.title > a.title) {
                        return -1;
                    } else {
                        return 0;
                    }
                }
                // Use compare function to sort by stream titles.
                var sorted_array = streams.channels.sort(compare)

Something along the lines of the above?

laere commented 8 years ago

I didn't even consider something like that, I will give it a shot, thanks for the advice!

On Tue, Apr 5, 2016 at 8:05 PM, TA notifications@github.com wrote:

https://api.twitch.tv/kraken/search/streams?q=starcraft

example: streams.channel.title => "RERUN: StarCraft 2 - Snute vs. Fantasy (ZvT) - IEM Katowice 2015 - EU Qualifier"

           /* Get data from ajax for
              https://api.twitch.tv/kraken/search/streams?q=starcraft
           */

           // Compare function for title to sort
           var compare = function(a, b) {
                //a.title b.title
                if (a.title < b.title) {
                    return 1;
                } else if (a.title > a.title) {
                    return -1;
                } else {
                    return 0;
                }
            }
            // Use compare function to sort by stream titles.
            var sorted_array = streams.channels.sort(compare)

Something along the lines of the above?

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/justintv/Twitch-API/issues/525#issuecomment-206041991

DallasNChains commented 8 years ago

I would recommend asking these types of questions in the Twitch Developer Forums. Lots of helpful folks there. :)