get method

Future<UsageReports> get (
  1. String userKey,
  2. String date,
  3. {String customerId,
  4. String filters,
  5. int maxResults,
  6. String orgUnitID,
  7. String pageToken,
  8. String parameters,
  9. String $fields}

Retrieves a report which is a collection of properties and statistics for a set of users with the account. For more information, see the User Usage Report guide. For more information about the user report's parameters, see the Users Usage parameters reference guides.

Request parameters:

userKey - Represents the profile ID or the user email for which the data should be filtered. Can be all for all information, or userKey for a user's unique G Suite profile ID or their primary email address.

date - Represents the date the usage occurred. The timestamp is in the ISO 8601 format, yyyy-mm-dd. We recommend you use your account's time zone for this. Value must have pattern "(\d){4}-(\d){2}-(\d){2}".

customerId - The unique ID of the customer to retrieve data for. Value must have pattern "C.+".

filters - The filters query string is a comma-separated list of an application's event parameters where the parameter's value is manipulated by a relational operator. The filters query string includes the name of the application whose usage is returned in the report. The application values for the Users Usage Report include accounts, docs, and gmail. Filters are in the form application name:relational operatorparameter value,....

In this example, the <> 'not equal to' operator is URL-encoded in the request's query string (%3C%3E): GET ?parameters=accounts:last_login_time &filters=accounts:last_login_time>2010-10-28T10:26:35.000Z

The relational operators include:

  • == - 'equal to'.
  • <> - 'not equal to'. It is URL-encoded (%3C%3E).
  • < - 'less than'. It is URL-encoded (%3C).
  • <= - 'less than or equal to'. It is URL-encoded (%3C=).
    • 'greater than'. It is URL-encoded (%3E).
  • = - 'greater than or equal to'. It is URL-encoded (%3E=). Value must have pattern "(((accounts)|(classroom)|(cros)|(gmail)|(calendar)|(docs)|(gplus)|(sites)|(device_management)|(drive)):a-z0-9_+^,+,)*(((accounts)|(classroom)|(cros)|(gmail)|(calendar)|(docs)|(gplus)|(sites)|(device_management)|(drive)):a-z0-9_+^,+)".

maxResults - Determines how many activity records are shown on each response page. For example, if the request sets maxResults=1 and the report has two activities, the report has two pages. The response's nextPageToken property has the token to the second page. The maxResults query string is optional. Value must be between "1" and "1000".

orgUnitID - ID of the organizational unit to report on. User activity will be shown only for users who belong to the specified organizational unit. Data before Dec 17, 2018 doesn't appear in the filtered results. Value must have pattern "(id:a-z0-9+)".

pageToken - Token to specify next page. A report with multiple pages has a nextPageToken property in the response. In your follow-on request getting the next page of the report, enter the nextPageToken value in the pageToken query string.

parameters - The parameters query string is a comma-separated list of event parameters that refine a report's results. The parameter is associated with a specific application. The application values for the Customers usage report include accounts, app_maker, apps_scripts, calendar, classroom, cros, docs, gmail, gplus, device_management, meet, and sites. A parameters query string is in the CSV form of app_name1:param_name1, app_name2:param_name2. Note: The API doesn't accept multiple values of a parameter. If a particular parameter is supplied more than once in the API request, the API only accepts the last value of that request parameter. In addition, if an invalid request parameter is supplied in the API request, the API ignores that request parameter and returns the response corresponding to the remaining valid request parameters.

An example of an invalid request parameter is one that does not belong to the application. If no parameters are requested, all parameters are returned. Value must have pattern "(((accounts)|(classroom)|(cros)|(gmail)|(calendar)|(docs)|(gplus)|(sites)|(device_management)|(drive)):^,+,)*(((accounts)|(classroom)|(cros)|(gmail)|(calendar)|(docs)|(gplus)|(sites)|(device_management)|(drive)):^,+)".

$fields - Selector specifying which fields to include in a partial response.

Completes with a UsageReports.

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.


async.Future<UsageReports> get(core.String userKey, core.String date,
    {core.String customerId,
    core.String filters, maxResults,
    core.String orgUnitID,
    core.String pageToken,
    core.String parameters,
    core.String $fields}) {
  var _url;
  var _queryParams = new core.Map<core.String, core.List<core.String>>();
  var _uploadMedia;
  var _uploadOptions;
  var _downloadOptions = commons.DownloadOptions.Metadata;
  var _body;

  if (userKey == null) {
    throw new core.ArgumentError("Parameter userKey is required.");
  if (date == null) {
    throw new core.ArgumentError("Parameter date is required.");
  if (customerId != null) {
    _queryParams["customerId"] = [customerId];
  if (filters != null) {
    _queryParams["filters"] = [filters];
  if (maxResults != null) {
    _queryParams["maxResults"] = ["${maxResults}"];
  if (orgUnitID != null) {
    _queryParams["orgUnitID"] = [orgUnitID];
  if (pageToken != null) {
    _queryParams["pageToken"] = [pageToken];
  if (parameters != null) {
    _queryParams["parameters"] = [parameters];
  if ($fields != null) {
    _queryParams["fields"] = [$fields];

  _url = 'usage/users/' +
      commons.Escaper.ecapeVariable('$userKey') +
      '/dates/' +

  var _response = _requester.request(_url, "GET",
      body: _body,
      queryParams: _queryParams,
      uploadOptions: _uploadOptions,
      uploadMedia: _uploadMedia,
      downloadOptions: _downloadOptions);
  return _response.then((data) => new UsageReports.fromJson(data));