API twitch update ? get viewers?

hi, i just saw the maj of API twitch. So now we need ID client in url but i’ve got a problem to get viewers of one channel.

$.getJSON(‘https://api.twitch.tv/kraken/streams?client_id=code&channel=streamer’, function(channel) {



Before the maj, i’ve got no problem to get viewers but now it doesn’t work… (undefined viewers)

Thanks !

In PHP i can show the Viewers with that Code:

$url = “https://api.twitch.tv/kraken/streams/streamer?client_id=$client_id”;

$result = file_get_contents($url);
$result = json_decode($result, true);


May it help…

1 Like

If you are only querying a single channel you want to use https://api.twitch.tv/kraken/streams/CHANNELNAME?client_id=code instead and your code would work.

/streams by itself will return an array of stream objects so you would need to access them index (channel["streams"][0..n]["viewers"]) or iterate over the streams array in the result.

1 Like

ah ok ! thanks a lot it’s work now !

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