Twitch helix stream status getJSON migration

Doesn’t work for me too :frowning:

  $.getJSON('https://api.twitch.tv/kraken/streams/wingobear?client_id=pj3uvjgd90hd6cowy4p4e567vv3eki', function(data) {	
      if (data.stream) {
          console.log("Online")
      } else {
          console.log("Offline")
      }  
  });
})();

I don’t know why, i have no response, no console log

You tried to call Kraken
Your call to kraken defaulted to v3 which is long dead

You need to upgrade to

And you won’t be able to do this via a Ajax/getJSON call.
You’ll need to relay it via a server using an app access token

I still don’t understand how calling a simple “Online/Offline” function works with this new API

You either get

offline:

{"data":[]}

or

online

{"data":[{"id":"23735582","login":"sacriel","display_name":"Sacriel","type":"","broadcaster_type":"partner","description":"Since 2012, I've focused on interactive educational content, especially in combat strategy and analysis. Our mature and welcoming community is one of the most respected on Twitch, self-named The 42nd. If you like what you see then hit follow and become part of the community! Warning: British humour!","profile_image_url":"https://static-cdn.jtvnw.net/jtv_user_pictures/d38c27f8-138c-49db-89c0-bc1d06693055-profile_image-300x300.png","offline_image_url":"https://static-cdn.jtvnw.net/jtv_user_pictures/f33e19fe-a982-4cdd-9216-7cac22465306-channel_offline_image-1920x1080.png","view_count":176824413,"created_at":"2011-07-29T19:17:32Z"}]}

I understand what I’m getting, but I don’t understand what to call it

You may want to refer to Twitch API | Twitch Developers in that case for the getting started guide

Thanks ! But it is for a wordpress website, i think i can’t install ```
twitch-cli

twitch-cli is for helping demonstrate the flows, as it’s for local development/testing, not production

For a wordpress site you’ll need to add PHP code to handle token generation and fetching/storing stream status for use by the wordpress site

see Twitch API | Twitch Developers

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