Advertisement
Guest User

YouTube subs counter

a guest
Jul 14th, 2022
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. <h3><span class="counter"><div id="subscriberCount"></div></span></h3>
  2.  
  3. <!-- Youtube Subs count section start -->
  4.  
  5. <body>
  6. YouTube Subscribers
  7.  
  8.  
  9.  
  10. <script>
  11. const APIKey = '***';
  12. const Userid = '***';
  13. const subscriberCount = document.getElementById('subscriberCount');
  14. const viewCount = document.getElementById('viewCount');
  15. const videoCount = document.getElementById('videoCount');
  16.  
  17.  
  18.  
  19. let getdata = () => {
  20.  
  21. fetch(`https://www.googleapis.com/youtube/v3/channels?part=statistics&id=${Userid}&key=${APIKey}`)
  22. .then(response => {
  23. return response.json()
  24. })
  25. .then(data => {
  26. console.log(data);
  27. subscriberCount.innerHTML = data["items"][0].statistics.subscriberCount;
  28. viewCount.innerHTML = data["items"][0].statistics.viewCount;
  29. videoCount.innerHTML = data["items"][0].statistics.videoCount;
  30.  
  31. })
  32.  
  33. }
  34.  
  35. getdata();
  36. </script>
  37.  
  38. </body>
  39.  
  40. <!-- Youtube Subs count section end -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement