在地生活服務廣告端對端透過 API 查詢商家狀態
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
用途
Google 地圖預訂 API 提供兩種方法,可透過程式輔助方式,針對各種整合或 Local Services Ads 廣告空間,擷取個別商家的狀態。
Merchant Status API 的用途:
- 強化現有的客戶關係管理工具,向客戶展示他們的商品目錄在 Google 上的呈現方式。
- 建立資訊主頁,以追蹤商家的商品目錄狀態和比對狀態。
- 以程式輔助方式擷取商家的相符和可預訂狀態,並修正任何不正確的資訊,以改善資料品質。
商家狀態包含哪些內容
MerchantStatus 包含下列資訊:
- 商家廣告空間狀態:適用於預訂和/或等候名單商家。
- 商家比對狀態:包含已比對的商家資訊
- (僅限 Google 在地生活服務廣告) 比對成功的商家服務供應商:包含客戶 ID 和服務類別。
- 用來說明商家在 Google 上的顯示方式。
查詢單一商家的狀態
您可以使用 inventory.partners.merchants.getStatus 取得單一商家的狀態:
GET https://mapsbooking.googleapis.com/v1alpha/inventory/partners/{partnerId}/merchants/{merchantId}/status
以下是 Python 程式碼範例 (如需其他語言的範例,請參閱這裡):
from google.auth.transport.requests import AuthorizedSession
from google.oauth2 import service_account
credentials = service_account.Credentials.from_service_account_file(
'./your_key.json')
scoped_credentials = credentials.with_scopes(
['https://www.googleapis.com/auth/mapsbooking'])
authed_session = AuthorizedSession(scoped_credentials)
response = authed_session.get('https://partnerdev-mapsbooking.googleapis.com' +
'/v1alpha/inventory/partners/123456789/merchants/001/status')
MerchantStatus 回應範例如下:
{
"name": "partners/123456789/merchants/001/status",
"merchantName": "Foo Bar Restaurant",
"inputGeoInfo": {
"unstructured_address": "123 Foo Bar Street, Mountain View"
},
"processingStatus": "COMPLETED",
"bookingStatus": {
"hasValidFutureInventory": true
},
"waitlistStatus": {
"hasValidWaitlistService": true
}
"geoMatch": {
"name": "Foo Bar Restaurant",
"formattedAddress": "123 Foo Bar St, Mountain View, CA 94043",
"placeId": "ChIAAAAAAAAABBBBBBBB"
},
"directUrls": [
{
"type": "BOOKING",
"url": "https://reserve-partnerdev.sandbox.google.com/maps/reserve/v/dine/m/Nwaaaaa"
},
{
"type": "WAITLIST",
"url": "https://reserve-partnerdev.sandbox.google.com/maps/reserve/v/wait/c/iDbbbbb"
}
]
}
大量擷取商家狀態
您可以使用 inventory.partners.merchants.status.list 擷取所有商家或符合特定商品目錄/比對條件的商家群組狀態。舉例來說,您可以發出以下呼叫,取得所有擁有有效預約商品目錄的不相符商家:
GET https://mapsbooking.googleapis.com/v1alpha/inventory/partners/{partnerId}/merchants/status?pageSize=50&bookingInventoryStatusRestrict=HAS_VALID_FUTURE_INVENTORY&geoMatchRestrict=GEO_UNMATCHED
回應範例如下所示:
{
"merchantStatuses": [
{
"name": "partners/123456789/merchants/002/status",
"merchantName": "Bar Foo Restaurant",
"inputGeoInfo": {
"unstructured_address": "234 Bar Foo Street, Mountain View"
},
"processingStatus": "COMPLETED",
"bookingStatus": {
"hasValidFutureInventory": true
},
"waitlistStatus": {},
},
...
{
"name": "partners/123456789/merchants/080/status",
"merchantName": "Baz Restaurant",
"inputGeoInfo": {
"unstructured_address": "345 Baz Street, Mountain View"
},
"processingStatus": "COMPLETED",
"bookingStatus": {
"hasValidFutureInventory": true
},
"waitlistStatus": {
"hasValidWaitlistService": true
},
},
],
"nextPageToken": "AAABBBB"
}
這個回應會包含 50 個符合篩選條件的 MerchantStatus,並依 merchant_id
排序。回應也包含分頁符記 (如果不是最後一頁),可用於查詢下一頁。
請注意:篩選條件應在所有頁面上保持一致。
最佳做法
由於商家狀態在大多數情況下不會經常變更,因此建議您將擷取的結果快取,並定期 (例如每隔幾小時) 透過新查詢擷取這些結果。如果每秒要求數量過高,Actions Center 可能會限制您的查詢。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間:2025-07-26 (世界標準時間)。"],[[["\u003cp\u003eThe Google Maps Booking API's Merchant Status API allows programmatic retrieval of individual merchant statuses for integrations and Local Services Ads inventory.\u003c/p\u003e\n"],["\u003cp\u003eUse this API to enhance customer relationship management tools, build inventory tracking dashboards, and improve data quality by fixing incorrect merchant information.\u003c/p\u003e\n"],["\u003cp\u003eMerchant status data includes inventory status, matching status, Local Services Ads details (if applicable), and URLs showcasing the merchant's Google presence.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can look up individual merchant status or retrieve statuses in bulk with filtering options, receiving responses containing relevant merchant data.\u003c/p\u003e\n"],["\u003cp\u003eCaching retrieved results and periodic refreshing are recommended to avoid excessive API requests and potential throttling.\u003c/p\u003e\n"]]],["The Merchant Status API provides methods to retrieve merchant inventory and matching status for Google Maps and Local Services Ads. Key actions include: retrieving a single merchant's status via a `GET` request using their `partnerId` and `merchantId`, and fetching multiple merchants' statuses with filtering options like `bookingInventoryStatusRestrict` and `geoMatchRestrict`. The API's response includes details such as inventory and matching statuses, and URLs showing the merchant's visibility on Google. Results should be cached to avoid excessive queries.\n"],null,["# Local Services Ads End-to-End Querying Merchant Status via the API\n\nUse cases\n---------\n\n\n[Google Maps Booking API](/maps-booking/reference/maps-booking-api/rest) provides two methods, which can be used\nto programmatically retrieve a status of the individual merchants for\nvarious integrations or\n[Local Services Ads](https://ads.google.com/local-services-ads)\ninventory.\n\nUse cases for Merchant Status API:\n\n- Enhance existing customer relation management tools to demonstrate your customers how their inventory is surfaced on Google.\n- Build a dashboard to track the inventory status and matching status of your merchants.\n- Programmatically retrieve matching and bookable statuses of your merchants and fix any incorrect information to improve data quality.\n\nWhat does the merchant status contain\n-------------------------------------\n\nThe\n[MerchantStatus](/maps-booking/reference/maps-booking-api/rest/v1alpha/MerchantStatus) contains the following information:\n\n- Merchant inventory status: applies to both booking and/or waitlist merchants.\n- Merchant matching status: includes details on the matched business listing\n- For [Google Local Services Ads](https://ads.google.com/local-services-ads) only) Matched merchant service provider: includes the customer ID and service categories.\n- The URLs to demonstrate how the merchant is surfaced on Google.\n\nLook up a single merchant status\n--------------------------------\n\nYou can get the status of a single merchant using\n[inventory.partners.merchants.getStatus](/maps-booking/reference/maps-booking-api/rest/v1alpha/inventory.partners.merchants/getStatus): \n\n```text\nGET https://mapsbooking.googleapis.com/v1alpha/inventory/partners/{partnerId}/merchants/{merchantId}/status\n```\n\nHere is a Python code sample (see examples in more languages\n[here](/actions-center/verticals/local-services/e2e/reference/real-time-updates-rest/code-samples)): \n\n```python\nfrom google.auth.transport.requests import AuthorizedSession\nfrom google.oauth2 import service_account\n\ncredentials = service_account.Credentials.from_service_account_file(\n './your_key.json')\nscoped_credentials = credentials.with_scopes(\n ['https://www.googleapis.com/auth/mapsbooking'])\nauthed_session = AuthorizedSession(scoped_credentials)\n\nresponse = authed_session.get('https://partnerdev-mapsbooking.googleapis.com' +\n '/v1alpha/inventory/partners/123456789/merchants/001/status')\n```\n\nAn example\n[MerchantStatus](/maps-booking/reference/maps-booking-api/rest/v1alpha/MerchantStatus) response looks like: \n\n```carbon\n {\n \"name\": \"partners/123456789/merchants/001/status\",\n \"merchantName\": \"Foo Bar Restaurant\",\n \"inputGeoInfo\": {\n \"unstructured_address\": \"123 Foo Bar Street, Mountain View\"\n },\n \"processingStatus\": \"COMPLETED\",\n \"bookingStatus\": {\n \"hasValidFutureInventory\": true\n },\n \"waitlistStatus\": {\n \"hasValidWaitlistService\": true\n }\n \"geoMatch\": {\n \"name\": \"Foo Bar Restaurant\",\n \"formattedAddress\": \"123 Foo Bar St, Mountain View, CA 94043\",\n \"placeId\": \"ChIAAAAAAAAABBBBBBBB\"\n },\n \"directUrls\": [\n {\n \"type\": \"BOOKING\",\n \"url\": \"https://reserve-partnerdev.sandbox.google.com/maps/reserve/v/dine/m/Nwaaaaa\"\n },\n {\n \"type\": \"WAITLIST\",\n \"url\": \"https://reserve-partnerdev.sandbox.google.com/maps/reserve/v/wait/c/iDbbbbb\"\n }\n ]\n }\n```\n\nRetrieve merchant statuses in bulk\n----------------------------------\n\nYou can retrieve statuses of all merchants, or a group of merchants\nsatisfying certain inventory/matching conditions, using\n[inventory.partners.merchants.status.list](/maps-booking/reference/maps-booking-api/rest/v1alpha/inventory.partners.merchants.status/list). For example, you can make\nthis call to get all unmatched merchants with valid future-dated booking\ninventory: \n\n```scdoc\nGET https://mapsbooking.googleapis.com/v1alpha/inventory/partners/{partnerId}/merchants/status?pageSize=50&bookingInventoryStatusRestrict=HAS_VALID_FUTURE_INVENTORY&geoMatchRestrict=GEO_UNMATCHED\n```\n\nA sample response would look like this: \n\n```carbon\n {\n \"merchantStatuses\": [\n {\n \"name\": \"partners/123456789/merchants/002/status\",\n \"merchantName\": \"Bar Foo Restaurant\",\n \"inputGeoInfo\": {\n \"unstructured_address\": \"234 Bar Foo Street, Mountain View\"\n },\n \"processingStatus\": \"COMPLETED\",\n \"bookingStatus\": {\n \"hasValidFutureInventory\": true\n },\n \"waitlistStatus\": {},\n },\n ...\n {\n \"name\": \"partners/123456789/merchants/080/status\",\n \"merchantName\": \"Baz Restaurant\",\n \"inputGeoInfo\": {\n \"unstructured_address\": \"345 Baz Street, Mountain View\"\n },\n \"processingStatus\": \"COMPLETED\",\n \"bookingStatus\": {\n \"hasValidFutureInventory\": true\n },\n \"waitlistStatus\": {\n \"hasValidWaitlistService\": true\n },\n },\n ],\n \"nextPageToken\": \"AAABBBB\"\n }\n```\n\nThis response will contain 50\n[MerchantStatus](/maps-booking/reference/maps-booking-api/rest/v1alpha/MerchantStatus) that satisfy the filtering conditions and ordered by\n`merchant_id`. The response also contains a page token (if it is\nnot the last page) to query the next page.\n\nPlease note: the filtering conditions should be consistent across all\npages.\n\nBest Practices\n--------------\n\nSince merchant statuses do not change frequently in most times, it is\nencouraged to cache the retrieved results and periodically (e.g. every few\nhours) retrieve them via new queries. The Actions Center may throttle your\nqueries if the number of requests per second deem to be excessively high."]]