Reports API:用户使用情况报告

用户使用情况报告会返回您网域中特定用户的 Google Workspace 服务使用情况信息。您可以针对特定使用情况信息自定义和过滤这些报告。每个报告的默认时间段和最长时间段均为过去 450 天。

这些用户使用情况报告只能用于依照《客户协议》的合法目的。这些报告适用于 Google Workspace 和 Google Workspace 教育版。

检索所有用户使用情况

要检索您帐号中所有用户活动的报告,请使用以下 GET HTTP 请求,并包含授权文档中所述的授权令牌。为确保可读性,以下示例采用换行格式:

GET https://admin.googleapis.com/admin/reports/v1/usage/users/all/dates/yyyy-mm-dd date
?parameters=application: user usage parameter,...
&filters=application: user usage parameter relational operator usage parameter's value,...
&maxResults=number of events listed on each page of the report

dates 值是使用情况的发生日期,时间戳采用 ISO 8601 格式,即 yyyy-mm-dd。如需详细了解查询字符串参数和响应属性,请参阅 API 参考。如需了解用户使用情况报告参数,请参阅用户使用情况参数参考文档

以下示例获取的是帐号中所有用户活动的报告。

GET https://admin.googleapis.com/admin/reports/v1/usage/users/all
/dates/2013-03-03?maxResults=2

以下示例获取了一个关于特定客户帐号的所有用户活动的报告。

GET https://admin.googleapis.com/admin/reports/v1/usage/users/all
/dates/2013-03-03?customerId=C03az79cb

以下示例获取有关帐号中用户的上次登录时间戳的报告。如需查看 API 响应的示例,请参阅 JSON 响应示例

GET https://admin.googleapis.com/admin/reports/v1/usage/users/all/dates/2013-03-03
?parameters=accounts:last_login_time&maxResults=2

以下示例获取帐号中用户的上次登录时间戳的报告,过滤依据是在特定时间后登录的用户。如需查看 API 响应的示例,请参阅 JSON 响应示例

GET https://admin.googleapis.com/admin/reports/v1/usage/users/all/dates/2013-03-03
?parameters=accounts:last_login_time&filters=accounts:last_login_time
>2010-10-28T10:26:35.000Z"

以下示例获取有关帐号中用户的上次登录时间戳和暂停状态的报告。如需查看 API 响应的示例,请参阅 JSON 响应示例

GET https://admin.googleapis.com/admin/reports/v1/usage/users/all/dates/2013-03-03
?parameters=accounts:last_login_time,accounts:is_disabled"

检索特定用户的使用情况

要检索您帐号中特定用户的活动报告,请使用以下 GET HTTP 请求,并包含授权文档中所述的授权令牌。为确保可读性,以下示例采用换行格式。

GET https://admin.googleapis.com/admin/reports/v1/usage/users/userKey/dates/yyyy-mm-dd date
?parameters=application: user usage parameter,...
&filters=application: user usage parameter relational operator usage parameter's value,...
&maxResults=number of events listed on each page of the report

userKey 可以是报告中用户的主电子邮件地址,也可以是用户的唯一 Google Workspace profileIddates 值是使用情况的发生日期,时间戳采用 ISO 8601 格式,即 yyyy-mm-dd。如需详细了解查询字符串参数和响应属性,请参阅 API 参考。如需了解用户使用情况报告参数,请参阅用户使用情况参数参考文档

以下示例会获取 john@example.com 的使用情况报告。

https://admin.googleapis.com/admin/reports/v1/usage/users/john@example.com/dates/2013-03-03

使用情况报告示例 JSON 响应

成功的响应将返回 HTTP 200 状态代码。响应将返回状态代码以及报告。

用户报告的 JSON 响应

{
 "kind": "reports#usageReports",
 "warnings": [
    {
      "code": warning machine-readable code,
      "message": warning human-readable message,
      "data": [
        {
          "key": key for key-value pair that gives detailed warning information,
          "value": value for key-value pair giving detailed warning information
        }
      ]
    }
  ],
 "nextPageToken": "N:NNN:NNN:N:C03az79cb",
 "usageReports": [
{
   "kind": "usageReport",
   "date": "2013-03-03",
   "entity": {
    "type": "USER",
    "customerId": "C03az79cb",
    "userEmail": "liz@example.com",
    "profileId": "user's unique Google Workspace ID"
   },
   "parameters": [
    {
      "name": "accounts:is_disabled",
      "boolValue": false
     },
    {
     "name": "accounts:disabled_reason",
     "stringValue": "reason description"
    },
    {
     "name": "accounts:first_name",
     "stringValue": "Liz"
    },
    {
     "name": "accounts:is_2sv_enforced",
     "boolValue": false
    },
    {
     "name": "accounts:is_2sv_enrolled",
     "boolValue": false
    },
    {
     "name": "accounts:last_name",
     "stringValue": "Smith"
    },
    {
     "name": "accounts:creation_time",
     "datetimeValue": "2010-10-28T10:26:35.000Z"
    },
    {
     "name": "accounts:last_login_time",
     "datetimeValue": "1970-01-01T00:00:00.000Z"
    },
    {
     "name": "accounts:last_sso_time",
     "datetimeValue": "1970-01-01T00:00:00.000Z"
    }
   ]
  }
 ]
}