# Collection

        <p>A collection is a grouping of products that merchants can create 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 <strong>Footwear</strong>. Merchants can create collections by selecting products individually or by defining rules that automatically determine whether products are included.</p>
        <p>Shopify stores start with a single collection, called <strong>Frontpage</strong>. This is a collection of products that are shown on the front page of the online store.</p>
        <p>There are two different types of collection:</p>
        <ul>
        <li><strong>Custom collections</strong>, which contain products that are manually added to a collection by a merchant. For more information, see the <a href="/docs/admin-api/rest/reference/products/customcollection">CustomCollection</a> resource.</li>
        <li><strong>Smart collections</strong>, which contain products that are automatically added based on selection conditions that a merchant chooses. For more information, see the <a href="/docs/admin-api/rest/reference/products/smartcollection">SmartCollection</a> resource.</li>
        </ul>
        <p>The <a href="/docs/admin-api/rest/reference/products/collect">Collect</a> resource is used to connect a product to a <a href="/docs/admin-api/rest/reference/products/customcollection">custom collection</a>.</p>

## Resource Properties

### Collection

* body_html:           A description of the collection, complete with HTML markup. Many templates display this on their collection pages.

  * Type: x-string
  * Example: "<p>The best selling iPods ever</p>"
* handle: A unique, human-readable string for the collection automatically generated from its title. This is used in themes by the Liquid templating language to refer to the collection. (limit: 255 characters)
  * Type: x-string
  * Example: "ipods"
