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.