 So for this tutorial I'm using Visual Studio Code and we will be using only one file and this will be the index.html and let me zoom in a little bit more so you can see I don't know whether this is too much but it'll be easier to see on mobile devices I guess so this is this is where we'll be adding pretty much everything in terms of we won't be writing any CSS so we're just going to do a little bit of JavaScript and that's why I'm not going to be creating another JS file but you can do that if you wish so let's start by writing the HTML quickly and I'm just going to be using the emit abbreviation here and I'm going to select HTML5 then let's change the title to YouTube API and then inside here at the bottom I'm going to add the script tag and this is where we'll be writing all JavaScript and then here at the top let's name this document something like YouTube subscribers and then we can create a div with the ID of SerpCount and this is where we'll be adding the number of the subscriptions that we will take of the YouTube API. Let's see what we have first of all if we go to the browser as you can see we just have YouTube subscribers and I will zoom in a little bit so you can see and then we'll add the number let's now focus on the JavaScript and let's start with creating two variables so the first variable is going to hold our YouTube key and the second variable is going to hold the YouTube username so we can do columns to YouTube key and for now we'll have an empty we'll get the YouTube key in a second and for the YouTube username we'll do the same and then we'll add the username here in a second so actually let's go ahead and get the YouTube username for this you can go to your YouTube channel you can do www.youtube.com slash your YouTube channel name but this is not the actual ID that we need if you click on videos the ID will be just be in between channels and videos so let's copy this ID in here from here and we can paste the ID in here so this is all YouTube ID now we need to register for the YouTube API key and let's see how we can do that so go to your browser and navigate to console.developers.google.com slash apis slash library if you don't have an account obviously you have to create a new one and then once you create an account let's go and create a new project to create a new project you can click in here and then right here on the top right corner you can just click new project and let's call this YouTube API and then we can just click create now that we have this project created it's going to take a second to see then the API that we need is the YouTube API so let's search for YouTube and the one that we need is YouTube Data API v3 and I've actually selected the wrong project so let me go back and click YouTube API and as you can see we need to first of all enable this API so let's do that it will take a second to create the API for you and then the next thing that we need to do is here on the right side of the screen you will see create credentials so let's click on that and the first thing that we need to choose in here is YouTube Data API v3 then we need to select web browser JavaScript and then we can just use public data after we've done this we need to click on this blue button and then that will give us the credentials so let's copy this for project go back to video studio code and paste this in here let's save and just before we continue with this let me just walk you through this as well we can click done but also if you wish to you can actually restrict this API to be used on different platforms or from different APIs let me show you so for example when you click on your API you can restrict this application to be used just from specific API addresses Android apps iOS apps and so on at the moment I don't want to restrict this API key and after this video I'm also going to be removing this API key so you won't be able to actually use it so let me save this and go back to our application and continue coding okay so now we need to create the function that will go and grab the the data we can do this without the function but let's wrap it in a function just so just in case you want to want to add more stuff and do more stuff too now let's get the data from the youtube API and to do this I'm just going to wrap everything in a function called get subscribers so let's do let get subscribers and this will be an arrow function okay and now we're going to use the fetch API which as a default uses the get method which makes it very easy for us so what we have to do is do fetch and now we need to put the URL that we want to fetch you can go to the to the console.developers.google.com and then you can literally go to your dashboard and if you click in here youtube data api v3 and then try in api explorer this will give you all the documentation that you need for example we're going to be using this URL we're going to be using the get method and we're also going to be using the uh channels here and let's paste the URL and then after this as you saw we can do channels and how to do a little bit more research to get the statistics but you can have a look at the documentation in a little bit more details and to do this to do to get the statistics all we have to do is do part equals statistics and now we need to add the youtube id or in this case this is our youtube username and to do this we can do dollar sign curly bracket and inside here we can just pass the variable youtube user and now we have to pass the youtube key as well and to do this is ant key equals dollar sign curly bracket and then youtube key okay we're done with this the next thing that we need to do is finish or fetch and because it's kind of hard to see i'm going to indent this back slightly like this and now we need to do then so we can get a response and we can do return response and the response is going to be jason and then we need to grab the data and now we can literally do anything we like with this data object so first of all let's see whether this all this worked and to test this we can simply console log the data and obviously this is not going to work because we have not called this function yet so let's do that below get subscribers and let's have a look whether we get any data from the api if you go back to the browser and click and right click inspector element then you can do console and then i'm just going to zoom in a little bit so you can see i don't know if you can see now but this brings this brings jason objects for us and inside this object we get an items array and if i click in in this to expand it we get another object and inside this object is actually all the data that we need so this is where the statistics are so let's expand the statistics and basically you can get from here you can get comment count hidden subscriber count subscribe subscriber count video count and view count so for this tutorial let's simply grab the subscriber count and i'm going to copy this actually and so we just need to go down this tree and then output this let's go back to our editor now let's select this div so we can insert the youtube subscriber count and to do this let's create a variable in here const and let's call a sub count and the sub count will be equals document dot get element by id and the id is obviously sub count now we can use this variable to actually insert to insert the data and to do this we can go in here and we can do sub count dot inner html and the inner html will be equals data and now we need to go down the tree as i showed you earlier and the tree goes something like this data items we need to select the first object then we need to go down to statistics and then we need to go down to subscribers subscriber count okay so let's save this and as you can see we are now getting the youtube subscriber count in here which is exactly what we wanted and just to show you how the tree worked so we selected the object then we went to items then we went to the first object then we went to statistics and then we went to subscriber count just like this and that's it and that's everything from this tutorial of course you can do a set interval to listen for new subscribers if you like and so on if you like this video please give it a thumbs up if you like my channel please consider subscribing and don't forget to leave a comment below thank you very much for watching i'll see you in the next tutorial