--- title: collections - Storefront API description: List of the shop’s collections. api_version: 2025-10 api_name: storefront type: query api_type: graphql source_url: html: https://shopify.dev/docs/api/storefront/latest/queries/collections md: https://shopify.dev/docs/api/storefront/latest/queries/collections.md --- # collections query List of the shop’s collections. ## CollectionConnection arguments [CollectionConnection!](https://shopify.dev/docs/api/storefront/latest/connections/CollectionConnection) * after [String](https://shopify.dev/docs/api/storefront/latest/scalars/String) Returns the elements that come after the specified cursor. * before [String](https://shopify.dev/docs/api/storefront/latest/scalars/String) Returns the elements that come before the specified cursor. * first [Int](https://shopify.dev/docs/api/storefront/latest/scalars/Int) Returns up to the first `n` elements from the list. * last [Int](https://shopify.dev/docs/api/storefront/latest/scalars/Int) Returns up to the last `n` elements from the list. * query [String](https://shopify.dev/docs/api/storefront/latest/scalars/String) Apply one or multiple filters to the query. Refer to the detailed [search syntax](https://shopify.dev/api/usage/search-syntax) for more information about using filters. * collection\_type * title * updated\_at * reverse [Boolean](https://shopify.dev/docs/api/storefront/latest/scalars/Boolean) Default:false Reverse the order of the underlying list. * sort​Key [Collection​Sort​Keys](https://shopify.dev/docs/api/storefront/latest/enums/CollectionSortKeys) Default:ID Sort the underlying list by the given key. *** ## Possible returns * edges [\[Collection​Edge!\]!](https://shopify.dev/docs/api/storefront/latest/objects/CollectionEdge) non-null A list of edges. * nodes [\[Collection!\]!](https://shopify.dev/docs/api/storefront/latest/objects/Collection) non-null A list of the nodes contained in CollectionEdge. * page​Info [Page​Info!](https://shopify.dev/docs/api/storefront/latest/objects/PageInfo) non-null Information to aid in pagination. * total​Count [Unsigned​Int64!](https://shopify.dev/docs/api/storefront/latest/scalars/UnsignedInt64) non-null The total count of Collections. *** ## Examples * ### Retrieve collections #### Description A collection represents a group of products that a store owner can create. The store owner can organize these product groups to make their stores easier to browse. For example, a merchant might create a collection for a specific type of product that they sell, such as footwear. Merchants can create collections by selecting products individually or by defining rules that automatically determine whether products are included. The following example shows how to query for collections and the products that belong to those collections. #### Query ```graphql query { collections(first: 2) { edges { node { id products(first: 5) { edges { node { id } } } } } } } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Storefront-Access-Token: {storefront_access_token}' \ -d '{ "query": "query { collections(first: 2) { edges { node { id products(first: 5) { edges { node { id } } } } } } }" }' ``` #### React Router ```javascript import { unauthenticated } from "../shopify.server"; export const loader = async () => { const { storefront } = await unauthenticated.storefront( 'your-development-store.myshopify.com' ); const response = await storefront.graphql( `#graphql query { collections(first: 2) { edges { node { id products(first: 5) { edges { node { id } } } } } } }`, ); const json = await response.json(); return json.data; } ``` #### Node.js ```javascript const client = new shopify.clients.Storefront({ domain: 'your-development-store.myshopify.com', storefrontAccessToken, }); const data = await client.query({ data: `query { collections(first: 2) { edges { node { id products(first: 5) { edges { node { id } } } } } } }`, }); ``` #### Response ```json { "collections": { "edges": [ { "node": { "id": "gid://shopify/Collection/547751128", "products": { "edges": [ { "node": { "id": "gid://shopify/Product/929898465" } }, { "node": { "id": "gid://shopify/Product/538825261" } } ] } } }, { "node": { "id": "gid://shopify/Collection/585546552", "products": { "edges": [] } } } ] } } ``` ## Retrieve collections [Open in GraphiQL](http://localhost:3457/graphiql?query=query%20%7B%0A%20%20collections\(first%3A%202\)%20%7B%0A%20%20%20%20edges%20%7B%0A%20%20%20%20%20%20node%20%7B%0A%20%20%20%20%20%20%20%20id%0A%20%20%20%20%20%20%20%20products\(first%3A%205\)%20%7B%0A%20%20%20%20%20%20%20%20%20%20edges%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20node%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20id%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D) ```javascript import { unauthenticated } from "../shopify.server"; export const loader = async () => { const { storefront } = await unauthenticated.storefront( 'your-development-store.myshopify.com' ); const response = await storefront.graphql( `#graphql query { collections(first: 2) { edges { node { id products(first: 5) { edges { node { id } } } } } } }`, ); const json = await response.json(); return json.data; } ``` ##### GQL ``` query { collections(first: 2) { edges { node { id products(first: 5) { edges { node { id } } } } } } } ``` ##### cURL ``` curl -X POST \ https://your-development-store.myshopify.com/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Storefront-Access-Token: {storefront_access_token}' \ -d '{ "query": "query { collections(first: 2) { edges { node { id products(first: 5) { edges { node { id } } } } } } }" }' ``` ##### React Router ``` import { unauthenticated } from "../shopify.server"; export const loader = async () => { const { storefront } = await unauthenticated.storefront( 'your-development-store.myshopify.com' ); const response = await storefront.graphql( `#graphql query { collections(first: 2) { edges { node { id products(first: 5) { edges { node { id } } } } } } }`, ); const json = await response.json(); return json.data; } ``` ##### Node.js ``` const client = new shopify.clients.Storefront({ domain: 'your-development-store.myshopify.com', storefrontAccessToken, }); const data = await client.query({ data: `query { collections(first: 2) { edges { node { id products(first: 5) { edges { node { id } } } } } } }`, }); ``` ## Response JSON ```json { "collections": { "edges": [ { "node": { "id": "gid://shopify/Collection/547751128", "products": { "edges": [ { "node": { "id": "gid://shopify/Product/929898465" } }, { "node": { "id": "gid://shopify/Product/538825261" } } ] } } }, { "node": { "id": "gid://shopify/Collection/585546552", "products": { "edges": [] } } } ] } } ```