BatchAvailabilityLookup 示例和定义
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
请求结构
BatchAvailabilityLookup
请求可以跨同一商家的多个服务,并且所请求的广告资源可以跨多个资源和日期。建议您在所有商家中使用单个服务 ID,以简化集成。
响应时间
BatchAvailabilityLookup
请求的延迟时间阈值为 1.5 秒,超过此阈值即视为响应失败。确保您的内部网络和 DNS 路由已同步,以尽可能减少到达基础架构的请求的延迟。如果出现严重的超时错误,您的集成可能会被下线,直到您解决这些错误为止。
对请求的每次响应都必须返回商品目录在当时(而不是在进入预订流程时)的实际状态。如果某个空档已被预订,请在当前回答中反映这一点。
定义
BatchAvailabilityLookup
方法用于验证在预订流程中是否仅向用户显示当前空档。
BatchAvailabilityLookup 请求
message BatchAvailabilityLookupRequest {
// ID of the merchant.
string merchant_id = 1;
// Multiple slot times to be checked for availability. All queried times apply
// to the same merchant_id and service_id.
repeated SlotTime slot_time = 3;
reserved 2;
}
BatchAvailabilityLookup 响应
// Response for the [ext.maps.booking.partner.v3.BatchAvailabilityLookupRequest]
// RPC with the availabilities of the appointment slots.
message BatchAvailabilityLookupResponse {
// The availabilities for the requested SlotTime entries. There must be
// exactly one slot_time_availability for each SlotTime entry in the
// [ext.maps.booking.partner.v3.BatchAvailabilityLookupRequest].
repeated SlotTimeAvailability slot_time_availability = 1;
}
SlotTime
// Identifies a Slot service_id and start time and optionally, the Slot duration
// and resources, for a specific merchant. Note that this differs from the
// definition of Slot, as it does not include merchant_id identifier.
message SlotTime {
// ID of the service. (required)
string service_id = 5;
// Start time of the appointment slot in seconds of UTC time since Unix epoch
// (required)
int64 start_sec = 1;
// Duration of the appointment slot in seconds (optional)
int64 duration_sec = 2;
// Opaque tag that identifies the availability slot and matches the value
// provided in the Availability Feed (optional)
string availability_tag = 3;
// The set of resources that specifies the appointment slot, e.g. by
// indicating the staff member and room selected by the user, or party size
// for dining slots (optional)
ResourceIds resource_ids = 4;
// Indicates whether bookings of this slot will be confirmed
// synchronously or asynchronously. (optional)
// An UNSPECIFIED value will be interpreted as synchronous.
ConfirmationMode confirmation_mode = 6;
}
SlotTimeAvailability
如果未找到任何广告位,则返回空响应。请勿返回 400 错误,您可以返回 204 或其他 2xx 代码。它会验证是否正确接收到响应。
message SlotTimeAvailability {
// The SlotTime for which availability was checked.
SlotTime slot_time = 1;
// Whether the requested SlotTime is available
bool available = 2;
}
BatchAvailabilityLookup 示例
网页加载
当用户点击在线预订以启动预订流程时,系统会发送 BatchAvailabilityLookup
请求,其中包含商家已知的可用性空档。对于请求中发送的每个空档,预订服务器都会返回一个包含该空档实际当前可用情况的响应。前端仅向用户显示可用的广告资源。
如果用户更改了同行人数或选择了其他日期,则可以发送另一网页加载请求。
网页加载请求
{
"merchant_id" : "1234",
"slot_time" : [
{
"duration_sec" : "1800",
"resource_ids" : {
"party_size" : 2
},
"service_id" : "1000",
"start_sec" : "1606467600"
},
{
"duration_sec" : "1800",
"resource_ids" : {
"party_size" : 2
},
"service_id" : "1000",
"start_sec" : "1606469400"
},
{
"duration_sec" : "1800",
"resource_ids" : {
"party_size" : 2
},
"service_id" : "1000",
"start_sec" : "1606471200"
}
]
}
网页加载响应
{ "slot_time_availability" :
[
{
"available" : true,
"slot_time" : {
"duration_sec" : "1800",
"resource_ids" : {
"party_size" : 2 },
"service_id" : "1000",
"start_sec" : "1606467600" }
},
{
"available" : true,
"slot_time" : {
"duration_sec" : "1800",
"resource_ids" : {
"party_size" : 2 },
"service_id" : "1000",
"start_sec" : "1606469400" }
},
{
"available" : false,
"slot_time" : {
"duration_sec" : "1800",
"resource_ids" : {
"party_size" : 2 },
"service_id" : "1000",
"start_sec" : "1606471200" }
}
]
}
插槽点击
当用户选择可预订的时段时,系统会针对该特定时段发送 BatchAvailabilityLookup
请求。预订服务器会返回一个包含相应时段实际当前空闲情况的响应。如果相应时段已被其他 Google 用户预订,则预期响应为 False(表示无空闲时段),无论该预订是在您的系统内部进行,还是在网页加载和时段点击请求之间进行。
广告位点击请求
{
"merchant_id" : "1234",
"slot_time" : [
{
"duration_sec" : "1800",
"resource_ids" : {
"party_size" : 2
},
"service_id" : "1000",
"start_sec" : "1606467600"
}
]
}
slot 点击响应
{
"slot_time_availability" : [
{
"available" : true,
"slot_time" : {
"duration_sec" : "1800",
"resource_ids" : {
"party_size" : 2
},
"service_id" : "1000",
"start_sec" : "1606467600"
}
}
]
}
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[],[],null,["# BatchAvailabilityLookup Samples and Definitions\n\nRequest structure\n-----------------\n\n`BatchAvailabilityLookup` requests can span across multiple services for the\nsame merchant, and slots requested can span multiple resources and days. We\nrecommend a single Service ID be used across merchants to simplify your\nintegration.\n\nResponse times\n--------------\n\n`BatchAvailabilityLookup` requests have a latency threshold of 1.5 seconds\nbefore the response is considered a failure. Make sure that your internal\nnetworking and DNS routing are synced to minimize any delay in the request that\nreaches your infrastructure. If there are significant timeout errors, your\nintegration might be taken offline until you can resolve them.\n\nEvery response to a request must return the actual status of your inventory at\nthat moment and not when the booking flow was entered. If a slot is booked out,\nreflect that in current responses.\n\nDefinitions\n-----------\n\nThe `BatchAvailabilityLookup` method verifies that only current slots are\npresented to users during the reservation flow.\n\n### BatchAvailabilityLookup request\n\n message BatchAvailabilityLookupRequest {\n // ID of the merchant.\n string merchant_id = 1;\n\n // Multiple slot times to be checked for availability. All queried times apply\n // to the same merchant_id and service_id.\n repeated SlotTime slot_time = 3;\n\n reserved 2;\n }\n\n### BatchAvailabilityLookup response\n\n // Response for the [ext.maps.booking.partner.v3.BatchAvailabilityLookupRequest]\n // RPC with the availabilities of the appointment slots.\n message BatchAvailabilityLookupResponse {\n // The availabilities for the requested SlotTime entries. There must be\n // exactly one slot_time_availability for each SlotTime entry in the\n // [ext.maps.booking.partner.v3.BatchAvailabilityLookupRequest].\n repeated SlotTimeAvailability slot_time_availability = 1;\n }\n\n### SlotTime\n\n // Identifies a Slot service_id and start time and optionally, the Slot duration\n // and resources, for a specific merchant. Note that this differs from the\n // definition of Slot, as it does not include merchant_id identifier.\n message SlotTime {\n // ID of the service. (required)\n string service_id = 5;\n\n // Start time of the appointment slot in seconds of UTC time since Unix epoch\n // (required)\n int64 start_sec = 1;\n\n // Duration of the appointment slot in seconds (optional)\n int64 duration_sec = 2;\n\n // Opaque tag that identifies the availability slot and matches the value\n // provided in the Availability Feed (optional)\n string availability_tag = 3;\n\n // The set of resources that specifies the appointment slot, e.g. by\n // indicating the staff member and room selected by the user, or party size\n // for dining slots (optional)\n ResourceIds resource_ids = 4;\n\n // Indicates whether bookings of this slot will be confirmed\n // synchronously or asynchronously. (optional)\n // An UNSPECIFIED value will be interpreted as synchronous.\n ConfirmationMode confirmation_mode = 6;\n }\n\n### SlotTimeAvailability\n\nIf no slots are found, return an empty response. Don't return a 400 error,\ninstead you can return 204 or other 2xx code. It verifies that the response is\ncorrectly received. \n\n message SlotTimeAvailability {\n // The SlotTime for which availability was checked.\n SlotTime slot_time = 1;\n\n // Whether the requested SlotTime is available\n bool available = 2;\n }\n\nBatchAvailabilityLookup samples\n-------------------------------\n\n### Page load\n\nWhen a user clicks **Book Online** to initiate the booking flow, a\n`BatchAvailabilityLookup` request is sent with known availability slots for the\nmerchant. For each slot sent in the request, your Booking Server returns a\nresponse with the actual, current availability of the slot. Only available slots\nare presented to the user on the frontend.\n\nIf a user changes their party size or selects another date, another page load\nrequest can be sent. \n\n### Page load request\n\n {\n \"merchant_id\" : \"1234\",\n \"slot_time\" : [\n {\n \"duration_sec\" : \"1800\",\n \"resource_ids\" : {\n \"party_size\" : 2\n },\n \"service_id\" : \"1000\",\n \"start_sec\" : \"1606467600\"\n },\n {\n \"duration_sec\" : \"1800\",\n \"resource_ids\" : {\n \"party_size\" : 2\n },\n \"service_id\" : \"1000\",\n \"start_sec\" : \"1606469400\"\n },\n {\n \"duration_sec\" : \"1800\",\n \"resource_ids\" : {\n \"party_size\" : 2\n },\n \"service_id\" : \"1000\",\n \"start_sec\" : \"1606471200\"\n }\n ]\n }\n\n### Page load response\n\n { \"slot_time_availability\" :\n [\n {\n \"available\" : true,\n \"slot_time\" : {\n \"duration_sec\" : \"1800\",\n \"resource_ids\" : {\n \"party_size\" : 2 },\n \"service_id\" : \"1000\",\n \"start_sec\" : \"1606467600\" }\n },\n {\n \"available\" : true,\n \"slot_time\" : {\n \"duration_sec\" : \"1800\",\n \"resource_ids\" : {\n \"party_size\" : 2 },\n \"service_id\" : \"1000\",\n \"start_sec\" : \"1606469400\" }\n },\n {\n \"available\" : false,\n \"slot_time\" : {\n \"duration_sec\" : \"1800\",\n \"resource_ids\" : {\n \"party_size\" : 2 },\n \"service_id\" : \"1000\",\n \"start_sec\" : \"1606471200\" }\n }\n ]\n }\n\n### Slot click\n\nWhen a user selects a bookable slot a `BatchAvailabilityLookup` request is sent\nfor the specific slot. Your Booking Server returns a response with the actual,\ncurrent availability of the slot. The expected response is **False** for the\navailability if that slot is booked out by another Google user, internally\nwithin your system or between the page load and slot click requests. \n\n### Slot click request\n\n {\n \"merchant_id\" : \"1234\",\n \"slot_time\" : [\n {\n \"duration_sec\" : \"1800\",\n \"resource_ids\" : {\n \"party_size\" : 2\n },\n \"service_id\" : \"1000\",\n \"start_sec\" : \"1606467600\"\n }\n ]\n }\n\n### Slot click response\n\n {\n \"slot_time_availability\" : [\n {\n \"available\" : true,\n \"slot_time\" : {\n \"duration_sec\" : \"1800\",\n \"resource_ids\" : {\n \"party_size\" : 2\n },\n \"service_id\" : \"1000\",\n \"start_sec\" : \"1606467600\"\n }\n }\n ]\n }"]]