產品 APIs (TW)

新增一個簡單的產品教育訓練課程

RCE 中的產品是運送給客戶的實體產品。例如,一個簡單的產品可能是一盞燈或一個真空吸塵器。它沒有附加選項,例如尺寸、顏色或材料。

每個簡單的產品都有自己唯一的 SKU、自己的唯一 URL 和自己的庫存計數(假設商店正在積極管理庫存水平)。

 

步驟 1. 規劃產品

您需要了解以下內容,並用撰寫程式的方式新增可配置產品:

  • 在分配給可配置產品的屬性集中定義的屬性名稱和值
  • 分配給可配置產品的類別編號
  • 屬性配置選項

由於本教程使用示例數據,我們可以利用 Top 屬性集提供的選項。此屬性集包含描述面料、袖長和其他特定於服裝的特性的屬性。它還包括尺寸和顏色等 EAV 屬性,這些屬性通常適用於所有類型的實物產品

T 恤的尺寸產品的配置。將為每種尺寸(小、中和大)新增一個簡單的產品.

定義產品特性

下表列出了我們正在製作的男士 T 恤的一般特徵。當選擇 Top 屬性集時,這些項目在管理中的新產品頁面上列出的項目中.

特徵 描述
屬性 默認
產品名稱 冠軍 T 卹
SKU MS-Champ
價格 25.00
稅率 應稅
重量 0.5
分類 Men, Tops, Tees
能見度 目錄,搜索
顏色 灰色
描述 Champ T 卹讓您在做事時保持涼爽和乾爽。只需 10 美元,只需在背面添加您的名字,讓所有人都知道您是誰

商家通常會提供產品名稱、SKU、價格、重量和描述。其他特徵由系統定義

找到系統定義的值

進行多次調整以找到新增產品所需的值

獲取屬性ID

示例數據提供了多個屬性集,包括 Default、Top 和 Bottom。要將 Top 屬性集分配給產品,我們需要知道對應的 attribute_set_id.

使用以下調用來搜索名為 的屬性 Top.

Endpoint

GET /rest/<store_code>/V1/eav/attribute-sets/list?
searchCriteria[filter_groups][0][filters][0][field]=attribute_set_name&
searchCriteria[filter_groups][0][filters][0][value]=Default&
searchCriteria[filter_groups][0][filters][0][condition_type]=eq

Response
The attribute_set_id for the Default attribute set is 2.

{
    "items": [
        {
            "attribute_set_id": 2,
            "attribute_set_name": "Default",
            "sort_order": 0,
            "entity_type_id": 4
        }
    ],
    "search_criteria": {
        "filter_groups": [
            {
                "filters": [
                    {
                        "field": "attribute_set_name",
                        "value": "Default",
                        "condition_type": "eq"
                    }
                ]
            }
        ]
    },
    "total_count": 1
}

獲取屬性 searchCriteria中定義的屬性列表

Use the GET V1/products/attribute-sets/:attributeSetId/attributes 調返有關在 Top 屬性集中定義的屬性的資訊。

Endpoint

GET /rest/default/V1/products/attribute-sets/9/attributes

回復

回應包含近 3,000 行。下表提供了本教程中相關屬性的摘要

Admin label Selected value Attribute ID attribute_code Attribute value
Tax Class Taxable Goods 132 tax_class_id 2
Visibility Catalog, Search 99 visibility 4
Color Gray 93 color 52

您安裝的屬性 ID 和值編號可能不同。在調用中使用它們之前,請仔細檢查這些值

獲取類別值列表

您必須將產品分配到一個或多個類別,以使客戶能夠通過瀏覽找到產品。我們會將 Champ Tee 分配給 Men、Tops 和 Tee 類別.

使用以下調用搜索所有類別 (id is greater than or equal to 0).

GET /rest/default/V1/categories?
searchCriteria[filter_groups][0][filters][0][field]=id&
searchCriteria[filter_groups][0][filters][0][value]=1&
searchCriteria[filter_groups][0][filters][0][condition_type]=gte

