Itβs easier to do this, please check the code snippet below to find demographic and gender statistics:
request.get({ url:'https://www.googleapis.com/youtube/analytics/v1/reports?key={Google Api Key}&ids=channel=={channelId}&dimensions=country&metrics=views&end-date={endDate}&start-date={startDate}', json:true, timeout: 10000, headers:{'Authorization':'Bearer '+accessToken}}, function (err,r,result) { console.log(result) });
If you need to find sex information below the code, you can use the code snippet:
request.get({ url:'https://www.googleapis.com/youtube/analytics/v1/reports?key={Google Api Key}&ids=channel=={channelId}&dimensions=gender&metrics=viewerPercentage&end-date={endDate}&start-date={startDate}', json:true, timeout: 10000, headers:{'Authorization':'Bearer '+accessToken}}, function (err,r,result) { console.log(result) });
If you need to find gender information along with ageGroup below the code snippet, you can use
request.get({ url:'https://www.googleapis.com/youtube/analytics/v1/reports?key={Google Api Key}&ids=channel=={channelId}&dimensions=gender,ageGroup&metrics=viewerPercentage&end-date={endDate}&start-date={startDate}', json:true, timeout: 10000, headers:{'Authorization':'Bearer '+accessToken}}, function (err,r,result) { console.log(result) });
source share