Migrating to the Collection endpoints

As of version 2020-01, the Collect resource no longer works with smart collections. If your app uses the REST Admin API and interacts with smart collections, then you need to migrate your app to use the Collection endpoints.

Summary of changes

Existing endpoints

  • GET /admin/collects.json: Now only returns collects associated with custom collections.
  • GET /admin/collects/count.json: Now only returns the count of collects associated with custom collections.
  • GET /admin/collects/#{collect_id}.json: If the collect_id is related to smart collection, then this endpoint returns a 404 error.

New endpoints

  • GET /admin/collection/id/products.json: Returns the products for the collection in the collection's sort order. Works for both smart collections and custom collections.
  • GET /admin/collection/id.json: Returns the collection associated with the ID. Works for both smart collections and custom collections.

To learn more about the New API see the Collection API documentation.

Migrating to the new endpoints

If your app makes request to the Collect endpoints interact with smart collections, then you need to update your app to instead use the Collection endpoints. Otherwise, you won't be able to access or update smart collections.

The Collect endpoints still work for custom collections, but you can also update your app to use the Collection endpoints for custom collections. Unlike the Collect endpoints, the Collection endpoints return the products in the collection's sort order.

Migrating to GraphQL Collection queries

Instead of using the REST Collection endpoint, you could migrate your app to the GraphQL API and use GraphQL queries to get the products of a collection. The following GraphQL query returns the first three products from a collection:

POST /admin/api/2020-01/graphql.json

query ProductsInCollection {
  collection(id: "gid:\/\/shopify\/Collection/1") {
    id
    products(first: 3) {
      edges{
        node{
          id
        }
      }
    }
  }
}

JSON response

{
  "data": {
    "collection": {
      "id": "gid://shopify/Collection/1",
      "products": {
        "edges": [
          {
            "node": {
              "id": "gid:\/\/shopify\/Product/1"
            }
          },
          {
            "node": {
              "id": "gid:\/\/shopify\/Product/2"
            }
          },
          {
            "node": {
              "id": "gid:\/\/shopify\/Product/3"
            }
          }
        ]
      }
    }
  }
}

Sign up for a Partner account to get started.

Sign up