Overview
The MTB Backend API uses Strapi’s powerful query syntax to filter, sort, and select specific fields from your data. These capabilities allow you to retrieve precisely the data you need.Basic Filtering
Filter results using query parameters with thefilters object:
Filter Operators
Strapi provides a comprehensive set of operators for filtering:Equality Operators
| Operator | Description | Example |
|---|---|---|
$eq | Equal to | filters[status][$eq]=published |
$ne | Not equal to | filters[status][$ne]=draft |
Comparison Operators
| Operator | Description | Example |
|---|---|---|
$lt | Less than | filters[price][$lt]=100 |
$lte | Less than or equal to | filters[price][$lte]=100 |
$gt | Greater than | filters[views][$gt]=1000 |
$gte | Greater than or equal to | filters[views][$gte]=1000 |
String Operators
| Operator | Description | Example |
|---|---|---|
$contains | Contains substring (case-sensitive) | filters[title][$contains]=tutorial |
$notContains | Does not contain substring | filters[title][$notContains]=draft |
$startsWith | Starts with substring | filters[title][$startsWith]=How to |
$endsWith | Ends with substring | filters[title][$endsWith]=guide |
String operators are case-sensitive by default. Use
$containsi, $startsWithi, and $endsWithi for case-insensitive matching.Array Operators
| Operator | Description | Example |
|---|---|---|
$in | Value in array | filters[status][$in][0]=published&filters[status][$in][1]=featured |
$notIn | Value not in array | filters[status][$notIn][0]=draft&filters[status][$notIn][1]=archived |
Null Operators
| Operator | Description | Example |
|---|---|---|
$null | Is null | filters[publishedAt][$null]=true |
$notNull | Is not null | filters[publishedAt][$notNull]=true |
Logical Operators
Combine multiple conditions using logical operators:Filtering Relations
Filter by related entity fields:Sorting
Sort results using thesort parameter:
Sort Options
- Ascending:
sort=fieldNameorsort=fieldName:asc - Descending:
sort=fieldName:desc - Multiple fields: Apply sorts in order of priority
Sorting Related Fields
Sorting Related Fields
Field Selection
Select specific fields to reduce response size and improve performance:By default, the
id field is always included. Other fields must be explicitly specified when using field selection.Populating Relations
Include related entities in the response:Combining Parameters
Combine filtering, sorting, field selection, and pagination for powerful queries:Best Practices
URL encoding: When using filters in URLs, ensure special characters are properly encoded. Most HTTP clients handle this automatically.
