Google Business Performance API 的
NEW API 方法可擷取單一 API 要求中的多個「DailyMetrics」。
請詳閱
淘汰時間表和從 v4 reportInsights API 方法遷移至 Google Business Profile Performance API 的操作說明。
擷取位置洞察資料
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
本教學課程將說明如何在商家檔案中擷取位置指標。Google My Business API 可讓您使用位置指標,擷取下列類型的資料:
事前準備
使用 Google 我的商家 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"
}
}
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-29 (世界標準時間)。
[null,null,["上次更新時間: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```"]]