Note that women’s tops and tees have different ids than men’s tops and tees. The values for men’s clothing are:

  • Men – 11
  • Tops – 12
  • Tees – 16

步驟 2. 新增產品

雖然不是必需的,但簡單的產品有效負載也包含stock_item信息。默認情況下,RCE 商店會隱藏缺貨商品,因此添加庫存將使 Champ Tee 在網站上可見

第一個產品新增

在使用此代碼範例之前,請驗證安裝中的屬性值是否相同。上方.

Endpoint

POST /rest/default/V1/products

Payload

{
  "product": {
    "sku": "MS-Champ",
    "name": "Champ Tee",
    "attribute_set_id": 2,
    "price": 25,
    "status": 1,
    "visibility": 4,
    "type_id": "simple",
    "weight": "0.5",
    "extension_attributes": {
    	"category_links": [
    		{
    			"position": 0,
    			"category_id": "11"
    		},
    		{
    			"position": 1,
    			"category_id": "12"
    		},
    		{
    			"position": 2,
    			"category_id": "16"
    		}
    	],
    	"stock_item": {
    		"qty": "10",
    		"is_in_stock": true
    	}
    },
    "custom_attributes": [
    	{
    		"attribute_code": "description",
    		"value": "The Champ Tee keeps you cool and dry while you do your thing. Let everyone know who you are by adding your name on the back for only $10."
    	},
    	{
    		"attribute_code": "tax_class_id",
    		"value": "2"
    	},
    	
    	{
    		"attribute_code": "color",
    		"value": "52"
    	}
    ]
  }
}

Response

 
{
    "id": 2079,
    "sku": "MS-Champ",
    "name": "Champ Tee",
    "attribute_set_id": 2,
    "price": 25,
    "status": 1,
    "visibility": 4,
    "type_id": "simple",
    "created_at": "2017-11-29 20:40:07",
    "updated_at": "2017-11-29 20:40:07",
    "weight": 0.5,
    "extension_attributes": {
        "website_ids": [
            1
        ],
        "category_links": [
            {
                "position": 0,
                "category_id": "11"
            },
            {
                "position": 1,
                "category_id": "12"
            },
            {
                "position": 2,
                "category_id": "16"
            }
        ],
        "stock_item": {
            "item_id": 2079,
            "product_id": 2079,
            "stock_id": 1,
            "qty": 10,
            "is_in_stock": true,
            "is_qty_decimal": false,
            "show_default_notification_message": false,
            "use_config_min_qty": true,
            "min_qty": 0,
            "use_config_min_sale_qty": 1,
            "min_sale_qty": 1,
            "use_config_max_sale_qty": true,
            "max_sale_qty": 10000,
            "use_config_backorders": true,
            "backorders": 0,
            "use_config_notify_stock_qty": true,
            "notify_stock_qty": 1,
            "use_config_qty_increments": true,
            "qty_increments": 0,
            "use_config_enable_qty_inc": true,
            "enable_qty_increments": false,
            "use_config_manage_stock": true,
            "manage_stock": true,
            "low_stock_date": null,
            "is_decimal_divided": false,
            "stock_status_changed_auto": 0
        }
    },
    "product_links": [],
    "options": [],
    "media_gallery_entries": [],
    "tier_prices": [],
    "custom_attributes": [
        {
            "attribute_code": "description",
            "value": "The Champ Tee keeps you cool and dry while you do your thing. Let everyone know who you are by adding your name on the back for only $10."
        },
        {
            "attribute_code": "color",
            "value": "52"
        },
        {
            "attribute_code": "category_ids",
            "value": [
                "11",
                "12",
                "16"
            ]
        },
        {
            "attribute_code": "options_container",
            "value": "container2"
        },
        {
            "attribute_code": "required_options",
            "value": "0"
        },
        {
            "attribute_code": "has_options",
            "value": "0"
        },
        {
            "attribute_code": "url_key",
            "value": "champ-tee-small"
        },
        {
            "attribute_code": "tax_class_id",
            "value": "2"
        }
        
    ]
}

