i was using this link to get names,viewers etc but not working anymore.
https://api.twitch.tv/kraken/streams/?game=Age%20Of%20Empires%20II&client_id=xxxxxxxxxxxxx
İ m newbie,need help.
You need to update your HTTP headers to accept v5
Accept: application/vnd.twitchtv.v5+json
Your client ID should also be an HTTP header, not a query string.
e.g.
curl -H 'Accept: application/vnd.twitchtv.v5+json' \
-H 'Client-ID: uo6dggojyb8d6soh92zknwmi5ej1q2' \
-X GET 'https://api.twitch.tv/kraken/streams/?game=Overwatch'
but i have to use only http link not curl.How to do with only http link?
you need to set the http header, what programming language are you using?
So you only used the raw JSON from the API to read? Not parsing it and using it for anything but reading?
Yes sir!
I m using appinventor and parsing jsons.So i just need json data with http.I parse my self.
I’m sorry, I don’t know what programming language that is. Most languages will allow you to set custom HTTP request headers before making the request of the server.
Well , my question is, isn it possible on helix like kraken? i was using on kraken with only http link.
On helix you would need to do the same, set HTTP headers for Client ID, etc.
But you would need to do two lookups, one to get the ID of the game, the other to list the streams for that game.
What is HTTP Link?
For Helix (and v5) you need to be able to attach headers to your Request. This is possible with most libraries.
If you are using chrome,
This would format the JSON cleanly
This will let you inject your client ID or OAuth into headers. Also, you can select which API to by default.
https://chrome.google.com/webstore/detail/twitch-client-id-injector/okebcaancimcjdklkimjgcpcamnbkhli
If you want to look at the same information via helix, you will probably have to reformat your query…
I’m using JSON and PHP code. This code will work for you.
$opts = [
"http" => [
"header" => "Accept: application/vnd.twitchtv.v5+json"
]
];
$context = stream_context_create($opts);
$url = " https://api.twitch.tv/kraken/streams/?game=Age%20Of%20Empires%20II&client_id=xxxxxxxxxxxxx";
$json = file_get_contents($url, false, $context);
$obj = json_decode($json);
var_dump($obj);
For security reasons you should be using cURL, most hosts prevent file_get_contents making http(s) requests
Thank you! I understand.