Kraken to helix [very noob developer]


#1

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.


#2

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'

#3

but i have to use only http link not curl.How to do with only http link?


#4

you need to set the http header, what programming language are you using?


#5

So you only used the raw JSON from the API to read? Not parsing it and using it for anything but reading?


#6

Yes sir!


#7

I m using appinventor and parsing jsons.So i just need json data with http.I parse my self.


#8

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.


#9

Well , my question is, isn it possible on helix like kraken? i was using on kraken with only http link.


#10

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.


#11

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.


#12

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.

If you want to look at the same information via helix, you will probably have to reformat your query…


#13

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);

#14

For security reasons you should be using cURL, most hosts prevent file_get_contents making http(s) requests


#15

Thank you! I understand.