新增可配置的產品教學課程

可配置產品是要求客戶在購買前選擇一個或多個“選項”

例如,在購買鞋子時,客戶需要選擇他們想要購買的鞋碼。許多服裝項目很可能具有必須由客戶做出的顏色和尺寸選擇

資源

https://rezolve.com/rceapidocs

步驟 1. 規劃產品

以編寫程式方式新增產品配置,您需要了解以下內容:

  • 在分配給可配置產品的屬性集中定義的屬性名稱和值
  • 分配給可配置產品的類別編號
  • 哪些屬性用作配置選項

由於本教程使用示例數據,我們可以利用 Top 屬性集提供的選項。此屬性集包含描述面料、袖長和其他特定於服裝的特性的屬性。它還包括尺寸和顏色等 EAV 屬性,這些屬性通常適用於所有類型的實物產品.

T 恤的尺寸將是該產品的可配置方面。因此,我們將為每種尺寸(小、中和大)新增一個產品

定義產品特性

下表列出了我們正在製作的男士 T 恤的一般特徵。當選擇 Top 屬性集時,這些項目在管理中的新產品頁面上列出的項目中.

Characteristic Description
Attribute Set Top
Product Name Champ Tee
SKU MS-Champ
Price 25.00
Tax Class Taxable Goods
Weight 0.5
Categories Men, Tops, Tees
Visibility Catalog, Search
Material LumaTech
Pattern Graphic Print
Color Gray
Size Configurable in small, medium, or large
Description The Champ Tee keeps you cool and dry while you do your thing. Let everyone know who you are by adding your name on the back for only $10.

商家通常會提供產品名稱、SKU、價格、重量和描述。其他特徵由系統定義.

查詢系統定義的值

我們將進行多次調用以找到創建產品所需的值

獲取屬性 ID

範例數據提供了多個屬性,包括 Default、Top 和 Bottom。要將 Top 屬性集分配給產品,我們需要知道對應的 attribute_set_id.

使用以下用來搜尋為 Top 的屬性

Endpoint

GET /rest/<store_code>/V1/eav/attribute-sets/list?
searchCriteria[filter_groups][0][filters][0][field]=attribute_set_name&
searchCriteria[filter_groups][0][filters][0][value]=Top&
searchCriteria[filter_groups][0][filters][0][condition_type]=eq

Response
The attribute_set_id for the Top attribute set is 9.

{
    "items": [
        {
            "attribute_set_id": 9,
            "attribute_set_name": "Top",
            "sort_order": 0,
            "entity_type_id": 4
        }
    ],
    "search_criteria": {
        "filter_groups": [
            {
                "filters": [
                    {
                        "field": "attribute_set_name",
                        "value": "Top",
                        "condition_type": "eq"
                    }
                ]
            }
        ]
    },
    "total_count": 1
}

獲取屬性searchCriteria中定義的屬性列表

Use the GET V1/products/attribute-sets/:attributeSetId/attributes call to return information about the attributes defined in the Top attribute set.

Endpoint

GET /rest/default/V1/products/attribute-sets/9/attributes

Response

包含近 3,000 行。下表提供了本教程中相關屬性的摘要

標籤 選定的值 屬性 ID 屬性代碼 屬性值
稅類 應稅貨物 132 tax_class_id 2
能見度 目錄,搜索 99 visibility 4
材料 LumaTech 136 material 148
圖案 圖形列印 152 pattern 196
顏色 灰色 93 color 52
尺寸 不適用 141 size 168 (small), 169 (medium), 170 (large)

您安裝的屬性 ID 和值編號可能不同。在調用中使用它們之前,請仔細檢查

獲取類別值列表

您必須將產品分配到一個或多個類別,以使客戶能夠通過瀏覽找到產品。我們會將 Champ Tee 分配給 Men、Tops 和 Tee 類別

使用以下調用搜索所有類別 (id is greater than or equal to 0).

