It's simple to do this, please check below code snippet to find demographic and gender statics:
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 gender info below code snippet can be used:
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 info along with ageGroup below code snippet can be used
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)
});