- 商品
- 您可以用商品做什么
- 商品特性
- 终点
- 检索所有商品
- 检索特定商品的列表。
- 检索所有商品,仅显示一些属性
- 检索属于某个集合的所有商品
- 在指定的ID之后检索所有商品
- 检索所有具有所选演示货币价格的商品
- 检索所有商品的计数
- 检索给定集合中所有商品的计数
- 通过ID检索单个商品
- 仅检索特定字段
- 使用默认商品变体创建新商品
- 创建一个新的未发布的商品
- 创建一个新的草稿商品
- 创建具有多个商品变型的新商品
- 创建具有多个商品变体和多个选项的新商品
- 创建具有默认变体和base64编码图像的新商品
- 创建具有默认变体的新商品和Shopify将下载的商品图片
- 创建没有标题的商品将返回错误
- 使用元字段创建商品
- 通过重新订购商品变型来更新商品
- 更新商品及其变体之一
- Update a product’s SEO title and description
- Show a hidden product by changing the published attribute to true
- Hide a published product by changing the published attribute to false
- Add a metafield to an existing product
- Update a product’s title
- Update a product’s status
- Update a product’s tags
- Update a product by clearing product images
- Update a product by adding a new product image
- Update a product by reordering product image
- Delete a product along with all its variants and images
商品
商品资源使您可以在商人的商店中更新和创建商品。您可以将商品变体与商品资源一起使用来创建或更新同一商品的不同版本。您还可以添加或更新商品图像。
您可以使用CustomCollection资源和SmartCollection资源将商品添加到集合中。
您可以用商品做什么
Shopify API使您可以对商品资源执行以下操作。这些常规操作的更详细的版本可能可用:
- GET /admin/api/2021-01/products.json检索商品列表
- GET /admin/api/2021-01/products/count.json检索商品数量
- GET /admin/api/2021-01/products/{product_id}.json检索单个商品
- POST /admin/api/2021-01/products.json创建新商品
- PUT /admin/api/2021-01/products/{product_id}.json更新商品
- 删除/admin/api/2021-01/products/{product_id}.json删除商品
商品特性
| body_html | plain "body_html": "It's the small iPod with a big idea: Video." 商品说明。支持HTML格式。 |
|---|---|
| created_at 只读 | plain "created_at": "2012-02-15T15:12:21-05:00" 商品创建 的日期和时间(ISO 8601格式)。 |
| 处理 | plain "handle": "ipod-nano" 商品的独特的人性化字符串。自动从商品的生成title。Liquid模板语言使用它来引用对象。 |
| ID 只读 | plain "id": 632910392 一个无符号的64位整数,用作商品的唯一标识符。每个id在Shopify系统中都是唯一的。id即使两种商品来自不同的商店,也不会有相同的商品。 |
| 图片 | plain "images": [ { "id": 850703190, "product_id": 632910392, "position": 1, "created_at": "2018-01-08T12:34:47-05:00", "updated_at": "2018-01-08T12:34:47-05:00", "width": 110, "height": 140, "src": "http://example.com/burton.jpg", "variant_ids": [ {} ] } ] 商品图像对象的 列表,每个代表与商品关联的图像。 |
| 选项 | plain "options": [ { "name": "Title" } ] 自定义商品属性名称一样Size,Color和Material。您最多可以添加3个选项,每个选项最多255个字符。 |
| 商品类别 | plain "product_type": "Cult Products" 用于过滤和搜索商品的商品的分类。 |
| 已发布 | plain "published_at": "2007-12-31T19:00:00-05:00" 商品发布 的日期和时间(ISO 8601格式)。可以设置为null从在线商店频道取消发布商品。 |
| published_scope | plain "published_scope": "global" 商品是否发布到销售点渠道。有效值:+ web:商品已发布到“在线商店”渠道,但未发布到“销售点”渠道。+ global:商品同时发布到在线商店渠道和销售点渠道。 |
| 状态 | plain "status": "active" 商品的状态。有效值:+ active:商品已准备就绪,可以在网上商店,销售渠道和应用程序上向客户购买。默认情况下,现有商品设置为活动。+ archived:该商品不再销售,并且无法通过销售渠道和应用程序向客户提供。+ draft:该商品尚未准备好销售,并且在销售渠道和应用上对客户不可用。默认情况下,重复和未存档商品设置为草稿。 |
| 标签 | plain "tags": "Emotive, Flash Memory, MP3, Music" 一串用逗号分隔的标签,用于过滤和搜索。一个商品最多可以包含250个标签。每个标签最多可包含255个字符。 |
| template_suffix | plain "template_suffix": "special" 商品页面使用的Liquid模板的后缀。如果指定了此属性,那么商品页面将使用名为“ product.suffix.liquid”的模板,其中“ suffix”是此属性的值。如果此属性是""或null,那么商品页面将使用默认模板“ product.liquid”。(默认值:null) |
| 标题 必需的 | plain "title": "IPod Nano - 8GB" 商品名称。 |
| Updated_at 只读 | plain "updated_at": "2012-08-24T14:01:47-04:00" 商品上次修改 的日期和时间(ISO 8601格式)。商品的updated_at价值可能因不同的原因而变化。例如,如果下达了具有库存跟踪设置的商品的订单,则将库存调整计为更新。 |
| 变体 | plain "variants": [ { "barcode": "1234_pink", "compare_at_price": null, "created_at": "2012-08-24T14:01:47-04:00", "fulfillment_service": "manual", "grams": 567, "weight": 0.2, "weight_unit": "kg", "id": 808950810, "inventory_item_id": 341629, "inventory_management": "shopify", "inventory_policy": "continue", "inventory_quantity": 10, "option1": "Pink", "position": 1, "price": 199.99, "presentment_prices": [ { "price": { "currency_code": "USD", "amount": "199.99" }, "compare_at_price": null }, { "price": { "currency_code": "EUR", "amount": "158.95" }, "compare_at_price": null }, { "price": { "currency_code": "GBP", "amount": "143.00" }, "compare_at_price": null }, { "price": { "currency_code": "JPY", "amount": "22400" }, "compare_at_price": null } ], "product_id": 632910392, "requires_shipping": true, "sku": "IPOD2008PINK", "taxable": true, "title": "Pink", "updated_at": "2012-08-24T14:01:47-04:00" } ] 商品变体的列表,每个代表商品的不同版本。该 position属性是只读的。变体的位置由其列出的顺序指示。要检索 presentment_prices变量的属性,请包含request标头'X-Shopify-Api-Features': 'include-presentment-prices'。 |
| 小贩 | plain "vendor": "Apple" 商品供应商的名称。 |
终点
得到/admin/api/2021-01/products.json 检索商品列表。注意:从2019-07版本开始,此端点通过使用响应标头中提供的链接来实现分页。发送<font style="background-color:#F4F6F8;">page</font>参数将返回错误。要了解更多信息,请参阅向分页的REST Admin API端点发出请求。
| 编号 | 仅返回由逗号分隔的商品ID列表指定的商品。 |
|---|---|
| 限制 | 每页最多返回这么多结果。 (默认值: 50最大: 250) |
| since_id | 仅返回指定ID之后的商品。 |
| 标题 | 按商品标题退回商品。 |
| 小贩 | 按商品标题退回商品。 |
| 处理 | 仅返回由逗号分隔的商品句柄列表指定的商品。 |
| 商品类别 | 按商品类型退货。 |
| 状态 | 仅返回由逗号分隔的状态列表指定的商品。 (默认值: any) + active:仅返回有效商品。 + 已归档:仅返回已归档的商品。 + 草稿:仅返回草稿商品。 |
| collection_id | 按商品集合ID返回商品。 |
| created_at_min | 返回指定日期之后创建的商品。(格式:2014-04-25T16:15:47-04:00) |
| created_at_max | 返回指定日期之前创建的商品。(格式:2014-04-25T16:15:47-04:00) |
| Updated_at_min | 返回指定日期后最后更新的商品。(格式:2014-04-25T16:15:47-04:00) |
| Updated_at_max | 返回指定日期之前最后更新的商品。(格式:2014-04-25T16:15:47-04:00) |
| Published_at_min | 返回指定日期之后发布的商品。(格式:2014-04-25T16:15:47-04:00) |
| published_at_max | 返回指定日期之前发布的商品。(格式:2014-04-25T16:15:47-04:00) |
| 已发布状态 | 按发布状态退货 (默认值: any) + 已发布:仅返回已发布的商品。 + 未发布:仅返回未发布的商品。 + 任何:退回所有商品。 |
| 领域 | 仅返回由逗号分隔的字段名称列表指定的某些字段。 |
| present_currencies | 仅以某些货币返回展示价格,这些货币由逗号分隔的ISO 4217货币代码列表指定。 |
检索所有商品
GET /admin/api/2021-01/products.json
检索特定商品的列表。
GET /admin/api/2021-01/products.json?ids=632910392,921728736
检索所有商品,仅显示一些属性
GET /admin/api/2021-01/products.json?fields=id,images,title
检索属于某个集合的所有商品
GET /admin/api/2021-01/products.json?collection_id=841564295
在指定的ID之后检索所有商品
GET /admin/api/2021-01/products.json?since_id=632910392
检索所有具有所选演示货币价格的商品
GET /admin/api/2021-01/products.json?presentment_currencies=USD
得到/admin/api/2021-01/products/count.json 检索商品数量。| 小贩 | 按商品标题退回商品。 |
|---|---|
| 商品类别 | 按商品类型退货。 |
| collection_id | 按商品集合ID返回商品。 |
| created_at_min | 返回指定日期之后创建的商品。(格式:2014-04-25T16:15:47-04:00) |
| created_at_max | 返回指定日期之前创建的商品。(格式:2014-04-25T16:15:47-04:00) |
| Updated_at_min | 返回指定日期后最后更新的商品。(格式:2014-04-25T16:15:47-04:00) |
| Updated_at_max | 返回指定日期之前最后更新的商品。(格式:2014-04-25T16:15:47-04:00) |
| Published_at_min | 返回指定日期之后发布的商品。(格式:2014-04-25T16:15:47-04:00) |
| published_at_max | 返回指定日期之前发布的商品。(格式:2014-04-25T16:15:47-04:00) |
| 已发布状态 | 按发布状态退货 (默认值: any) + 已发布:仅返回已发布的商品。 + 未发布:仅返回未发布的商品。 + 任何:退回所有商品。 |
检索所有商品的计数
GET /admin/api/2021-01/products/count.json
检索给定集合中所有商品的计数
GET /admin/api/2021-01/products/count.json?collection_id=841564295
得到/admin/api/2021-01/products/{product_id}.json 检索单个商品。| 领域 | 以逗号分隔的字段列表,包括在响应中。 |
|---|---|
通过ID检索单个商品
GET /admin/api/2021-01/products/632910392.json
仅检索特定字段
GET /admin/api/2021-01/products/632910392.json?fields=id,图片,标题
邮政/admin/api/2021-01/products.json创建一个新商品。
如果要设置商品的SEO信息,则可以使用以下属性:
- metafields_global_title_tag:用于SEO的商品名称。通常添加到
<meta name='title'>标签中。 - metafields_global_description_tag:用于SEO的商品说明。通常添加到
<meta name='description'>标签中。
使用默认商品变体创建新商品
POST /admin/api/2021-01/products.json
{
“商品” : {
标题:“ Burton Custom Freestyle 151”,“ body_html” :“ <strong>单板滑雪好!</ strong>”,“供应商” :“伯顿”,“ product_type” :“滑雪板”,“标签” : [“ Barnes&Noble”,“ John's Fav”,“ \ Big Air \”]
}
}
创建一个新的未发布的商品
POST /admin/api/2021-01/products.json
{
“商品” : {
标题:“ Burton Custom Freestyle 151”,“ body_html” :“ <strong>单板滑雪好!</ strong>”,“供应商” :“伯顿”,“ product_type” :“滑雪板”,“已发布” :false
}
}
创建一个新的草稿商品
POST /admin/api/2021-01/products.json
{
“商品” : {
标题:“ Burton Custom Freestyle 151”,“ body_html” :“ <strong>单板滑雪好!</ strong>”,“供应商” :“伯顿”,“ product_type” :“滑雪板”,“商店” : {“ id” :690933842,“名称” :“苹果计算机”,“电子邮件” :“ steve@apple.com”,“域” :“ apple.myshopify.com”,“省” :“加利福尼亚”,“ country” :“ US”,“ address1” :“ 1个无限循环”,“ zip” :“ 95014”,“ city” :“ Cupertino”,“源” :null,“ phone” :“ 1231231234”,“纬度” :45.45,“经度” :-75.43,“ primary_locale” :“ en”,“ address2” :“套房100”,“ created_at” :“ 2007-12-31T19:00:00-05:00”,“ updated_at” :“ 2021-02-17T19:22:04-05:00”,“ country_code” :“美国”,“ country_name” :“美国”,“ currency” :“ USD”,“ customer_email” :“ steve@apple.com”,“ timezone” :“(GMT-05:00)美国东部时间(美国和加拿大)”,“ iana_timezone” :“美国/纽约”,“ shop_owner” :“史蒂夫·乔布斯”,“ money_format” :“ $”,“ money_with_currency_format” :“ $ USD”,“ weight_unit” :“ lb”,“ province_code” :“ CA”,“ taxes_included” :null,“ auto_configure_tax_inclusivity” :null,“ tax_shipping” :null,“ county_taxes” :是,“ plan_display_name” :“ Shopify Plus”,“ plan_name” :“企业”,“ has_discounts” :是,“ has_gift_cards” :是,“ myshopify_domain” :“ apple.myshopify.com”,“ google_apps_domain” :null,“ google_apps_login_enabled” :null,“ money_in_emails_format” :“ $”,“ money_with_currency_in_emails_format” :“ $ USD”,“ eligible_for_payments” :true,“ requires_extra_payments_agreement” :false,“ password_enabled” :null,“ has_storefront” :是,“ eligible_for_card_reader_giveaway” :false,“财务” :真实,“ primary_location_id” :905684977,“ cookie_consent_level” :“隐式”,“ visitor_tracking_consent_preference” :“ allow_all”,“ force_ssl” :是,“ checkout_api_supported” :是,“ multi_location_enabled” :false,“ setup_required” :false,“ pre_launch_enabled” :false,“ enabled_presentment_currencies” : [“ USD”]},“状态” :“草稿”
}
}
创建具有多个商品变型的新商品
POST /admin/api/2021-01/products.json
{
“商品” : {
标题:“ Burton Custom Freestyle 151”,
“ body_html” :“ <strong>单板滑雪好!</ strong>”,
“供应商” :“伯顿”,
“ product_type” :“滑雪板”,
“变体” : [
{
“ option1” :“第一”,
“价格” :“ 10.00”,
“ sku” :“ 123”
},
{
“ option1” :“第二个”,
“价格” :“ 20.00”,
“ sku” :“ 123”
}
]
}
}
创建具有多个商品变体和多个选项的新商品
POST /admin/api/2021-01/products.json
{
“商品” : {
标题:“ Burton Custom Freestyle 151”,
“ body_html” :“ <strong>单板滑雪好!</ strong>”,
“供应商” :“伯顿”,
“ product_type” :“滑雪板”,
“变体” : [
{
“ option1” :“蓝色”,
“ option2” :“ 155”
},
{
“ option1” :“黑色”,
“ option2” :“ 159”
}
],
“选项” : [
{
“名称” :“颜色”,
“值” : [
“蓝色”,
“黑色”
]
},
{
“名称” :“大小”,
“值” : [
“ 155”,
“ 159”
]
}
]
}
}
创建具有默认变体和base64编码图像的新商品
POST /admin/api/2021-01/products.json
{
“商品” : {
标题:“ Burton Custom Freestyle 151”,
“ body_html” :“ <strong>单板滑雪好!</ strong>”,
“供应商” :“伯顿”,
“ product_type” :“滑雪板”,
“图像” : [
{
“ attachment” :“ R0lGODlhAQABAIAAAAAAAAAAACHACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw == \ n”
}
]
}
}
创建具有默认变体的新商品和Shopify将下载的商品图片
POST /admin/api/2021-01/products.json
{
“商品” : {
标题:“ Burton Custom Freestyle 151”,
“ body_html” :“ <strong>单板滑雪好!</ strong>”,
“供应商” :“伯顿”,
“ product_type” :“滑雪板”,
“图像” : [
{
“ src” :“ [http://example.com/rails_logo.gif](http://example.com/rails_logo.gif)”
}
]
}
}
创建没有标题的商品将返回错误
POST /admin/api/2021-01/products.json
{
“商品” : {
“ body_html” :“一个谜!
}
}
使用元字段创建商品
POST /admin/api/2021-01/products.json
{
“商品” : {
标题:“ Burton Custom Freestyle 151”,
“ body_html” :“ <strong>单板滑雪好!</ strong>”,
“供应商” :“伯顿”,
“ product_type” :“滑雪板”,
“ metafields” : [
{
“ key” :“ new”,
“ value” :“ newvalue”,
“ value_type” :“字符串”,
“ namespace” :“ global”
}
]
}
}
放/admin/api/2021-01/products/{product_id}.json更新商品及其变体和图像。
如果要更新商品的SEO信息,则可以使用以下属性:
- metafields_global_title_tag:用于SEO的商品名称。通常添加到
<meta name='title'>标签中。 - metafields_global_description_tag:用于SEO的商品说明。通常添加到
<meta name='description'>标签中。
通过重新订购商品变型来更新商品
PUT /admin/api/2021-01/products/632910392.json
{
“商品” : {
“ id” :632910392,
“变体” : [
{
“ id” :457924702
},
{
“ id” :39072856
},
{
“ id” :49148385
},
{
“ id” :808950810
}
]
}
}
更新商品及其变体之一
PUT /admin/api/2021-01/products/632910392.json
{
“商品” : {
“ id” :632910392,
"title": "Updated Product Title",
"variants": [
{
"id": 808950810,
"price": "2000.00",
"sku": "Updating the Product SKU"
},
{
"id": 49148385
},
{
"id": 39072856
},
{
"id": 457924702
}
]
}
}
Update a product’s SEO title and description
PUT /admin/api/2021-01/products/632910392.json
{
“product”: {
"id": 632910392,
"metafields_global_title_tag": "Brand new title",
"metafields_global_description_tag": "Brand new description"
}
}
Show a hidden product by changing the published attribute to true
PUT /admin/api/2021-01/products/632910392.json
{
“product”: {
"id": 632910392,
"published": true
}
}
Hide a published product by changing the published attribute to false
PUT /admin/api/2021-01/products/632910392.json
{
“product”: {
"id": 632910392,
"published": false
}
}
Add a metafield to an existing product
PUT /admin/api/2021-01/products/632910392.json
{
“product”: {
"id": 632910392,
"metafields": [
{
"key": "new",
"value": "newvalue",
"value_type": "string",
"namespace": "global"
}
]
}
}
Update a product’s title
PUT /admin/api/2021-01/products/632910392.json
{
“product”: {
"id": 632910392,
"title": "New product title"
}
}
Update a product’s status
PUT /admin/api/2021-01/products/632910392.json
{
“product”: {
"id": 632910392,
"status": "draft"
}
}
Update a product’s tags
PUT /admin/api/2021-01/products/632910392.json
{
“product”: {
"id": 632910392,
"tags": "Barnes & Noble, John's Fav"
}
}
Update a product by clearing product images
PUT /admin/api/2021-01/products/632910392.json
{
“product”: {
"id": 632910392,
"images": []
}
}
Update a product by adding a new product image
PUT /admin/api/2021-01/products/632910392.json
{
“product”: {
"id": 632910392,
"images": [
{
"id": 850703190
},
{
"id": 562641783
},
{
"src": "http://example.com/rails_logo.gif"
}
]
}
}
Update a product by reordering product image
PUT /admin/api/2021-01/products/632910392.json
{
“product”: {
"id": 632910392,
"images": [
{
"id": 850703190,
"position": 2
},
{
"id": 562641783,
"position": 1
}
]
}
}
DELETE/admin/api/2021-01/products/{product_id}.json Deletes a product.Delete a product along with all its variants and images
DELETE /admin/api/2021-01/products/632910392.json