GET /rest/default/V1/categories?
searchCriteria[filter_groups][0][filters][0][field]=id&
searchCriteria[filter_groups][0][filters][0][value]=1&
searchCriteria[filter_groups][0][filters][0][condition_type]=gte

注意,女士上衣和 T 恤的 ID 與男士上衣和 T 卹不同。男裝的價值觀是:

  • Men – 11
  • Tops – 12
  • Tees – 16

步驟 2. 新增可配置產品

我們擁有創建 Champ Tee 可配置產品所需的信息。

樣本有效載荷不包含價格或大小。這些屬性將在簡單產品中定義

The visibility 屬性設置為4, 表示可以通過瀏覽或搜索找到該產品。對於簡單產品,此值將更改

在使用此代碼範例前,請驗證安裝中的屬性值是否相同.

Endpoint

POST /rest/default/V1/products

Payload

{
  "product": {
    "sku": "MS-Champ",
    "name": "Champ Tee",
    "attribute_set_id": 9,
    "status": 1,
    "visibility": 4,
    "type_id": "configurable",
    "weight": "0.5",
    "extension_attributes": {
    	"category_links": [
    		{
    			"position": 0,
    			"category_id": "11"
    		},
    		{
    			"position": 1,
    			"category_id": "12"
    		},
    		{
    			"position": 2,
    			"category_id": "16"
    		}
    	]
    },
    "custom_attributes": [
    	{
    		"attribute_code": "description",
    		"value": "The Champ Tee keeps you cool and dry while you do your thing. Let everyone know who you are by adding your name on the back for only $10."
    	},
    	{
    		"attribute_code": "tax_class_id",
    		"value": "2"
    	},
    	{
    		"attribute_code": "material",
    		"value": "148"
    	},
    	{
    		"attribute_code": "pattern",
    		"value": "196"
    	},
    	{
    		"attribute_code": "color",
    		"value": "52"
    	}
    ]
  }
}

Response

{
    "id": 2078,
    "sku": "MS-Champ",
    "name": "Champ Tee",
    "attribute_set_id": 9,
    "price": 0,
    "status": 1,
    "visibility": 4,
    "type_id": "configurable",
    "created_at": "2017-11-29 19:57:20",
    "updated_at": "2017-11-29 19:57:20",
    "weight": 0.5,
    "extension_attributes": {
        "website_ids": [
            1
        ],
        "category_links": [
            {
                "position": 0,
                "category_id": "11"
            },
            {
                "position": 1,
                "category_id": "12"
            },
            {
                "position": 2,
                "category_id": "16"
            }
        ],
        "stock_item": {
            "item_id": 2078,
            "product_id": 2078,
            "stock_id": 1,
            "qty": 0,
            "is_in_stock": false,
            "is_qty_decimal": false,
            "show_default_notification_message": false,
            "use_config_min_qty": true,
            "min_qty": 0,
            "use_config_min_sale_qty": 1,
            "min_sale_qty": 1,
            "use_config_max_sale_qty": true,
            "max_sale_qty": 10000,
            "use_config_backorders": true,
            "backorders": 0,
            "use_config_notify_stock_qty": true,
            "notify_stock_qty": 1,
            "use_config_qty_increments": true,
            "qty_increments": 0,
            "use_config_enable_qty_inc": true,
            "enable_qty_increments": false,
            "use_config_manage_stock": true,
            "manage_stock": true,
            "low_stock_date": null,
            "is_decimal_divided": false,
            "stock_status_changed_auto": 0
        },
        "configurable_product_options": [],
        "configurable_product_links": []
    },
    "product_links": [],
    "options": [],
    "media_gallery_entries": [],
    "tier_prices": [],
    "custom_attributes": [
        {
            "attribute_code": "description",
            "value": "The Champ Tee keeps you cool and dry while you do your thing. Let everyone know who you are by adding your name on the back for only $10."
        },
        {
            "attribute_code": "color",
            "value": "52"
        },
        {
            "attribute_code": "category_ids",
            "value": [
                "11",
                "12",
                "16"
            ]
        },
        {
            "attribute_code": "options_container",
            "value": "container2"
        },
        {
            "attribute_code": "required_options",
            "value": "0"
        },
        {
            "attribute_code": "has_options",
            "value": "0"
        },
        {
            "attribute_code": "url_key",
            "value": "champ-tee"
        },
        {
            "attribute_code": "tax_class_id",
            "value": "2"
        },
        {
            "attribute_code": "material",
            "value": "148"
        },
        {
            "attribute_code": "size",
            "value": "91"
        },
        {
            "attribute_code": "pattern",
            "value": "196"
        }
    ]
}

 

