Overview
MocklyAPI provides powerful query capabilities for JSON array responses. You can filter, sort, and limit your mock data using URL query parameters. Operations are applied in this order:- Filtering - Narrow down results based on conditions
- Ordering - Sort the filtered results
- Limiting - Restrict the number of results returned
These operations only work when your mock data is a JSON array. Single objects or non-JSON responses will be returned as-is.
Query Parameters
| Parameter | Type | Description |
|---|---|---|
filters | string | URL-encoded filter conditions (supports nested paths) |
order_by | string | Field name to sort by (supports nested paths) |
order_direction | string | Sort direction: asc or desc (default: asc) |
limit | number | Maximum number of results to return (minimum: 0) |
URL Encoding
Why URL Encoding is Required
When you include multiple filter conditions, the& character needs to be encoded as %26 to prevent it from being interpreted as a query parameter separator.
Encoding Examples
❌ Incorrect (will only apply first filter):Common Character Encodings
| Character | URL Encoded | Usage |
|---|---|---|
= | %3D | Equality operator |
& | %26 | Filter condition separator |
[ | %5B | Operator start bracket |
] | %5D | Operator end bracket |
: | %3A | Used in nested paths |
Filtering
Apply conditions to narrow down your results using thefilters query parameter.
Supported Operators
| Operator | Description | Case Sensitive |
|---|---|---|
$eq | Equals | Yes |
$eqi | Equals (case-insensitive) | No |
$ne | Not equals | Yes |
$nei | Not equals (case-insensitive) | No |
| (implicit) | Direct equality (no operator) | Yes |
Filter Syntax
Filters use query string format and support:- Simple equality:
filters=status=active - Operators:
filters=status[$eq]=active - Multiple conditions (AND logic):
filters=status=active&role=admin - Nested fields:
filters=user.name=John
Filter Examples
Simple equality:Ordering
Sort your results by any field usingorder_by and order_direction parameters.
Syntax
Examples
Ascending order (default):Limiting
Restrict the number of results returned using thelimit parameter.
Syntax
Examples
Get first 5 results:Combining Operations
You can combine filtering, ordering, and limiting in a single request.Example Request
- Filter for records where
statusis “active” ANDroleis “user” - Sort by
createdAtin descending order - Return only the first 3 results
Example usage
Sample Dataset
This dataset demonstrates both simple fields and nested object structures:Query Examples & Results
Example 1: Filter active usersExample 2: Order by age descending
Example 3: Active users, newest first, limit 2
Example 4: Case-insensitive email search
Example 5: Exclude admins, youngest first
Example 6: Filter by nested country (USA)
Example 7: Order by first name ascending (Nested path)
Nested Path Support:
- Use dot notation to access nested properties at any depth (e.g.,
profile.address.city) - Ordering supports nested paths for both ascending and descending sorts
Limitations & Conditions
- JSON Arrays Only: Operations only apply to JSON array responses. Single objects are returned unchanged.
- AND Logic: Multiple filter conditions use AND logic (all must match). OR logic is not supported.
- Supported Operators: Only
$eq,$eqi,$ne,$neiare supported. Other operators will result an error. - Nested Path Support: Use dot notation for nested fields (e.g.,
user.profile.age) - URL Encoding Required: Always URL-encode the
filtersparameter to avoid parsing errors

