I having some trouble to understand something related to the API of youtube So my code is basically very simple:
name = input("enter the username: ")
key = "MY API KEY"
data = urllib.request.urlopen("https://www.googleapis.com/youtube/v3/channels?
part=statistics&forUsername="+name+"&key="+key).read()
subs = json.loads(data)["items"][0]["statistics"]["subscriberCount"]
print(name + " has " + "{:,d}".format(int(subs)) + " subscribers!")
just yelling the number of subscribers after giving specific YouTube Username: The thing is that some Usernames(for example: Vsuase/Veritasium/Unbox Therapy ) which have many subs and the API-URL giving me wrong Data
Vsause - in return giving me back 72 subs
Veritasium/Unbox Therapy - not giving my any number at all
BUT, a channel "Computerphile" giving me that exact same subs they have.
How come that few Usernames work and few do not??
I tested in both, using the try-it functionality available in the YouTube Data API - Official Documentation and in the Google API Explorer and in both sites the results are closely1 similar.
For example, when the statistics of the YouTube user
vsauceis requested vía YouTube API, the value insubscriberCountis14220819and checking his YouTube channel it says:14,220,825.Here is the example for request the statistics of the YouTube user
vsauce(using the try-it)And here is the demo for request the statistics of the YouTube user
vsauce(using the Google API Explorer).I didn't see any differences in the values in
subscriberCountby requesting the other channels you mentioned in your question.1 You need consider that some channels has more changes in the quantity of subscribers than others and such results vary too in the responses of the API.