I am trying to create a Python program to get channel statisitics, but when I run it the YouTube API website gives this output (error):
JavaScript
x
16
16
1
{
2
"error": {
3
"code": 400,
4
"message": "'statisitcs'",
5
"errors": [
6
{
7
"message": "'statisitcs'",
8
"domain": "youtube.part",
9
"reason": "unknownPart",
10
"location": "part",
11
"locationType": "parameter"
12
}
13
]
14
}
15
}
16
This is my code:
JavaScript
1
14
14
1
class YTstats:
2
def __init__(self, api_key, channel_id):
3
self.api_key = api_key
4
self.channel_id = channel_id
5
self.channel_stats = None
6
7
def get_channel_statistics(self):
8
url = f'https://www.googleapis.com/youtube/v3/channels?part=statisitcs&id={self.channel_id}&key={self.api_key}'
9
print(url)
10
11
API_KEY = 'I cannot share my api key so I am not showing it but it is in my code'
12
yt = YTstats(API_KEY, 'UCbXgNpp0jedKWcQiULLbDTA')
13
yt.get_channel_statistics()
14
Advertisement
Answer
This problem is fixed now (it was a typo)