Ever since I started the channel I wanted to build myself a subscriber counter to use it as a decoration in my home office and make a video of the process. However, my dreams were almost crushed by YouTube when they announced that they will no longer provide the full count through the API.
Instead, since they were unifying the display of data across the platform, if you had 12,345 subscribers, for example, they will display 12.3K instead while the API will return 12300.
This is really bad and quite boring for a subscriber counter but then I read a piece of information that kinda stuck to my head.
The full count will still be available from the Analytics API!
I’ve dug up the documentation for it and yet again I was disappointed to find out the handy API key authorization is not available for it and only OAuth can be used.
How can I make this work?? How to provide consent for getting the data out and use it in a device that has no browser capabilities?
I’ve had these questions in my head for several weeks and about two weeks ago I had a breakthrough and I now introduce you to YouTube Sight.
Sight is an open-source application built with Laravel that allows you to connect your YouTube channel and you are presented with a dashboard of your basic metrics from the YouTube Analytics API. The nice thing about it is that once you connect the application with your account on YouTube, the application generates a direct URL specific to your channel that you can use with your subscriber counter without any login.
To connect your device, you can check out the example implementation that is also available on GitHub, where you simply need to make a single HTTP request and get full data for your channel, containing the total number of views, gained and lost subscribers count, current subscriber count, estimated minutes watched and the average view duration for your channel.
The data is provided as a string and in the example repo on GitHub, I’ve added a function that can extract each individual metric for your convenience.
Since the Analytics API functions quite differently than the Data API, the data presented here is not always the actual real-time situation from the channel. YouTube usually aggregates the views and subscribers data at intervals of about a day, so there will always be a slight difference compared to the creator studio. However, this is a lot better than just showing a nice rounded number for long periods of time.
Currently, I have the tool hosted on a shared server ($50 off promo!) where I don’t really have a lot of resources so I’ve implemented a rate limit of 30 requests per minute from a single IP address. With that, I give you the right to fetch new data every two seconds which I think should be more than enough especially with the aggregation of data by YouTube and possible changes of once per day.
However, I strongly advise that you reconsider this limit when you do your counter and do something like once every 10 seconds or once a minute even. It will be really beneficial to me as I can keep the server costs low and it will present basically no difference to you in the display of the stats on the subscriber counter.
Even though the API URL is kind of private, you are free to share it with the world if you choose to. This way you can allow for fans to create subscriber counters for your channel, add them to websites and track your real progress from basically anywhere.
Feel free to give it a spin, connect your channel and fix your broken subscriber counter today!