开发文档
Alcampo groceries 接口的完整参考文档
Alcampo groceries 接口参考:分类树、分类浏览、商品详情与关键词搜索的入参默认值、限制与返回字段。
另见: Alcampo 杂货数据概览与价格 · Alcampo groceries 接口指南:跨操作工作流程
本页内容
`alcampo-categories`:分类树字段
alcampo-categories 返回杂货分类树,每个节点包含 id、name、retailer_category_id 与 children 四个字段。id 就是调用 alcampo-category 时 body.category_id 所需要的值;retailer_category_id 是连锁门店内部使用的另一套编码,并不是 body.category_id 可接受的取值。分类树只有两级:每个顶层节点的 children 中包含它自己的子分类节点,这些子分类节点同样带有这四个字段,但不会再向下嵌套,因此沿着任意一条分支往下读,最多只会遇到两级 id。
本节涉及的字段(1)
alcampo-categories
`alcampo-category`:浏览单个分类
alcampo-category 从分类树中取出某个分类的 id,作为 body.category_id 发送,返回的商品行字段与 alcampo-search 相同,并附带该分类下商品的总数。由于分类与其商品都是通过这一个标识符查找的,无论这个分类 id 取自顶层还是取自分类树的子分类层级,调用方式都完全一样。
本节涉及的字段(2)
alcampo-category, body.category_id
`alcampo-product`:完整商品记录
alcampo-product 接受来自搜索行或分类行的商品 id,也可以改用别名 product_id,或者一个 www.compraonline.alcampo.es 商品页面地址作为 url 别名;三者之中无论发送哪一个,该操作都会读取。description 存放商品的文字介绍,fields 与 ingredients 分别存放结构化的标签属性与配料文字。
allergens 存放标签标注的致敏物,nutrition 营养表存放每单位的营养数值,breadcrumbs 则记录商品页面上方显示的分类路径,与 images 并列。gtin 是标签上印的条码,只有当商品标签确实印有 EAN 码时才会出现。
本节涉及的字段(2)
alcampo-product, body.id
`alcampo-search`:关键词搜索及其返回内容
alcampo-search 用 body.query(最多 100 个字符)或其别名 q 在目录中匹配商品,每一条匹配的商品返回一行,包含其欧元标价、单位价格、促销信息、库存状态、品牌、包装规格、图片与链接。除了这些商品行,返回内容中还带有一个 facets 筛选分组列表、一个用于请求下一页的 next_cursor 值,以及一个 location 信息块。其中 region 字段说明本次定价所采用的配送区域,store_defaulted 字段在该区域是连锁门店默认区域、而非由 body.latitude 与 body.longitude 设定时为真。
本节涉及的字段(2)
alcampo-search, body.query
Alcampo groceries 接口的分页、排序、筛选与收货地点
alcampo-category 与 alcampo-search 共用同一套分页、排序与筛选入参。body.limit 每次请求 1 到 48 行,默认 24 行;超出该范围的取值会被拒绝,而不是被调整到范围以内;数据源本身也可能因为在其内部分组之间去除重复行,而在分页构建完成前返回比 body.limit 更少的行数。请求下一页时,把上一次返回内容中的 next_cursor 原样放进下一次请求的 body.cursor,并保持相同的查询或分类、相同的筛选条件与相同的收货地点。
body.sort 默认是 favorite,否则只接受 priceAscending、priceDescending、pricePerAscending 或 pricePerDescending 其中之一,其他取值都会被拒绝。body.brand 会把结果限定为上一次返回内容中 facets[id=brands] 分组里的某一个精确取值,body.on_offer(true 或 false,默认 false)则只保留带有促销信息的行。
alcampo-category、alcampo-product 与 alcampo-search 都把 body.latitude 与 body.longitude 当作一对入参:两者一起发送时,会按照这组坐标确定的收货地点来决定返回内容中的价格、促销与库存状态;只发送其中一个,或者两个都不发送,这三个操作都会改用连锁门店自己的默认区域。body.postal_code 只是随坐标一起发送,单独发送时不会起到设定收货地点的作用。
本节涉及的字段(11)
alcampo-category, alcampo-search, alcampo-product, body.limit, body.cursor, body.sort, body.brand, body.on_offer, body.latitude, body.longitude, body.postal_code
操作
公共网关操作统一使用 POST /api/v1/{project}/{action}。
使用 JSON 对象,按文档将参数放入 path、query、headers 和 body,省略未使用的位置。input.headers 是供操作使用的 JSON 数据,不是浏览器请求头。请勿在此填写凭证。按文档保留 body 的数组、标量或 null;省略与 null 含义不同。
分类树
POST /api/v1/alcampo/alcampo-categories
返回杂货分类树,并给出每个节点用于直接浏览该分类的 id。
输入字段
此操作没有输入字段,发送下方所示的 JSON 请求体即可。
请求示例
# Server-side only. Set KAKIAPI_API_KEY in your secret manager.
# Every gateway operation is called with POST.
# Only operations shown as enabled on the API page can be called.
# Generate once per intent; retain the same value on status checks.
REQUEST_ID="$(uuidgen)"
curl --request POST 'https://kakiapi.com/api/v1/alcampo/alcampo-categories' \
--header "Content-Type: application/json" \
--header "x-api-key: $KAKIAPI_API_KEY" \
--header "Idempotency-Key: $REQUEST_ID" \
--data '{"body":{}}'浏览分类
POST /api/v1/alcampo/alcampo-category
按 id 列出某个分类下的商品,筛选、排序与翻页方式与关键词搜索相同。
输入字段
| 字段 | 类型 | 是否必填 | 默认值 | 允许的值 | 范围限制 |
|---|---|---|---|---|---|
body.category_id | string | 必填 | — | — | — |
body.brand | string | 可选 | — | — | — |
body.cursor | string | 可选 | — | — | — |
body.latitude | number | 可选 | — | — | — |
body.limit | integer | 可选 | 24 | — | 1–48 |
body.longitude | number | 可选 | — | — | — |
body.on_offer | boolean | 可选 | false | — | — |
body.postal_code | string | 可选 | — | — | — |
body.sort | string | 可选 | "favorite" | "favorite""priceAscending""priceDescending""pricePerAscending""pricePerDescending" | — |
请求示例
# Server-side only. Set KAKIAPI_API_KEY in your secret manager.
# Every gateway operation is called with POST.
# Only operations shown as enabled on the API page can be called.
# Generate once per intent; retain the same value on status checks.
REQUEST_ID="$(uuidgen)"
curl --request POST 'https://kakiapi.com/api/v1/alcampo/alcampo-category' \
--header "Content-Type: application/json" \
--header "x-api-key: $KAKIAPI_API_KEY" \
--header "Idempotency-Key: $REQUEST_ID" \
--data '{"body":{"category_id":"48c34870-c5a3-46c9-870b-590c66fe8848"}}'商品详情
POST /api/v1/alcampo/alcampo-product
返回单个商品的完整记录,包括配料、致敏物、营养信息与图片。
输入字段
| 字段 | 类型 | 是否必填 | 允许的值 | 范围限制 |
|---|---|---|---|---|
body.id | string | 必填 | — | — |
body.latitude | number | 可选 | — | — |
body.longitude | number | 可选 | — | — |
body.postal_code | string | 可选 | — | — |
请求示例
# Server-side only. Set KAKIAPI_API_KEY in your secret manager.
# Every gateway operation is called with POST.
# Only operations shown as enabled on the API page can be called.
# Generate once per intent; retain the same value on status checks.
REQUEST_ID="$(uuidgen)"
curl --request POST 'https://kakiapi.com/api/v1/alcampo/alcampo-product' \
--header "Content-Type: application/json" \
--header "x-api-key: $KAKIAPI_API_KEY" \
--header "Idempotency-Key: $REQUEST_ID" \
--data '{"body":{"id":"473577"}}'商品搜索
POST /api/v1/alcampo/alcampo-search
按关键词搜索目录,返回匹配商品的价格、促销、库存状态与图片。
输入字段
| 字段 | 类型 | 是否必填 | 默认值 | 允许的值 | 范围限制 |
|---|---|---|---|---|---|
body.query | string | 必填 | — | — | — |
body.brand | string | 可选 | — | — | — |
body.cursor | string | 可选 | — | — | — |
body.latitude | number | 可选 | — | — | — |
body.limit | integer | 可选 | 24 | — | 1–48 |
body.longitude | number | 可选 | — | — | — |
body.on_offer | boolean | 可选 | false | — | — |
body.postal_code | string | 可选 | — | — | — |
body.sort | string | 可选 | "favorite" | "favorite""priceAscending""priceDescending""pricePerAscending""pricePerDescending" | — |
请求示例
# Server-side only. Set KAKIAPI_API_KEY in your secret manager.
# Every gateway operation is called with POST.
# Only operations shown as enabled on the API page can be called.
# Generate once per intent; retain the same value on status checks.
REQUEST_ID="$(uuidgen)"
curl --request POST 'https://kakiapi.com/api/v1/alcampo/alcampo-search' \
--header "Content-Type: application/json" \
--header "x-api-key: $KAKIAPI_API_KEY" \
--header "Idempotency-Key: $REQUEST_ID" \
--data '{"body":{"limit":24,"query":"leche"}}'调用方式
- 使用
POST /api/v1/alcampo/<action>,并携带x-api-key、Content-Type: application/json和必需的Idempotency-Key。 - 调用成功时返回
ok: true:data是操作的结果,meta.requestId标识已记录的请求,meta.chargedCreditUnits是实际扣费金额。否则ok为false,error.code说明原因;请读取ok和error.code,不要只依赖 HTTP 状态码。每个网关响应都带有供支持使用的请求 ID:meta.requestId;没有meta的响应(如受理前被拒绝)则为顶层requestId。 - 只有调用成功才按标价扣费。失败不扣费;结果无法确认时,最多 900 秒后释放,不扣费。
- 请求完成后,以同一个 Idempotency-Key 重复发送相同请求,24 小时内返回已保存的响应,不会再次扣费。
网关调用参考: