AI 概览
GET /sfs/v1/filter 返回产品系列、搜索页或首页的产品,以及匹配的筛选选项和各值的数量,方便您构建完全自定义的筛选界面。
- 需要
read:catalog权限范围;不带任何参数时返回“All Products”筛选器。 - 使用
page_type和 Shopify 产品系列的数字collectionID(而不是 handle 或 gid)限定请求范围。 - 可通过
filter、sort_by、page、limit(上限为200)、q、Vehicle Finder 的form值以及 Markets 或 B2B 参数进一步细化。 - 响应包含
products、filters和pagination;在初始同步期间则返回processing。
摘要由 AI 生成,可能有误,请以下方完整指南为准。
功能说明
返回指定页面(产品系列、搜索页面或首页)的产品列表,以及应在旁边显示的筛选选项和值。这与应用自身店面筛选侧边栏使用的数据相同,因此您可以基于它构建完全自定义的筛选界面。
端点
GET /sfs/v1/filter需要 read:catalog 权限范围。请参阅 API 访问与身份验证。
确定所请求的页面
没有必填参数:不带参数调用 /filter 会返回您的“All Products”筛选器及其完整产品目录。如需将请求限定到特定页面,请结合使用 page_type 和/或 collection:
page_type |
含义 | collection |
|---|---|---|
collection(或省略) |
产品系列页面 | 传入 Shopify 产品系列的数字 ID 即可限定到该产品系列。省略 collection 或传入 0 表示“All Products”。 |
search |
搜索结果页面 | 不使用。 |
index |
首页 | 不使用。 |
collection 必须是纯数字的 Shopify 产品系列 ID(例如 278901234567),不能是 handle,也不能是 gid://... 字符串。
如果 page_type/collection 组合与您为该范围配置的任何筛选器都不匹配,请求仍会成功(200)并返回未经筛选的产品,而不是报错。如果您需要检测这种情况,请检查响应中的 filters 数组是否为空。
参数
所有参数都不是必填的,省略全部参数时返回的内容请参阅上文。
| 参数 | 是否必填 | 类型 | 示例 | 说明 |
|---|---|---|---|---|
collection |
可选 | 数字字符串 | 278901234567 |
Shopify 产品系列 ID。请参阅上文。 |
page_type |
可选 | string | collection |
collection、search 或 index。请参阅上文。 |
sort_by |
可选 | string | best-selling |
best-selling、manual、relevance、price-ascending、price-descending、title-ascending、title-descending、created-ascending、created-descending、sale-ascending、sale-descending、published-ascending、published-descending、updated-ascending、updated-descending、stock-descending、inventory-ascending、inventory-descending,或用于按元字段排序的 mf-<metafield>。默认为 created-descending。任何无法识别的值都会回退为默认值。 |
page |
可选 | integer | 1 |
页码,1–9999。默认为 1。 |
limit |
可选 | integer | 24 |
每页产品数。默认为您商店中配置的每页产品数设置;无论传入什么值,上限均为 200。 |
q |
可选 | string | red shoes |
在产品系列/搜索页面内进行自由文本搜索。 |
filter |
可选 | array | filter[color][]=Red |
已选择的筛选选项值,以筛选选项 ID 或 handle 为键,与顾客在店面筛选侧边栏中勾选某个值时发送的内容一致。 |
form |
可选 | array | form[99][]=Toyota |
Vehicle Finder(YMM)字段选择,会合并到 filter 中。 |
form_id |
可选 | integer | 88 |
与 form 搭配使用的 Vehicle Finder 字段集 ID。必须是真实存在的筛选器 ID,无法识别的 form_id 会返回错误(见下文)。 |
tags |
可选 | array | tags[]=Sale |
仅包含带有这些标签的产品。 |
exclude_tags |
可选 | array | exclude_tags[]=Hidden |
排除带有这些标签的产品。 |
vendor |
可选 | string | Nike |
仅筛选单个厂商。 |
type |
可选 | string | Shoes |
仅筛选单个产品类型。 |
locale |
可选 | string | fr |
店面语言区域,仅在您的商店配置了多种语言时生效。 |
currency |
可选 | string | EUR |
展示币种,仅在您的商店启用了多币种时生效。 |
country |
可选 | string | US |
用于 Shopify Markets 定价的国家/地区上下文。 |
market_id |
已弃用 | string | 123456789 |
已不再使用:为保持向后兼容仍可接受,但会被忽略。舍入和产品目录解析改为基于 country/company_location_country。 |
catalog_ids |
可选 | array | catalog_ids[]=1 |
B2B 产品目录 ID,适用于使用 B2B 产品目录和定价的商店。 |
company_location_id |
可选 | string | 998877 |
B2B 公司地点 ID。 |
company_location_country |
可选 | string | US |
B2B 公司地点所在国家/地区;省略时回退为 country。 |
rate |
可选 | number | 1.08 |
应用于显示价格的货币汇率。默认为 1。 |
adjustment |
可选 | number | 1 |
价格调整系数。默认为 1。 |
响应
{ "products": [ { "id": ..., "handle": ..., "title": ..., "variants": [...], "...": "..." } ], "filters": [ { "id": ..., "handle": "color", "label": "Color", "attribute": "option:color", "values": [ { "value": "Red", "label": "Red", "count": 12, "selected": false } ] } ], "has_filter": true, "pagination": { "from": 1, "to": 24, "total": 132, "per_page": 24, "current_page": 1, "last_page": 6, "hasMorePages": true }}products:每个条目都是完整的产品文档(id、handle、title、厂商、产品类型、标签、选项、变体、图片、元字段及类似字段),并且变体价格会反映您所应用的rate/adjustment。filters(通过form_id请求时为form):与此页面相关的筛选选项,每个选项都包含其当前的values以及每个值对应的产品count。Price筛选选项则包含ranges/presentment_ranges,而不是values。pagination:当前请求的标准分页/偏移信息。
如果您的商店仍在完成初始产品同步,您将收到 {"processing": 1, "message": "..."},请稍后重试。
错误
{"error": 1, "message": "No Filter"}:在提供了form_id但与任何现有筛选器都不匹配时返回。- 共享的
401/403/429情况请参阅 API 访问与身份验证。
相关页面
此页面对您有帮助吗?
感谢您的反馈! 告诉我们缺少了什么
报告问题