2

I am using googleapi package.

I want to get 'insightTrafficSourceDetail' from youtube analytics API.

Here is my code:

google.youtubeAnalytics('v2').reports.query({
    metrics: 'estimatedMinutesWatched,views',
    dimensions: 'insightTrafficSourceDetail',
    filter: 'video==[some_video_id];insightTrafficSourceType==YT_SEARCH',
    startDate: '2019-01-01',
    endDate: '2019-02-12',
    ids: 'channel==MINE',
    sort: '-estimatedMinutesWatched',
    maxResults: 25,
  });

Here is the response I am getting:

  code: 400,
  errors:
   [ { message:
        'The query is not supported. Check the documentation at https://developers.google.com/youtube/analytics/v2/available_reports for a list of supported queries.',
       domain: 'global',
       reason: 'badRequest' } ] }

Although in google docs, they have given the same request as sample request Top 10 – External websites that generate the most traffic for a video

Rahul Saini
  • 216
  • 1
  • 16

1 Answers1

1
google.youtubeAnalytics('v2').reports.query({
    metrics: 'estimatedMinutesWatched,views',
    dimensions: 'insightTrafficSourceDetail',
    filter: 'video==[some_video_id];insightTrafficSourceType==YT_SEARCH',
    startDate: '2019-01-01',
    endDate: '2019-02-12',
    ids: 'channel==MINE',
    sort: '-estimatedMinutesWatched',
    maxResults: 25,
  }); 

In the above code, It should be 'filters' not 'filter'. When I replaced it, it started working perfectly.

filters: 'video==[some_video_id];insightTrafficSourceType==YT_SEARCH',

Rahul Saini
  • 216
  • 1
  • 16