--- title: collectionsCount - GraphQL Admin description: Count of collections. Limited to a maximum of 10000 by default. api_version: 2024-10 api_name: admin type: query api_type: graphql source_url: html: 'https://shopify.dev/docs/api/admin-graphql/2024-10/queries/collectionsCount' md: >- https://shopify.dev/docs/api/admin-graphql/2024-10/queries/collectionsCount.txt --- # collections​Count query Requires `read_products` access scope. Count of collections. Limited to a maximum of 10000 by default. ## Arguments * query [String](https://shopify.dev/docs/api/admin-graphql/2024-10/scalars/String) A filter made up of terms, connectives, modifiers, and comparators. You can apply one or more filters to a query. Learn more about [Shopify API search syntax](https://shopify.dev/api/usage/search-syntax). * * default string * collection\_type string * handle string - Filter by a case-insensitive search of multiple fields in a document. - Example: * `query=Bob Norman` * `query=title:green hoodie` - Valid values: * `custom` * `smart` * * id id * product\_id id - Filter by `id` range. - Example: * `id:1234` * `id:>=1234` * `id:<=1234` Filter by collections containing a product by its ID. * * product\_publication\_status string * publishable\_status string * published\_at time - Filter by the publication status of the resource on a channel, such as the online store. The value is a composite of the [channel `app` ID](https://shopify.dev/api/admin-graphql/latest/objects/Channel#app-price) (`Channel.app.id`) and one of the valid values. - Valid values: * `approved` * `rejected` * `needs_action` * `awaiting_review` * `published` * `demoted` * `scheduled` * `provisionally_published` Example: * `product_publication_status:189769876-approved` Filter by the publishable status of the resource on a channel, such as the online store. The value is a composite of either the [channel `app` ID](https://shopify.dev/api/admin-graphql/latest/objects/Channel#app-price) (`Channel.app.id`) or [channel `name`](https://shopify.dev/docs/api/admin-graphql/latest/objects/Channel#field-name) and one of the valid values. - Valid values: * `online_store_channel` * `published` * `unpublished` * `visible` * `unavailable` * `hidden` * `intended` * `visible` Example: * `publishable_status:published` * `publishable_status:189769876-visible` * `publishable_status:pos-hidden` Filter by the date and time when the collection was published to the Online Store. * * published\_status string * title string - Filter by the published status of the resource on a channel, such as the online store. - Valid values: * `unset` * `pending` * `approved` * `not approved` Example: * `published_status:approved` * updated\_at time * saved​Search​Id [ID](https://shopify.dev/docs/api/admin-graphql/2024-10/scalars/ID) The ID of an existing saved search. The search’s query string is used as the query argument. Refer to the [`SavedSearch`](https://shopify.dev/api/admin-graphql/latest/objects/savedsearch) object. *** ## Possible returns * Count [Count](https://shopify.dev/docs/api/admin-graphql/2024-10/objects/Count) Details for count of elements. *** ## Examples * ### Retrieves a count of custom collections #### Query ```graphql query CollectionsCount { collectionsCount(query: "collection_type:custom") { count } } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query CollectionsCount { collectionsCount(query: \"collection_type:custom\") { count } }" }' ``` #### Remix ```javascript const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query CollectionsCount { collectionsCount(query: "collection_type:custom") { count } }`, ); const data = await response.json(); ``` #### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query CollectionsCount { collectionsCount(query: "collection_type:custom") { count } } QUERY response = client.query(query: query) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: `query CollectionsCount { collectionsCount(query: "collection_type:custom") { count } }`, }); ``` #### Response ```json { "collectionsCount": { "count": 8 } } ``` * ### Retrieves a count of smart collections #### Query ```graphql query CollectionsCount { collectionsCount(query: "collection_type:smart") { count } } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query CollectionsCount { collectionsCount(query: \"collection_type:smart\") { count } }" }' ``` #### Remix ```javascript const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query CollectionsCount { collectionsCount(query: "collection_type:smart") { count } }`, ); const data = await response.json(); ``` #### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query CollectionsCount { collectionsCount(query: "collection_type:smart") { count } } QUERY response = client.query(query: query) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: `query CollectionsCount { collectionsCount(query: "collection_type:smart") { count } }`, }); ``` #### Response ```json { "collectionsCount": { "count": 10 } } ``` [Open in GraphiQL](http://localhost:3457/graphiql?query=query%20CollectionsCount%20%7B%0A%20%20collectionsCount\(query%3A%20%22collection_type%3Acustom%22\)%20%7B%0A%20%20%20%20count%0A%20%20%7D%0A%7D) ```javascript const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query CollectionsCount { collectionsCount(query: "collection_type:custom") { count } }`, ); const data = await response.json(); ``` ## Response JSON ```json { "collectionsCount": { "count": 8 } } ```