Get the fewest Viewer count of an game & stream?


#1

How to get the less Viewer Count of an Stream of an Game, is my question?

$resp = json_decode($response);
$viewerCount = $resp->data[0]->viewer_count;
$name = $resp->data[0]->user_name;

$channelsApi = 'https://api.twitch.tv/helix/streams?first=1&language=de&game_id=';


#2

Please stop creating duplicate threads and just use one.

To answer your question though you simply use the Get Streams endpoint, specify the game, and paginate through all the pages of results. Once you have the results, do whichever filtering or ordering you like on your end.


#3

I am sorry, the other one was with the most viewers, so i thought i should seperate.


#4

So i should use before instead of first?


#5

As the docs tell you, first is how many results you want to get with each request (up to 100), and you should use after to paginate with the cursor.


#6

So how i get the last data entry? Of using first and 20 for 100 entries?


#7

Pagination equal 100?


#8

Or after 100


#9

please read the documentation!

Set first to however many results you wish to get on each page.

Set after to the cursor provided in the last request.

Repeat until you have all results.


#10

Thanks


#12

It’s not worth the hassle/fetching.

99% of the time it’ll be some random with zero viewers as a small streamer, or a big streamer that literally just went live.


#13

Hello, I have an other Question, is it possible to sum the total count of viewers for an game of game id and sort it by language by the Twitch API?


#14

Yes


#15

Can you maybe tell how?


#16

Make the relevant API calls and then compare and sort the data you have retrieved.


#17

So I ve tried but get ever the count of just one Streamer!

https://api.twitch.tv/helix/streams?first=1&language=de&game_id=


#18

first=1 will return the first one records


#19
$resp2 = json_decode($response2);
$viewerCount2 = $resp2->data[0]->viewer_count;

#20

so how it is possible to set for all?


#21

first=100 gets you the first 100 records and then you follow the pagination

we covered that here: