Product response has a collection field?

virtualWorks
New Member
3 0 4

I know it's possible to retrieve custom-collections from its endpoint. I'm wandering if  it's possible to see the collections a product belongs to when making a Get request to the products endpoint? This way I don't have to make another external API call.

Apologies if this is obvious but I've looked on the Product JSON response object and can't find it.

Thanks.

 

0 Likes
Jayvin
Shopify Partner
221 34 57

Hi,

You are looking for the collect endpoint. https://shopify.dev/docs/admin-api/rest/reference/products/collect

GET /admin/api/2021-01/collects.json?product_id=XXXXXXXXX
0 Likes
virtualWorks
New Member
3 0 4

Apologies I don't think I was clear. I want to be able to make a get request for all products:

/admin/api/2021-01/products.json

... and within the response to see, for each product, which collections they belong to.

0 Likes
Jayvin
Shopify Partner
221 34 57

Hi,

With the rest api, you first need to get all the products and then loop through the products and get the collects for each of them. What you want does not exist in rest api.

Maybe you should have a look at the graphql product endpoints.

0 Likes