Unable to filter products by category (template_suffix) for Rest Admin API

I’ve been trying to filter category wise data. But it’s not working for this. Plz help me out

https://83f7b9-e3.myshopify.com/admin/api/2024-10/products.json?template_suffix=cabinets

I’m able to filter data with vendor/other keys. But not with, I’m getting all prods.

Even the tags also not working. Plz check & suggest on this

Filtering is only possible for a subset of fields. template_suffix and tags are both unsupported.
Products List REST API Reference.

You can’t filter by template_suffix in graphql, but you can filter by tags. As the REST API is deprecated, we recommend you move to graphql if possible.
Products Graphql API Reference

I hope this answers your question!

@jsharps I can’t use GraphQl here as the data that I need everything like vendor, template_suffix, title, image, page urls, tags, description etc are available only above REST api that I shared

Vendor is there in the same object. I’m able to filter products by vendor. But not by any other keys. My main concern is to filter data with tags/template_suffix as I’m currently using above api that I shared to display products. But I’m unable filter data after user selects any category (template_suffix) as the api itself is not accepting.

Plz check & suggest on this as it’s a very important for my business.

REST is being deprecated so you will need to move over to GraphQL and find a work around.

@Luke Will I get all data like vendor, IDs, template_suffix, title, description, image, page urls etc as I got in REST api shared above for all products to display if I use GraphQl and filter out based on user selection for any key to get specific products to meet above mentioned my request?

If so, please share the resources for the same to help me out

Thanks for the quick reply

Please explore the documentation on https://shopify.dev/ you will find everything you need on there

@Luke I tried already. But couldn’t fetch all above data. All I got is Collections/collection IDs/product IDs

I’m looking to get above all data that I requested to display vendor>template suffix to show them to user based on option selected by user.

Then display all the products to user based on the selected options for above filters which I’m unable to achieve it

Plz help me on the same with steps and resources

Highly appreciated, thanks for the quick reply

@jsharps @Luke I tried this api as u guys suggested

#1 But I’m not getting product_type, product_id & price data in api response.

#2 Also, I’m still unable to filter products by tags/title any other keys I’m getting in api response.

Plz check & help me out on this.

#1 . Get first 10 product’s type, variants id, price and sku:

query MyQuery {
  products(first: 10) {
    nodes {
      productType
      id
      variants(first: 10) {
        nodes {
          id
          price
          sku
        }
      }
    }
    pageInfo {
      hasNextPage
    }
  }
}

2#. Get the first 10 products of a specific product type:

query {
  products(first: 10, query: "product_type:snowboards") {
    edges {
      node {
        title
      }
    }
  }
}

Use the query argument to filter the products. Please follow the document:

@AMaL Still I’m not getting any category data. Product_Type is empty for all products.

I’m trying to fetch this same category data or template_suffix which I’m getting on REST Admin API. Plz check & help me out on this.

Please check the provided URL in the postman:

https://example.myshopify.com/admin/api/2024-10/graphql.json

query {
  products(first: 10, query: "product_type:snowboard") {
    edges {
      node {
        title
      }
    }
  }
}

@AMaL @jsharps I’m already getting Product Type data in api response. But as u can see in above screenshots.

The Product Type column is completely empty for all prods on my shopify dashboard. But data exists for Category

I’m trying to fetch category data which is available here in api. Plz check & help me out on this.

You won’t get Category returned unless you specify it in your request.

@Luke Tried this to get all category data available on my shopify dasboard

But still I’m not getting any categories in api response.

Plz check & suggest in getting category data in api response which is available on my dashboard.

As I said per my last response, you’re not passing category in the request so it won’t be returned. I’d suggest studying a bit more how GraphQL works to understand the basics of it.

Hi @Luke
I tried passing category in collections/products request.

But I’m getting doesn’t exist error. Tried asking chatgpt too, but no luck.

Plz check & suggest how to pass it in order to get categories data.

Please try using the category field as shown below:

{
  products(first: 10, query: "status:active") {
    edges {
      node {
        title
        status
        productType
        category {
          id
          name
        }
        collections(first: 10) {
          nodes {
            id
            title
          }
        }
      }
    }
  }
}

@AMaL Tried this too, but I’m still unable to fetch category data. Plz check.

Is it even possible to get category value? I checked it with the GraphQL app and it always returns null.

Could you please change the API version to latest one(2024-10)?