-
Notifications
You must be signed in to change notification settings - Fork 0
Query parameters
All query parameters that control yrest behaviour are prefixed with _.
Field filters use the field name directly (with optional operator suffixes).
Filter items by exact field value. Multiple filters are ANDed — all conditions must match.
GET /users?role=admin
GET /users?role=admin&active=trueRepeated params on the same field are treated as OR — any match passes:
GET /users?role=admin&role=user # role is admin OR userAppend an operator suffix to the field name to use advanced comparisons.
GET /products?price_gte=100Numeric comparison when both sides are numbers; lexicographic otherwise.
GET /products?price_lte=500
GET /products?price_gte=100&price_lte=500 # rangeGET /users?status_ne=inactiveGET /users?name_like=ali # matches Alice, Alicia, …GET /users?name_start=A # matches Alice, Ana, Avocado, …GET /users?email_regex=gmail
GET /users?email_regex=^aliceCase-insensitive by default. Invalid patterns return no results without crashing.
Searches the term across all scalar fields of each item (case-insensitive substring). Object and array values are skipped. An item passes if any field matches.
GET /users?_q=alice
GET /users?_q=example.com?_q can be combined with field filters and operators:
GET /users?_q=example&role=adminGET /users?_sort=name
GET /users?_sort=name&_order=desc
GET /products?_sort=price&_order=asc| Param | Values | Default |
|---|---|---|
_sort |
Any field name | (no sort) |
_order |
asc | desc
|
asc |
Numbers are compared numerically; strings are compared case-insensitively. Items missing the sort field are pushed to the end.
GET /users?_page=2&_limit=10Returns the requested slice. The X-Total-Count response header contains the
total number of items before pagination.
When the server runs with --pageable, the response is wrapped in an envelope:
{
"data": [ … ],
"pagination": {
"page": 2,
"limit": 10,
"totalItems": 47,
"totalPages": 5,
"isFirst": false,
"isLast": false,
"hasNext": true,
"hasPrev": true
}
}?_limit overrides the server default per request:
GET /users?_page=1&_limit=5Embeds a related parent object into each child item.
Requires a _rel declaration in the YAML file.
GET /posts?_expand=user
GET /posts/1?_expand=userMultiple expansions — comma-separated or repeated:
GET /posts?_expand=user,category
GET /posts?_expand=user&_expand=categoryThe parent object is embedded under the relation key (e.g. user).
The original foreign key field (e.g. userId) is preserved.
See Relations for how to declare _rel.
Embeds a related child collection into each parent item.
The inverse of ?_expand. Requires a _rel declaration.
GET /users?_embed=posts
GET /users/1?_embed=postsMultiple embeds:
GET /users?_embed=posts,comments
GET /users?_embed=posts&_embed=commentsEach parent item gets a key with an array of its matching children. Items with no children receive an empty array.
See Relations for how to declare _rel.
Returns only the specified fields. Applied last in the pipeline, so it
can project fields added by ?_expand or ?_embed.
GET /users?_fields=id,name
GET /users/1?_fields=id,name,email
GET /posts?_expand=user&_fields=id,title,user
GET /users?_embed=posts&_fields=id,postsFields not present in the item are silently ignored.
When multiple params are combined, yrest applies them in this order:
1. filterByQuery (field filters + operators)
2. fullTextSearch (?_q)
3. sortBy (?_sort, ?_order)
4. paginate (?_page, ?_limit)
5. expandItems (?_expand)
6. embedItems (?_embed)
7. projectFields (?_fields)
This means ?_fields can include keys added by ?_expand or ?_embed,
and ?_q runs on the original fields before expansion.