Filtering Examples
This page provides a collection of real-world examples to demonstrate how to build complex queries using the API's advanced filtering capabilities. For a full list of operators, see the Advanced Filtering page.
E-Commerce Store
Goal: Find all products that are either on clearance or part of the "Summer Sale" collection, are currently in stock, and have a price lower than $50.
Collections:
products: with fieldsname,price(number),in_stock(boolean),tags(array).promotions: with a fieldname(e.g., "Summer Sale").- A relation field
campaignonproductspointing topromotions.
Query:
/products?where[in_stock]=true&where[price][lt]=50&where[or][0][tags]=clearance&where[or][1][campaign][name]=Summer SaleExplanation:
where[in_stock]=true: Filters for products that are in stock.where[price][lt]=50: Filters for products that cost less than $50.where[or][0][tags]=clearance: Begins anORgroup, finding products tagged with "clearance".where[or][1][campaign][name]=Summer Sale: The second part of theORgroup, finding products related to a promotion named "Summer Sale".
Blog or News Site
Goal: Find all "published" articles by a specific author that were published after the start of 2023 and contain either "API" or "Headless" in their title.
Collections:
articles: with fieldstitle,published_at(datetime),status(text).authors: with a fieldname.- A relation field
authoronarticlespointing toauthors.
Query:
/articles?where[status]=published&where[author][name]=Jane Doe&where[published_at][gte]=2023-01-01T00:00:00Z&where[or][0][title][like]=API&where[or][1][title][like]=HeadlessExplanation:
where[status]=published: Ensures only published articles are returned (core field filter).where[author][name]=Jane Doe: A relational filter to get articles by a specific author.where[published_at][gte]=...: Filters by a core datetime field.where[or][...]: AnORgroup to find articles with "API" or "Headless" in the title.
Real Estate Listings
Goal: Find 2-bedroom apartments in "New York" that allow pets and whose price is not exactly $450,000.
Collections:
listings: with fieldscity,bedrooms(number),allows_pets(boolean),price(number).
Query:
/listings?where[city]=New York&where[bedrooms]=2&where[allows_pets]=true&where[price][not]=450000Explanation:
- This query chains multiple
ANDconditions. where[price][not]=450000: Uses thenotoperator to exclude listings with a specific price.
Job Board
Goal: Find all remote "Software Engineer" or "Product Manager" jobs posted by the company "ElmapiCMS".
Collections:
jobs: with fieldstitle,location_type(text),company_name(text).
Query:
/jobs?where[location_type]=remote&where[company_name]=ElmapiCMS&where[title][in]=Software Engineer,Product ManagerExplanation:
where[company_name]=ElmapiCMS: A simple equality filter.where[title][in]=...: Uses theinoperator to find jobs where the title is one of several options.