步驟 3. 新增產品

創建簡單產品和可配置產品的有效負載是相同的,但有以下例外:

  • 簡單產品sku將可配置選項(本教程中的大小)附加到可配置產品sku.
  • name 表示大小
  • type_id is set to simple.
  • visibility設置為1,表示不應在商店中展示簡單產品
  • price屬性size已指定

雖然不是必需的,但簡單的產品有效負載也包含stock_item信息。默認情況下,RCE 商店會隱藏缺貨商品,因此添加庫存將使 Champ Tee 在網站上可見

新增第一個產品

在使用此代碼範例前,請驗證安裝中的屬性值是否相同.

Endpoint

POST /rest/default/V1/products

Payload

{
  "product": {
    "sku": "MS-Champ-S",
    "name": "Champ Tee Small",
    "attribute_set_id": 9,
    "price": 25,
    "status": 1,
    "visibility": 1,
    "type_id": "simple",
    "weight": "0.5",
    "extension_attributes": {
    	"category_links": [
    		{
    			"position": 0,
    			"category_id": "11"
    		},
    		{
    			"position": 1,
    			"category_id": "12"
    		},
    		{
    			"position": 2,
    			"category_id": "16"
    		}
    	],
    	"stock_item": {
    		"qty": "10",
    		"is_in_stock": true
    	}
    },
    "custom_attributes": [
    	{
    		"attribute_code": "description",
    		"value": "The Champ Tee keeps you cool and dry while you do your thing. Let everyone know who you are by adding your name on the back for only $10."
    	},
    	{
    		"attribute_code": "tax_class_id",
    		"value": "2"
    	},
    	{
    		"attribute_code": "material",
    		"value": "148"
    	},
    	{
    		"attribute_code": "pattern",
    		"value": "196"
    	},
    	{
    		"attribute_code": "color",
    		"value": "52"
    	},
    	{
    		"attribute_code": "size",
    		"value": "168"
    	}
    ]
  }
}

Response

 
 
