Codeconia -Learn Programming

How to Get YouTube Subscriber , Views and Video Counts using JavaScript

Hello guys,

Today we are going to make a javascript for getting the youtube channel subscriber count, total video views count, and total videos count. so we need an API key for that ..   Go to this website Create a project ->

the click library  -> search for YouTube Data API v3 ->

then Enable it  -> then click create credentials -> select Credential Type Public -> and get the api key

now get your channel ID  and start coding

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>YouTube API</title>
    YouTube Subscribers
    <div id="subscriberCount"></div>

    YouTube Video Views
    <div id="viewCount"></div>

    YouTube Video Count
    <div id="videoCount"></div>


    const APIKey = 'Your API Key here';
    const Userid = 'Your Channel ID here';
    const subscriberCount= document.getElementById('subscriberCount');
    const viewCount = document.getElementById('viewCount');
    const videoCount = document.getElementById('videoCount');


    let getdata = () => {

        .then(response => {
            return response.json()
        .then(data => {
            subscriberCount.innerHTML = data["items"][0].statistics.subscriberCount;
            viewCount.innerHTML = data["items"][0].statistics.viewCount;
            videoCount.innerHTML = data["items"][0].statistics.videoCount;








Ajith Jojo

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.

Most popular