Magento – Product Details for color and size Rest Magento 2.x

androidmagento2rest api

Get Request
Url:
https://example.com/index.php/rest/V1/products/sku

Response:

{
    "id": 176,
    "sku": "8544501",
    "name": "BATA-8544501",
    "attribute_set_id": 4,
    "price": 0,
    "status": 1,
    "visibility": 4,
    "type_id": "configurable",
    "created_at": "2018-01-12 07:25:07",
    "updated_at": "2018-01-12 07:25:07",
    "weight": 0.5,
    "extension_attributes": {
        "configurable_product_options": [
            {
                "id": 73,
                "attribute_id": "93",
                "label": "Color",
                "position": 0,
                "values": [
                    {
                        "value_index": 10
                    }
                ],
                "product_id": 176
            },
            {
                "id": 74,
                "attribute_id": "135",
                "label": "Size",
                "position": 1,
                "values": [
                    {
                        "value_index": 4
                    },
                    {
                        "value_index": 5
                    },
                    {
                        "value_index": 6
                    },
                    {
                        "value_index": 7
                    },
                    {
                        "value_index": 8
                    }
                ],
                "product_id": 176
            }
        ],
        "configurable_product_links": [
            171,
            172,
            173,
            174,
            175
        ]
    },
    "product_links": [],
    "options": [],
    "media_gallery_entries": [
        {
            "id": 285,
            "media_type": "image",
            "label": null,
            "position": 1,
            "disabled": false,
            "types": [
                "image",
                "small_image",
                "thumbnail"
            ],
            "file": "/8/5/854-4501-a_1_2.jpg"
        },
        {
            "id": 286,
            "media_type": "image",
            "label": null,
            "position": 2,
            "disabled": false,
            "types": [],
            "file": "/8/5/854-4501-b_2.jpg"
        },
        {
            "id": 287,
            "media_type": "image",
            "label": null,
            "position": 3,
            "disabled": false,
            "types": [],
            "file": "/8/5/854-4501-c_2.jpg"
        },
        {
            "id": 288,
            "media_type": "image",
            "label": null,
            "position": 4,
            "disabled": false,
            "types": [],
            "file": "/8/5/854-4501-d_2.jpg"
        },
        {
            "id": 289,
            "media_type": "image",
            "label": null,
            "position": 5,
            "disabled": false,
            "types": [],
            "file": "/8/5/854-4501-e_2.jpg"
        }
    ],
    "tier_prices": [],
    "custom_attributes": [
        {
            "attribute_code": "meta_title",
            "value": "BATA-8544501"
        },
        {
            "attribute_code": "meta_keyword",
            "value": "BATA-8544501"
        },
        {
            "attribute_code": "meta_description",
            "value": " "
        },
        {
            "attribute_code": "image",
            "value": "/8/5/854-4501-a_1_2.jpg"
        },
        {
            "attribute_code": "small_image",
            "value": "/8/5/854-4501-a_1_2.jpg"
        },
        {
            "attribute_code": "thumbnail",
            "value": "/8/5/854-4501-a_1_2.jpg"
        },
        {
            "attribute_code": "category_ids",
            "value": [
                "83",
                "97",
                "121"
            ]
        },
        {
            "attribute_code": "options_container",
            "value": "container2"
        },
        {
            "attribute_code": "required_options",
            "value": "1"
        },
        {
            "attribute_code": "has_options",
            "value": "1"
        },
        {
            "attribute_code": "url_key",
            "value": "bata-8544501"
        },
        {
            "attribute_code": "tax_class_id",
            "value": "2"
        },
        {
            "attribute_code": "gift_message_available",
            "value": "2"
        },
        {
            "attribute_code": "size",
            "value": "4"
        }
    ]
}

It is returning me "value_index" for color and size.

How i can use that "value_index" for mobile app.

Actually i need color code and size but not value_index.

Is there any other api or filter available?

Best Answer

GET /V1/products/attributes/{attributeCode}

Use above API to get the details of each attribute.