---
title: "codeDiscountNodes"
description: "查询店铺折扣码活动列表。"
doc_type: graphql
doc_category: adminGraphQL
doc_version: v20270301
source_url:
  html: 'https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/discounts-and-marketing/queries/code-discount-nodes'
  md: 'https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/discounts-and-marketing/queries/code-discount-nodes.md'
---
# codeDiscountNodes

查询店铺折扣码活动列表。

- **Required Scopes:** `read_discounts`
- **API Version:** v20270301
- **API Type:** Admin
- **API Protocol:** GraphQL
- **Operation Type:** Query

## Required Permissions

* `read_discounts`

接口访问需要令牌，具体如何获取令牌参考：[身份认证](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/graph-ql-admin-api/overview.md)。

## Arguments

* `after`

  [String](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/string.md)

  返回指定游标之后的元素。如果指定了该参数，也必须要指定 `first` 参数。

* `before`

  [String](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/string.md)

  返回指定游标之前的元素。如果指定了该参数，也必须要指定 `last` 参数。

* `first`

  [Int](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/int.md)

  返回列表中的前 n 个元素。

* `last`

  [Int](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/int.md)

  返回列表中的最后 n 个元素。

* `reverse`

  [Boolean](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/boolean.md)

  是否反转列表的顺序。
  
  ● true：反转
  
  ● false：不反转
  
  默认值：false

* `query`

  [String](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/string.md)

  指定一个或多个查询结果筛选器。支持的筛选字段及可选值如下：
  
  * `discount_type`：折扣优惠类型。可选值包括：
    - `bogo`：买 X 送 Y。
    - `fix_amount`：固定金额折扣。
    - `percentage`：百分比折扣。
    - `free_shipping`：免运费。
  * `status`：活动状态。可选值包括：
    - `active`：进行中。
    - `expired`：已过期。
    - `scheduled`：待开始。
  * `times_used`：折扣使用次数，可以是次数范围。  
    例如，`times_used:>0` 表示筛选使用次数大于 `0` 的活动。
  * `starts_at`：活动开始时间，可以是开始时间范围。  
    例如，`starts_at:>='2023-01-10T00:00:00Z'` 表示筛选在 `2023-01-10T00:00:00Z` 后开始的活动。
  * `title`：活动的名称，传入的关键词需要包裹在单引号 `''` 里面。  
    按名称筛选时采用模糊匹配。
  * `code`：折扣码，传入的关键词需要包裹在单引号 `''` 里面。  
    按折扣码筛选时采用精确匹配。
  * `sales_channel`：销售渠道。可选值包括：
    - `web`：在线销售渠道。
    - `pos`：POS 销售渠道。
    - `all`：所有销售渠道。
  * `source_key`：指定折扣活动创建来源。

* `sortKey`

  [CodeDiscountSortKeys](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/discounts-and-marketing/enums/code-discount-sort-keys.md)

  筛选出的折扣码活动的排序依据。例如，`STARTS_AT` 表示按活动开始时间排序，`TIMES_USED` 表示按折扣使用次数排序。

## Returns

* `edges`

  [[DiscountCodeNodeEdge!]](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/discounts-and-marketing/objects/discount-code-node-edge.md)

  edges列表

* `nodes`

  [[DiscountCodeNode]](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/discounts-and-marketing/objects/discount-code-node.md)

  帮助分页的信息

* `pageInfo`

  [PageInfo!](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common-objects/objects/page-info.md)

  DiscountCodeNodeEdge 中包含的节点列表

## Examples

### 通过标题查询折扣码活动

使用标题作为请求参数，查询折扣码活动。

**Request:**

