Some days ago I used the code below to create a new job on Youtube's Analytics and Reporting API. The createTime
for this job is 2022-07-25T13:54:51Z
.
def create_job(token, reportTypeId, name): print(F"START: RUNNING create_job") data = {"reportTypeId": reportTypeId,"name": name} resp = requests.post("https://youtubereporting.googleapis.com/v1/jobs", headers = {"Authorization": "Bearer " + token}, json = data) print(F"DONE: RUNNING create_job") return None
I waited the 24h for the API to generate the reports, and when I ran the code below to list the existing reports for that job, I got urls for distinct dates.
def list_job_reports(token, jobId): print(F"START: RUNNING list_job_reports") # Fetching all existing reports for this job url = f"https://youtubereporting.googleapis.com/v1/jobs/{jobId}/reports" resp = requests.get(url, headers = {"Authorization": "Bearer " + token}) resp = json.loads(resp.text) # Wrangling resp into dictionary with report date and url reports_dict = {} for row in resp['reports']: report_date = row['startTime'].split('T')[0] download_url = row['downloadUrl'] reports_dict[report_date] = download_url print(F"DONE: RUNNING list_job_reports") return reports_dict
I ran the function above on 2022-07-26, and the maximum date for a report generated was 2022-07-25 (same date as the job creation). Today, on 2022-07-28, I expected to have new reports, for 26th and 27th, but when I run list_job_reports
now, the latest report is still the one for the 25th. It is as if the job didn't generate new daily reports automatically. I took a look at the documentation and I saw that just by creating a job, new reports should be generated daily (print below).
Did I miss something? Do I need to trigger the daily report generation somehow?