0

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:

  1. ROWS not returning in Youtube Analytics API?
  2. YouTube Analytics API doesn't return ROWS for query for a specific video
  3. YouTube Analytics API returns no rows for demographic query - but does return views
  4. YouTube Analytics API channel: The response has no rows parameter

I've verified some of the leads in these questions.

  1. I am getting data for the query... just not via batch nor the API explorer.
  2. 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.
  3. See investigations for #4
  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.

YouTube Interface Screenshot

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

Community
  • 1
  • 1
inimicus
  • 1
  • 2
  • Postman has a button to view raw request. Have you tried comparing the headers sent by Postman with the ones you send in your request? – W.K.S Jun 13 '16 at 09:59
  • Aside from the addition of `Postman-Token`, headers are the same, yes. Granted, using the batch endpoint places these headers as part of the batch's `POST` multipart... but they match Postman when looking at the multipart section. Would be nice to see what the API Explorer's headers consisted of to compare, but only the URI is provided. – inimicus Jun 13 '16 at 16:09
  • I found the error in my program: I overlooked the values of the start and end dates in the `GET` requests. There was a hard-coded date in an area that caused a date mismatch and, thus, no data available. Now my program returns data as expected and the results match with Postman. However, there still remains the issue of the API Explorer not returning rows while Postman does on the same copy/pasted `GET` request. Interesting. – inimicus Jun 14 '16 at 07:02

0 Answers0