How can I make a realtime YouTube subscriber count?

I’m a Roblox YouTuber/Developer.

I would like to create a live event with my viewers to celebrate a subscriber milestone. However, I’m stuck on one problem:
Creating the live subcount.

Additionally, (as long as this is allowed) I will give 3k robux or more to whoever can fully fix this problem.

There’s a couple of problems that occur when attempting to create a subcount that displays in real time – but the primary one is this:

The YouTube API does not allow for specific numbers. For example, if I had 72,142 subscribers, it would only display 72,100. The only workaround for this is to be signed in to the account. When I’m signed in, I can view the exact amount of subscribers I have.

What I see:

What third parties see:

Here is a tutorial on how to do it. However, this tutorial still causes the number to be rounded. If anyone knows a workaround for this, please let me know.

My question is:
How can I create an accurate subscriber count that displays in real-time?

All responses are appreciated!! :slight_smile:

2 Likes

Unfortunately, the only (public) youtube api gives the rounded result (Channels  |  YouTube Data API  |  Google for Developers)

While I’m not great with scraping html data, if you really need the accurate count your best bet would be to either

  1. Use an “estimate” (come up with a somewhat random number)
  2. (The crackhead way) leave your pc on and find some way to scrape the html data from that webpage, then display it in the game.

Again, not an API guy, just taking a guess and feel free anyone to correct me :^)

4 Likes

Ah wow this is a difficult problem. In general I wouldn’t advise working around APIs as it always means breaking the terms of service, however if you really need to do this you could make it using puppeteer (https://pptr.dev/) and a server (replit.com seems good for this). Read up there if you dare. This is the way to do it the “crackhead way” as @RealMysticall said. Probably the best solution though is to just figure out a way to make it work with rounded numbers.

Edit for clarity.

4 Likes

Mind explaining where this goes against the terms of service? I wasn’t aware that this wasn’t allowed.
Additionally, I’m not experienced enough at all to do that so I would need to have a step-by-step guide or hire a developer to make it for me. (Most likely the latter :laughing:)

Thanks!

2 Likes

Also, now that I see how difficult this would be to solve, I’m adding a 3,000 robux (or more) prizepool for whoever can fix this problem (as long as this is allowed by the devforum).

2 Likes

Hey! Although its not easy through youtube.com there are other websites that use GET requests to show a live sub count for channels, using one of them we can use this script to get an estimate of your subscribers:

local http = game:GetService('HttpService')

local channel_id = 'UCs6yDXwXuKeLoz0d87Uhosg'
local url = 'https://api.socialcounts.org/youtube-live-subscriber-count/'..channel_id

local success,data = pcall(function()
	return http:GetAsync(url)
end)

if data then
	local decoded = http:JSONDecode(data)
	local subs = decoded["est_sub"]
	print(subs)
end

1 Like

Check these out :^)

1 Like

no way im bouta be rich (idk if my solution follows roblox TOS pretty sure it does)

2 Likes

This is, unfortunately, an estimation. If OP doesn’t need anything exact than this is fine but it only gives a relatively rough estimate.

2 Likes

I’ve never heard anything about sending external API calls being against Roblox TOS? Maybe I could just be stupid but I’ve never seen this

1 Like

I have so many questions!!

How does this site access realtime info?
Why does no other site access info in realtime like this one?
How am I just now finding out about this?

I’ll test this and get back to you! Thanks.

1 Like

You’re going to have to scrape the from the analytics page that you’re viewing. You’re gonna have to run a webserver using something like aws, or if you want to be cheap you could run it off your pc.

1 Like

neither,

this is what I’m basing that off but I’m too lazy to check

1 Like

Best guess is youtube has a private API they only release to certain people. Either that or they just have some really good estimation tactics.

(Nevermind)

I believe using https://cloud.google.com/ you are able to achieve this, they have their own section for setting up a youtube statistics API

1 Like

What does this mean? I’m a bit confused on the wording.

1 Like

Affiliate link

This uses the same API as the youtube one, cloud is just like a big umbrella for developers.

2 Likes

The website calculates the last two numbers based on addition info (views per hour + other data) on their own, and gets the rest from the youtube api.

1 Like

That shocks me! As I’m able to dynamically unsubscribe and resubscribe and within a matter of seconds the sub count correctly updates. I’m so confused as to how this works?

1 Like

Genuinely no idea. Unless youtube doesn’t want people knowing about them having a private api of sort so they have to use that as a coverup (which I find hard to believe) there has to be some api message which detects when someone unsubscribes / resubscribes.

Sorry I can’t be of much more help, late where I am and the last thing I want to do is dig through the youtube api :rofl: