Twitch JSON API

Size
2,808 Kb
Views
40,480

How do I make an twitch json api?

A Twitch JSON API for a FreeCodeCamp zipline.. What is a twitch json api? How do you make a twitch json api? This script and codes were developed by Joo Vctor De Oliveira Santos on 27 August 2022, Saturday.

Twitch JSON API Previews

Twitch JSON API - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Twitch JSON API</title> <link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="container"> <div class="row"> <div class="page-header"> <h1 class="text-center">Twitch Streamers</h1> </div> </div> </br> <div class="row"> <div class="col-sm-6 col-sm-offset-3"> <div id="itemContainer" class="list-group"> </div> </div> </div>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Twitch JSON API - Script Codes CSS Codes

.logo{
width:45px;
height:45px;
}
.itemTable{ width:100%;
}

Twitch JSON API - Script Codes JS Codes

var onlineBadge = '<sup><span class="label label-success label-as-badge">Online</span></sup>';
var template = '<a href="{USER_LINK}" target="_blank"><table class="itemTable table table-hover"><tr class="{TABLE_COLOR}"><td style="width:50px;height:50px"><img id="{USERNAME}_img" src="{IMAGE_LOGO}" class="img-responsive img-circle logo"></img></td><td class="text-left" style="padding-left: 25px;width:150px">{USERNAME} {IS_ONLINE}</td><td class="text-center"><span>{STATUS}</span></td></tr></table></a>';
var channels = ["freecodecamp", "comster404", "storbeck", "terakilobyte", "habathcx", "RobotCaleb", "thomasballinger", "noobs2ninjas", "beohoff"];
function generateItem(table_color, status, username, image, user_link) { var item = template.replace(/{TABLE_COLOR}/g, table_color).replace(/{STATUS}/g, status).replace(/{USERNAME}/g, username).replace(/{USER_LINK}/g, user_link).replace(/{IMAGE_LOGO}/g, image).replace(/{IS_ONLINE}/g, (table_color == "success") ? onlineBadge : ""); return item;
}
function load() { $.each(channels, addChannel);
}
function getUserImage(username) { var change = "/{" + username + "_image}/g"; $.getJSON("https://api.twitch.tv/kraken/users/" + username, function(json) { //alert( json.logo); if (json.logo == null) $("#" + username + "_img").attr("src", "http://www.iau.usp.br/pesquisa/grupos/arqtema/images/Imagens/sem_perfil.jpg"); else $("#" + username + "_img").attr("src", json.logo); });
}
function addChannel(i, channel) { var username = channel; //Can i do that? var userLink = "http://www.twitch.tv/" + username; $.ajax({ url: 'https://api.twitch.tv/kraken/streams/' + username, dataType: "json", complete: function(data, status) { json = data.responseJSON; var table_color; var status; var image; if (json.stream !== null && json.stream !== undefined) { //is Online //Get stream infos status = json.stream.channel.status; table_color = "success"; } else if (json.stream === null) { //is Offline table_color = "info"; status = "Offline"; } else { table_color = "danger"; status = "Account Closed"; } image = "http://www.iau.usp.br/pesquisa/grupos/arqtema/images/Imagens/sem_perfil.jpg"; var item = generateItem(table_color, status, username, image, userLink); $('#itemContainer').append(item); getUserImage(username); } });
}
load();
Twitch JSON API - Script Codes
Twitch JSON API - Script Codes
Home Page Home
Developer Joo Vctor De Oliveira Santos
Username jvhti
Uploaded August 27, 2022
Rating 3
Size 2,808 Kb
Views 40,480
Do you need developer help for Twitch JSON API?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Joo Vctor De Oliveira Santos (jvhti) Script Codes
Create amazing video scripts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!