Price Range filter using API

I need to implement a Price Range filter by using https://developer.squareup.com/explorer/square/catalog-api/search-catalog-objects this API. I am first trying in the API Explorer. I could find the “range_query” under the query parameter. Here I passed the attribute name ie. “price_money”, but I am getting this error
“errors”: [
{
“category”: “INVALID_REQUEST_ERROR”,
“code”: “INVALID_VALUE”,
“detail”: “Unknown attribute definition name “price_money”.”,
“field”: “range_query.attribute_name”
}
]
Can anybody please help me? Thanks in advance.

Hi @iglobeapps welcome to the forums!

price_money is the Money object, so you won’t be able to use it. Please try using amount instead and let me know if that doesn’t work.

Hello sjosey,

Thank you for your response.

I checked by passing amount and getting the same error.

{
  "errors": [
    {
      "category": "INVALID_REQUEST_ERROR",
      "code": "INVALID_VALUE",
      "detail": "Unknown attribute definition name \"amount\".",
      "field": "range_query.attribute_name"
    }
  ]
}
Let me show you what I have used in the request. So may be you can find any mistake if I made. 
https://prnt.sc/yon8j1
https://prnt.sc/yona18

Please correct if any mistakes. Thank you

Ah I checked in with the team, it’s possible amount hasn’t been added, so they’re going to add that. Try using price for the time being, my apologies.

Thanks for the quick response. Well, price works partially correct. But When I am using exact_query and pass Category_Id and then use price as range_query then The response isn’t filtering product from the category which I passed. Instead, it filters all products.

Hm, what do you mean by filters all products? Are you saying you’re supplying both queries in the same request? If so, realistically, the response should be empty. This is because the category_id only lives on the ITEM, while the price/amount only lives on the ITEM_VARIATION, thus if you supply both queries it works as an AND query, and none of them have any root objects in common.

yes, it is giving a blank response. Is there any solution to achieve this. I have explained in detail in my other topic. So you will get a basic idea how my listing page looks like and what you can help me to achieve this.