```json
query MyQuery {
  codeDiscountNodes(
    first: 10
       query: "title:'demo'"
    sortKey: CREATED_AT
    reverse: true
  ) {
    pageInfo {
      endCursor
      hasNextPage
      hasPreviousPage
      startCursor
    }
    edges {
      cursor
      node {
        codeDiscount {
          ... on DiscountCodeBasic {
            summary
              shareableUrls {
            targetType
            title
            url
          }
            asyncUsageCount
            codeCount
            codes
            appliesTimesPerCustomer
            createdAt
            combinesWith {
              orderDiscounts
              productDiscounts
              shippingDiscounts
            }
            customerGets {
              items {
                ... on AllDiscountItems {
                  __typename
                  allItems
                }
                ... on DiscountCollections {
                  __typename
                  collections
                }
                ... on DiscountProducts {
                  __typename
                  productVariants
                  products
                }
              }
              value {
                ... on DiscountAmount {
                  appliesOnEachItem
                  amount {
                    amount
                    currencyCode
                  }
                }
                ... on DiscountPercentage {
                  __typename
                  percentage
                }
                ... on DiscountOnQuantity {
                  __typename
                  effect {
                    ... on DiscountAmount {
                      appliesOnEachItem
                      amount {
                        amount
                        currencyCode
                      }
                    }
                    ... on DiscountPercentage {
                      __typename
                      percentage
                    }
                  }
                  quantity {
                    quantity
                  }
                }
              }
            }
            customerSelection {
              ... on DiscountCustomerAll {
                allCustomers
              }
              ... on DiscountCustomerSegments {
                __typename
                segments
              }
              ... on DiscountCustomers {
                __typename
                customers
              }
            }
            discountClass
            endsAt
            minimumRequirement {
              ... on DiscountMinimumQuantity {
                __typename
                greaterThanOrEqualToQuantity
              }
              ... on DiscountMinimumSubtotal {
                __typename
                greaterThanOrEqualToSubtotal {
                  amount
                  currencyCode
                }
              }
            }
            shareableUrls {
              targetType
              title
              url
            }
            shortSummary
            startsAt
            status
            title
            updatedAt
            totalSales {
              amount
              currencyCode
            }
            usageLimit
          }
          ... on DiscountCodeBxgy {
            summary
            asyncUsageCount
            appliesTimesPerCustomer
            codeCount
            combinesWith {
              orderDiscounts
              productDiscounts
              shippingDiscounts
            }
            createdAt
            customerBuys {
              items {
                ... on AllDiscountItems {
                  __typename
                  allItems
                }
                ... on DiscountCollections {
                  __typename
                  collections
                }
                ... on DiscountProducts {
                  __typename
                  productVariants
                  products
                }
              }
              value {
                ... on DiscountQuantity {
                  __typename
                  quantity
                }
                ... on DiscountPurchaseAmount {
                  amount
                }
              }
            }
            customerGets {
              items {
                ... on AllDiscountItems {
                  __typename
                  allItems
                }
                ... on DiscountCollections {
                  __typename
                  collections
                }
                ... on DiscountProducts {
                  __typename
                  productVariants
                  products
                }
              }
              value {
                ... on DiscountAmount {
                  appliesOnEachItem
                  amount {
                    amount
                    currencyCode
                  }
                }
                ... on DiscountPercentage {
                  __typename
                  percentage
                }
                ... on DiscountOnQuantity {
                  __typename
                  effect {
                    ... on DiscountAmount {
                      appliesOnEachItem
                      amount {
                        amount
                        currencyCode
                      }
                    }
                    ... on DiscountPercentage {
                      __typename
                      percentage
                    }
                  }
                  quantity {
                    quantity
                  }
                }
              }
            }
            customerSelection {
              ... on DiscountCustomerAll {
                allCustomers
              }
              ... on DiscountCustomerSegments {
                __typename
                segments
              }
              ... on DiscountCustomers {
                __typename
                customers
              }
            }
            discountClass
            endsAt
            shareableUrls {
              targetType
              title
              url
            }
            startsAt
            status
            title
            totalSales {
              amount
              currencyCode
            }
            usageLimit
            usesPerOrderLimit
          }
          ... on DiscountCodeFreeShipping {
            summary
            asyncUsageCount
            appliesTimesPerCustomer
            codeCount
            combinesWith {
              orderDiscounts
              productDiscounts
              shippingDiscounts
            }
            createdAt
            customerSelection {
              ... on DiscountCustomerAll {
                allCustomers
              }
              ... on DiscountCustomerSegments {
                __typename
                segments
              }
              ... on DiscountCustomers {
                __typename
                customers
              }
            }
            destinationSelection {
              ... on DiscountCountries {
                includeRestOfWorld
                countries
              }
              ... on DiscountCountryAll {
                allCountries
              }
            }
            discountClass
            endsAt
            maximumShippingPrice {
              amount
              currencyCode
            }
            minimumRequirement {
              ... on DiscountMinimumQuantity {
                __typename
                greaterThanOrEqualToQuantity
              }
              ... on DiscountMinimumSubtotal {
                __typename
                greaterThanOrEqualToSubtotal {
                  amount
                  currencyCode
                }
              }
            }
            shareableUrls {
              targetType
              title
              url
            }
            shortSummary
            startsAt
            status
            title
            updatedAt
            usageLimit
            totalSales {
              amount
              currencyCode
            }
          }
        }
        id
      }
    }
    nodes {
      codeDiscount {
        ... on DiscountCodeBasic {
          summary
            shareableUrls {
            targetType
            title
            url
          }
          asyncUsageCount
          codeCount
          createdAt
          endsAt
          shortSummary
          startsAt
          status
          title
          codes
          updatedAt
          usageLimit
          appliesTimesPerCustomer
          combinesWith {
            orderDiscounts
            productDiscounts
            shippingDiscounts
          }
          customerGets {
            items {
              ... on AllDiscountItems {
                __typename
                allItems
              }
              ... on DiscountCollections {
                __typename
                collections
              }
              ... on DiscountProducts {
                __typename
                productVariants
                products
              }
            }
            value {
              ... on DiscountAmount {
                appliesOnEachItem
                amount {
                  amount
                  currencyCode
                }
              }
              ... on DiscountPercentage {
                __typename
                percentage
              }
              ... on DiscountOnQuantity {
                __typename
                effect {
                  ... on DiscountAmount {
                    appliesOnEachItem
                    amount {
                      amount
                      currencyCode
                    }
                  }
                  ... on DiscountPercentage {
                    __typename
                    percentage
                  }
                }
                quantity {
                  quantity
                }
              }
            }
          }
          customerSelection {
            ... on DiscountCustomerAll {
              allCustomers
            }
            ... on DiscountCustomerSegments {
              __typename
              segments
            }
            ... on DiscountCustomers {
              __typename
              customers
            }
          }
          discountClass
          minimumRequirement {
            ... on DiscountMinimumQuantity {
              __typename
              greaterThanOrEqualToQuantity
            }
            ... on DiscountMinimumSubtotal {
              __typename
              greaterThanOrEqualToSubtotal {
                amount
                currencyCode
              }
            }
          }
      
          totalSales {
            amount
            currencyCode
          }
        }
        ... on DiscountCodeBxgy {
          summary
          asyncUsageCount
          title
          appliesTimesPerCustomer
          combinesWith {
            orderDiscounts
            productDiscounts
            shippingDiscounts
          }
          codeCount
          createdAt
          customerBuys {
            items {
              ... on AllDiscountItems {
                __typename
                allItems
              }
              ... on DiscountCollections {
                __typename
                collections
              }
              ... on DiscountProducts {
                __typename
                productVariants
                products
              }
            }
            value {
              ... on DiscountQuantity {
                __typename
                quantity
              }
              ... on DiscountPurchaseAmount {
                amount
              }
            }
          }
          customerGets {
            items {
              ... on AllDiscountItems {
                __typename
                allItems
              }
              ... on DiscountCollections {
                __typename
                collections
              }
              ... on DiscountProducts {
                __typename
                productVariants
                products
              }
            }
            value {
              ... on DiscountAmount {
                appliesOnEachItem
                amount {
                  amount
                  currencyCode
                }
              }
              ... on DiscountPercentage {
                __typename
                percentage
              }
              ... on DiscountOnQuantity {
                __typename
                effect {
                  ... on DiscountAmount {
                    appliesOnEachItem
                    amount {
                      amount
                      currencyCode
                    }
                  }
                  ... on DiscountPercentage {
                    __typename
                    percentage
                  }
                }
                quantity {
                  quantity
                }
              }
            }
          }
          customerSelection {
            ... on DiscountCustomerAll {
              allCustomers
            }
            ... on DiscountCustomerSegments {
              __typename
              segments
            }
            ... on DiscountCustomers {
              __typename
              customers
            }
          }
          discountClass
          endsAt
          shareableUrls {
            targetType
            title
            url
          }
          startsAt
          status
          totalSales {
            amount
            currencyCode
          }
          usageLimit
          usesPerOrderLimit
        }
        ... on DiscountCodeFreeShipping {
          summary
          asyncUsageCount
          appliesTimesPerCustomer
          codeCount
          combinesWith {
            orderDiscounts
            productDiscounts
            shippingDiscounts
          }
          createdAt
          customerSelection {
            ... on DiscountCustomerAll {
              allCustomers
            }
            ... on DiscountCustomerSegments {
              __typename
              segments
            }
            ... on DiscountCustomers {
              __typename
              customers
            }
          }
          destinationSelection {
            ... on DiscountCountries {
              includeRestOfWorld
              countries
            }
            ... on DiscountCountryAll {
              allCountries
            }
          }
          discountClass
          endsAt
          maximumShippingPrice {
            amount
            currencyCode
          }
          minimumRequirement {
            ... on DiscountMinimumQuantity {
              __typename
              greaterThanOrEqualToQuantity
            }
            ... on DiscountMinimumSubtotal {
              __typename
              greaterThanOrEqualToSubtotal {
                amount
                currencyCode
              }
            }
          }
          shareableUrls {
            targetType
            title
            url
          }
          shortSummary
          startsAt
          status
          title
          totalSales {
            amount
            currencyCode
          }
          updatedAt
          usageLimit
        }
      }
      id
    }
  }
}

```

