query method
Retrieve your YouTube Analytics reports.
Request parameters:
currency
- The currency to which financial metrics should be converted.
The default is US Dollar (USD). If the result contains no financial
metrics, this flag will be ignored. Responds with an error if the
specified currency is not recognized.", pattern: [A-Z]{3}
dimensions
- A comma-separated list of YouTube Analytics dimensions,
such as views
or ageGroup,gender
. See the [Available
Reports](/youtube/analytics/v2/available_reports) document for a list of
the reports that you can retrieve and the dimensions used for those
reports. Also see the [Dimensions](/youtube/analytics/v2/dimsmets/dims)
document for definitions of those dimensions." pattern: [0-9a-zA-Z,]+
endDate
- The end date for fetching YouTube Analytics data. The value
should be in YYYY-MM-DD
format. required: true, pattern:
[0-9]{4}-[0-9]{2}-[0-9]{2}
filters
- A list of filters that should be applied when retrieving
YouTube Analytics data. The [Available
Reports](/youtube/analytics/v2/available_reports) document identifies the
dimensions that can be used to filter each report, and the
[Dimensions](/youtube/analytics/v2/dimsmets/dims) document 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.",
ids
- 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==CHANNEL_ID
, where CHANNEL_ID
specifies the unique YouTube channel ID. - To request data for a YouTube
CMS content owner, set the ids
parameter value to
contentOwner==OWNER_NAME
, where OWNER_NAME
is the CMS name of the
content owner. required: true, pattern: [a-zA-Z]+==[a-zA-Z0-9_+-]+
includeHistoricalChannelData
- If set to true historical data (i.e.
channel data from before the linking of the channel to the content owner)
will be retrieved.",
maxResults
- The maximum number of rows to include in the response.",
minValue: 1
metrics
- A comma-separated list of YouTube Analytics metrics, such as
views
or likes,dislikes
. See the [Available
Reports](/youtube/analytics/v2/available_reports) document for a list of
the reports that you can retrieve and the metrics available in each
report, and see the [Metrics](/youtube/analytics/v2/dimsmets/mets)
document for definitions of those metrics. required: true, pattern:
[0-9a-zA-Z,]+
sort
- 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.", pattern:
[-0-9a-zA-Z,]+
startDate
- The start date for fetching YouTube Analytics data. The
value should be in YYYY-MM-DD
format. required: true, pattern:
"[0-9]{4}-[0-9]{2}-[0-9]{2}
startIndex
- An index of the first entity to retrieve. Use this
parameter as a pagination mechanism along with the max-results parameter
(one-based, inclusive).", minValue: 1
$fields
- Selector specifying which fields to include in a partial
response.
Completes with a QueryResponse.
Completes with a commons.ApiRequestError if the API endpoint returned an error.
If the used http.Client
completes with an error when making a REST call,
this method will complete with the same error.
Implementation
async.Future<QueryResponse> query({
core.String? currency,
core.String? dimensions,
core.String? endDate,
core.String? filters,
core.String? ids,
core.bool? includeHistoricalChannelData,
core.int? maxResults,
core.String? metrics,
core.String? sort,
core.String? startDate,
core.int? startIndex,
core.String? $fields,
}) async {
final queryParams_ = <core.String, core.List<core.String>>{
if (currency != null) 'currency': [currency],
if (dimensions != null) 'dimensions': [dimensions],
if (endDate != null) 'endDate': [endDate],
if (filters != null) 'filters': [filters],
if (ids != null) 'ids': [ids],
if (includeHistoricalChannelData != null)
'includeHistoricalChannelData': ['${includeHistoricalChannelData}'],
if (maxResults != null) 'maxResults': ['${maxResults}'],
if (metrics != null) 'metrics': [metrics],
if (sort != null) 'sort': [sort],
if (startDate != null) 'startDate': [startDate],
if (startIndex != null) 'startIndex': ['${startIndex}'],
if ($fields != null) 'fields': [$fields],
};
const url_ = 'v2/reports';
final response_ = await _requester.request(
url_,
'GET',
queryParams: queryParams_,
);
return QueryResponse.fromJson(
response_ as core.Map<core.String, core.dynamic>);
}