https://serve.faux-api.com/tokenNo/cache_clearPagination with Advanced Filtering, Searching, and Sorting
Efficiently browse through extensive datasets by using pagination, searching, and sorting. Faux API provides a powerful set of query parameters and logical suffixes to help you retrieve exactly the data you need.
Understanding Keys and Values
In Faux API, your database fields are referred to as keys in the query string. The data you are filtering for is the value.
Example: If your API has a key (field) named status and you want to see only active records, you would use:
API Endpoint Structure
The API endpoint for implementing pagination with advanced filtering follows this format:
1. Core Query Parameters
These parameters control the overall behavior of your request, such as pagination, sorting, and global search.
| Parameter | Description | Example |
|---|---|---|
| page | Select which page of results to display. Starts at 1. | ?page=2 |
| limit | Number of records per page. | ?limit=50 |
| sortBy | Key(s) to sort by (comma separated). | ?sortBy=name,price |
| sortOrder | Sort direction (ASC/DESC, comma separated). | ?sortOrder=ASC,DESC |
| searchMode | How to combine filters (AND or OR). Default is OR. | ?searchMode=AND |
| globalSearch | Fuzzy search across all keys. | ?globalSearch=apple |
| fields | Select specific keys to return (comma separated). | ?fields=name,price |
| distinct | Returns unique results if set to true. | ?distinct=true |
| cache | Bypass Redis cache if set to false. | ?cache=false |
2. Advanced Filter Suffixes
Append these suffixes to any key name to perform specific logical operations beyond simple equality.
| Suffix | Logic | Example |
|---|---|---|
| _between | Values within a range | ?price_between=10,100 |
| _in | Value matches any in a list | ?status_in=active,pending |
| _like | Partial text match (contains) | ?name_like=alex |
| _isnull | Checks if value is NULL | ?deleted_at_isnull=true |
| _isnotnull | Checks if value is NOT NULL | ?email_isnotnull=true |
| _regex | Match a Regular Expression pattern | ?code_regex=^[A-Z]{2} |
| _ne | Value is not equal to (!=) | ?role_ne=admin |
| _gt | Value is greater than (>) | ?age_gt=21 |
| _gte | Value is greater than or equal to (>=) | ?stock_gte=0 |
| _lt | Value is less than (<) | ?price_lt=500 |
| _lte | Value is less than or equal to (<=) | ?weight_lte=10 |
3. Date & Time Presets
Use these keywords as values in any date-related key or suffix for dynamic time-based filtering.
| Keyword | Description | Example |
|---|---|---|
| today | Today's date (YYYY-MM-DD) | ?created_at=today |
| yesterday | Yesterday's date | ?updated_at_gt=yesterday |
| last_7_days | Exactly 7 days ago | ?created_at_gte=last_7_days |
Examples and Logic
🔥 Example Dataset: users
| id | name | role | status |
|---|---|---|---|
| 1 | Nora | admin | active |
| 2 | Omar | user | active |
| 3 | Ivy | admin | inactive |
| 4 | Liam | user | inactive |
| 5 | Sara | trainer | inactive |
Using searchMode: OR (Default)
Returns records that match any of the conditions.
✅ Results: Nora (matches name) and Omar/Liam (match role).
Using searchMode: AND
Returns records that match all conditions simultaneously.
✅ Results: Only Nora matches both role='admin' and status='active'.
Complex Combined Example
const params = new URLSearchParams({
"status_in": "active,pending",
"age_gte": "21",
"sortBy": "name",
"sortOrder": "ASC",
"page": "1",
"limit": "10"
});
fetch(`<API URL>?${params.toString()}`)
.then(res => res.json())
.then(data => console.log(data));
Conclusion
By combining pagination, sorting, and advanced filtering suffixes, you can build powerful data-driven applications. Faux API gives you the flexibility to simulate a complex backend with simple query strings.