Base URLUse this to call your APIs
https://serve.faux-api.com/tokenNo/cache_clear

Pagination 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.

Structure: ?key=value

Example: If your API has a key (field) named status and you want to see only active records, you would use:

?status=active

API Endpoint Structure

The API endpoint for implementing pagination with advanced filtering follows this format:

API URL: {Base URL}/<apiName>?key1=value1&key2=value2&searchMode=AND&page=1&limit=10&sortBy=key1&sortOrder=DESC

1. Core Query Parameters

These parameters control the overall behavior of your request, such as pagination, sorting, and global search.

ParameterDescriptionExample
pageSelect which page of results to display. Starts at 1.?page=2
limitNumber of records per page.?limit=50
sortByKey(s) to sort by (comma separated).?sortBy=name,price
sortOrderSort direction (ASC/DESC, comma separated).?sortOrder=ASC,DESC
searchModeHow to combine filters (AND or OR). Default is OR.?searchMode=AND
globalSearchFuzzy search across all keys.?globalSearch=apple
fieldsSelect specific keys to return (comma separated).?fields=name,price
distinctReturns unique results if set to true.?distinct=true
cacheBypass 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.

SuffixLogicExample
_betweenValues within a range?price_between=10,100
_inValue matches any in a list?status_in=active,pending
_likePartial text match (contains)?name_like=alex
_isnullChecks if value is NULL?deleted_at_isnull=true
_isnotnullChecks if value is NOT NULL?email_isnotnull=true
_regexMatch a Regular Expression pattern?code_regex=^[A-Z]{2}
_neValue is not equal to (!=)?role_ne=admin
_gtValue is greater than (>)?age_gt=21
_gteValue is greater than or equal to (>=)?stock_gte=0
_ltValue is less than (<)?price_lt=500
_lteValue 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.

KeywordDescriptionExample
todayToday's date (YYYY-MM-DD)?created_at=today
yesterdayYesterday's date?updated_at_gt=yesterday
last_7_daysExactly 7 days ago?created_at_gte=last_7_days

Examples and Logic

🔥 Example Dataset: users

idnamerolestatus
1Noraadminactive
2Omaruseractive
3Ivyadmininactive
4Liamuserinactive
5Saratrainerinactive

Using searchMode: OR (Default)

Returns records that match any of the conditions.

API URL: {Base URL}/<apiName>?name=Nora&role=user&searchMode=OR

✅ Results: Nora (matches name) and Omar/Liam (match role).

Using searchMode: AND

Returns records that match all conditions simultaneously.

API URL: {Base URL}/<apiName>?role=admin&status=active&searchMode=AND

✅ 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.