注意:API 即将进行重大更改,需要进行迁移工作。请时常关注我们即将发布的版本页面和弃用时间表,了解最新动态。您还可以注册加入我们的邮寄名单,以便接收最新动态。

添加服务

商家可以将他们提供的服务添加到 GMB 商家信息中。这可能包括在商店内提供的服务,或在营业地点为客户提供的服务。

资格条件和格式

并非所有商家都可以将服务添加到他们的 GMB 商家信息中。要查看资格条件,请检查 LocationStatecanModifyServiceList 的状态。

服务以 ServiceItem 的形式表示,ServiceItem 支持以下两种格式:

  • StructuredServiceItem:Google 的预定义服务能以 StructuredServiceItem 的形式表示,其中包含 serviceTypeId
  • FreeFormServiceItem:要提供自定义服务,请使用 FreeFormServiceItem,其中包含标签

按类别名称列出预定义服务

要按类别名称搜索某一类别下的预定义服务,请使用 categories.list。以下“请求”部分中显示了针对新加坡境内所有类别且包含名称“salon”的请求。

请求

CategoryView 必须设置为 FULL

HTTP
GET https://mybusiness.googleapis.com/v4/categories?regionCode=SG&languageCode=EN&searchTerm=salon&view=FULL

响应

以下部分响应会返回所有受支持的 ServiceTypes

{
    "categories": [
        {
            "displayName": "Hairdresser",
            "categoryId": "gcid:hair_salon",
            "serviceTypes": [
                {
                    "serviceTypeId": "job_type_id:body_waxing",
                    "displayName": "Body Waxing"
                },
                {
                    "serviceTypeId": "job_type_id:hair_coloring",
                    "displayName": "Hair coloring"
                },
                {
                    "serviceTypeId": "job_type_id:hair_extensions",
                    "displayName": "Hair extensions"
                },
                {
                    "serviceTypeId": "job_type_id:hair_styling",
                    "displayName": "Hair styling"
                },
                {
                    "serviceTypeId": "job_type_id:manicures",
                    "displayName": "Manicures"
                },
                {
                    "serviceTypeId": "job_type_id:pedicures",
                    "displayName": "Pedicures"
                }
            ]
        }
}

按类别 ID 列出预定义服务

要按特定类别 ID 搜索预定义服务,请使用 categories.batchGet。以下“请求”部分显示了针对美国境内类别 ID“gcid:electrician”下所含服务相关详细信息的请求。

请求

CategoryView 必须设置为 FULL

HTTP
GET https://mybusiness.googleapis.com/v4/categories:batchGet?regionCode=US&languageCode=en&categoryIds=gcid:electrician&view=FULL

响应

响应包含 gcid:electrician 的所有受支持的 ServiceTypes

{
    "categories": [
        {
            "displayName": "Electrician",
            "categoryId": "gcid:electrician",
            "serviceTypes": [
                {
                    "serviceTypeId": "job_type_id:construction",
                    "displayName": "Construction"
                },
                {
                    "serviceTypeId": "job_type_id:electric_car_charger",
                    "displayName": "Install electric car charger"
                },
                {
                    "serviceTypeId": "job_type_id:electrician_remodeling",
                    "displayName": "Remodeling"
                },
                {
                    "serviceTypeId": "job_type_id:general_repairs",
                    "displayName": "General repairs"
                },
                {
                    "serviceTypeId": "job_type_id:install_fan",
                    "displayName": "Install fan"
                },
                {
                    "serviceTypeId": "job_type_id:install_ground_wire",
                    "displayName": "Install ground wire"
                },
                {
                    "serviceTypeId": "job_type_id:install_light_fixtures",
                    "displayName": "Install light fixtures"
                },
                {
                    "serviceTypeId": "job_type_id:install_outdoor_lighting",
                    "displayName": "Install outdoor lighting"
                },
                {
                    "serviceTypeId": "job_type_id:install_outlets_switches",
                    "displayName": "Install outlets or switches"
                },
                {
                    "serviceTypeId": "job_type_id:install_security_system",
                    "displayName": "Install security system"
                },
                {
                    "serviceTypeId": "job_type_id:installation",
                    "displayName": "Installation"
                },
                {
                    "serviceTypeId": "job_type_id:relocate_outlets_switches",
                    "displayName": "Relocate outlets or switches"
                },
                {
                    "serviceTypeId": "job_type_id:repair_fan",
                    "displayName": "Repair fan"
                },
                {
                    "serviceTypeId": "job_type_id:repair_light_fixtures",
                    "displayName": "Repair light fixtures"
                },
                {
                    "serviceTypeId": "job_type_id:repair_outlets_switches",
                    "displayName": "Repair outlets or switches"
                },
                {
                    "serviceTypeId": "job_type_id:repair_panel",
                    "displayName": "Repair panel"
                },
                {
                    "serviceTypeId": "job_type_id:replace_upgrade_panel",
                    "displayName": "Replace or upgrade panel"
                },
                {
                    "serviceTypeId": "job_type_id:restore_power",
                    "displayName": "Restore power"
                }
            ]
        }
    ]
}

在商家信息中列出现有服务

要获取当前服务列表,请使用 locations.getServiceList

请求

HTTP
GET https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/serviceList

响应

以下是示例响应

{
    "serviceItems": [
        {
            "structuredServiceItem": {
                "serviceTypeId": "job_type_id:hair_coloring"
            }
        },
        {
            "isOffered": true,
            "structuredServiceItem": {
                "serviceTypeId": "job_type_id:hair_styling"
            }
        },
        {
            "isOffered": true,
            "freeFormServiceItem": {
                "categoryId": "gcid:barber_shop",
                "label": {
                    "displayName": "Student Cuts"
                }
            }
        }
    ]
}

为商家信息设置服务

要更新服务,请使用 locations.updateServiceListupdateMask=serviceItems。不支持更新单项服务。

要使用 StructuredServiceItemFreeFormServiceItem 设置服务,请参阅以下示例:

HTTP
PATCH
https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/serviceList?updateMask=serviceItems
{
   "serviceItems":[
      {
         "isOffered":false,
         "structuredServiceItem":{
            "serviceTypeId":"job_type_id:hair_coloring"
         }
      },
      {
         "isOffered":true,
         "structuredServiceItem":{
            "serviceTypeId":"job_type_id:hair_styling"
         }
      },
      {
         "isOffered":true,
         "freeFormServiceItem":{
            "categoryId":"gcid:hair_salon",
            "label":{
               "displayName":"Student Cuts"
            }
         }
      }
   ]
}