Retrieving products from collections, including images and descriptions

Highlighted
New Member
20 0 0

Hello,

 

Is it possible to retrieve products from a collection and treat them as individual products, including pulling each product's images, description, price, etc? From the API documentation, it seems like there is a default image for a collection, but can't tell how to get the attributes for all products in a collection.

0 Likes
Shopify Staff
Shopify Staff
299 32 59

Hey there,

 

This is definitely possible with the Admin API and quite easy if you're using GraphQL. The following code snippet shows how you would go about getting individual product data from the first 10 items in your first 10 collections.

 

{
  collections(first: 10) {
    edges {
      node {
        products(first: 10) {
          edges {
            node {
              id
              title
              images(first: 5) {
                edges {
                  node {
                    id
                    originalSrc
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

For a list of all possible fields which you can query, check the Product object documentation.

0 Likes