---
title: "collections"
description: "Query a list of the store's collections."
doc_type: graphql
doc_category: storefront
doc_version: v20270301
source_url:
  html: 'https://developer.shopline.com/docs/storefront-api/products/queries/collections'
  md: 'https://developer.shopline.com/docs/storefront-api/products/queries/collections.md'
---
# collections

Query a list of the store's collections.

- **API Version:** v20270301
- **API Type:** Storefront
- **API Protocol:** GraphQL
- **Operation Type:** Query

## Arguments

* `after`

  [String](https://developer.shopline.com/docs/storefront-api/common/scalars/string.md)

  Returns elements following the specified cursor. The `first` argument must also be specified when using this argument.

* `before`

  [String](https://developer.shopline.com/docs/storefront-api/common/scalars/string.md)

  Returns elements preceding the specified cursor. The `last` argument must also be specified when using this argument.

* `first`

  [Int](https://developer.shopline.com/docs/storefront-api/common/scalars/int.md)

  Returns the first n elements in the list. 

* `last`

  [Int](https://developer.shopline.com/docs/storefront-api/common/scalars/int.md)

  Returns the last n elements in the list. 

* `reverse`

  [Boolean](https://developer.shopline.com/docs/storefront-api/common/scalars/boolean.md)

  Whether to reverse the order of the list. 
  
  ● true: reverse
  
  ● false: do not reverse
  
  Default value: false

* `sortkey`

  [CollectionSortKeys](https://developer.shopline.com/docs/storefront-api/products/enums/collection-sort-keys.md)

  Sorts the list by a specific sorting dimension.

* `query`

  [String](https://developer.shopline.com/docs/storefront-api/common/scalars/string.md)

  Applies one or multiple filters to the query. 
  
  :::warning{title="CAUTION"}
  1. If keywords are used in the value, they must be escaped first.
  
  2. A maximum of 5 filters are supported per query.
  :::
  
  | Filter field | Description |
  | --- | --- |
  | collection_type | Filters by collection type. Valid values are `manual` (manual collection) and `smart` (smart collection). If no type is specified, all types of collections are returned. |
  | title | Filters by collection title. Only one title can be specified in the `title` field. |
  | updated_at | Filters by collection update time. Format: [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html). Filtering by time range is supported. |
  
  #### Search syntax reference
  
  ```js
  title:'T-shirt' AND updated_at:>'2020-10-21T23:39:20Z'
  ```
  

* `ids`

  [[ID]](https://developer.shopline.com/docs/storefront-api/common/scalars/id.md)

  Specifies the collection IDs to query, with multiple IDs separated by commas.

## Returns

* `edges`

  [[CollectionEdge!]](https://developer.shopline.com/docs/storefront-api/products/objects/collection-edge.md)

  A list of edges.

* `nodes`

  [[Collection]](https://developer.shopline.com/docs/storefront-api/products/objects/collection.md)

   A list of the nodes contained in CollectionEdge.

* `pageInfo`

  [PageInfo!](https://developer.shopline.com/docs/storefront-api/online-store/objects/page-info.md)

  Information to aid in pagination.

* `totalCount`

  [Int](https://developer.shopline.com/docs/storefront-api/common/scalars/int.md)

  the number of collections in the published scope

## Examples

### Query collections based on the specified titles

Query collections based on the specified titles.

**Request:**

```json
query collections @inContext(saleChannel: "web",country:CN,language:EN){
  collections(first: 2, query: "title:\"collection\" OR title:\"Custom\"" ) {
    edges {
      node {
        id
        title
        products(first: 2) {
          edges {
            node {
              id
              title
            }
          }
        }
      }
    }
  }
}
```

**Response:**

```json
{
  "data": {
    "data": {
      "collections": {
        "edges": [
          {
            "node": {
              "id": "gid://shopline/Collection/12261186277836500577262340",
              "products": {
                "edges": []
              },
              "title": "Third Custom Collection"
            }
          },
          {
            "node": {
              "id": "gid://shopline/Collection/12273187462690727542132340",
              "products": {
                "edges": [
                  {
                    "node": {
                      "id": "gid://shopline/Product/16073187380346473690812340",
                      "title": "A product title"
                    }
                  }
                ]
              },
              "title": "Third Custom Collection"
            }
          }
        ]
      }
    },
    "extensions": {
      "cost": {
        "requestedQueryCost": 31,
        "throttleStatus": {
          "currentlyAvailable": 4969,
          "maximumAvailable": 5000,
          "restoreRate": 5000
        },
        "actualQueryCost": 31
      }
    }
  }
}
```

## Error Handling

For detailed information about common codes, see [Status and error codes](https://developer.shopline.com/docs/apps/api-instructions-for-use/storefront-api/overview.md#status-and-error-codes).

