检索营业地点数据分析
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
本教程介绍了如何在商家资料中检索营业地点指标。借助 Google My Business API,您可以使用营业地点指标来检索以下类型的数据:
准备工作
在使用 Google My Business API 之前,您需要注册您的应用并获取 OAuth 2.0 凭据。要详细了解如何开始使用 Google My Business API,请参阅基本设置。
支持的数据分析
要了解支持的数据分析,请参阅指标参考页面。
基本数据分析
检索指定营业地点列表的基本数据分析。使用 accounts.locations.reportInsights
API 可返回与某个营业地点关联的数据分析。
要返回与某个营业地点关联的基本数据分析,请使用以下命令:
POST
https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations:reportInsights
{
"locationNames": [
"accounts/{accountId}/locations/{locationId}"
],
"basicRequest": {
"metricRequests": [
{
"metric": "QUERIES_DIRECT"
},
{
"metric": "QUERIES_INDIRECT"
}
],
"timeRange": {
"startTime": "2016-10-12T01:01:23.045123456Z",
"endTime": "2017-01-10T23:59:59.045123456Z"
}
}
}
行车路线
检索指定营业地点列表的行车路线指标。使用 accounts.locations.reportInsights
API 可返回与某个营业地点关联的行车路线指标。
要返回行车路线指标,请使用以下命令:
POST
https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations:reportInsights
{
"locationNames": [
"accounts/{accountId}/locations/{locationId}"
],
"drivingDirectionsRequest": {
"numDays": "NINETY"
}
}
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-29。
[null,null,["最后更新时间 (UTC):2025-08-29。"],[[["\u003cp\u003eThis tutorial demonstrates how to retrieve location metrics, such as basic insights and driving directions, using the Google My Business API.\u003c/p\u003e\n"],["\u003cp\u003eBefore using the API, you'll need to register your application and obtain OAuth 2.0 credentials as outlined in the basic setup guide.\u003c/p\u003e\n"],["\u003cp\u003eYou can retrieve basic insights like direct and indirect queries for specific locations within a defined timeframe using the \u003ccode\u003eaccounts.locations.reportInsights\u003c/code\u003e API.\u003c/p\u003e\n"],["\u003cp\u003eDriving direction metrics, including data for the past 90 days, can also be retrieved using the \u003ccode\u003eaccounts.locations.reportInsights\u003c/code\u003e API with a driving directions request.\u003c/p\u003e\n"],["\u003cp\u003eRefer to the Metric reference page for a comprehensive list of supported insights available through the Google My Business API.\u003c/p\u003e\n"]]],[],null,["# Retrieve location insights\n\n\u003cbr /\u003e\n\nThis tutorial shows you how to retrieve location metrics in Business Profile.\nThe Google My Business API provides you with the ability to work with location\nmetrics to retrieve the following types of data:\n\n- [Supported insights](#supported_insights)\n- [Basic insights](#basic_insights)\n- [Driving directions](#driving_directions)\n\nBefore you begin\n----------------\n\nBefore you use the Google My Business API, you need to register your application\nand obtain OAuth 2.0 credentials. For details on how to get started with the\nGoogle My Business API, see [Basic setup](/my-business/content/basic-setup).\n\nSupported insights\n------------------\n\nFor supported insights, see the [Metric](/my-business/reference/rest/v4/Metric)\nreference page.\n\nBasic insights\n--------------\n\nRetrieves basic insights for a given list of locations. Use the [`accounts.locations.reportInsights`](/my-business/reference/rest/v4/accounts.locations/reportInsights)\nAPI to return the insights that are associated with a location.\n\nTo return the basic insights associated with a location, use the following:\nHTTP \n\n```\nPOST\nhttps://mybusiness.googleapis.com/v4/accounts/{accountId}/locations:reportInsights\n{\n \"locationNames\": [\n \"accounts/{accountId}/locations/{locationId}\"\n ],\n \"basicRequest\": {\n \"metricRequests\": [\n {\n \"metric\": \"QUERIES_DIRECT\"\n },\n {\n \"metric\": \"QUERIES_INDIRECT\"\n }\n ],\n \"timeRange\": {\n \"startTime\": \"2016-10-12T01:01:23.045123456Z\",\n \"endTime\": \"2017-01-10T23:59:59.045123456Z\"\n }\n }\n}\n```\n\nDriving directions\n------------------\n\nRetrieves driving direction metrics for a given list of locations. Use the\n[`accounts.locations.reportInsights`](/my-business/reference/rest/v4/accounts.locations/reportInsights)\nAPI to return driving direction metrics that are associated with a location.\n\nTo return the driving direction metrics, use the following:\nHTTP \n\n```\nPOST\nhttps://mybusiness.googleapis.com/v4/accounts/{accountId}/locations:reportInsights\n{\n \"locationNames\": [\n \"accounts/{accountId}/locations/{locationId}\"\n ],\n \"drivingDirectionsRequest\": {\n \"numDays\": \"NINETY\"\n }\n}\n```"]]