Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

issue with Youtube Analytics data via API

Hi

I am trying to fetch monthly reports for views and estimated streaming minutes from my YouTube channel using the YouTube Analytics API at the video or playlist level. However, I am encountering an issue when specifying dimensions='playlist'.

Code Snippet:

SCOPES = [
'https://www.googleapis.com/auth/yt-analytics.readonly',
'https://www.googleapis.com/auth/youtube.readonly',
'https://www.googleapis.com/auth/youtube'
]
API_SERVICE_NAME = 'youtubeAnalytics'
API_VERSION = 'v2'
CLIENT_SECRETS_FILE = 'credentials.json'

execute_api_request(
youtubeAnalytics.reports().query,
ids='channel==MINE',
startDate='2024-01-01',
endDate='2024-12-01',
dimensions='playlist,month',
metrics='estimatedMinutesWatched,views,likes'
)

 

Issue:

  • The API works fine when using Day or Month as dimensions.
  • When I try fetching data for video or playlist, I get the following error:

HttpError 400 when requesting https://youtubeanalytics.googleapis.com/v2/reports?ids=channel%3D%3DMINE&startDate=2023-01-01&endDat... returned "The query is not supported. Check the documentation at https://developers.google.com/youtube/analytics/v2/available_reports for a list of supported queries.". Details: "[{'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'}]"

 

What I Tried:

  • Verified using the Try API feature in the official documentation, where I was able to download the data successfully.
  • The issue seems to occur only when making the request via the API.

Question:

How can I fetch video or playlist-level analytics using the API without encountering this error? Is there an alternative approach or a workaround to retrieve this data?

Thank you in advance for your help!

0 0 195
0 REPLIES 0
Top Labels in this Space