Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3642

Get detailed watch time data from YouTube endpoints

$
0
0

I'm looking to create a piece of software that sends requests to YouTube's server on behalf of the user and organizes the watch time data nicely into charts

So far, I have come up with the following:

async function getYouTubeAnalyticsData(result: GoogleTokensResult) {  // https://developers.google.com/youtube/analytics/content_owner_reports  const params = {    dimensions: "day",    startDate: "2023-07-01",    endDate: "2023-08-02",    ids: "channel==MINE",    // https://developers.google.com/youtube/analytics/metrics    metrics: "views,estimatedMinutesWatched,averageViewDuration,averageViewPercentage"  };  const searchParams = new URLSearchParams(params);  // https://developers.google.com/youtube/analytics/reference/reports/query  const response = await fetch(`https://youtubeanalytics.googleapis.com/v2/reports?${searchParams}`, {    headers: {      Authorization: `Bearer ${result.access_token}`    }  });  return response.json();}

The problem is that I only get a basic report
In this case, the output shape returned by getYouTubeAnalyticsData is:

{"columnHeaders": [    {"name": "day", "columnType": "DIMENSION", "dataType": "STRING"}, {"name": "channel", "columnType": "DIMENSION", "dataType": "STRING"},    {"name": "views", "columnType": "METRIC", "dataType": "INTEGER"},    {"name": "estimatedMinutesWatched", "columnType": "METRIC", "dataType": "INTEGER"},    {"name": "averageViewDuration", "columnType": "METRIC", "dataType": "INTEGER"},    {"name": "averageViewPercentage", "columnType": "METRIC", "dataType": "FLOAT"},  ],"kind": "youtubeAnalytics#resultTable","rows": [    ["2023-07-01", "CHANNEL_ID", 27, 39, 87, 11.95],    [...]  ]}

Instead, I'm looking to get much deeper data, for example:

  1. In day 1, the user watched 100s in channel A and 200s in channel B
  2. In day 2, the user watched 300s in channel C and 400s in channel D

Viewing all articles
Browse latest Browse all 3642

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>