Share

Show channel view count in overlay

A code snippet that can be used as a browser source overlay (for example OBS) to show viewer count on the stream that updates every minute.

<!DOCTYPE html>
<html>
    <head>
        <meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
        <title>Blushyface.com</title>
    </head>
    <body>
        <p id="viewers"></p>
        <script>
            const url = "https://decapi.me/twitch/viewercount/blushyface";
            const intervalInSeconds = 60;
            const getViewersAsync = async () => {
                try {
                    const response = await fetch(url);
                    const textResponse = await response.text();
                    document.getElementById("viewers").innerHTML = textResponse;
                } catch (ex) {
                    console.log(ex);
                }
            };
 getViewersAsync();
            setInterval(function () {
               getViewersAsync();
            }, intervalInSeconds * 1000);
        </script>
    </body>
</html>