{
    "id": 2079,
    "sku": "MS-Champ-S",
    "name": "Champ Tee Small",
    "attribute_set_id": 9,
    "price": 25,
    "status": 1,
    "visibility": 1,
    "type_id": "simple",
    "created_at": "2017-11-29 20:40:07",
    "updated_at": "2017-11-29 20:40:07",
    "weight": 0.5,
    "extension_attributes": {
        "website_ids": [
            1
        ],
        "category_links": [
            {
                "position": 0,
                "category_id": "11"
            },
            {
                "position": 1,
                "category_id": "12"
            },
            {
                "position": 2,
                "category_id": "16"
            }
        ],
        "stock_item": {
            "item_id": 2079,
            "product_id": 2079,
            "stock_id": 1,
            "qty": 10,
            "is_in_stock": true,
            "is_qty_decimal": false,
            "show_default_notification_message": false,
            "use_config_min_qty": true,
            "min_qty": 0,
            "use_config_min_sale_qty": 1,
            "min_sale_qty": 1,
            "use_config_max_sale_qty": true,
            "max_sale_qty": 10000,
            "use_config_backorders": true,
            "backorders": 0,
            "use_config_notify_stock_qty": true,
            "notify_stock_qty": 1,
            "use_config_qty_increments": true,
            "qty_increments": 0,
            "use_config_enable_qty_inc": true,
            "enable_qty_increments": false,
            "use_config_manage_stock": true,
            "manage_stock": true,
            "low_stock_date": null,
            "is_decimal_divided": false,
            "stock_status_changed_auto": 0
        }
    },
    "product_links": [],
    "options": [],
    "media_gallery_entries": [],
    "tier_prices": [],
    "custom_attributes": [
        {
            "attribute_code": "description",
            "value": "The Champ Tee keeps you cool and dry while you do your thing. Let everyone know who you are by adding your name on the back for only $10."
        },
        {
            "attribute_code": "color",
            "value": "52"
        },
        {
            "attribute_code": "category_ids",
            "value": [
                "11",
                "12",
                "16"
            ]
        },
        {
            "attribute_code": "options_container",
            "value": "container2"
        },
        {
            "attribute_code": "required_options",
            "value": "0"
        },
        {
            "attribute_code": "has_options",
            "value": "0"
        },
        {
            "attribute_code": "url_key",
            "value": "champ-tee-small"
        },
        {
            "attribute_code": "tax_class_id",
            "value": "2"
        },
        {
            "attribute_code": "material",
            "value": "148"
        },
        {
            "attribute_code": "size",
            "value": "168"
        },
        {
            "attribute_code": "pattern",
            "value": "196"
        }
    ]
}
 

新增其他產品

重複調用並對有效負載進行以下更改:

屬性 Medium Value Large Value
sku MS-Champ-M MS-Champ-L
name Champ Tee Medium Champ Tee Large
size 169 170

 

步驟 4. 定義可配置的產品選項

現在我們已經創建了所有 Champ Tee 產品,我們需要將其分配size為可配置屬性並將簡單產品鏈接到可配置產品.

設定可配置屬性

The POST V1/configurable-products/:sku/options call assigns the specified attribute_id to be the configurable attribute. Specify the sku of the configurable product in the URI.

The value assigned to the value_index must be unique within the system.

Endpoint

POST /rest/default/V1/configurable-products/MS-Champ/options

Payload

{
  "option": {
    "attribute_id": "141",
    "label": "Size",
    "position": 0,
    "is_use_default": true,
    "values": [
      {
        "value_index": 9
      }
    ]
  }
}

回復

可配置的選項 ID 號,例如"335"

將簡單(子)產品鏈接到可配置產品的調用只接受一個childSku值。MS-Champ-M您必須對和MS-Champ-L產品重複此調用

Endpoint

POST /rest/default/V1/configurable-products/MS-Champ/child

Payload

{
	"childSku": "MS-Champ-S"
}

Response

 

true

驗證此步驟

  • 登錄到 RCE 並選擇目錄 > 產品。單擊Champ Tee可配置產品並展開配置部分
  • Call GET /V1/products/MS-Champ. The response includes the configurable_product_options and configurable_product_links arrays.
 
...
"configurable_product_options": [
    {
        "id": 338,
        "attribute_id": "141",
        "label": "Size",
        "position": 0,
        "values": [
            {
                "value_index": 168
            },
            {
                "value_index": 169
            },
            {
                "value_index": 170
            }
        ],
        "product_id": 2078
    }
],
"configurable_product_links": [
    2079,
    2080,
    2081
]
},
...

步驟 5. 創建個性化選項

讓我們在產品頁面中添加一個文本框,允許客戶在襯衫背面添加他的姓名(最多 15 個字符)

product_skusku配置產品的。有效負載中sku指定的字符串是附加到product_sku客戶決定購買此選項時的字符串。同樣,price有效載荷中提供的內容被添加到可配置的產品價格中

Endpoint

POST /rest/default/V1/products/options

Payload

{
  "option": {
    "product_sku": "MS-Champ",
    "title": "Add Your Name (Max 15 Characters)",
    "type": "field",
    "sort_order": 1,
    "is_require": false,
    "price": 10,
    "price_type": "fixed",
    "sku": "Personalized",
    "max_characters": 15
  }
}

