collections
query
An access token is required to call this API. Refer to Authorization for more information about how to obtain the token.
Query a list of the store's collections.
Arguments
Returns elements following the specified cursor. The
first argument must also be specified when using this argument.Returns elements preceding the specified cursor. The
last argument must also be specified when using this argument.Returns the first n elements in the list.
Returns the last n elements in the list.
Whether to reverse the order of the list.
● true: reverse
● false: do not reverse
Default value: false
Sorts the list by a specific sorting dimension.
Applies one or multiple filters to the query.
CAUTION
-
If keywords are used in the value, they must be escaped first.
-
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. Filtering by time range is supported. |
Search syntax reference
title:'T-shirt' AND updated_at:>'2020-10-21T23:39:20Z'
Specifies the collection IDs to query, with multiple IDs separated by commas.
Return
A list of edges.
A list of the nodes contained in CollectionEdge.
Information to aid in pagination.
the number of collections in the published scope
Status and error codes
For detailed information about common codes, see Status and error codes.
Example
Query collections based on the specified titles
Code
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
{
"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
}
}
}
Was this article helpful to you?