I know I can send GET requests to the YouTube API specifying startDates
and endDates
using a format YYYY-MM-DD
, but I'm hoping there is a certain format you could specify to tell the start date to be equal to the published date or upload date?
My simple query is as follows:
startDate <- "2020-01-01" # THIS IS WHAT I'D LIKE TO CHANGE TO BE THE PUBISHING OR UPLOAD DATE
endDate <- Sys.Date()
token <- MY_TOKEN
url <- paste0("https://youtubeanalytics.googleapis.com/v2/reports?",
"&ids=channel%3D%3DMINE",
"&startDate=", startDate,
"&endDate=", endDate,
"&metrics=views,estimatedMinutesWatched,averageViewDuration",
"&filter=video==", MY_VIDEO_ID)
myRequest <- GET(url, token)
I know that you can query from the Data API first, get the published date, and then use that to feed into your query, but I'm hoping to save on API credits because I need to analyze lots of videos.
I found the easiest thing to do is just specify Jan 1, 2000 as the start date, and that seems to work.