Sort /streams By created_at (uptime)

Hello. I’m attempting to create a personal PHP page for myself that will allow me to sort streams in a variety of ways. What I’m having trouble with currently is being able to sort the created_at, or essentially the uptime or duration, of streams (e.g. people who just started streaming show up first in the list). Ultimately I’m trying to replicate how the website Loots does it here (I’d love to simply use theirs but it hardly ever works).

I was attempting something like this, because I know sortby works for some endpoints:

But it doesn’t look like that’s a valid request because it just returns information starting with the stream with the most live views (I also tried adding direction, asc, desc, etc but no go).

Could anyone help me out or point me in the right direction of the documentation that addresses this? Thanks!

If you have a look at the docs for that endpoint you’ll see that sortby and direction are not valid query parameters for that endpoint, which is why they didn’t change the results.

Looking at the link I’m not sure how they do it, but considering they seem to be doing a lot of work with tracking channel stats I wouldn’t be surprised if they just poll all streams (at the time of writing this there’s about 17000 live, so not too hard to poll through the pages), store the results in their own database and then use their own API which does allow for sorting that the page can use.

Bummer, but thanks for the clarifiation @Dist. I’m not sure how they do it either, but (when it’s working which again is rare) it’s a great tool because I got so frustrated with finding streams right as they were ending.

For me, being able to sort streams by ones that just started (mostly) guarantees a longer stream you can participate in, and if it’s a very story-driven game then you get to watch it from the very beginning if you haven’t played/watched it yourself prior.

It looks like that is where I need to go to suggest ideas for Twitch services/infrastructure so I’ll mention it on there if it hasn’t already been mentioned. Again, appreciate the clarification!

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