Retrieve Most Popular Videos On Particular channel via API call

Can anyone tell me how to get most popular videos on particular channel via an API call?

i have this call GET /channels/:channel/videos to get videos of that channel and want most popular among it.

There is an API for videos here: https://github.com/justintv/Twitch-API/blob/master/v3_resources/videos.md You would use the /top/ endpoint for the most popular videos.

@DallasNChains - Thanks…but didn’t help I have seen that documentation for TOP videos and it just gives me general results about latest created and viewed but as i mentioned i want TOP videos for particular channel and yeah put /top/ endpoint also didn’t work for existing another API call.

Ah! There isn’t an API that will give you a ranked list directly. You would have to call the channel videos API and rank those by the views field that you get in the response.

@DallasNChains - Done that already sorting via views worked but only for smaller number of videos say there would be 300 videos then i have to make API call and these calls give results in limit of 10 and offset of 10 i would have to make so many call to check if there is next link then get views of videos and after all these operations it takes much time for my application.

Is there any way to get views of all videos of channel disregard of offset and limit in API call? Please suggest!!

@jaypandya29 You can’t disregard the limit and offset. The default limit is 10, but you’re free to set the limit up to 100. If you look at the parameters in the documentation, you will see that it says maximum of 100 for the limit. Hope that helps! :smile:

@DallasNChains - Yeah i have seen that i kept that as my last option as of now till i found something which i can replace. Just afraid that what if that limit = 100 would not fill proper requirement for most popular video for channel.(Plus application performace affects for limit 100)
i really appreciate your help! Thanks!!!

@jaypandya29 Just FYI, the API calls include the next attribute in the _links object. This will give you the next URL to request for the next 100 results for the channel. Makes it super easy to page through all the videos for that channel. :slight_smile:

@DallasNChains- Yes i do know that but its not very good for coding to go through so many pages via call it totally get affect to application and hope you know that i posted here for the alternate solution which i don’t know about twitch.
Go through next 100 pages and pick views and then compare to previous one and do all these till total videos Does this really seems to a proper solution?

@jaypandya29 I wouldn’t suggest trying to rank in realtime. That’s definitely going to be slow. :slight_smile: If I were implementing this, I would have a backend service that calls the Twitch API and caches the views data. That would be where I get data for my UI rendering. The views data in my cache would be updated either a) on-demand when someone accesses a given channel or b) nightly. It all depends on your use case!

1 Like

@DallasNChains - Ahhh, Thanks for your suggestion. I would look forward to it. :smile:

@DallasNChains - Just to ask result from call GET /channels/:channel/videos i analyzed this and want to make sure that result will be based on most recent creation on videos? what’s your view on this?

@jaypandya29 That’s correct. It is sorted by most recent.

@DallasNChains - Thanks… :grinning:

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