How to retrieve all products from a Smart Collection through Shopify API?

Update: API version 2020-04

See Codesmith's answer below. As of API version 2020-04, you can now use a smart collection id with the collections endpoint:

GET /admin/api/2020-04/collections/{collection_id}/products.json

See the Collection API docs for more info.


Pre-2020 solution

From the SmartCollection page in the Shopify API docs:

Smart Collections also use collects to connect a product to that smart collection.

And on the Collects page:

List only collects for a certain collection

GET /admin/collects.json?collection_id=841564295

HTTP/1.1 200 OK

{
  "collects": [
    {
      "collection_id": 841564295,
      "created_at": "2014-05-23T14:16:47-04:00",
      "featured": false,
      "id": 1071559648,
      "product_id": 921728736,
      "sort_value": "0000000001",
      "updated_at": "2014-05-23T14:16:47-04:00",
      "position": 1
    },
    ...
  ]
}

The collects contain the product_ids for each of the products in the collection with the specified collection_id.

Tags:

Shopify