--- title: discountNodesCount - GraphQL Admin description: >- The total number of discounts for the shop. Limited to a maximum of 10000 by default. api_version: 2026-01 api_name: admin type: query api_type: graphql source_url: html: 'https://shopify.dev/docs/api/admin-graphql/latest/queries/discountNodesCount' md: >- https://shopify.dev/docs/api/admin-graphql/latest/queries/discountNodesCount.md --- # discount​Nodes​Count query Requires `read_discounts` access scope. The total number of discounts for the shop. Limited to a maximum of 10000 by default. ## Arguments * limit * query * savedSearchId *** ## Possible returns * Count *** ## Examples * ### Retrieve the number of discounts used more than once #### Description Returns the number of discounts that were used more than once. #### Query ```graphql query discountNodesCount($query: String!) { discountNodesCount(query: $query) { count precision } } ``` #### Variables ```json { "query": "times_used:>1" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2026-01/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query discountNodesCount($query: String!) { discountNodesCount(query: $query) { count precision } }", "variables": { "query": "times_used:>1" } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query discountNodesCount($query: String!) { discountNodesCount(query: $query) { count precision } }`, { variables: { "query": "times_used:>1" }, }, ); const json = await response.json(); return json.data; } ``` #### 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 discountNodesCount($query: String!) { discountNodesCount(query: $query) { count precision } } QUERY variables = { "query": "times_used:>1" } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query discountNodesCount($query: String!) { discountNodesCount(query: $query) { count precision } }`, "variables": { "query": "times_used:>1" }, }, }); ``` #### Response ```json { "discountNodesCount": { "count": 3, "precision": "EXACT" } } ``` * ### Retrieve the number of discounts used within a range #### Description Returns the number of discounts that were used more than onceand less than four times. #### Query ```graphql query discountNodesCount($query: String!) { discountNodesCount(query: $query) { count precision } } ``` #### Variables ```json { "query": "times_used:>1 AND times_used:<4" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2026-01/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query discountNodesCount($query: String!) { discountNodesCount(query: $query) { count precision } }", "variables": { "query": "times_used:>1 AND times_used:<4" } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query discountNodesCount($query: String!) { discountNodesCount(query: $query) { count precision } }`, { variables: { "query": "times_used:>1 AND times_used:<4" }, }, ); const json = await response.json(); return json.data; } ``` #### 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 discountNodesCount($query: String!) { discountNodesCount(query: $query) { count precision } } QUERY variables = { "query": "times_used:>1 AND times_used:<4" } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query discountNodesCount($query: String!) { discountNodesCount(query: $query) { count precision } }`, "variables": { "query": "times_used:>1 AND times_used:<4" }, }, }); ``` #### Response ```json { "discountNodesCount": { "count": 2, "precision": "EXACT" } } ``` * ### Retrieve the number of unused discounts #### Description Returns the number of discounts that were never used. #### Query ```graphql query discountNodesCount($query: String!) { discountNodesCount(query: $query) { count precision } } ``` #### Variables ```json { "query": "times_used:0" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2026-01/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query discountNodesCount($query: String!) { discountNodesCount(query: $query) { count precision } }", "variables": { "query": "times_used:0" } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query discountNodesCount($query: String!) { discountNodesCount(query: $query) { count precision } }`, { variables: { "query": "times_used:0" }, }, ); const json = await response.json(); return json.data; } ``` #### 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 discountNodesCount($query: String!) { discountNodesCount(query: $query) { count precision } } QUERY variables = { "query": "times_used:0" } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query discountNodesCount($query: String!) { discountNodesCount(query: $query) { count precision } }`, "variables": { "query": "times_used:0" }, }, }); ``` #### Response ```json { "discountNodesCount": { "count": 37, "precision": "EXACT" } } ``` * ### Retrieve the total number of discounts #### Description Returns the total number of discounts. #### Query ```graphql query discountNodesCount { discountNodesCount { count precision } } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2026-01/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query discountNodesCount { discountNodesCount { count precision } }" }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query discountNodesCount { discountNodesCount { count precision } }`, ); const json = await response.json(); return json.data; } ``` #### 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 discountNodesCount { discountNodesCount { count precision } } QUERY response = client.query(query: query) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: `query discountNodesCount { discountNodesCount { count precision } }`, }); ``` #### Response ```json { "discountNodesCount": { "count": 41, "precision": "EXACT" } } ``` * ### Retrieves a count of all price rules #### Query ```graphql query DiscountCount { discountNodesCount { count precision } } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2026-01/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query DiscountCount { discountNodesCount { count precision } }" }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query DiscountCount { discountNodesCount { count precision } }`, ); const json = await response.json(); return json.data; } ``` #### 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 DiscountCount { discountNodesCount { count precision } } QUERY response = client.query(query: query) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: `query DiscountCount { discountNodesCount { count precision } }`, }); ``` #### Response ```json { "discountNodesCount": { "count": 41, "precision": "EXACT" } } ```