I want to return discounts based on title given as an input from the user. That is for example if a user input “flat” then it should return all the discounts having “flat” in their titles (eg. FLAT50OFF,FLAT100). So is their any way I can implement this using REST or GraphQL admin APIs. I have seen a query like this requirement for products:
The Shopify GraphQL Admin API does not currently have a way to query for discounts by title. However, you may be able to accomplish this using the REST Admin API.
There is no specific code example that I can provide since this would be dependent on your particular implementation. However, you may be able to use the REST Admin API’s List Discounts endpoint to accomplish this: https://help.shopify.com/api/reference/discount#list-discounts You would need to make a GET request to this endpoint, passing in the title as a query parameter. The response would return a list of all discounts that match the title.
The request would typically look like this: GET /admin/api/2020-04/discounts.json?title=flat
Hey sorry about that I pulled that link from an old bookmark. I took a look at the REST API for the discount codes at https://shopify.dev/api/admin-rest/2022-07/resources/discountcode. It may take some parsing but the requests are there as long as you can retrieve the discount codes you can use the json to do the parsing with the responses. I could set it up for you if you’d like just give me a call and we could get started within the hour. Good Luck!