« ^ »
[WIP]

Youtube Analytics and Reporting APIsを使う

所要時間: 約 1分

Youtube Analytics and Reporting APIを用いて各種情報を自動で収集する方法を調査する。

https://developers.google.com/youtube/analytics/sample-requests

GET https://youtubeanalytics.googleapis.com/v2/reports metrics=views,comments,likes,dislikes,estimatedMinutesWatched,averageViewDuration

GET https://youtubeanalytics.googleapis.com/v2/reports
{
  "error": {
    "code": 401,
    "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
    "errors": [
      {
        "message": "Login Required.",
        "domain": "global",
        "reason": "required",
        "location": "Authorization",
        "locationType": "header"
      }
    ],
    "status": "UNAUTHENTICATED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "CREDENTIALS_MISSING",
        "domain": "googleapis.com",
        "metadata": {
          "service": "youtubeanalytics.googleapis.com",
          "method": "google.youtube.analytics.v2.TargetedQueriesService.Query"
        }
      }
    ]
  }
}

// GET https://youtubeanalytics.googleapis.com/v2/reports
// HTTP/1.1 401 Unauthorized
// WWW-Authenticate: Bearer realm="https://accounts.google.com/"
// Vary: Origin
// Vary: X-Origin
// Vary: Referer
// Content-Type: application/json; charset=UTF-8
// Date: Tue, 13 Dec 2022 01:30:19 GMT
// Server: ESF
// Cache-Control: private
// X-XSS-Protection: 0
// X-Frame-Options: SAMEORIGIN
// X-Content-Type-Options: nosniff
// Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
// Transfer-Encoding: chunked
// Request duration: 1.311815s