查询商品
你可以通过商品查询 Ajax API,在前端界面上查询允许在C端展示的所有商品的详细信息
请求信息
GET
https://{handle}.myshopline.com/api/product/products.json
请求参数
参数名 | 参数类型 | 是否数组 | 是否必填 | 示例 | 描述 |
---|---|---|---|---|---|
handle | String | 否 | 是 | product-handle |
响应信息
响应body
一级参数 | 二级参数 | 三级参数 | 参数类型 | 是否数组 | 示例 | 描述 |
---|---|---|---|---|---|---|
message | String | 否 | ||||
description | String | 否 | ||||
products | Object | |||||
id | String | 否 | 产品ID | |||
title | String | 否 | 产品标题 | |||
handle | String | 否 | 产品的handle | |||
url | String | 否 | 产品的相对路径,格式为: /products/handle | |||
description | String | 否 | 产品的描述 | |||
brand | String | 否 | 品牌名称 | |||
tags | List<String> | 否 | 产品的标签数组 | |||
images | List<String> | 否 | 产品主图数组 | |||
featured_image | String | 否 | 产品的特色图,等同于images[0] | |||
medias | Object | |||||
resource | String | 否 | 以 URL 形式表示的资源位置 | |||
cover | String | 否 | 以 URL 形式表示的封面图位置 | |||
type | String | 否 | 媒体资源类型 | |||
alt | String | 否 | 具有图像特征或内容的单词或短语 | |||
sold_out | Boolean | 否 | 是否售罄 | |||
price | Long | 否 | 产品售价,等同于price_min | |||
price_min | Long | 否 | 产品的最小售价 | |||
price_max | Long | 否 | 产品的最大售价 | |||
price_varies | Boolean | 否 | 表明产品变体的最小售价和最大售价是否一致 | |||
compare_at_price | Long | 否 | 变体的原价,等同于 compareAtPriceMin | |||
compare_at_price_min | Long | 否 | 变体的最小原价 | |||
compare_at_price_max | Long | 否 | 变体的最大原价 | |||
compare_at_price_varies | Boolean | 否 | 表明产品变体的最小原价和最大原价是否一致 | |||
created_at | Date | 否 | 产品创建时间 | |||
published_at | Date | 否 | 产品发布时间 | |||
options | Object | 选项数组 | ||||
name | String | 否 | 选项名称 | |||
values | List<String> | 否 | 选项值数组 | |||
values_images | Map<String,String> | 否 | 选项值和选项值图片的映射字典 | |||
variants | Object | 变体数组 | ||||
id | String | 否 | 变体ID | |||
barcode | String | 否 | 条形码 | |||
title | String | 否 | 变体标题 | |||
option1 | String | 否 | 变体的第1个选项值 | |||
option2 | String | 否 | 变体的第2个选项值 | |||
option3 | String | 否 | 变体的第3个选项值 | |||
option4 | String | 否 | 变体的第4个选项值 | |||
option5 | String | 否 | 变体的第5个选项值 | |||
sku | String | 否 | 变体的SKU码 | |||
featured_image | String | 否 | 变体图片 | |||
name | String | 否 | 变体名称,格式为:产品标题 · 变体标题 | |||
public_title | String | 否 | 公共标题,等同于 variant.title | |||
options | List<String> | 否 | 变体选项数组 | |||
weight | BigDecimal | 否 | 重量 | |||
weight_unit | String | 否 | 重量单位 | |||
price | Long | 否 | 变体售价,单位为:最小货币精度 | |||
compare_at_price | Long | 否 | 变体原价,单位为:最小货币精度 | |||
inventory_policy | String | 否 | 是否允许超卖,continue:允许,deny:不允许 | |||
inventory_tracker | Boolean | 否 | 是否追踪库存,默认为false |
请求、响应示例
场景1:正常查询商品
请求
fetch("https://sholinedemo.myshopline.com/api/product/products.json?handle=loose-high-waist-sequined-wide-leg-pants-2")
响应
{
"products": [
{
"id": "16054505410172913613383867",
"title": "Loose high waist sequined wide-leg pants",
"handle": "loose-high-waist-sequined-wide-leg-pants-2",
"url": "https://img.myshopline.com/image/official/e46e6189dd5641a3b179444cacdcdd2a.png",
"description": "product descritption",
"price": 1379400,
"options": [
{
"name": "Color",
"values": [
"Silver",
"White"
],
"values_images": {
"Silver": "",
"White": ""
}
},
{
"name": "Size",
"values": [
"S",
"M",
"L"
],
"values_images": {
"S": "",
"L": "",
"M": ""
}
}
],
"variants": [
{
"id": "18054505410177275688963867",
"barcode": "",
"title": "Silver · S",
"option1": "Silver",
"option2": "S",
"sku": "80353SilverS-96",
"name": "Loose high waist sequined wide-leg pants · Silver · S",
"options": [
"Silver",
"S"
],
"price": 1379400,
"public_title": "Silver · S",
"compare_at_price": 3298,
"inventory_policy": "deny",
"inventory_tracker": true
},
{
"id": "18054505410177275689033867",
"barcode": "",
"title": "Silver · M",
"option1": "Silver",
"option2": "M",
"sku": "80353SilverM-34",
"name": "Loose high waist sequined wide-leg pants · Silver · M",
"options": [
"Silver",
"M"
],
"price": 1379400,
"public_title": "Silver · M",
"compare_at_price": 3298,
"inventory_policy": "deny",
"inventory_tracker": true
},
{
"id": "18054505410177275689073867",
"barcode": "",
"title": "Silver · L",
"option1": "Silver",
"option2": "L",
"sku": "80353SilverL-72",
"name": "Loose high waist sequined wide-leg pants · Silver · L",
"options": [
"Silver",
"L"
],
"price": 1379400,
"public_title": "Silver · L",
"compare_at_price": 3298,
"inventory_policy": "deny",
"inventory_tracker": true
},
{
"id": "18054505410177275689113867",
"barcode": "",
"title": "White · S",
"option1": "White",
"option2": "S",
"sku": "80353WhiteS-62",
"name": "Loose high waist sequined wide-leg pants · White · S",
"options": [
"White",
"S"
],
"price": 1379400,
"public_title": "White · S",
"compare_at_price": 3298,
"inventory_policy": "deny",
"inventory_tracker": true
},
{
"id": "18054505410177275689153867",
"barcode": "",
"title": "White · M",
"option1": "White",
"option2": "M",
"sku": "80353WhiteM-46",
"name": "Loose high waist sequined wide-leg pants · White · M",
"options": [
"White",
"M"
],
"price": 1379400,
"public_title": "White · M",
"compare_at_price": 3298,
"inventory_policy": "deny",
"inventory_tracker": true
},
{
"id": "18054505410177275689183867",
"barcode": "",
"title": "White · L",
"option1": "White",
"option2": "L",
"sku": "80353WhiteL-46",
"name": "Loose high waist sequined wide-leg pants · White · L",
"options": [
"White",
"L"
],
"price": 1379400,
"public_title": "White · L",
"compare_at_price": 3298,
"inventory_policy": "deny",
"inventory_tracker": true
}
],
"medias": [],
"sold_out": true,
"price_min": 1379400,
"price_max": 1379400,
"price_varies": true,
"compare_at_price": 3298,
"compare_at_price_min": 3298,
"compare_at_price_max": 3298,
"compare_at_price_varies": true,
"created_at": "2022-06-14T19:21:10.228+0800",
"published_at": "2022-06-14T19:21:10.290+0800"
}
]
}
场景2:商品handle非法
请求
fetch("https://shoplinedemo.myshopline.com/api/product/products.json?handle=handle-that-does-not-exist")
响应
{
"message": "Not found"
}
{
"message": "Not found",
"description": "No product with id unrealproducthandle is published in the online store."
}
这篇文章对你有帮助吗?