Getting stream title, followers, etc. to show up in HTML?

Hello, i’m currently working on a site for a streamer, and when it comes to this API, I have almost no clue as to what i’m doing.

On lirik’s website - http://lirik.tv/ - He has his title updated live. Can someone explain to me how to do this? Mainly the back end part is what I need.

The API is pretty well documented here https://github.com/justintv/Twitch-API

As far as retrieving data from it, I personally prefer PHP (because that’s the only thing I know :slight_smile: ), here is a simple example for the things you asked about:

<?php

    $json = file_get_contents("https://api.twitch.tv/kraken/channels/lirik");
    $api = json_decode($json, true);
    
    echo "Stream title: ".$api['status']."<br>\n";
    echo "Game: ".$api['game']."<br>\n";
    echo "Followers: ".$api['followers']."<br>\n";

?>

Ok, I prefer PHP as well :smiley: thank you for this, this should help alot.

So, one more question: how would I use this? Like can you give me an html example as well?

You’d have to do it with Javascript. jQuery’s getJSON or ajax methods are fairly easy to use if you are not too experienced with JS.

Oh alright. Thank you guys so much :slight_smile:

Can you give me an example of this?

You can read the jQuery documentation for examples of using their methods: http://api.jquery.com/jquery.getjson/

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