Website viewer count embedding with new API

API change seems to have broke my viewer count embedding, any easy way to embed stream viewer count on a webpage? Anyone could mock up some some html for me, or an example would be appreciated!

This isn’t a coding service and you seem to have existing code that used to work. We can tell you what’s wrong with it. The only breaking change has been requiring client id, but that was months ago.

1 Like

In the amount of text you replied with you could have probably wrote a simple html code. If it was already covered in a wiki or somewhere else I wouldn’t have even bothered to ask, I was the original person to even ask about the code in the first place, and I do appreciate help that I originally got, just figured things like that might have gotten easier with a change of API.

Give a man a fish and he’ll be covered for a day… Teach a man to fish and he’ll be covered for the rest of his life. Besides, I’m not going to be writing code on Android keyboard.

2 Likes

Give a man a smartphone and he’ll blab all day without being useful. Being as how I’m asking for a code it would mean I would have basic understanding of html, however I don’t with json, java, css, python, xml, and the millions of other sub-coding that goes along with making a webpage, all I needed was a simple basic short response, but instead we go back and forth about who should know what. This is exactly why some people just give up instead of actually doing something, rude useless people, instead of short concise answers. A topic of 200 replies of ass clowns with no useful information, and really what was the point, when sometimes things could be as simple as 1 short reply that takes a lot less typing, and actual thought. Tell you what I’ll look into it some more, and if I actually get a piece of code working for me i’ll leave it for others to use without spending 1/2 a day learning something you’ll forget anyways because you’re trying to do something simple that should only take 5 minutes.

esl_csgo has <span id="viewers"></span> viewers
<script>
var ve = document.getElementById('viewers');
setInterval(_ => {
    fetch('https://api.twitch.tv/kraken/streams/31239503', {
        headers: new Headers({
            'Client-Id': '',
            'Accept': 'application/vnd.twitchtv.v5+json'
        })
    }).then(response => response.json()).then(data => {
        ve.textContent = data.stream.viewers;
    });
}, 10000);
</script>

For reference only, now that I’m at a computer.

1 Like

Thanks exactly what I need, i’ll figure out the rest!

1 Like

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