My first attempt at setting up the Google apiclient
for YouTube and by following the docs I made this as a test (didn't find a specific example for the YouTube API):
import json
from apiclient.discovery import build
service = build('youtube', 'v3', developerKey = 'tralalala')
videos = service.videos()
request = videos.list(part = '7lCDEYXw3mM') # some video id
response = request.execute()
json.dumps(response, sort_keys = True, indent = 4)
I get this
{
"error": {
"errors": [
{
"domain": "youtube.parameter",
"reason": "missingRequiredParameter",
"message": "No filter selected.",
"locationType": "parameter",
"location": ""
}
],
"code": 400,
"message": "No filter selected."
}
}
Obviously I'm missing this filter
, but I can't seem to find it anywhere in the docs google-api-client-libraries.appspot.com. My intent is to fetch a videos details by providing its id
.
You need at least one selector to list. 'id' is one of them. You can always check YouTube API Samples project for reference. Here's a Python list usage in one of examples.
Following @pypat's suggestion, I changed the attributes for my list()
method
videos = service.videos()
request = videos.list(part = 'id', id = '7lCDEYXw3mM')
response = request.execute()
With both part
and id
being required to produce a result.
In order to get the full list or properties for a given video, the attribute part
has to include a list of property groups
request = videos.list(part = 'id, snippet, contentDetails, statistics, status, topicDetails',
id = '7lCDEYXw3mM')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With