Chrome Management Reports API 的代码示例
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
访问 Chrome Management Reports API 获取
简要了解 API 功能。
下面显示的所有请求都使用以下变量:
$TOKEN
- OAuth 2 令牌
$CUSTOMER
- 客户 ID 或实际值 my_customer
$ORG_UNIT_ID
- 要为其生成请求的特定组织部门的 ID。
指定日期范围内有效的 Chrome 版本数
若要查看在指定时间范围内有效的 Chrome 版本,
使用 filter
参数中的 last_active_date
值。您可以控制
使用 pageSize
和 pageToken
参数对结果进行分页。
请求
curl -X GET \
-H "Authorization: Bearer $TOKEN" \
"https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/reports:countChromeVersions?filter=last_active_date<2020-11-06+AND+last_active_date>2020-11-04"
响应
{
"browserVersions": [
{
"count": "1",
"version": "85.0.4183.83",
"system": "SYSTEM_MAC",
"channel": "STABLE"
},
{
"count": "1",
"version": "85.0.4183.102",
"system": "SYSTEM_WINDOWS",
"channel": "STABLE"
},
{
"count": "13697",
"version": "71.0.3578.96",
"system": "SYSTEM_MAC",
"channel": "STABLE"
},
{
"count": "1",
"version": "87.0.4280.40",
"system": "SYSTEM_MAC",
"channel": "BETA"
},
{
"count": "1",
"version": "88.0.4314.0",
"system": "SYSTEM_MAC",
"channel": "CANARY"
},
{
"count": "1718"
},
],
"totalSize": 5
}
统计具有多种权限的应用安装的分布情况
要查看已安装特定应用(具有指定
权限数量,请使用number_of_permissions
filter
参数。您可以使用
pageSize
和 pageToken
参数。
有关更多过滤器参数,请访问
reference。
请求
curl -X GET \
-H "Authorization: Bearer $TOKEN" \
"https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/reports:countInstalledApps?filter=number_of_permissions>6"
响应
{
"totalSize": 1,
"installedApps": [
{
"browserDeviceCount": "2",
"appSource": "CHROME_WEBSTORE",
"displayName": "Secure Shell App",
"description": "Terminal emulator and SSH and SFTP client.",
"appType": "APP",
"appInstallType": "ADMIN",
"appId": "pnhechapfaindjhompbnflcldabbghjo",
"homepageUri": "https://chrome.google.com/webstore/detail/pnhechapfaindjhompbnflcldabbghjo",
"permissions": [
"clipboardRead",
"clipboardWrite",
"crashReportPrivate",
"idle",
"metricsPrivate",
"notifications",
"storage",
"unlimitedStorage"
]
},
]
}
统计已安装应用的设备数量
上面的示例展示了一款已在 2 台设备上安装的应用。
如需查看已安装此应用的设备,您可以使用
findInstalledAppDevices
自定义方法。
您可以使用 pageSize
和 pageToken
控制结果的分页。
参数。
请求
curl -X GET \
-H "Authorization: Bearer $TOKEN" \
"https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/reports:findInstalledAppDevices?appType=app&appId=pnhechapfaindjhompbnflcldabbghjo"
响应
{
"totalSize": 2,
"devices": [
{
"machine": "MACHINEA-A",
"deviceId": "b472473e-fe50-4c6e-9ac3-03fe0d0753ce"
},
{
"machine": "MACHINE-B",
"deviceId": "a5f49e54-b07b-409f-bc5c-aaf27c483249"
}
]
}
跟进请求
根据上一个示例中返回的设备 ID,
使用
适用于 Chrome 浏览器的 Admin SDK Directory API。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003eUse the Chrome Management Reports API to retrieve data on Chrome browser and app usage within your organization.\u003c/p\u003e\n"],["\u003cp\u003eThe API allows you to count Chrome versions active within a specified date range, filter by criteria like the number of app permissions, and identify devices with specific apps installed.\u003c/p\u003e\n"],["\u003cp\u003eUtilize the \u003ccode\u003ecountChromeVersions\u003c/code\u003e, \u003ccode\u003ecountInstalledApps\u003c/code\u003e, and \u003ccode\u003efindInstalledAppDevices\u003c/code\u003e methods for gathering data insights.\u003c/p\u003e\n"],["\u003cp\u003eDetailed information about specific devices can be retrieved through the Admin SDK Directory API using the device ID.\u003c/p\u003e\n"]]],[],null,["# Code Samples for the Chrome Management Reports API\n\nVisit [Chrome Management Reports API](/chrome/management/guides/reports_api) for\nan overview of API features.\n\nAll the requests shown below use the following variables:\n\n- `$TOKEN` - OAuth 2 token\n- `$CUSTOMER` - ID of the customer or literal `my_customer`\n- `$ORG_UNIT_ID` - ID of a particluar org unit for which you want to generate a request.\n\nCount Chrome versions active in date range\n------------------------------------------\n\nTo view which Chrome versions were active over a given range of time,\nuse the `last_active_date` value in the `filter` parameter. You can control\npagination of the results using the `pageSize` and `pageToken` parameters.\n\n#### Request\n\n curl -X GET \\\n -H \"Authorization: Bearer $TOKEN\" \\\n \"https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/reports:countChromeVersions?filter=last_active_date\u003c2020-11-06+AND+last_active_date\u003e2020-11-04\"\n\n#### Response\n\n {\n \"browserVersions\": [\n {\n \"count\": \"1\",\n \"version\": \"85.0.4183.83\",\n \"system\": \"SYSTEM_MAC\",\n \"channel\": \"STABLE\"\n },\n {\n \"count\": \"1\",\n \"version\": \"85.0.4183.102\",\n \"system\": \"SYSTEM_WINDOWS\",\n \"channel\": \"STABLE\"\n },\n {\n \"count\": \"13697\",\n \"version\": \"71.0.3578.96\",\n \"system\": \"SYSTEM_MAC\",\n \"channel\": \"STABLE\"\n },\n {\n \"count\": \"1\",\n \"version\": \"87.0.4280.40\",\n \"system\": \"SYSTEM_MAC\",\n \"channel\": \"BETA\"\n },\n {\n \"count\": \"1\",\n \"version\": \"88.0.4314.0\",\n \"system\": \"SYSTEM_MAC\",\n \"channel\": \"CANARY\"\n },\n {\n \"count\": \"1718\"\n },\n ],\n \"totalSize\": 5\n }\n\nCount distribution of app installations with a number of permissions\n--------------------------------------------------------------------\n\nTo view the number of devices that have installed a particular app with a given\nnumber of permissions, use the `number_of_permissions` value in the\n`filter` parameter. You can control pagination of the results using the\n`pageSize` and `pageToken` parameters.\n\nFor more filter parameters, visit the\n[reference](/chrome/management/reference/rest/v1/customers.reports/countInstalledApps).\n\n#### Request\n\n curl -X GET \\\n -H \"Authorization: Bearer $TOKEN\" \\\n \"https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/reports:countInstalledApps?filter=number_of_permissions\u003e6\"\n\n#### Response\n\n {\n \"totalSize\": 1,\n \"installedApps\": [\n {\n \"browserDeviceCount\": \"2\",\n \"appSource\": \"CHROME_WEBSTORE\",\n \"displayName\": \"Secure Shell App\",\n \"description\": \"Terminal emulator and SSH and SFTP client.\",\n \"appType\": \"APP\",\n \"appInstallType\": \"ADMIN\",\n \"appId\": \"pnhechapfaindjhompbnflcldabbghjo\",\n \"homepageUri\": \"https://chrome.google.com/webstore/detail/pnhechapfaindjhompbnflcldabbghjo\",\n \"permissions\": [\n \"clipboardRead\",\n \"clipboardWrite\",\n \"crashReportPrivate\",\n \"idle\",\n \"metricsPrivate\",\n \"notifications\",\n \"storage\",\n \"unlimitedStorage\"\n ]\n },\n ]\n }\n\nCount devices that have an installed app\n----------------------------------------\n\nThe previous example showed an app that has been installed on 2 devices.\nTo view the devices that have installed this app, you can use the\n`findInstalledAppDevices` custom method.\nYou can control pagination of the results using the `pageSize` and `pageToken`\nparameters.\n\n#### Request\n\n curl -X GET \\\n -H \"Authorization: Bearer $TOKEN\" \\\n \"https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/reports:findInstalledAppDevices?appType=app&appId=pnhechapfaindjhompbnflcldabbghjo\"\n\n#### Response\n\n {\n \"totalSize\": 2,\n \"devices\": [\n {\n \"machine\": \"MACHINEA-A\",\n \"deviceId\": \"b472473e-fe50-4c6e-9ac3-03fe0d0753ce\"\n },\n {\n \"machine\": \"MACHINE-B\",\n \"deviceId\": \"a5f49e54-b07b-409f-bc5c-aaf27c483249\"\n }\n ]\n }\n\n### Follow-up request\n\nGiven the device ID returned in the previous example, you can get more\ninformation about the device that has installed the app by using the\n[Admin SDK Directory API for Chrome Browsers](/admin-sdk/directory/v1/guides/manage-chrome-browsers)."]]