Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

YouTube API v3 apiclient.errors.HttpError "No filter selected." - where do I select a filter?

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.

like image 732
Morgan Wilde Avatar asked May 24 '13 12:05

Morgan Wilde


2 Answers

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.

like image 114
Ibrahim Ulukaya Avatar answered Oct 15 '22 16:10

Ibrahim Ulukaya


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')
like image 25
Morgan Wilde Avatar answered Oct 15 '22 16:10

Morgan Wilde