YouTube Reporting API
利用 YouTube Reporting API,开发者可以安排报告作业,然后下载生成的批量报告。该 API 支持一组预定义的报告,每个报告都包含针对频道或内容所有者的一套全面的 YouTube 数据分析数据。
下面的步骤说明了如何安排报告作业时间和检索报告:
- 调用
reportTypes.list()
方法来检索频道或内容所有者可以检索到的报告的列表。 - 调用
jobs.create()
方法,确定应为频道或内容所有者生成的报告。然后,您就可以使用该 API 的 jobs.list()
和 jobs.delete()
检索或更改要生成的报告列表。 - 调用
jobs.reports.list()
方法来检索为特定作业生成的报告列表。响应中的每个资源都包含一个 downloadUrl
属性,用于指定可供下载报告的网址。 - 发送经过授权的
GET
请求,以从下载网址检索报告。
授权
所有 YouTube Reporting API 请求都必须获得授权。授权指南介绍了如何使用 OAuth 2.0 协议检索授权令牌。
YouTube Reporting API 请求使用以下授权范围:
权限范围 |
https://www.googleapis.com/auth/yt-analytics.readonly |
查看有关您的 YouTube 内容的 YouTube 数据分析报告。通过此范围,您可以访问用户活动指标,例如观看次数和评分计数。 |
https://www.googleapis.com/auth/yt-analytics-monetary.readonly |
查看 YouTube 分析工具为您的 YouTube 内容出具的财务报告。通过此范围,您可以访问用户活动指标,以及估算收入和广告效果指标。 |
资源类型
以下部分提供了 API 的资源和方法的一般说明。表中显示的所有方法 URI 均相对于 https://youtubereporting.googleapis.com
。
方法 |
create |
POST /v1/jobs
创建报告作业。创建报告作业,即表示您指示 YouTube 每天生成一次此报告。报告会在作业创建后的 24 小时内生成。 |
delete |
DELETE /v1/jobs/{jobId}
删除报告作业。 |
get |
GET /v1/jobs/{jobId}
检索已为频道或内容所有者安排的特定报告作业的相关信息。 |
list |
GET /v1/jobs
列出已针对频道或内容所有者安排的报告作业。响应中的每个资源都包含一个 id 属性,该属性用于指定 YouTube 用来唯一标识招聘信息的 ID。您需要使用该 ID 来检索为作业生成的报表列表或删除作业。 |
方法 |
get |
GET /v1/jobs/{jobId}/reports/{reportId}
检索特定报告的元数据。 |
list |
GET /v1/jobs/{jobId}/reports 列出为指定报告作业生成的报告。 |
方法 |
list |
GET /v1/reportTypes
返回可供频道或内容所有者检索的报告类型列表。 |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2023-02-22。
[null,null,["最后更新时间 (UTC):2023-02-22。"],[[["The YouTube Reporting API allows developers to schedule and download bulk reports containing comprehensive YouTube Analytics data for channels or content owners."],["Developers can use the API to retrieve a list of available reports, create jobs to generate reports, and manage these jobs through listing and deletion."],["Generated reports can be downloaded via a specified URL obtained from the API's response, after retrieving them by using the `jobs.reports.list()` method."],["The API requires OAuth 2.0 authorization, and provides scopes for viewing user activity metrics (`https://www.googleapis.com/auth/yt-analytics.readonly`) and monetary reports (`https://www.googleapis.com/auth/yt-analytics-monetary.readonly`)."]]],["Developers use the YouTube Reporting API to schedule and download bulk reports containing YouTube Analytics data. Key actions include: listing available report types via `reportTypes.list()`, creating reporting jobs with `jobs.create()`, and managing jobs using `jobs.list()` and `jobs.delete()`. To get data, retrieve generated reports for a specific job with `jobs.reports.list()`, each with a downloadable URL. Finally, you can request the download using the given URL. All actions require authorization via OAuth 2.0.\n"]]