开发文档
BestPrice.gr API 技术参考
BestPrice.gr API 参考:条码、分类、商品与搜索的输入及其别名,以及各个答复中字段的含义。
另见: BestPrice.gr 比价接口概览与价格 · BestPrice.gr API 指南:条码、搜索与价格流程
本页内容
BestPrice.gr API 条码输入规则
body.barcode 接受 EAN-13、EAN-8、UPC-12 或 GTIN-14 条码,例如 8806091024749。条码中的空格和连字符会被忽略,13 位条码未命中时,会补零到 14 位再试一次。
ean、gtin、upc、code 和 barcode_number 都被接受为 body.barcode 的别名。
body.strict 控制返回哪些行:
- 取 true 时只保留 BestPrice.gr 为其声明了精确条码匹配的行
- 取 false 时加入它的模糊名称匹配行,这些行在
match_type中标为text_match
模糊匹配的行并不是条码匹配。无效的 body.strict 或 body.limit 会被忽略,并采用默认值。
本节涉及的字段(4)
bestprice-barcode, body.barcode, body.strict, body.limit
条码答复字段
行的 match_type 为 barcode_exact 表示精确的条码匹配,为 text_match 表示来自模糊的名称匹配,match_confidence 显示该匹配的可信程度。exact_match 显示查询是否得到精确匹配,strict 显示查询所用的模式,barcode_queried 显示查询所用的条码。
空的 products 列表是有效的答复:条码索引中没有收录该条码。行内的 price_from_eur 是以欧元表示的起始价格,offer_count 统计该商品的报价条数,category_title 是它所属分类的名称,variant 是该型号的款式。
本节涉及的字段(1)
bestprice-barcode
分类输入规则
body.category_id 接受分类的数字编号,例如 806,也接受分类 URL,category、cid 和 url 都被接受为它的别名。这个编号就是搜索行的 category_id,或者分类 URL 中的数字。
body.query 把商品网格缩小到某个关键词,例如 iphone,q 被接受为它的别名。无效的 body.query 会被忽略。
body.page 选择网格的页码,只有第 1 页会返回行:更深的页不返回任何行。body.limit 设置该页返回多少行,无效的 body.page 或 body.limit 会被忽略,并采用默认值。
本节涉及的字段(5)
bestprice-category, body.category_id, body.query, body.page, body.limit
分类行字段
products 的每个元素与搜索行的结构相同。title、url 和 image 描述该商品,product_id 标识它,category_id 把它归入某个分类。
price_eur 与 currency 给出展示的价格,shop_count 统计销售该商品的商店数量,listing_type、offer_id 和 merchant_id 用来区分参与比价的商品与单家商店的报价。
本节涉及的字段(2)
bestprice-category, bestprice-search
商品编号输入
body.product_id 接受商品的数字编号,例如 2159006120,也接受商品 URL,id 和 url 都被接受为它的别名。这个编号就是搜索、分类或条码结果行的 product_id。
本节涉及的字段(2)
bestprice-product, body.product_id
商品记录字段
price_low_eur 与 price_high_eur 给出市场上的价格区间。offer_count 显示市场上拥有多少条报价,offers_listed 则显示本次答复带有多少条报价。
gtin 是商品的条码,gtin_type 说明它来自哪一种键。mpn 与 sku 是制造商零件编号和库存单位,category_path 给出分类路径,rating 与 rating_count 给出评分及评分数量。
offers 的每个元素是一家商店的报价。shop 是商店名称,price_eur 与 currency 给出它的价格,availability 与 condition 描述商品,url 是该报价的地址。
本节涉及的字段(1)
bestprice-product
搜索输入规则
body.query 是希腊语或英语关键词,q、keyword 和 term 都被接受为它的别名。条码不能在 bestprice-search 中当作关键词使用,因为文本索引不包含条码:EAN、GTIN 或 UPC 请使用 bestprice-barcode。
网格只提供第 1 页。body.page 大于 1 时不返回任何行,page_available 显示为 false,而不是再次返回第 1 页的行,body.limit 设置第 1 页返回多少行。无效的 body.page 或 body.limit 会被忽略,并采用默认值。
本节涉及的字段(4)
bestprice-search, body.query, body.page, body.limit
搜索答复字段
listing_type 为 product 表示参与比价的商品,为 shop_offer 表示单家商店的报价。后一种带有 offer_id 和 merchant_id,而 product_id 为 null,price_eur 是该行展示的价格,也就是各商店中的最低价。
只有查询被重定向到分类页或品牌页时才会出现 redirected_to。它的 type 是 category 或 brand,id、title 和 url 标识该页面。这些行是该页面的商品网格,redirected_to 指明那是哪个页面。
本节涉及的字段(1)
bestprice-search
操作
公共网关操作统一使用 POST /api/v1/{project}/{action}。
使用 JSON 对象,按文档将参数放入 path、query、headers 和 body,省略未使用的位置。input.headers 是供操作使用的 JSON 数据,不是浏览器请求头。请勿在此填写凭证。按文档保留 body 的数组、标量或 null;省略与 null 含义不同。
条码查询
POST /api/v1/bestprice/bestprice-barcode
查找某个 EAN、UPC 或 GTIN 条码对应的 BestPrice.gr 商品。
输入字段
| 字段 | 类型 | 是否必填 | 默认值 | 允许的值 | 范围限制 |
|---|---|---|---|---|---|
body.barcode | string | 必填 | — | — | — |
body.limit | integer | 可选 | 8 | — | 1–8 |
body.strict | boolean | 可选 | true | — | — |
请求示例
# 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/bestprice/bestprice-barcode' \
--header "Content-Type: application/json" \
--header "x-api-key: $KAKIAPI_API_KEY" \
--header "Idempotency-Key: $REQUEST_ID" \
--data '{"body":{"barcode":"8806091024749"}}'响应字段
products[]product_idurltitlebrandmodelvariantcategory_idcategory_titleprice_from_eurcurrencyoffer_countavailabilityratingrating_countimagematch_typematch_confidence
barcodebarcode_queriedstrictexact_match
分类商品列表
POST /api/v1/bestprice/bestprice-category
按编号列出某个分类的商品,可用关键词缩小范围。
输入字段
| 字段 | 类型 | 是否必填 | 默认值 | 允许的值 | 范围限制 |
|---|---|---|---|---|---|
body.category_id | string | 必填 | — | — | — |
body.limit | integer | 可选 | 24 | — | 1–24 |
body.page | integer | 可选 | 1 | — | 1–9007199254740991 |
body.query | 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/bestprice/bestprice-category' \
--header "Content-Type: application/json" \
--header "x-api-key: $KAKIAPI_API_KEY" \
--header "Idempotency-Key: $REQUEST_ID" \
--data '{"body":{"category_id":"806"}}'响应字段
products[]pagelimitcategory_id
商品报价
POST /api/v1/bestprice/bestprice-product
读取单个商品的商店报价、价格区间、条码与评分。
输入字段
| 字段 | 类型 | 是否必填 | 允许的值 | 范围限制 |
|---|---|---|---|---|
body.product_id | 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/bestprice/bestprice-product' \
--header "Content-Type: application/json" \
--header "x-api-key: $KAKIAPI_API_KEY" \
--header "Idempotency-Key: $REQUEST_ID" \
--data '{"body":{"product_id":"2162499899"}}'响应字段
productproduct_idurltitlebrandgtingtin_typempnskucategory_pathprice_low_eurprice_high_euroffer_countoffers_listedratingrating_countoffers[]shopprice_eurcurrencyurlavailabilitycondition
商品搜索
POST /api/v1/bestprice/bestprice-search
用希腊语或英语关键词搜索商品,并读取每行的价格与商店数量。
输入字段
| 字段 | 类型 | 是否必填 | 默认值 | 允许的值 | 范围限制 |
|---|---|---|---|---|---|
body.query | string | 必填 | — | — | — |
body.limit | integer | 可选 | 24 | — | 1–24 |
body.page | integer | 可选 | 1 | — | 1–9007199254740991 |
请求示例
# 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/bestprice/bestprice-search' \
--header "Content-Type: application/json" \
--header "x-api-key: $KAKIAPI_API_KEY" \
--header "Idempotency-Key: $REQUEST_ID" \
--data '{"body":{"query":"iphone"}}'响应字段
products[]listing_typeproduct_idoffer_idmerchant_idurltitleprice_eurcurrencycategory_idshop_countimage
pagelimitqueryredirected_totypeidtitleurl
page_available
调用方式
- 使用
POST /api/v1/bestprice/<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 小时内返回已保存的响应,不会再次扣费。
网关调用参考: