6

I'm requesting products list using the following API call GET /V1/products

http://127.0.0.1/magento2github/index.php/rest/default/V1/products?searchCriteria%5BpageSize%5D=100000&searchCriteria%5BcurrentPage%5D=1

That gives me the following response:

{
 "items": [
 {
 "id": 1298,
 "sku": "2000315",
 "name": "testProduct",
 "attribute_set_id": 4,
 "price": 5,
 "status": 1,
 "visibility": 4,
 "type_id": "simple",
 "created_at": "2015-12-29 19:51:31",
 "updated_at": "2015-12-29 19:53:09",
 "weight": 0,
 "product_links": [],
 "options": [],
 "tier_prices": [
 {
 "customer_group_id": 0,
 "qty": 1,
 "value": 5.75
 },
 {
 "customer_group_id": 1,
 "qty": 1,
 "value": 5.75
 },
 {
 "customer_group_id": 26,
 "qty": 1,
 "value": 5.35
 },
 {
 "customer_group_id": 27,
 "qty": 1,
 "value": 5.75
 }
 ],
 "custom_attributes": [
 {
 "attribute_code": "description",
 "value": "<p>Some description about this item comes here...</p>"
 },
 {
 "attribute_code": "image",
 "value": "/w/i/wijn1_back_1.jpg"
 },
 {
 "attribute_code": "small_image",
 "value": "/w/i/wijn1_back_1.jpg"
 },
 {
 "attribute_code": "thumbnail",
 "value": "/w/i/wijn1_back_1.jpg"
 },
 {
 "attribute_code": "options_container",
 "value": "container2"
 },
 {
 "attribute_code": "required_options",
 "value": "0"
 },
 {
 "attribute_code": "has_options",
 "value": "0"
 },
 {
 "attribute_code": "url_key",
 "value": "testproduct"
 },
 {
 "attribute_code": "swatch_image",
 "value": "/w/i/wijn1_back_1.jpg"
 },
 {
 "attribute_code": "tax_class_id",
 "value": "2"
 }
 ]
 }
 ],
 "search_criteria": {
 "filter_groups": [],
 "page_size": 100000,
 "current_page": 1
 },
 "total_count": 1
}

If you look at custom_attributes array you will only see the base image. How can I retrieve the other images configured in Magento2?

enter image description here

Alex Paliarush
13.8k5 gold badges53 silver badges57 bronze badges
asked Dec 29, 2015 at 20:03

1 Answer 1

6

It is possible to iterate over products and retrieve images using GET /V1/products/:sku/media, there does not seem to be a way without multiple requests.

answered Dec 30, 2015 at 10:41
2
  • thanks, must have looked over that operation. Can confirm I get both images now. One more api call isn't an issue! Commented Dec 31, 2015 at 12:20
  • @emp does the json data helps to add images via default api in magento 2.3 ? hope it has to be base64 encode Commented Aug 20, 2019 at 19:16

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.