Today, I tested Google Apps Script to get data from youtube dashboard, because I make some streams on youtube and another social platforms.
The source code is large, but I will show this part to understand the basics:
function getChannelStats() {
const response = YouTube.Channels.list(
"snippet,statistics",
{ mine: true }
);
const ch = response.items[0];
return {
title: ch.snippet.title,
subs: Number(ch.statistics.subscriberCount),
views: Number(ch.statistics.viewCount),
videos: Number(ch.statistics.videoCount)
};
} ...