开发文档
BigBasket API 技术参考
BigBasket API 的参考资料:PIN 码输入、分类 slug、搜索输入,以及分类、配送、商品和搜索各自返回的内容。
另见: BigBasket 网上超市数据接口概览与价格 · BigBasket API 指南:搜索与规格比较
本页内容
BigBasket API 的分类树条目
bigbasket-categories 不需要输入。在 categories 中,顶级条目是一个大类,其 children 是子分类,叶子分类位于它们之下。name 是条目的名称,url 是它的页面地址,id 是它的标识,count 随列表一起返回。
slug 是需要带到后续调用中的部分:它是 bigbasket-search 中 body.category 的取值,category_slug 也被接受为该输入的替代名称。分类树能显示有哪些 slug 可供搜索使用。
本节涉及的字段(2)
bigbasket-categories, body.category
PIN 码配送信息的字段
body.pincode 是 6 位的印度 PIN 码。pin、pin_code、postal_code 和 zip 被接受为它的替代名称,解析后的编码以 pincode 返回。返回的字段分为三组:
- 地点:
place、area、city和state给出该 PIN 码对应的地点,lat和lng是其坐标 - 服务状态:
serviceable显示 BigBasket 是否配送到该 PIN 码,services把各服务名称映射到其状态,其中 bb-b2c 对应时段配送,bbnow 对应快速配送,location包含city_id - 配送:
stores的每个条目有store_id、services列表、eta和eta_message(例如 Get it in 10 mins),next_slots的每个条目有store_id、message、eta_minutes、slot_time和slots_full
stores 与 next_slots 描述的是配送到能定位的 PIN 码的情况。
本节涉及的字段(2)
bigbasket-pincode, body.pincode
商品详情的输入与字段
body.product_id 接受搜索结果行原样返回的 product_id。商品页的地址也可以代替它,其中的 id 位于 /pd/ 之后的那一段,id、sku、url 和 product_url 被接受为替代名称。pin、pin_code、postal_code 和 zip 被接受为 body.pincode 的替代名称,它以 pincode 返回。
在 product 内,discount_text 是文字形式的折扣,unit_price 是单位价格。breadcrumb 列出分类路径,images 是商品图片,tags 是商品的标签。sections 保存商品页的各个板块,other_info 给出生产商和保质期等信息。
packs 对商品的每个规格重复规格字段,因此每个规格都有自己的 url、price、mrp 和 unit_price,is_best_value 标出最划算的规格。
本节涉及的字段(3)
bigbasket-product, body.product_id, body.pincode
搜索输入及其作用
body.pincode 是 6 位的印度 PIN 码,决定搜索读取的商品目录、价格和库存,所以同一个搜索词在两个 PIN 码下会得到不同的总数和价格。pin、pin_code、postal_code 和 zip 被接受为它的替代名称。
搜索需要 body.query、body.category、body.brand 中的一个,其中 body.category 不与 body.query 组合使用:
body.query是输入 BigBasket 搜索框的文字,q、keyword和search被接受为替代名称body.category是分类 slug,取自分类树或结果行category中的 slug,category_slug被接受为替代名称body.brand是品牌 slug,与结果行在brand_slug中返回的一致,brand_slug被接受为替代名称;单独使用时列出该品牌的页面,与body.query或body.category一起使用时作为筛选条件
筛选条件缩小同一个结果集:body.price_band 按以卢比计的销售价,body.discount_band 按相对 MRP 的折扣,body.min_rating 按最低星级评分。sort_by 和 order 被接受为 body.sort 的替代名称。body.page 从 1 开始,关键词搜索每页 40 行,分类页或品牌页每页 48 行。
本节涉及的字段(10)
bigbasket-search, body.pincode, body.query, body.category, body.brand, body.price_band, body.discount_band, body.min_rating, body.sort, body.page
搜索结果的字段
data 的顶层概括了这次搜索。total 是 BigBasket 报告的数量,returned 是本页的行数。page、last_page 和 has_next 说明页的位置,query、category 和 brand 重复所搜索的内容。
substituted_results 显示没有任何匹配、页面中是建议商品,substituted_for 说明这些建议替代的是什么。rows_outside_price_filter 统计所展示规格落在 body.price_band 之外的行数。
results 的一行包含以下几组字段:
- 标识:
product_id是商品详情调用所需的值,name、brand和brand_slug给出商品及其品牌,url和image指向商品页和图片,image_count是图片数量 - 规格:
pack_size和pack_description描述该行所展示的规格,other_packs列出其他规格及其各自的价格与库存字段 - 价格:
price、mrp、discount_percent、discount_text、currency、unit_price和offer_text给出各项数据,offer_type说明优惠的种类 - 库存:
in_stock和availability_code给出库存状态,not_for_sale显示商品不对外销售,eta是预计送达时间 - 其他字段:
rank是该行的位置,store_id指明门店,rating包含average、ratings和reviews,ean仅在检查位有效时才给出 GTIN
本节涉及的字段(1)
bigbasket-search
操作
公共网关操作统一使用 POST /api/v1/{project}/{action}。
使用 JSON 对象,按文档将参数放入 path、query、headers 和 body,省略未使用的位置。input.headers 是供操作使用的 JSON 数据,不是浏览器请求头。请勿在此填写凭证。按文档保留 body 的数组、标量或 null;省略与 null 含义不同。
分类树
POST /api/v1/bigbasket/bigbasket-categories
列出分类树,含名称、slug、编号、页面地址和下级分类。
输入字段
此操作没有输入字段,发送下方所示的 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/bigbasket/bigbasket-categories' \
--header "Content-Type: application/json" \
--header "x-api-key: $KAKIAPI_API_KEY" \
--header "Idempotency-Key: $REQUEST_ID" \
--data '{"body":{}}'PIN 码配送情况
POST /api/v1/bigbasket/bigbasket-pincode
查看 BigBasket 如何服务某个 PIN 码:所在地点、各项服务、门店和最近的配送时段。
输入字段
| 字段 | 类型 | 是否必填 | 允许的值 | 范围限制 |
|---|---|---|---|---|
body.pincode | 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/bigbasket/bigbasket-pincode' \
--header "Content-Type: application/json" \
--header "x-api-key: $KAKIAPI_API_KEY" \
--header "Idempotency-Key: $REQUEST_ID" \
--data '{"body":{"pincode":"560001"}}'商品详情
POST /api/v1/bigbasket/bigbasket-product
读取某个 PIN 码下的单个商品,含价格、库存、营养信息和各规格。
输入字段
| 字段 | 类型 | 是否必填 | 允许的值 | 范围限制 |
|---|---|---|---|---|
body.pincode | string | 必填 | — | — |
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/bigbasket/bigbasket-product' \
--header "Content-Type: application/json" \
--header "x-api-key: $KAKIAPI_API_KEY" \
--header "Idempotency-Key: $REQUEST_ID" \
--data '{"body":{"pincode":"400020","product_id":"30006887"}}'响应字段
pincodelocationserviceableproductproduct_idnamebrandpack_sizeurleanean_code_rawean_on_pagepricemrpdiscount_percentdiscount_textunit_priceunit_price_consistentoffer_textin_stockavailability_codecategoryratingfood_typebreadcrumb[]images[]descriptioningredientsnutritionstorageother_infosectionstags[]
packs[]product_idpack_sizeurlpricemrpdiscount_percentdiscount_textunit_pricein_stockavailability_codeis_best_value
商品搜索
POST /api/v1/bigbasket/bigbasket-search
按关键词、分类或品牌搜索某个 PIN 码下的商品,并用价格、评分和排序条件筛选。
输入字段
| 字段 | 类型 | 是否必填 | 默认值 | 允许的值 | 范围限制 |
|---|---|---|---|---|---|
body.pincode | string | 必填 | — | — | — |
body.brand | string | 可选 | — | — | — |
body.category | string | 可选 | — | — | — |
body.discount_band | string | 可选 | — | "upto_5""5_10""10_15""15_25""over_25" | — |
body.min_rating | string | 可选 | — | "3""4""5" | — |
body.page | integer | 可选 | 1 | — | 1–9007199254740991 |
body.price_band | string | 可选 | — | "under_20""21_50""51_100""101_200""201_500""over_500" | — |
body.query | string | 可选 | — | — | — |
body.sort | string | 可选 | "relevance" | "relevance""price_asc""price_desc""saving_desc""saving_asc""discount_desc" | — |
请求示例
# 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/bigbasket/bigbasket-search' \
--header "Content-Type: application/json" \
--header "x-api-key: $KAKIAPI_API_KEY" \
--header "Idempotency-Key: $REQUEST_ID" \
--data '{"body":{"pincode":"400020","query":"atta"}}'响应字段
pincodelocationcity_id
serviceablequerycategorybrandtotalpagelast_pagehas_nextreturnedsubstituted_resultssubstituted_forrows_outside_price_filterresults[]product_idnamebrandbrand_slugpack_sizepack_descriptionurlimageimage_counteanean_code_rawpricemrpdiscount_percentdiscount_textcurrencyunit_priceamountper
unit_price_consistentoffer_textoffer_typein_stockavailability_codenot_for_salebuttonetais_best_valuecategorytoptop_slugmidmid_slugleafleaf_id
ratingaverageratingsreviews
food_typeother_packs[]product_idpack_sizeurlpricemrpdiscount_percentdiscount_textunit_priceunit_price_consistentin_stockavailability_codeis_best_value
store_idrank
调用方式
- 使用
POST /api/v1/bigbasket/<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 小时内返回已保存的响应,不会再次扣费。
网关调用参考: