Analytics

class youtube.Analytics(access_token=None)

The YouTube Analytics API currently provides a single method that lets you retrieve Analytics reports for a YouTube channel.

https://developers.google.com/youtube/analytics/v1/available_reports.html identifies the different reports that you can retrieve. For each report, it lists the dimensions that are used to aggregate data, available metrics, and supported filtering options.

Create a YouTube service.

Variables:access_token

Service methods

Analytics.get(ids, metrics, start_date, end_date, dimensions=None, filters=None, max_results=None, start_index=None, sort=None)

Retrieve YouTube Analytics data

Variables:
  • ids (str) – Identifies the YouTube channel or content owner for which you are retrieving YouTube Analytics data. To request data for a YouTube user, set the ids parameter value to channel==USER_ID. To request data for a YouTube CMS content owner, set the ids parameter value to contentOwner==OWNER_NAME
  • metrics (str) – A comma-separated list of YouTube Analytics metrics, such as views or likes,dislikes. See https://developers.google.com/youtube/analytics/v1/available_reports.html for a list of the reports that you can retrieve and the metrics available in each report, and seehttps://developers.google.com/youtube/analytics/v1/dimsmets/mets.html for definitions of those metrics.
  • start_date (str) – The start date for fetching YouTube Analytics data. The value should be in YYYY-MM-DD format.
  • end_date (str) – The start date for fetching YouTube Analytics data. The value should be in YYYY-MM-DD format.
  • dimensions (str) – A comma-separated list of YouTube Analytics dimensions, such as video or ageGroup,gender. See https://developers.google.com/youtube/analytics/v1/available_reports.html for a list of the reports that you can retrieve and the dimensions used for those reports. Also see https://developers.google.com/youtube/analytics/v1/dimsmets/dims for definitions of those dimensions.
  • filters (str) – A list of filters that should be applied when retrieving YouTube Analytics data. The https://developers.google.com/youtube/analytics/v1/available_reports.html identifies the dimensions that can be used to filter each report, and https://developers.google.com/youtube/analytics/v1/dimsmets/dims defines those dimensions. If a request uses multiple filters, join them together with a semicolon (;), and the returned result table will satisfy both filters. For example, a filters parameter value of video==dMH0bHeiRNg;country==IT restricts the result set to include data for the given video in Italy.
  • max_results (str) – The maximum number of rows to include in the response
  • start_index (int) – The 1-based index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
  • sort (str) – A comma-separated list of dimensions or metrics that determine the sort order for YouTube Analytics data. By default the sort order is ascending. The ‘-‘ prefix causes descending sort order