Question

Need to get Product Stock Status in products details using Rest API.

Method: GET

Using API URL: http://testwebsite/rest/en/V1/products/sku

Above api returns products details but need also products stock status.

Any help would be appreciated. Thanks!

UPDATE

Magento ver. 2.3.0

API Response :

{
    "id": 1075,
    "sku": "ACREATSGRACJ5050",
    "name": "Brow Set",
    "attribute_set_id": 14,
    "price": 10.5,
    "status": 1,
    "visibility": 4,
    "type_id": "simple",
    "created_at": "2019-04-06 08:39:24",
    "updated_at": "2019-08-28 06:10:01",
    "extension_attributes": {
        "website_ids": [
            1
        ],
        "category_links": [
            {
                "position": 0,
                "category_id": "7"
            },
            {
                "position": 0,
                "category_id": "77"
            },
            {
                "position": 0,
                "category_id": "78"
            },
            {
                "position": 0,
                "category_id": "83"
            }
        ]
    },
    "product_links": [],
    "options": [],
    "media_gallery_entries": [],
    "tier_prices": [],
    "custom_attributes": [
        {
            "attribute_code": "url_key",
            "value": "brow-set"
        },
        {
            "attribute_code": "gift_message_available",
            "value": "0"
        },
        {
            "attribute_code": "rma_allowed",
            "value": "1"
        },
        {
            "attribute_code": "acce_brand",
            "value": "208"
        },
        {
            "attribute_code": "options_container",
            "value": "container2"
        },
        {
            "attribute_code": "acce_type",
            "value": "223"
        },
        {
            "attribute_code": "acce_item",
            "value": "209"
        },
        {
            "attribute_code": "supplier_sku",
            "value": "RT-1468"
        },
        {
            "attribute_code": "in_html_sitemap",
            "value": "1"
        },
        {
            "attribute_code": "msrp_display_actual_price_type",
            "value": "0"
        },
        {
            "attribute_code": "retail_price",
            "value": "10.5000"
        },
        {
            "attribute_code": "tax_class_id",
            "value": "2"
        },
        {
            "attribute_code": "use_in_crosslinking",
            "value": "1"
        },
        {
            "attribute_code": "in_xml_sitemap",
            "value": "1"
        },
        {
            "attribute_code": "required_options",
            "value": "0"
        },
        {
            "attribute_code": "has_options",
            "value": "0"
        },
        {
            "attribute_code": "category_ids",
            "value": [
                "7",
                "77",
                "78",
                "83"
            ]
        },
        {
            "attribute_code": "country_of_manufacture",
            "value": "US"
        },
        {
            "attribute_code": "color",
            "value": "4"
        },
        {
            "attribute_code": "upc_ean",
            "value": "79625014686"
        },
        {
            "attribute_code": "as_featured",
            "value": "0"
        }
    ]
}
Was it helpful?

Solution

You can get product stock status from here :

/V1/stockItems/:productSku

API Response :

{
    "item_id": 1,
    "product_id": 1,
    "stock_id": 1,
    "qty": 100,
    "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
}

UPDATE :

Get with product details

/V1/products/:productSku

API Response :

{
    "id": 1,
    "sku": "24-MB01",
    "name": "Joust Duffle Bag",
    "attribute_set_id": 15,
    "price": 34,
    "status": 1,
    "visibility": 4,
    "type_id": "simple",
    "created_at": "2019-07-30 10:50:45",
    "updated_at": "2019-07-30 10:50:45",
    "extension_attributes": {
        "website_ids": [
            1
        ],
        "category_links": [
            {
                "position": 0,
                "category_id": "3"
            },
            {
                "position": 0,
                "category_id": "4"
            }
        ],
        "stock_item": {
            "item_id": 1,
            "product_id": 1,
            "stock_id": 1,
            "qty": 100,
            "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": [
        {
            "sku": "24-MB01",
            "link_type": "crosssell",
            "linked_product_sku": "24-WG086",
            "linked_product_type": "simple",
            "position": 1
        },
        {
            "sku": "24-MB01",
            "link_type": "crosssell",
            "linked_product_sku": "24-WG083-blue",
            "linked_product_type": "simple",
            "position": 2
        },
        {
            "sku": "24-MB01",
            "link_type": "crosssell",
            "linked_product_sku": "24-UG01",
            "linked_product_type": "simple",
            "position": 3
        },
        {
            "sku": "24-MB01",
            "link_type": "crosssell",
            "linked_product_sku": "24-WG085_Group",
            "linked_product_type": "grouped",
            "position": 4
        },
        {
            "sku": "24-MB01",
            "link_type": "upsell",
            "linked_product_sku": "24-MB02",
            "linked_product_type": "simple",
            "position": 1
        },
        {
            "sku": "24-MB01",
            "link_type": "upsell",
            "linked_product_sku": "24-MB03",
            "linked_product_type": "simple",
            "position": 2
        },
        {
            "sku": "24-MB01",
            "link_type": "upsell",
            "linked_product_sku": "24-MB05",
            "linked_product_type": "simple",
            "position": 3
        },
        {
            "sku": "24-MB01",
            "link_type": "upsell",
            "linked_product_sku": "24-MB06",
            "linked_product_type": "simple",
            "position": 4
        },
        {
            "sku": "24-MB01",
            "link_type": "upsell",
            "linked_product_sku": "24-UB02",
            "linked_product_type": "simple",
            "position": 5
        },
        {
            "sku": "24-MB01",
            "link_type": "upsell",
            "linked_product_sku": "24-WB03",
            "linked_product_type": "simple",
            "position": 6
        },
        {
            "sku": "24-MB01",
            "link_type": "upsell",
            "linked_product_sku": "24-WB04",
            "linked_product_type": "simple",
            "position": 7
        },
        {
            "sku": "24-MB01",
            "link_type": "upsell",
            "linked_product_sku": "24-WB07",
            "linked_product_type": "simple",
            "position": 8
        }
    ],
    "options": [],
    "media_gallery_entries": [
        {
            "id": 1,
            "media_type": "image",
            "label": "Image",
            "position": 1,
            "disabled": false,
            "types": [
                "image",
                "small_image",
                "thumbnail"
            ],
            "file": "/m/b/mb01-blue-0.jpg"
        }
    ],
    "tier_prices": [],
    "custom_attributes": [
        {
            "attribute_code": "image",
            "value": "/m/b/mb01-blue-0.jpg"
        },
        {
            "attribute_code": "small_image",
            "value": "/m/b/mb01-blue-0.jpg"
        },
        {
            "attribute_code": "thumbnail",
            "value": "/m/b/mb01-blue-0.jpg"
        },
        {
            "attribute_code": "url_key",
            "value": "joust-duffle-bag"
        },
        {
            "attribute_code": "required_options",
            "value": "0"
        },
        {
            "attribute_code": "has_options",
            "value": "0"
        },
        {
            "attribute_code": "category_ids",
            "value": [
                "3",
                "4"
            ]
        },
        {
            "attribute_code": "description",
            "value": "<p>The sporty Joust Duffle Bag can't be beat - not in the gym, not on the luggage carousel, not anywhere. Big enough to haul a basketball or soccer ball and some sneakers with plenty of room to spare, it's ideal for athletes with places to go.<p>\n<ul>\n<li>Dual top handles.</li>\n<li>Adjustable shoulder strap.</li>\n<li>Full-length zipper.</li>\n<li>L 29\" x W 13\" x H 11\".</li>\n</ul>"
        }
    ]
}

For more details, you can see here

https://devdocs.magento.com/guides/v2.0/rest/list.html#cataloginventory

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top