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

YouTube Analytics API: video + day aggregation. Is it possible?

$
0
0

I have a YouTube channel and I want to extract the video information (likes, dislikes, views, subscribes, unsubscribes, visualization time, etc) with a daily aggregation from my own channel. I have read in some posts/blogs it is possible to do this, but I haven't been able to find the information on the YouTube Analytics API.

In fact, when I try to select in the API Explorer on YouTube API page the dimensions of 'day' and 'video', it returns an error saying the query is not supported.

enter image description here

This doesn't happen when I use only the dimension of day, for example:

enter image description here

I have tried this in Python and it isn't working either. Is there any way to get this information or would I have to download it from the YouTube Analytics statistics directly day by day?

This is the code I used:

import googleapiclient.errorsimport osfrom googleapiclient.discovery import buildimport google_auth_oauthlib.flowfrom google.auth.transport.requests import Requestscopes = ["https://www.googleapis.com/auth/youtube.readonly"]def main():    # Disable OAuthlib's HTTPS verification when running locally.    # *DO NOT* leave this option enabled in production.    #os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1"    api_service_name = "youtubeAnalytics"    api_version = "v2"    client_secrets_file = "supercliente.json"    # Get credentials and create an API client    flow = google_auth_oauthlib.flow.InstalledAppFlow.from_client_secrets_file(        client_secrets_file, scopes)    credentials = flow.run_console()    youtube_analytics = googleapiclient.discovery.build(        api_service_name, api_version, credentials=credentials)    request = youtube_analytics.reports().query(        dimensions="day,video",        endDate="2022-05-01",        ids="channel==MINE",        maxResults=50,        metrics="likes",        startDate="2021-03-01",    )    response = request.execute()    print(response)if __name__ == "__main__":    main()

The error I get:

HttpError: <HttpError 400 when requesting https://youtubeanalytics.googleapis.com/v2/reports?dimensions=day&endDate=2022-05-01&ids=channel%3D%3DMINE&maxResults=50&metrics=likes&startDate=2021-03-01&filters=vBDX3bljsGw&alt=json returned "Could not parse content (N/A) of field parameters.filters.". Details: "[{'message': 'Could not parse content (N/A) of field parameters.filters.', 'domain': 'global', 'reason': 'badRequest'}]">

Thanks!


Viewing all articles
Browse latest Browse all 3638

Trending Articles



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