0

I'm using channel_reports from YouTube analytics API to fetch metrics such as views, likes, etc, but I can't fetch data for the current day (I can tough, get data spanning from a few days back). Even if I watch, like a bunch of videos and subscribe to the channel I'm trying to fetch the data from, I don't see any data.

I'm using the following to get data:

from datetime import datetime, timedelta

youtubeAnalytics = build(api_name, version, credentials=credentials) ### using Oauth token and all

startDate = (datetime.today() - timedelta(days=1)).date()
endDate = (datetime.today() - timedelta(days=0)).date()

metric_names = ["likes", "dislikes", "views", "subscribersGained", "subscribersLost"]
youtubeAnalytics.reports().query(
    ids='channel==MINE',
    startDate=startDate.isoformat(),
    endDate=endDate.isoformat() ,
    metrics=",".join(metric_names ),
    dimensions="day"
).execute()

But with the startDate and endDate representing today and yesterday, the results are empty (even after viewing lots of videos, subscribing, liking with other accounts).

For past data though, it yields results.

leoni loris
  • 1
  • 1
  • 1
  • Jus to make sure, can you print the values of `startDate` and `endDate`? - if the problem persists, consider also include this info in a ticket on [Issue Tracker](https://issuetracker.google.com/issues?q=status:open%20componentid:186600&s=created_time:desc) – Marco Aurelio Fernandez Reyes Feb 22 '23 at 21:42
  • Sure thing. but it's just the isoformatting of the day (I edited the post, cuz I think I missed the isoformat() there). But it prints: (datetime.date(2023, 2, 22), datetime.date(2023, 2, 23)) that's for today – leoni loris Feb 23 '23 at 14:13

0 Answers0