I have been working on a project to pull analytics data from the YouTube Analytics API (v1, v1beta1 provides the same results). I began getting no rows returned in a batch call and, naturally, I suspected errors on my end.
I recreated one of the queries from my program in the Google APIs Explorer to see where I may have gone wrong. And that's where things got complicated.
Note: I am using OAuth and executing my program and the API explorer with OAuth authentication of the same user in all locations. I have omitted the Authorization Bearer [token]
details from this post for obvious reasons.
Google API Explorer query:
GET https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3DMINE&start-date=2016-05-01&end-date=2016-05-31&metrics=views%2CestimatedMinutesWatched&dimensions=insightTrafficSourceType&filters=video%3D%3DEeEHdFmKrGo%3Bcountry%3D%3DUS&fields=rows&key={YOUR_API_KEY}
Google API Explorer results:
200 HTTP/2.0 200
- Show headers -
{
}
Postman query:
GET https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3DMINE&start-date=2016-05-01&end-date=2016-05-31&metrics=views%2CestimatedMinutesWatched&dimensions=insightTrafficSourceType&filters=video%3D%3DEeEHdFmKrGo%3Bcountry%3D%3DUS&fields=rows
Postman results:
{
"rows": [
[
"YT_PLAYLIST_PAGE",
83,
153
],
[
"YT_CHANNEL",
21,
38
],
[
"PLAYLIST",
103,
193
],
[
"SUBSCRIBER",
41,
63
],
[
"NOTIFICATION",
16,
5
],
[
"ADVERTISING",
1954,
2973
],
[
"RELATED_VIDEO",
179,
294
],
[
"YT_OTHER_PAGE",
16,
20
],
[
"EXT_URL",
98,
189
],
[
"NO_LINK_OTHER",
603,
23
],
[
"YT_SEARCH",
80,
130
]
]
}
So data is available. Why does the API Explorer not show it? The API Explorer matches the behavior of my program: no rows returned.
Yes, if I omit the fields
value, it will give me the column headers:
200 HTTP/2.0 200
- Show headers -
{
"kind": "youtubeAnalytics#resultTable",
"columnHeaders": [
{
"name": "insightTrafficSourceType",
"columnType": "DIMENSION",
"dataType": "STRING"
},
{
"name": "views",
"columnType": "METRIC",
"dataType": "INTEGER"
},
{
"name": "estimatedMinutesWatched",
"columnType": "METRIC",
"dataType": "INTEGER"
}
]
}
Other similar questions:
- ROWS not returning in Youtube Analytics API?
- YouTube Analytics API doesn't return ROWS for query for a specific video
- YouTube Analytics API returns no rows for demographic query - but does return views
- YouTube Analytics API channel: The response has no rows parameter
I've verified some of the leads in these questions.
- I am getting data for the query... just not via batch nor the API explorer.
- Same as #1, really. If I change or extend the date ranges, the API Explorer still returns no rows while Postman's query shows rows.
- See investigations for #4
- I can pull the report in the YouTube interface — as the same user being used for the API Explorer and my program — and see data.
This data matches what I get from Postman's query. This implies that the same data should be available via the API Explorer and batch requests, however they obviously differ.
Am missing something? Shouldn't I receive rows in the response from the API Explorer? Likewise, shouldn't a batch response contain the same contents as the direct GET
request I'm seeing via Postman?
Any insight or suggestions for further exploration appreciated. If you've made it this far, thanks for your time.
Garret