Twitch API
How do I make an twitch api?
What is a twitch api? How do you make a twitch api? This script and codes were developed by Claudia Contreras on 14 October 2022, Friday.
Twitch API - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Twitch API</title> <link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css'>
<link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <body> <div class="container"> <div class="row"> <h1>TWITCH API</h1> </div> <div class="row"> <h2>Channels</h2> <div class="col-xs-12 cBtns"> <button class="btn" id="allBtn" >All</button> <button class="btn" id="onBtn" >Online</button> <button class="btn" id="offBtn" >Offline</button> </div> <div id="channelDisp"> </div> </div> </div>
</body> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/js/bootstrap.min.js'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Twitch API - Script Codes CSS Codes
body{ background: #45484d; /* Old browsers */
background: -moz-radial-gradient(center, ellipse cover, #45484d 0%, #000000 100%); /* FF3.6-15 */
background: -webkit-radial-gradient(center, ellipse cover, #45484d 0%,#000000 100%); /* Chrome10-25,Safari5.1-6 */
background: radial-gradient(ellipse at center, #45484d 0%,#000000 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#45484d', endColorstr='#000000',GradientType=1 ); color:white;
}
a{ color:white;
}
a:hover{ color:white;
}
.row h1{ text-align:center; color:white; font-weight:bold;
}
.row h2{ color:white; text-align:center;
}
.cBtns{ text-align:center;
}
button{ color:black; font-weight:bold;
}
.streamer{ margin-top:20px; padding:20px; border-top-right-radius:10px;
}
.streamerInfo{ background-color:gray; padding:5px; border-top:2px dashed white; border-bottom-right-radius:10px; border-bottom-left-radius:10px;
}
.streamerSearch{ margin-top:20px; padding:20px; border-top-right-radius:10px;
}
.streamerInfoSearch{ background-color:gray; padding:5px; border-top:2px dashed white; border-bottom-right-radius:10px; border-bottom-left-radius:10px;
}
.sImage{ width:80px; height:auto; border-radius:50px;
}
.sName{ margin-left:20px;
}
.sStatus { margin-left:20px;
}
.red{ background-color:rgba(243, 0, 0, 0.54);
}
.green{ background-color:rgba(23, 177, 23, 0.57);
}
.gray{ background-color:rgba(186,185,185, 0.54);
}
Twitch API - Script Codes JS Codes
$(document).ready(function(){ var users = ["freecodecamp", "storbeck", "OgamingSC2", "habathcx","RobotCaleb","brunofin","noobs2ninjas","cretetion"] var cname = ""; var logo; var name; var game; var descr; var cstatus; var bcolor; //check the api call for all users in our users array for(var i = 0 ; i < users.length; i++){ var isStreaming; //check to see if channels are currently streaming $.getJSON('https://wind-bow.hyperdev.space/twitch-api/streams/'+ users[i] +'?callback=?', function(data){ if(data.stream){ isStreaming = true; }else{ isStreaming = false; } }); $.getJSON('https://wind-bow.hyperdev.space/twitch-api/channels/'+ users[i] +'?callback=?', function(data){ if(data.error){ //if user no longer exists, display message $('#channelDisp').append('<div class="col-xs-12 streamer gray">' + '<img src="' + "http://placehold.it/60x60" + '" alt="" class="sImage pull-left" />'+ '<h3 class="pull-left sName">' + data.message +"</h3>" + "</div>" + "<div class='col-xs-12 streamerInfo gray'>" + "<p class='pull-left '>" + "<strong>Channel Info:" + "</strong>" + " Account Closed" + "</p>" + "</div>" + "</div>"); }else if (isStreaming === true){ //if user exists and is currently streaming get channel info logo = data.logo; name = data.display_name; cname = data.name; game = data.game; descr = data.status; bcolor = "green" cstatus = "Currently Streaming: " //display information on page $('#channelDisp').append('<div class="col-xs-12 streamer '+ bcolor +'">' + '<img src="' + logo + '" alt="" class="sImage pull-left" />'+ '<h3 class="pull-left sName">' + "<a href='https://www.twitch.tv/" + cname + "' target= '_blank'>" + name + "</a>" +"</h3>" + "<a href='https://www.twitch.tv/" + cname + "' class='pull-right sStatus'>" + cstatus + " " + game + "</a>" +"</div>" + "<div class='col-xs-12 streamerInfo " + bcolor + "'>" + "<p class='pull-left'>" + "<strong>Channel Info: </strong>" + descr + "</p>" + "</div>"); }else{ //if user exists but is not currenlty streaming get channel info var logo = data.logo; name = data.display_name; cname = data.name; game = ""; descr = data.status; bcolor = "red"; cstatus = "Offline"; if(!data.status){ descr = 'This user has not provided any channel information'; } //display information on page $('#channelDisp').append('<div class="col-xs-12 streamer '+ bcolor +'">' + '<img src="' + logo + '" alt="" class="sImage pull-left" />'+ '<h3 class="pull-left sName">' + "<a href='https://www.twitch.tv/" + cname + "' target= '_blank'>" + name + "</a>" +"</h3>" + "<a href='https://www.twitch.tv/" + cname + "' class='pull-right sStatus'>" + cstatus + " " + game + "</a>" +"</div>" + "<div class='col-xs-12 streamerInfo " + bcolor + "'>" + "<p class='pull-left'>" + "<strong>Channel Info: </strong>" + descr + "</p>" + "</div>"); } }); }
//filter channel on button click based on class that is applied to div $("#onBtn").on("click", function(){ $(".red").hide(); $(".green").show(); $(".gray").hide(); }); $("#allBtn").on("click", function(){ $(".green").show(); $(".red").show(); $(".gray").show(); }); $("#offBtn").on("click", function(){ $(".green").hide(); $(".red").show(); $(".gray").show(); });
});
Developer | Claudia Contreras |
Username | coderpilot |
Uploaded | October 14, 2022 |
Rating | 3 |
Size | 3,412 Kb |
Views | 34,408 |
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!
Name | Size |
Weather App | 2,688 Kb |
Walt Disney Tribute Page | 3,635 Kb |
Random Quote Generator | 2,677 Kb |
Wikipedia API | 2,802 Kb |
TEst | 1,622 Kb |
Coder Pilot Portfolio | 5,826 Kb |
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!
Name | Username | Size |
Marching Squares Visualized | Sakri | 7,074 Kb |
Loader | MikitaLisavets | 3,321 Kb |
Animated skewed panes | NyX | 4,462 Kb |
CSS Patterns | Alyda | 3,953 Kb |
Spiralator 9000 | AdmiralPotato | 4,671 Kb |
Filter inputs | Rowinf | 1,721 Kb |
SlideDown FixedMenu | Mp_graphic | 5,602 Kb |
FontAwesome icons with animation | Nicotinell | 2,083 Kb |
Prototype Responsive Homepage | Heyitsolivia | 7,677 Kb |
Motion Lines - codevember - 02 - 2016 | Caiocares | 2,744 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!