# New rules Twitch API

**URL:** <https://discuss.dev.twitch.com/t/new-rules-twitch-api/7432>\
**Category:** API\
**Created:** [September 16, 2016, 11:18am UTC](https://discuss.dev.twitch.com/t/new-rules-twitch-api/7432 "2016-09-16T11:18:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![11129](https://avatars.discourse-cdn.com/v4/letter/1/898d66/32.png) [@11129](https://discuss.dev.twitch.com/u/11129)\
**Post date:** [September 16, 2016, 11:18am UTC](https://discuss.dev.twitch.com/t/new-rules-twitch-api/7432/1 "2016-09-16T11:18:38Z")

</div>

Hello, since yesterday stopped working plugin that I have used on your site. I read that at the time of anonymous requests to the API will banned Twitch. For register unique ID. But I can not understand where you want to paste, here’s the script please help. I myself in Java and other affairs do not understand, ask for help, plug-in is very necessary.

```
 $(document).ready(function () {
var initUrl = "https://api.twitch.tv/kraken/streams?game=rocket+league&callback=?";
var arr = [];
var total = 0;
var iter = 0; //for debugging
var settings = {
    "offset" : 0,
    "limit" : 100
}

$(".aDiv").empty();

function getter() {
    iter++; //for debugging
    $.getJSON(initUrl, settings, function (rsp) {
        var resp = rsp.streams;
        $.merge(arr, resp);
        total = rsp._total;
        console.log(total);
        settings.offset += settings.limit;
        if (settings.offset < total) {
            getter();
        }else{
            console.log("finished. " + iter + " iterations");
            arr = arr.sort(function (a, b) {
                return b.viewers - a.viewers;
            }).filter(function(item, ind) {
                return item.game == "Rocket League" && ind < 10;
            });
            builder(arr);
        }          
    });
};

function builder(arra) {
    console.log("building");
    for (var i = 0; i < arra.length; i++) {
        $(".aDiv").append(
            '<a href="' + arra[i].channel.url + '" target="_blank" class="bDiv">' +
                '<div class="row">' +
                    '<div class = " proPic col-sm-3">' +
                        '<img src="' + arr[i].channel.logo + '" class="img-responsive">' +
                    '</div>' +
                    '<div class="col-sm-9">' +
                            '<span>' + arr[i].channel.url.slice(21) + '</span><br/>' +
                            '<span>Viewers: ' + arr[i].viewers + '</span>' + 
                    '</div>' +
                '</div>' +
            '</a>'
        );
    }
    $(".bDiv").children().filter(":even").css({"background-color" : "rgba(100, 100, 100, 0.95"});
    $(".bDiv").children().filter(":odd").css({"background-color" : "rgba(200, 200, 200, 0.95"});
};
getter();
console.log(arr);

```

});

---

<div class="post-metadata">

**Author:** ![TournyMasterBot](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/tournymasterbot/32/2013_2.png) [@TournyMasterBot](https://discuss.dev.twitch.com/u/TournyMasterBot)\
**Post date:** [September 16, 2016, 12:47pm UTC](https://discuss.dev.twitch.com/t/new-rules-twitch-api/7432/2 "2016-09-16T12:47:51Z")

</div>

You need to add a client id to your request either in the header (Client-ID: someToken) or as part of the url

/Streams?client\_id=someToken&game=

You can get a client id by registering an app in your user settings under connections on [twitch.tv](http://twitch.tv)

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [October 16, 2016, 12:48pm UTC](https://discuss.dev.twitch.com/t/new-rules-twitch-api/7432/3 "2016-10-16T12:48:10Z")

</div>

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