当前位置: 首页 > 知识库问答 >
问题:

YouTube Analytics API-按内容所有者的频道分组的总视图

晏志明
2023-03-14

我正在尝试获取内容所有者拥有的每个频道的总视图。

我可以得到所有频道的总视图,但我想得到每个频道的视图。

以下是我尝试的代码。我设置了一个 dimensions=channel 来执行此操作,但它返回了 400 错误。


from googleapiclient.discovery import build


analytics_service = build("youtubeAnalytics", "v2", credentials=credentials)

report_result = analytics_service.reports().query(
    ids= f'contentOwner=={owner_id}',
    startDate='2020-12-01',
    endDate='2021-03-30',
    dimensions='channel',  # <-- It raise the error.
    metrics='views,comments,likes,dislikes',
    filters='uploaderType==self',
).execute()

错误:

HttpError: <HttpError 400 when requesting https://youtubeanalytics.googleapis.com/v2/reports?ids=contentOwner%3D%3DkNuvRJ6GzXE5GEKbcUp7MA&startDate=2020-12-01&endDate=2021-03-30&dimensions=channel&metrics=views%2Ccomments%2Clikes%2Cdislikes&filters=uploaderType%3D%3Dself&maxResults=10&sort=-views&alt=json returned "The query is not supported. Check the documentation at https://developers.google.com/youtube/analytics/v2/available_reports for a list of supported queries.". Details: "The query is not supported. Check the documentation at https://developers.google.com/youtube/analytics/v2/available_reports for a list of supported queries.">

我检查了API的文档,但我找不到获取它的方法。
请告诉我您是否知道任何好的方法来做到这一点。

谢谢。

共有1个答案

程举
2023-03-14

我无法具体想出一种方法,但您始终可以派生所有通道ID,并为每个通道ID发出请求,并像这样获取它。

from googleapiclient.discovery import build


analytics_service = build("youtubeAnalytics", "v2", credentials=credentials)

report_result = analytics_service.reports().query(
    ids= f'contentOwner=={owner_id}',
    startDate='2020-12-01',
    endDate='2021-03-30',
    dimensions='day',
    metrics='views,comments,likes,dislikes',
    filters='channel=={channelID};uploaderType==self',
).execute()
 类似资料:
  • 我已阅读YouTube-分析和报告API的留档,我能够作为频道所有者或内容所有者提取分析数据。是否有API来提取我在YouTube中不拥有的视频的指标?

  • YouTube Analytics API 提供兩種類型的報告 https://developers.google.com/youtube/analytics/v1/reports 1.频道报告2.内容所有者报告。 有人能解释YouTube渠道和内容所有者之间的区别吗?

  • 问题内容: 我想获取特定频道的所有视频网址。我认为带python或java的json是一个不错的选择。我可以使用以下代码获取最新的视频,但是如何获得所有视频链接(> 500)? 问题答案: 将最大结果从1增加到您想要的任何数目,但是请注意,他们不建议一次通话就抓住太多,并且将您限制为50(https://developers.google.com/youtube/2.0/developers_gu

  • 我想获取具有Id的单个频道的所有视频。我只得到频道信息的问题。这是我正在使用的链接: https://g data . YouTube . com/feeds/API/users/UCD CIB _ pnqpr 0m _ kkdg 4d z5 a?v=2

  • 我使用YouTube数据API从一个频道获取视频信息。API响应不包括上传到相应频道的所有视频。 这是频道(现在有6个视频):https://www.youtube.com/channel/UCdSjDEx46aNP0oKPN_J6hOA/videos 视频列表(现在):https://i.ibb.co/K91bJxS/image.png 这是我的API调用:https://www.googlea

  • 因此,我正在尝试使用货币分析API来获取给定YouTube频道的收入报告。https://developers.google.com/youtube/analytics/v1/content_owner_reports 但是,要使用此API,需要以下内容: 要检索内容所有者报告,请将API请求中的id参数值设置为contentOwner==OWNER_NAME,其中OWNER_NAME指定内容所有