Quantcast
Here is a template code in HTML that uses Twitch user ID, access token, and client ID to display the top 5 views for the week for a user: - by rudy.brown.545 on 2023-03-01 03:29:24
rudy.brown.545 on 2023-03-01 03:29:24
11 Posts
Since 11 years ago

<!DOCTYPE html>
<html>
<head>
    <title>Top 5 Twitch Clips for the Week</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
    <h1>Top 5 Twitch Clips for the Week</h1>
    <ul id="top-5">
    </ul>
   
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
        $(document).ready(function() {
            var userID = 'USER_ID'; // replace with your Twitch user ID
            var accessToken = 'ACCESS_TOKEN'; // replace with your Twitch access token
            var clientID = 'CLIENT_ID'; // replace with your Twitch client ID
           
            $.ajax({
                url: 'https://api.twitch.tv/helix/clips?broadcaster_id=' + userID + '&first=5',
                headers: {
                    'Client-ID': clientID,
                    'Authorization': 'Bearer ' + accessToken
                },
                success: function(response) {
                    $.each(response.data, function(index, clip) {
                        $('#top-5').append('<li><a href="' + clip.url + '">' + clip.title + '</a><br>Views: ' + clip.view_count + '</li>');
                    });
                },
                error: function(xhr, status, error) {
                    console.log(xhr.responseText);
                }
            });
        });
    </script>
</body>
</html>

Make sure you have read the forum rules before posting