# Collection - storefront - OBJECT Version: 2024-10 ## Description A collection represents a grouping of products that a shop owner can create to organize them or make their shops easier to browse. ### Access Scopes `unauthenticated_read_product_listings` access scope. ## Fields * [description](/docs/api/storefront/2024-10/scalars/String): String! - Stripped description of the collection, single line with HTML tags removed. * [descriptionHtml](/docs/api/storefront/2024-10/scalars/HTML): HTML! - The description of the collection, complete with HTML formatting. * [handle](/docs/api/storefront/2024-10/scalars/String): String! - A human-friendly unique string for the collection automatically generated from its title. Limit of 255 characters. * [id](/docs/api/storefront/2024-10/scalars/ID): ID! - A globally-unique ID. * [image](/docs/api/storefront/2024-10/objects/Image): Image - Image associated with the collection. * [metafield](/docs/api/storefront/2024-10/objects/Metafield): Metafield - Returns a metafield found by namespace and key. * [metafields](/docs/api/storefront/2024-10/objects/Metafield): Metafield! - The metafields associated with the resource matching the supplied list of namespaces and keys. * [onlineStoreUrl](/docs/api/storefront/2024-10/scalars/URL): URL - The URL used for viewing the resource on the shop's Online Store. Returns `null` if the resource is currently not published to the Online Store sales channel. * [seo](/docs/api/storefront/2024-10/objects/SEO): SEO! - The collection's SEO information. * [title](/docs/api/storefront/2024-10/scalars/String): String! - The collection’s name. Limit of 255 characters. * [trackingParameters](/docs/api/storefront/2024-10/scalars/String): String - URL parameters to be added to a page URL to track the origin of on-site search traffic for [analytics reporting](https://help.shopify.com/manual/reports-and-analytics/shopify-reports/report-types/default-reports/behaviour-reports). Returns a result when accessed through the [search](https://shopify.dev/docs/api/storefront/current/queries/search) or [predictiveSearch](https://shopify.dev/docs/api/storefront/current/queries/predictiveSearch) queries, otherwise returns null. * [updatedAt](/docs/api/storefront/2024-10/scalars/DateTime): DateTime! - The date and time when the collection was last modified. ## Connections * [products](/docs/api/storefront/2024-10/connections/ProductConnection): ProductConnection! ## Related queries * [collection](/docs/api/storefront/2024-10/queries/collection) Fetch a specific `Collection` by one of its unique attributes. * [collectionByHandle](/docs/api/storefront/2024-10/queries/collectionByHandle) Find a collection by its handle. * [collections](/docs/api/storefront/2024-10/queries/collections) List of the shop’s collections. ## Related mutations ## Related Unions * [MenuItemResource](/docs/api/storefront/2024-10/unions/MenuItemResource) The list of possible resources a `MenuItem` can reference. * [MetafieldParentResource](/docs/api/storefront/2024-10/unions/MetafieldParentResource) A resource that the metafield belongs to. * [MetafieldReference](/docs/api/storefront/2024-10/unions/MetafieldReference) Returns the resource which is being referred to by a metafield. ## Examples ### Retrieve a single collection by ID Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Storefront-Access-Token: {storefront_access_token}' \\\n-d '{\n\"query\": \"query getCollectionById($id: ID!) { collection(id: $id) { title } }\"\n}'\n" Node example: "const client = new shopify.clients.Storefront({\n domain: 'your-development-store.myshopify.com',\n storefrontAccessToken,\n});\nconst data = await client.query({\n data: `query getCollectionById($id: ID!) {\n collection(id: $id) {\n title\n }\n }`,\n});\n" Ruby example: null Remix example: "const { storefront } = await unauthenticated.storefront(\n 'your-development-store.myshopify.com'\n);\n\nconst response = await storefront.graphql(\n `#graphql\n query getCollectionById($id: ID!) {\n collection(id: $id) {\n title\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query getCollectionById($id: ID!) {\n collection(id: $id) {\n title\n }\n}" #### Graphql Input null #### Graphql Response { "data": { "collection": { "title": "FrontPage" } } } ### Retrieve a single collection by handle Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Storefront-Access-Token: {storefront_access_token}' \\\n-d '{\n\"query\": \"query getCollectionByHandle($handle: String!) { collection(handle: $handle) { title } }\"\n}'\n" Node example: "const client = new shopify.clients.Storefront({\n domain: 'your-development-store.myshopify.com',\n storefrontAccessToken,\n});\nconst data = await client.query({\n data: `query getCollectionByHandle($handle: String!) {\n collection(handle: $handle) {\n title\n }\n }`,\n});\n" Ruby example: null Remix example: "const { storefront } = await unauthenticated.storefront(\n 'your-development-store.myshopify.com'\n);\n\nconst response = await storefront.graphql(\n `#graphql\n query getCollectionByHandle($handle: String!) {\n collection(handle: $handle) {\n title\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query getCollectionByHandle($handle: String!) {\n collection(handle: $handle) {\n title\n }\n}" #### Graphql Input null #### Graphql Response { "data": { "collection": { "title": "FrontPage" } } }