按关键字和类别ID搜索YouTube API

时间:2013-08-30 10:53:47

标签: api request youtube-api

我正在尝试按类别ID和关键字搜索视频。

这是我的链接:

https://www.googleapis.com/youtube/v3/search?part=snippet&key=API_KEYs&videoCategoryId=10&q=bieber

我得到了:

{
 "error": {
  "errors": [
   {
    "domain": "youtube.search",
    "reason": "invalidSearchFilter",
    "message": "Invalid combination of search filters and/or restrictions.",
    "locationType": "parameter",
    "location": ""
   }
  ],
  "code": 400,
  "message": "Invalid combination of search filters and/or restrictions."
 }
}

我的api请求应该改变什么?

1 个答案:

答案 0 :(得分:6)

Data API具有统一搜索功能,即搜索返回视频,播放列表和频道。要按视频特定参数(如videoCategoryId)进行过滤,您必须定义“type = video”

https://www.googleapis.com/youtube/v3/search?part=snippet&q=bieber&type=video&videoCategoryId=10&key={YOUR_API_KEY}