**Response:**

```json
{
  "data": {
    "data": {
      "codeDiscountNodes": {
        "pageInfo": {
          "hasNextPage": false,
          "hasPreviousPage": false,
          "startCursor": "2AAF90F13C58A5EF353DD555E8D6CCD6",
          "endCursor": "C61FAE0199C84A33DB551A7831B8E034"
        },
        "edges": [
          {
            "cursor": "-",
            "node": {
              "codeDiscount": {
                "endsAt": "2026-07-18T08:41:54.000Z",
                "shareableUrls": [
                  {
                    "targetType": "HOME",
                    "title": "demo",
                    "url": "https://ella01pre.myshoplinestg.com/activity/SL201SAS07614802632470692879"
                  }
                ],
                "updatedAt": "2026-07-16T12:41:55.000Z",
                "usageLimit": -1,
                "codeCount": 1,
                "codes": [
                  "995639"
                ],
                "customerGets": {
                  "items": {
                    "__typename": "DiscountProducts",
                    "productVariants": [],
                    "products": [
                      "16064393365790313753160195",
                      "16064393365833431198690195",
                      "16064393365879904087440195",
                      "16064393365916813963040195",
                      "16064393365975701991600195",
                      "16064393366023181513580195"
                    ]
                  },
                  "value": {
                    "amount": {
                      "amount": "22.32",
                      "currencyCode": "SGD"
                    },
                    "appliesOnEachItem": true
                  }
                },
                "customerSelection": {
                  "__typename": "DiscountCustomers",
                  "customers": [
                    "4208821948"
                  ]
                },
                "title": "demo",
                "appliesTimesPerCustomer": -1,
                "combinesWith": {
                  "orderDiscounts": false,
                  "productDiscounts": false,
                  "shippingDiscounts": false
                },
                "discountClass": "PRODUCT",
                "shortSummary": "22.32 off 6 products",
                "summary": "22.32 off 6 products • Minimum purchase of 100.56 • Applies to each eligible item per order",
                "asyncUsageCount": 0,
                "createdAt": "2026-07-16T12:41:54.000Z",
                "minimumRequirement": {
                  "__typename": "DiscountMinimumSubtotal",
                  "greaterThanOrEqualToSubtotal": {
                    "amount": "100.56",
                    "currencyCode": "SGD"
                  }
                },
                "startsAt": "2025-12-30T08:41:54.000Z",
                "status": "ACTIVE",
                "totalSales": {
                  "amount": "0",
                  "currencyCode": "SGD"
                }
              },
              "id": "gid://shopline/DiscountCodeNode/SL201SAS07614802632470692879"
            }
          }
        ],
        "nodes": [
          {
            "id": "gid://shopline/DiscountCodeNode/SL201SAS07614802632470692879",
            "codeDiscount": {
              "status": "ACTIVE",
              "totalSales": {
                "amount": "0",
                "currencyCode": "SGD"
              },
              "discountClass": "PRODUCT",
              "minimumRequirement": {
                "__typename": "DiscountMinimumSubtotal",
                "greaterThanOrEqualToSubtotal": {
                  "amount": "100.56",
                  "currencyCode": "SGD"
                }
              },
              "shareableUrls": [
                {
                  "targetType": "HOME",
                  "title": "demo",
                  "url": "https://ella01pre.myshoplinestg.com/activity/SL201SAS07614802632470692879"
                }
              ],
              "startsAt": "2025-12-30T08:41:54.000Z",
              "summary": "22.32 off 6 products • Minimum purchase of 100.56 • Applies to each eligible item per order",
              "updatedAt": "2026-07-16T12:41:55.000Z",
              "appliesTimesPerCustomer": -1,
              "asyncUsageCount": 0,
              "combinesWith": {
                "orderDiscounts": false,
                "productDiscounts": false,
                "shippingDiscounts": false
              },
              "createdAt": "2026-07-16T12:41:54.000Z",
              "customerSelection": {
                "__typename": "DiscountCustomers",
                "customers": [
                  "4208821948"
                ]
              },
              "endsAt": "2026-07-18T08:41:54.000Z",
              "title": "demo",
              "codeCount": 1,
              "customerGets": {
                "items": {
                  "__typename": "DiscountProducts",
                  "productVariants": [],
                  "products": [
                    "16064393365790313753160195",
                    "16064393365833431198690195",
                    "16064393365879904087440195",
                    "16064393365916813963040195",
                    "16064393365975701991600195",
                    "16064393366023181513580195"
                  ]
                },
                "value": {
                  "amount": {
                    "amount": "22.32",
                    "currencyCode": "SGD"
                  },
                  "appliesOnEachItem": true
                }
              },
              "usageLimit": -1,
              "codes": [
                "995639"
              ],
              "shortSummary": "22.32 off 6 products"
            }
          }
        ]
      }
    },
    "extensions": {
      "cost": {
        "actualQueryCost": 131,
        "requestedQueryCost": 131,
        "throttleStatus": {
          "currentlyAvailable": 49869,
          "maximumAvailable": 50000,
          "restoreRate": 50000
        }
      }
    }
  }
}
```

## Error Handling

关于更多通用错误码说明，参考：[状态码和错误码](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/graph-ql-admin-api/overview.md#status-and-error-codes)。

