开发文档
A101 API 参考文档
A101 API 参考:促销活动、商品详情、搜索和输入联想各输入项的作用,以及返回的结果行和记录字段的含义。
另见: A101 API:Kapıda 日用百货与 Ekstra 商品数据概览与价格 · A101 API 指南:搜索、促销活动与价格跟踪
本页内容
A101 API 促销活动列表:a101-campaigns
a101-campaigns 返回某个 A101 促销活动页上的商品。各个活动取值对应网店所用的促销名称及开展该活动的网店:
aldin_aldin是 Aldın Aldın,是两家网店都有的唯一取值haftanin_yildizlari是 Haftanın Yıldızları,属于 Kapıdaaldin_aldin_x是 Aldın Aldın X,属于 Kapıdaaylik_firsat是 Aylık Fırsat Ürünleri,属于 Kapıdasepette_10_tl是购物满 10 里拉即享的购物篮优惠,属于 Kapıdacok_al_az_ode是 Çok Al Az Öde 多买优惠,属于 Kapıdaaldin_aldin_ekstra是 Aldın Aldın Ekstra,属于 Ekstra
请把取值与开展该活动的网店搭配。results 中的行与搜索结果行字段相同,每页 60 行。除此之外,回复还带有用于分页的 count、total_results、total_pages、page、page_size 和 has_more。
它还给出所读取的 channel,描述所列活动的 campaign、campaign_code 和 campaign_page,以及表示 Kapıda 配送门店的 store_code。只要 has_more 显示还有下一页,就把 page 加一;超出范围的页码会被拒绝。
本节涉及的字段(4)
a101-campaigns, body.campaign, body.channel, body.page
按 id 或地址读取商品记录:a101-product-detail
a101-product-detail 读取单个商品。product_id 接收搜索结果行或活动结果行中的 product_id,例如 Kapıda 的 12002661 或 Ekstra 的 26077738。url 是另一种方式:a101.com.tr 的商品地址,以 _p- 加 id 结尾,或包含 /kapida/product/ 加 id。
使用 id 时,auto 会在两家网店中查找,指定 kapida 或 ekstra 则只在其中一家查找;使用地址时,由地址本身决定网店。id 和 sku 也可以代替 product_id,product_url 也可以代替 url。在返回的 product 中,有几项条目带有自己的字段:
breadcrumb的条目带有id、name和urlcampaign_period带有name、starts_on和ends_oninstallments的条目把信用卡card与其max_interest_free_installments配对specifications的条目把name与value配对variants的条目带有product_id、size、color、price、in_stock和urlother_channel_offer描述同一商品在另一家 A101 网店的情况,价格为那家网店自己的价格,含channel、product_id、price、price_before_discount、discount_percent、in_stock、url和store_code;商品只在一家网店销售时,该字段为 null
如果记录只能依据搜索索引生成,product_page 的值为 false。
本节涉及的字段(4)
a101-product-detail, body.product_id, body.url, body.channel
关键词搜索:a101-search
a101-search 在一家网店中查找土耳其语关键词,每页返回 60 个商品。食品杂货只在 Kapıda 销售,电视、手机、家具和服装则在 Ekstra。品牌名和商品词都可以使用,A101 的搜索能容忍拼写错误。
q 和 keyword 也可以代替 query。排序取决于网店:Ekstra 提供自己的排序方式,而 Kapıda 的搜索没有可用的排序,因此 Kapıda 请求只接受 relevance,其他排序都会被拒绝。当 A101 没有匹配的商品时,它会用无关商品填满页面:
- 这些行默认会被去掉,
fallback_results_dropped报告去掉了多少行。 - 把
include_fallback_results设为 true 时,它们会单独放在fallback_results中返回,并附带fallback_total。
keyword_matches_on_page 和 page_notice 说明该页与关键词的关系,在搜索中 total_results 可能为 null。除 results 中的行之外,回复还带有 count、total_pages、page、page_size 和 has_more。回复还带有 channel,在 Kapıda 上还带有 store_code。
本节涉及的字段(4)
a101-search, body.query, body.sort, body.include_fallback_results
输入联想建议:a101-suggest
a101-suggest 处理输入到一半的关键词,即用户目前已输入的文字,至少需要 2 个字符;在输入 peynir 的过程中发送 peyn 就是这样一种输入。这里同样可以用 q 和 keyword 代替 query。回复包含 products,即最匹配的商品,行字段与搜索结果相同;还包含 categories,其条目把类目名称 name 与对应的 count 配对。
在 Ekstra 上,它还返回 brands,其条目把品牌名称 name 与对应的 count 配对。total_results 给出匹配数量,channel 和 query 重复所用的网店和文字,便于客户端丢弃属于更早一次按键的回复。
本节涉及的字段(3)
a101-suggest, body.query, body.channel
A101 API 商品行内部的字段
在 results 和 products 的行中,price 是以土耳其里拉计的货架价,在 Kapıda 上是配送门店的价格;price_before_discount 是划线价,没有划线价时为 null。行内的一些块带有自己的字段:
campaigns的条目带有code、label、site_name、starts_on和ends_on- 在 Kapıda 的行中,
basket_offer即只在满足条件的购物篮内适用的价格,含price、regular_price、code、label、condition和ends_on - 在 Kapıda 的行中,
multi_buy含min_quantity、unit_price、regular_unit_price、code、label和ends_on - 在 Kapıda 的行中,
unit_price含price、per和label
请把 basket_offer 视为有条件的价格:它不是货架价。Ekstra 的行另有存放 GTIN 的 barcode,以及 sales_channels、max_order_quantity 和 country_of_origin。在商品详情记录中,barcodes 列出该商品的编码,对 Kapıda 商品而言,它包含 A101 列出的每一个条形码。
本节涉及的字段(4)
a101-search, a101-campaigns, a101-suggest, a101-product-detail
困难请求的尝试次数:max_rotations
四个操作都接受 max_rotations,这是一个高级设置,决定请求遇到困难时一次调用会尝试多少次。超出可接受范围的值会被忽略,改用默认值 4,因此在发送前自行计算这个数字的客户端,应把它保持在各操作输入表所示的范围之内。
本节涉及的字段(5)
body.max_rotations, a101-campaigns, a101-product-detail, a101-search, a101-suggest
{
"body": {
"product_id": "12002661",
"channel": "kapida"
}
}{
"body": {
"campaign": "haftanin_yildizlari",
"channel": "kapida",
"page": 1
}
}操作
公共网关操作统一使用 POST /api/v1/{project}/{action}。
使用 JSON 对象,按文档将参数放入 path、query、headers 和 body,省略未使用的位置。input.headers 是供操作使用的 JSON 数据,不是浏览器请求头。请勿在此填写凭证。按文档保留 body 的数组、标量或 null;省略与 null 含义不同。
促销活动商品
POST /api/v1/a101/a101-campaigns
逐页列出 A101 Kapıda 或 Ekstra 中某个促销活动页上的商品。
输入字段
| 字段 | 类型 | 是否必填 | 默认值 | 允许的值 | 范围限制 |
|---|---|---|---|---|---|
body.campaign | string | 可选 | "aldin_aldin" | "aldin_aldin""haftanin_yildizlari""aldin_aldin_x""aylik_firsat""sepette_10_tl""cok_al_az_ode""aldin_aldin_ekstra" | — |
body.channel | string | 可选 | "kapida" | "kapida""ekstra" | — |
body.max_rotations | integer | 可选 | 4 | — | 1–8 |
body.page | integer | 可选 | 1 | — | 1–200 |
请求示例
# 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/a101/a101-campaigns' \
--header "Content-Type: application/json" \
--header "x-api-key: $KAKIAPI_API_KEY" \
--header "Idempotency-Key: $REQUEST_ID" \
--data '{}'商品详情
POST /api/v1/a101/a101-product-detail
按商品 id 或商品页地址读取 A101 任一网店中的单个商品。
输入字段
| 字段 | 类型 | 是否必填 | 默认值 | 允许的值 | 范围限制 |
|---|---|---|---|---|---|
body.channel | string | 可选 | "auto" | "auto""kapida""ekstra" | — |
body.max_rotations | integer | 可选 | 4 | — | 1–8 |
body.product_id | string | 可选 | — | — | — |
body.url | 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/a101/a101-product-detail' \
--header "Content-Type: application/json" \
--header "x-api-key: $KAKIAPI_API_KEY" \
--header "Idempotency-Key: $REQUEST_ID" \
--data '{"body":{"product_id":"12002661"}}'关键词搜索
POST /api/v1/a101/a101-search
用土耳其语关键词搜索 Kapıda 或 Ekstra 网店,返回一页匹配的商品。
输入字段
| 字段 | 类型 | 是否必填 | 默认值 | 允许的值 | 范围限制 |
|---|---|---|---|---|---|
body.query | string | 必填 | — | — | — |
body.channel | string | 可选 | "kapida" | "kapida""ekstra" | — |
body.include_fallback_results | boolean | 可选 | false | — | — |
body.max_rotations | integer | 可选 | 4 | — | 1–8 |
body.page | integer | 可选 | 1 | — | 1–200 |
body.sort | string | 可选 | "relevance" | "relevance""price_asc""price_desc""newest""discount""best_selling" | — |
请求示例
# 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/a101/a101-search' \
--header "Content-Type: application/json" \
--header "x-api-key: $KAKIAPI_API_KEY" \
--header "Idempotency-Key: $REQUEST_ID" \
--data '{"body":{"channel":"kapida","query":"peynir"}}'输入联想建议
POST /api/v1/a101/a101-suggest
针对输入到一半的关键词,返回最匹配的商品以及类目和品牌建议。
输入字段
| 字段 | 类型 | 是否必填 | 默认值 | 允许的值 | 范围限制 |
|---|---|---|---|---|---|
body.query | string | 必填 | — | — | — |
body.channel | string | 可选 | "kapida" | "kapida""ekstra" | — |
body.max_rotations | integer | 可选 | 4 | — | 1–8 |
请求示例
# 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/a101/a101-suggest' \
--header "Content-Type: application/json" \
--header "x-api-key: $KAKIAPI_API_KEY" \
--header "Idempotency-Key: $REQUEST_ID" \
--data '{"body":{"query":"peynir"}}'调用方式
- 使用
POST /api/v1/a101/<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 小时内返回已保存的响应,不会再次扣费。
网关调用参考: