Product response has a collection field?

virtualWorks
Shopify Partner
5 1 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.

 

Replies 3 (3)

Jayvin
Shopify Partner
284 42 89

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
banned
virtualWorks
Shopify Partner
5 1 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.

Jayvin
Shopify Partner
284 42 89

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.

banned