Get product list with images/files -- v1 vs v2


#1

Hi All,

We are trying to develop the ecommerce app for that we started using moltin v1 few months back.
But we heard that v1 going to shotdown, So we started looking into moltin v2.
We observed that lot of changes you have done in v2 w.r.t dashboad, request, responce data and etc..
Some of the things also you are going to implement soon..

To Get Products:
	As per my observation b/w v1 vs v2 responce for products list is different.
	In v1 responce gives products list with images URL's directly --> here single api service call is enough
	But In v2 responce gives only proudcts list with out image URL's --> Here we need call more api services if we want product list with image URL's it will take too much time to calling more api services internally based these services we need to prepare own response which contain product list with image URL's

	Need to call below api services to get product list with images/files
	In v1 :
		curl -X GET https://api.molt.in/v1/products -H "Authorization: Bearer 32ef60c45d17f0744acc377dbc30271068e3d49c"

	In v2 :
		curl -X GET https://api.moltin.com/v2/products -H "Authorization: Bearer 253a32f4e4353852860ad794796ef096da10a4c4"
		curl -X GET https://api.moltin.com/v2/files/8116501b-1c76-47fa-a5a5-9a7a56592da2 -H "Authorization: Bearer 253a32f4e4353852860ad794796ef096da10a4c4"

Is it possible to show the image/files URL’s directly in the response of get products - v2 ?


Product main image and files
#2

This might answer your question Rendering the main_image from the ID


#3

If we fallow above suggested article

Constructed CURL statment:
curl -X GET https://api.moltin.com/v2/products?include=main_image -H “Authorization: Bearer 207887e12503e81b05963e6c2315268b6c5f2628”

Actaul:
In above curl response it showing all products related images in “main_images” array inside “included” this “included” object parallel to “data” object

Here For Finding which href link is related which product is takes huge time.

Expected:
main image href link and File href link should be come under each w.r.t product object itself like v1 image url
Each product itself href link should come related to “main_images” and “files”, So that we can easily retrieve href links for products


#4

The expected output from your request is the actual you have given. The API closely follows the JSONAPI Spec.

By putting the included data where it is, it avoids duplication of nested resources and is more efficient, giving you responses faster and with less data transferred over the wire.

It is fairly trivial, in most languages, to use the data objects relationships and match them with the corresponding resource in the included data.


#5

Actually we need product list with file/image link href inside the respective product.
Expected Products list like attached screen shot


#6

I understood that this is where you want the image to be referred to.

What I’m trying to get across is that this is not the way the API is designed to present the information, for the reasons I mentioned above.

You will need to cross reference the id of the product you’re looking at with the included resources in the response.


#7

You mean that we to call the 2 api services to get product list with image links
like below
1.curl -X GET https://api.moltin.com/v2/products -H "Authorization: Bearer 1075bfb1dc8e04788d532ba0034446ca12124ac2"
2. curl -X GET https://api.moltin.com/v2/products/9c6078a1-72f4-477b-8ad6-e221009b0097?include=main_image -H “Authorization: Bearer 1075bfb1dc8e04788d532ba0034446ca12124ac2”

So not possible with single api service call to get product list with each product href link directly?


#8

This is the call you should be making. There is no need for 2 calls unless you have > 100 products in the catalogue.


#9

Actually we need to show the list of products with respective images.
To achieve this one from above response it will take too much time to get the each product href link


#10

Why will this take too much time?


#11

We need to check one main_image id with all main_images array obj id’s if it is exist then only we need to pick href link assign to respective product.

Suppose we have 20000 products means “included”: “main_images” will have 20000 objects
Checking one product main_image id with “included”: “main_images” objects array.


#12

That iteration should not be expensive.

If the image is there as a relationship, it will be in your included data.

Also, you also won’t get 20,000 products in a call - you will get 100 and will have to page through your other products.


#13

How to get the main image href link and other files href links for all products?


#14

Use the following resource URL in your request:

https://api.moltin.com/v2/products?include=main_image,files