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
傳回頻道或內容擁有者可擷取的報表類型清單。 |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2023-02-22 (世界標準時間)。
[null,null,["上次更新時間: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"]]