Filtering $in and $nin

Hi there, I’m trying to create a query with $In and $nin but don’t get results
I’m not sure if it is possible!

{
“query.data.categories.category.$in”: “[‘business_ki’]”,
“query.data.categories.category.$nin”: “[‘business_sale’]”
}

is there another way to do it ?, I’m doing it in Builder.io: Visual Development Platform

I really appreciate any help you can provide.
Carlos Vieira

Hello @Shintaro,

To perform a query using the $in and $nin operators with Builder’s Content API, you need to use a slightly different syntax. The correct approach involves properly wrapping the query operators within the JSON structure.

Here is an example:

{
  "query": {
    "data.categories.category": {
      "$in": ["business_ki"],
      "$nin": ["business_sale"]
    }
  }
}

For more detailed information, you can refer to the Builder.io documentation on querying.

If the above solution doesn’t resolve your issue, please share the Builder content or model link so that we can better understand the data structure and assist you further.

Thanks,

Hi, thanks for a quick reply.
my doubt is regarding how I can do it with URL encoded…
I have tried with postman as a post and got this:

can you help me further?
thanks

hi,

I want to use something like this:

https://cdn.builder.io/api/v3/content/marktplatz-offers?apiKey=test&query.data.categories.category.$in[]=business_sport&query.data.categories.category.$nin[]=business_sale

Hello @Shintaro,

Could you help us with your API key?

hi there
did you get my API key in a message?
can you help there?
thanks

Hi @Shintaro,

Yes, thanks for sharing that. I’m reviewing your setup and will provide an update shortly.

Thanks,

Hello @Shintaro,

Please clarify the condition you want. I don’t see any category with the value “business_sale”. Do you want to query all category that are in “business_ki” and not in “business_sale”?

I’m able to get API response when using just $in for “business_ki”
https://cdn.builder.io/api/v3/content/marktplatz-offers?apiKey=3166cadadb704aa9a67e8be0704e2661&query.data.categories.category.$in=[‘business_ki’]&limit=5&omit=id,name,data.blocks

sorry for the late reply,
thanks, I think I could manage it.
But I have another question
I will create a new topic
Thanks
Carlos Vieira