回復

{
    "product_sku": "MS-Champ",
    "option_id": 7,
    "title": "Add Your Name (Max 15 Characters)",
    "type": "field",
    "sort_order": 1,
    "is_require": false,
    "price": 10,
    "price_type": "fixed",
    "sku": "Personalized",
    "max_characters": 15
}

單一 SKU 更新

以下調用異步更改 sku 為 sku1 的產品的價格

PUT <host>/rest/<store_code>/async/V1/products/sku1

Request Data

{
  "product": {
    "price": 29
  }
}

Response

{
    "bulk_uuid": "fbfca270-7a90-4c4e-9f32-d6cf3728cdc7",
    "request_items": [
        {
            "id": 0,
            "data_hash": "9c1bd4bfd8defcc856ddf129cc01d172625d139d5f7dcf53b6cb09a0e9a843a3",
            "status": "accepted"
        }
    ],
    "errors": false
}

批次 SKU 更新


可以使用批量更新 API 更新庫存和價格

獲取每個產品的庫存項目

Product 1

GET <host>/rest/V1/stockItems/test1%22

Product 1 Response

{
   "item_id":1,
   "product_id":1,
   "stock_id":1,
   "qty":1,
   "is_in_stock":true,
   "is_qty_decimal":false,
   "show_default_notification_message":false,
   "use_config_min_qty":true,
   "min_qty":0,
   "use_config_min_sale_qty":1,
   "min_sale_qty":1,
   "use_config_max_sale_qty":true,
   "max_sale_qty":20,
   "use_config_backorders":true,
   "backorders":0,
   "use_config_notify_stock_qty":true,
   "notify_stock_qty":1,
   "use_config_qty_increments":true,
   "qty_increments":0,
   "use_config_enable_qty_inc":true,
   "enable_qty_increments":false,
   "use_config_manage_stock":true,
   "manage_stock":true,
   "low_stock_date":null,
   "is_decimal_divided":false,
   "stock_status_changed_auto":0,
   "extension_attributes":[
      
   ]
}

Product 2

GET <host>/rest/V1/stockItems/test2

Product 2 Response

{
   "item_id":2,
   "product_id":2,
   "stock_id":1,
   "qty":1,
   "is_in_stock":true,
   "is_qty_decimal":false,
   "show_default_notification_message":false,
   "use_config_min_qty":true,
   "min_qty":0,
   "use_config_min_sale_qty":1,
   "min_sale_qty":1,
   "use_config_max_sale_qty":true,
   "max_sale_qty":20,
   "use_config_backorders":true,
   "backorders":0,
   "use_config_notify_stock_qty":true,
   "notify_stock_qty":1,
   "use_config_qty_increments":true,
   "qty_increments":0,
   "use_config_enable_qty_inc":true,
   "enable_qty_increments":false,
   "use_config_manage_stock":true,
   "manage_stock":true,
   "low_stock_date":null,
   "is_decimal_divided":false,
   "stock_status_changed_auto":0,
   "extension_attributes":[
      
   ]
}

Update stock by request

PUT <host>/rest/async/bulk/V1/products/bySku

Payload

[
   {
      "product":{
         "sku":"test1",
         "name":"Test1",
         "attribute_set_id":4,
         "status":1,
         "visibility":4,
         "price":30,
         "type_id":"simple",
         "extension_attributes":{
            "stock_item":{
               "item_id":1,
               "product_id":1,
               "stock_id":1,
               "qty":20,
               "is_in_stock":true
            }
         },
         "custom_attributes":[
            
         ]
      }
   },
   {
      "product":{
         "sku":"test2",
         "name":"Test2",
         "attribute_set_id":4,
         "status":1,
         "visibility":4,
         "price":50,
         "type_id":"simple",
         "extension_attributes":{
            "stock_item":{
               "item_id":2,
               "product_id":2,
               "stock_id":1,
               "qty":70,
               "is_in_stock":true
            }
         },
         "custom_attributes":[
            
         ]
      }
   }
]