如何列出 YouTube 频道的所有视频,包括每个视频的观看次数

How can I list all videos of an YouTube channel including each video's view count

我正在使用这个link

https://www.googleapis.com/youtube/v3/search?order=date&part=snippet&channelId=[id]&maxResults=200&key=[key]

从我的频道获取所有视频。 我想获得每个视频的观看次数。当我使用 part=statistics 它 returns 一个错误。

很遗憾,想要你想要的实现是不可能的:Search.list API endpoint does not return a video's viewCount 属性.

此行为符合官方规范:response of Search.list has its items property made of search resource 对象。这些对象不提供有关各自 API 资源(视频、频道或播放列表)的详细信息。

当您通过 Search.list 调用获得视频 ID 列表时,您可能会要求 Videos.list API 端点提供与这些视频有关的任何元数据 --包括 viewCount 属性.

请注意,Videos.list 端点接受其请求参数 id to be a comma-separated list of at most 50 video IDs. Also note that (irrespective of the number of actual IDs passed on to id) the quota cost 一次调用 Videos.list1 个单位(非常便宜) .