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

Using the youtube analytics api or youtube data api, is there a way to get the video from a channel with the most comments?

$
0
0

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 ?


Viewing all articles
Browse latest Browse all 3831

Trending Articles



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