I've been trying for some days now by reading the docs to figure out how to use any of the two APIs mentioned in the title to retrieve a channel's most commented video.
This query doesn't work:
curl --location --request GET 'https://youtubeanalytics.googleapis.com/v2/reports?ids=channel==MINE&dimensions=video&metrics=comments&maxResults=1&sort=-comments&startDate=2022-07-12&endDate=2022-09-12'
But querying for the same dimension but for the views metric instead works:
curl --location --request GET 'https://youtubeanalytics.googleapis.com/v2/reports?ids=channel==MINE&dimensions=video&metrics=views&maxResults=1&sort=-views&startDate=2022-07-12&endDate=2022-09-12'
One weird thing is that even though the documentation specifies that ascending order sorting is working by default (Docs: A comma-separated list of dimensions or metrics that determine the sort order for YouTube Analytics data. By default the sort order is ascending. The - prefix causes descending sort order.
) you can't run some requests without specifically using descending order. For example the views request above.
But changing the sort parameter to sort=view
(Ascending) results in the following response:
{
"error": {
"code": 400,
"message": "The query is not supported. Check the documentation at https://developers.google.com/youtube/analytics/v2/available_reports for a list of supported queries.",
"errors": [
{
"message": "The query is not supported. Check the documentation at https://developers.google.com/youtube/analytics/v2/available_reports for a list of supported queries.",
"domain": "global",
"reason": "badRequest"
}
]
}
}
And removing the sort parameter has the same result.
Anyone knows how to solve this mystery with the youtube analytics api?
By using YouTube Data API v3 endpoints you can get the most commented video on a given channel.
Indeed by:
part=snippet
and playlistId=UPLOADS_PLAYLIST_ID
where UPLOADS_PLAYLIST_ID
is the channel id with its second character (C
) replaced by U
.part=statistics
commentCount
s