Youtube REST API v3 - 在搜索查询结果中包含视频的统计信息 [英] Youtube REST API v3 - include statistics for video in search query result
问题描述
我想使用 Youtube API v3 执行搜索查询.我需要的是检索每个视频的视频 ID 和统计信息.从 docs 我可以看到没有为视频项目返回统计信息.如果我尝试使用此查询查询统计信息:
I want to perform search queries using Youtube API v3. What I need is to retrieve video ids and statistics for each video. From the docs I can see that statistics is not returned for video items. If I try to ask for statistics using this query:
https://www.googleapis.com/youtube/v3/search?type=video&part=snippet,statistics&q=kittens&key={MY_KEY}
我收到一个错误:
{
"error": {
"errors": [
{
"domain": "youtube.part",
"reason": "unknownPart",
"message": "statistics",
"locationType": "parameter",
"location": "part"
}
],
"code": 400,
"message": "statistics"
}
}
所以我想我需要提出两个请求:
So I guess that I need to make two requests:
- 执行实际搜索并检索视频 ID 列表.
- 发出 API 请求 https://developers.google.com/youtube/v3/docs/videos/list 检索每个视频的统计信息.
- Perform actual search and retrieve list of video ids.
- Make API request https://developers.google.com/youtube/v3/docs/videos/list to retrieve statistics for each video.
也许我遗漏了一些东西,有没有一种方法可以在一个搜索查询中获取视频的统计信息?
Or maybe I'm missing something and there's a way to get statistics for videos within one search query?
推荐答案
在指南中,当使用 https://www.googleapis.com/youtube/v3/search.(统计数据不是可接受的值).
In the guide, they specify "the part names that you can include in the parameter value are id and snippet" when using https://www.googleapis.com/youtube/v3/search. (statistics is not an accepted value).
所以我认为你必须像你所说的那样提出两个要求,至少我是这样做的.我找不到任何其他解决方案.我很想知道是否有解决方法...
So I think that you have to make two requests as you say, at least that is what I'm doing. I couldn't find any other solution. I would be interested to know if there was a workaround...
这篇关于Youtube REST API v3 - 在搜索查询结果中包含视频的统计信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!