* image:           <p>Image associated with the collection. Valid values are:</p>
            <ul>
              <li><strong>attachment</strong>: An image attached to a collection returned as Base64-encoded binary data.</li>
              <li><strong>src</strong>: The source URL that specifies the location of the image.</li>
              <li><strong>alt</strong>: The alternative text that describes the collection image.</li>
              <li><strong>created_at</strong>: The time and date (<a href="https://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a> format) when the image was added to the collection.</li>
              <li><strong>width</strong>: The width of the image in pixels.</li>
              <li><strong>height</strong>: The height of the image in pixels.</li>
            </ul>

  * Type: x-string
  * Example: {"src"=>"http://static.shopify.com/collections/ipod.jpg?0", "alt"=>"iPods", "width"=>500, "height"=>488, "created_at"=>"2018-04-19T09:34:47-04:00"}
* id: The ID for the collection.
  * Type: x-string
  * Example: 841564295
* published_at:           <p>The time and date (<a href="https://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a> format) when the collection was made visible. Returns <code>null</code> for a hidden collection.</p>

  * Type: x-string
  * Example: "2008-02-01T19:00:00-05:00"
* published_scope:           Whether the collection is published to the Point of Sale channel. Valid values:
          <ul>
            <li><code>web</code>: The collection is published to the Online Store channel but not published to
              the Point of Sale channel.</li>
            <li><code>global</code>: The collection is published to both the Online Store channel and the Point
              of Sale channel.</li>
          </ul>

  * Type: x-string
  * Example: "global"
* sort_order:           <p>The order in which products in the collection appear. Valid values:</p>
          <ul>
            <li><strong>alpha-asc</strong>: Alphabetically, in ascending order (A - Z).</li>
            <li><strong>alpha-desc</strong>: Alphabetically, in descending order (Z - A).</li>
            <li><strong>best-selling</strong>: By best-selling products.</li>
            <li><strong>created</strong>: By date created, in ascending order (oldest - newest).</li>
            <li><strong>created-desc</strong>: By date created, in descending order (newest - oldest).</li>
            <li><strong>manual</strong>: In the order set manually by the shop owner.</li>
            <li><Strong>price-asc</strong>: By price, in ascending order (lowest - highest).</li>
            <li><strong>price-desc</strong>: By price, in descending order (highest - lowest).</li>
          </ul>

  * Type: x-string
  * Example: "manual"
* template_suffix: The suffix of the liquid template being used. For example, if the value is <code>custom</code>, then the collection is using the <code>collection.custom.liquid</code> template. If the value is <code>null</code>, then the collection is using the default <code>collection.liquid</code>.
  * Type: x-string
  * Example: "custom"
* title: The name of the collection. (limit: 255 characters)
  * Type: x-string
  * Example: "IPods"
* updated_at: The date and time (<a href="https://en.wikipedia.org/wiki/ISO_8601" target="_blank">ISO 8601</a> format) when the collection was last modified.
  * Type: x-string
  * Example: "2008-02-01T19:00:00-05:00"
## Retrieves a single collection

Retrieves a single collection

### Endpoint
/admin/api/#{api_version}/collections/{collection_id}.json (GET)

### Parameters
* api_version (required): 
* collection_id (required): 
* fields: Show only certain fields, specified by a comma-separated list of field names.

### Responses
#### 200
Retrieves a single collection

Examples:
##### Retrieve a specific collection by its ID
Request:
```
GET /admin/api/2020-01/collections/841564295.json
```

Response:
```
HTTP/1.1 200 OK
{"collection":{"id":841564295,"handle":"ipods","title":"IPods","updated_at":"2008-02-01T19:00:00-05:00","body_html":"<p>The best selling ipod ever</p>","published_at":"2008-02-01T19:00:00-05:00","sort_order":"manual","template_suffix":null,"products_count":1,"collection_type":"custom","published_scope":"web","admin_graphql_api_id":"gid://shopify/Collection/841564295","image":{"created_at":"2025-01-02T11:29:59-05:00","alt":"MP3 Player 8gb","width":123,"height":456,"src":"https://cdn.shopify.com/s/files/1/0005/4838/0009/collections/ipod_nano_8gb.jpg?v=1735835399"}}}
```
## Retrieve a list of products belonging to a collection

Retrieve a list of products belonging to a collection. <strong>Note:</strong> This endpoint implements pagination by using links that are provided in the response header. To learn more, refer to <a href='/api/usage/pagination-rest'>Make paginated requests to the REST Admin API</a>.. The products returned are sorted by the collection's sort order.

### Endpoint
/admin/api/#{api_version}/collections/{collection_id}/products.json (GET)

### Parameters
* api_version (required): 
* collection_id (required): 
* limit: The number of products to retrieve.

### Responses
#### 200
Retrieve a list of products belonging to a collection

Examples:
##### Retrieve a list of products belonging to a collection
Request:
```
GET /admin/api/2020-01/collections/841564295/products.json
```

Response:
```
HTTP/1.1 200 OK
{"products":[{"id":632910392,"title":"IPod Nano - 8GB","body_html":"<p>It's the small iPod with one very big idea: Video. Now the world's most popular music player, available in 4GB and 8GB models, lets you enjoy TV shows, movies, video podcasts, and more. The larger, brighter display means amazing picture quality. In six eye-catching colors, iPod nano is stunning all around. And with models starting at just $149, little speaks volumes.</p>","vendor":"Apple","product_type":"Cult Products","created_at":"2025-01-02T11:29:59-05:00","handle":"ipod-nano","updated_at":"2025-01-02T11:29:59-05:00","published_at":"2007-12-31T19:00:00-05:00","template_suffix":null,"published_scope":"web","tags":"Emotive, Flash Memory, MP3, Music","admin_graphql_api_id":"gid://shopify/Product/632910392","options":[{"id":594680422,"product_id":632910392,"name":"Color","position":1}],"images":[{"id":850703190,"alt":null,"position":1,"product_id":632910392,"created_at":"2025-01-02T11:29:59-05:00","updated_at":"2025-01-02T11:29:59-05:00","admin_graphql_api_id":"gid://shopify/ProductImage/850703190","width":123,"height":456,"src":"https://cdn.shopify.com/s/files/1/0005/4838/0009/products/ipod-nano.png?v=1735835399"},{"id":562641783,"alt":null,"position":2,"product_id":632910392,"created_at":"2025-01-02T11:29:59-05:00","updated_at":"2025-01-02T11:29:59-05:00","admin_graphql_api_id":"gid://shopify/ProductImage/562641783","width":123,"height":456,"src":"https://cdn.shopify.com/s/files/1/0005/4838/0009/products/ipod-nano-2.png?v=1735835399"},{"id":378407906,"alt":null,"position":3,"product_id":632910392,"created_at":"2025-01-02T11:29:59-05:00","updated_at":"2025-01-02T11:29:59-05:00","admin_graphql_api_id":"gid://shopify/ProductImage/378407906","width":123,"height":456,"src":"https://cdn.shopify.com/s/files/1/0005/4838/0009/products/ipod-nano.png?v=1735835399"}],"image":{"id":850703190,"alt":null,"position":1,"product_id":632910392,"created_at":"2025-01-02T11:29:59-05:00","updated_at":"2025-01-02T11:29:59-05:00","admin_graphql_api_id":"gid://shopify/ProductImage/850703190","width":123,"height":456,"src":"https://cdn.shopify.com/s/files/1/0005/4838/0009/products/ipod-nano.png?v=1735835399"}}]}
```