--- title: codeDiscountNodes - GraphQL Admin description: Returns a list of [code-based discounts](https://help.shopify.com/manual/discounts/discount-types#discount-codes). api_version: 2025-10 api_name: admin type: query api_type: graphql source_url: html: https://shopify.dev/docs/api/admin-graphql/latest/queries/codeDiscountNodes md: https://shopify.dev/docs/api/admin-graphql/latest/queries/codeDiscountNodes.md --- # code​Discount​Nodes query Requires Apps must have `read_discounts` access scope. Returns a list of [code-based discounts](https://help.shopify.com/manual/discounts/discount-types#discount-codes). ## DiscountCodeNodeConnection arguments [DiscountCodeNodeConnection!](https://shopify.dev/docs/api/admin-graphql/latest/connections/DiscountCodeNodeConnection) * after [String](https://shopify.dev/docs/api/admin-graphql/latest/scalars/String) The elements that come after the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * before [String](https://shopify.dev/docs/api/admin-graphql/latest/scalars/String) The elements that come before the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * first [Int](https://shopify.dev/docs/api/admin-graphql/latest/scalars/Int) The first `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * last [Int](https://shopify.dev/docs/api/admin-graphql/latest/scalars/Int) The last `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * query [String](https://shopify.dev/docs/api/admin-graphql/latest/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 * combines\_with string * created\_at time * discount\_type string * ends\_at time * id id * starts\_at time * status string * times\_used integer * title string * type string * updated\_at time - Filter by a case-insensitive search of multiple fields in a document. - Example: * `query=Bob Norman` * `query=title:green hoodie` Filter by the [discount classes](https://help.shopify.com/manual/discounts/combining-discounts/discount-combinations) that you can use in combination with [Shopify discount types](https://help.shopify.com/manual/discounts/discount-types). - Valid values: * `order_discounts` * `product_discounts` * `shipping_discounts` Example: * `combines_with:product_discounts` Filter by the date and time when the discount was created. - Example: * `created_at:>'2020-10-21T23:39:20Z'` * `created_at:'2020-10-21T23:39:20Z'` * `ends_at:=1234` * `id:<=1234` Filter by the date and time, in the shop's timezone, when the discount becomes active and is available for customer use. - Example: * `starts_at:>'2020-10-21T23:39:20Z'` * `starts_at:150` * `times_used:>=200` Filter by the discount name that displays to customers. - Example: * `title:Black Friday Sale` Filter by the [discount type](https://help.shopify.com/manual/discounts/discount-types). - Valid values: * `all` * `all_with_app` * `app` * `bxgy` * `fixed_amount` * `free_shipping` * `percentage` Example: * `type:percentage` Filter by the date and time when the discount was last updated. Example: * `updated_at:>'2020-10-21T23:39:20Z'` * `updated_at: { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query { codeDiscountNodes(first: 3) { nodes { id codeDiscount { ... on DiscountCodeBasic { title summary } ... on DiscountCodeBxgy { title codesCount { count } } } } } }`, ); 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 { codeDiscountNodes(first: 3) { nodes { id codeDiscount { ... on DiscountCodeBasic { title summary } ... on DiscountCodeBxgy { title codesCount { count } } } } } } QUERY response = client.query(query: query) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: `query { codeDiscountNodes(first: 3) { nodes { id codeDiscount { ... on DiscountCodeBasic { title summary } ... on DiscountCodeBxgy { title codesCount { count } } } } } }`, }); ``` #### Response ```json { "codeDiscountNodes": { "nodes": [ { "id": "gid://shopify/DiscountCodeNode/1057371281", "codeDiscount": { "title": "10% off one-time", "summary": "10% off one-time purchase products" } }, { "id": "gid://shopify/DiscountCodeNode/1057371282", "codeDiscount": { "title": "60% off one-time", "summary": "60% off one-time purchase products" } }, { "id": "gid://shopify/DiscountCodeNode/1057371283", "codeDiscount": { "title": "BXGY Raincoats", "codesCount": { "count": 1 } } } ] } } ``` * ### Retrieve code discounts by discount type #### Description This example shows how to retrieve code discounts that offer a fixed amount off products in an order. #### Query ```graphql query { codeDiscountNodes(first: 1, query: "value_type:fixed_amount") { nodes { id codeDiscount { ... on DiscountCodeBasic { title codes(first: 1) { nodes { code } } } } } } } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query { codeDiscountNodes(first: 1, query: \"value_type:fixed_amount\") { nodes { id codeDiscount { ... on DiscountCodeBasic { title codes(first: 1) { nodes { code } } } } } } }" }' ``` #### 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 { codeDiscountNodes(first: 1, query: "value_type:fixed_amount") { nodes { id codeDiscount { ... on DiscountCodeBasic { title codes(first: 1) { nodes { code } } } } } } }`, ); 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 { codeDiscountNodes(first: 1, query: "value_type:fixed_amount") { nodes { id codeDiscount { ... on DiscountCodeBasic { title codes(first: 1) { nodes { code } } } } } } } QUERY response = client.query(query: query) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: `query { codeDiscountNodes(first: 1, query: "value_type:fixed_amount") { nodes { id codeDiscount { ... on DiscountCodeBasic { title codes(first: 1) { nodes { code } } } } } } }`, }); ``` #### Response ```json { "codeDiscountNodes": { "nodes": [ { "id": "gid://shopify/DiscountCodeNode/1057371284", "codeDiscount": { "title": "Fixed amount off", "codes": { "nodes": [ { "code": "FIXEDOFF" } ] } } } ] } } ``` [Open in GraphiQL](http://localhost:3457/graphiql?query=query%20%7B%0A%20%20codeDiscountNodes\(first%3A%203\)%20%7B%0A%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20id%0A%20%20%20%20%20%20codeDiscount%20%7B%0A%20%20%20%20%20%20%20%20...%20on%20DiscountCodeBasic%20%7B%0A%20%20%20%20%20%20%20%20%20%20title%0A%20%20%20%20%20%20%20%20%20%20summary%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20...%20on%20DiscountCodeBxgy%20%7B%0A%20%20%20%20%20%20%20%20%20%20title%0A%20%20%20%20%20%20%20%20%20%20codesCount%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20count%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D) ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query { codeDiscountNodes(first: 3) { nodes { id codeDiscount { ... on DiscountCodeBasic { title summary } ... on DiscountCodeBxgy { title codesCount { count } } } } } }`, ); const json = await response.json(); return json.data; } ``` ##### GQL ``` query { codeDiscountNodes(first: 3) { nodes { id codeDiscount { ... on DiscountCodeBasic { title summary } ... on DiscountCodeBxgy { title codesCount { count } } } } } } ``` ##### cURL ``` curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query { codeDiscountNodes(first: 3) { nodes { id codeDiscount { ... on DiscountCodeBasic { title summary } ... on DiscountCodeBxgy { title codesCount { count } } } } } }" }' ``` ##### React Router ``` import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query { codeDiscountNodes(first: 3) { nodes { id codeDiscount { ... on DiscountCodeBasic { title summary } ... on DiscountCodeBxgy { title codesCount { count } } } } } }`, ); const json = await response.json(); return json.data; } ``` ##### Node.js ``` const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: `query { codeDiscountNodes(first: 3) { nodes { id codeDiscount { ... on DiscountCodeBasic { title summary } ... on DiscountCodeBxgy { title codesCount { count } } } } } }`, }); ``` ##### 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 { codeDiscountNodes(first: 3) { nodes { id codeDiscount { ... on DiscountCodeBasic { title summary } ... on DiscountCodeBxgy { title codesCount { count } } } } } } QUERY response = client.query(query: query) ``` ## Response JSON ```json { "codeDiscountNodes": { "nodes": [ { "id": "gid://shopify/DiscountCodeNode/1057371281", "codeDiscount": { "title": "10% off one-time", "summary": "10% off one-time purchase products" } }, { "id": "gid://shopify/DiscountCodeNode/1057371282", "codeDiscount": { "title": "60% off one-time", "summary": "60% off one-time purchase products" } }, { "id": "gid://shopify/DiscountCodeNode/1057371283", "codeDiscount": { "title": "BXGY Raincoats", "codesCount": { "count": 1 } } } ] } } ```