Filtering and sorting
A filter tree with AND and OR groups, operators for each field type, sorting and pagination.
On this page
On this page
You narrow the record list from POST /database/:databaseId/items with a filter in the request body, and sort and paginate it with URL parameters.
Filter tree
A filter is a tree with two kinds of nodes. A group combines conditions with the and or or operator. A condition compares one field with a value. Groups can be nested.
{
"filter": {
"type": "group",
"operator": "and",
"items": [
{
"type": "property",
"id": "<status field id>",
"operator": {"type": "equals"},
"payload": {"type": "static", "value": "<New option id>"},
"isDisabled": false
},
{
"type": "property",
"id": "<amount field id>",
"operator": {"type": "greater-than"},
"payload": {"type": "static", "value": 1000},
"isDisabled": false
}
]
}
}| Condition field | Meaning |
|---|---|
type | Always property |
id | The field ID |
operator.type | An operator from the tables below |
payload.type | static for a fixed value or dynamic for a value calculated at request time |
payload.value | The value or the name of a dynamic value |
isDisabled | true disables the condition without removing it from the tree |
Operators
| Kind | Operators |
|---|---|
| Comparison | equals, not-equals, greater-than, greater-than-or-equal, less-than, less-than-or-equal |
| Text | contains, not-contains, starts-with, ends-with, regexp |
| Sets | in, not-in |
| Emptiness | empty, not-empty, start-or-end-date-empty, start-or-end-date-not-empty |
| Dates | between-dates, on-or-after-date, on-or-before-date, after-date, before-date, is-relative-to-today |
| Lists | array-includes, array-not-includes, array-contains, array-not-contains, array-empty, array-not-empty |
| Location | further-than, no-further-than |
| Checklist | checklist-completed, checklist-not-completed |
| Boolean | truthy, falsy |
Not every operator fits every field type. Text has no location operators, and a number has no text operators.
Compare a date with equals and not-equals and a value like {"date": "2026-03-20", "time": null}. Without a time only the day counts; with a time the hour counts too. The older date-equals and date-not-equals still work the same as equals and not-equals.
Dynamic values
With payload.type set to dynamic, the filter calculates the value at request time. That way the same filter works tomorrow and a month from now.
| Value | Meaning |
|---|---|
me | The person sending the request |
one-of-my-groups | Any of that person's groups |
today, yesterday, tomorrow, now | A day or moment relative to today |
this-month, last-month, next-month | Months |
this-year, last-year, next-year | Years |
start-of-this-week, end-of-this-week | Week boundaries |
start-of-this-month, end-of-this-month | Month boundaries |
start-of-this-year, end-of-this-year | Year boundaries |
{
"type": "property",
"id": "<people field id>",
"operator": {"type": "array-includes"},
"payload": {"type": "dynamic", "value": "me"},
"isDisabled": false
}Sorting
You sort with URL parameters: sort is the field ID, and sortDirection is 1 (ascending) or -1 (descending).
POST /database/:databaseId/items?sort=<field id>&sortDirection=-1Pagination
Use offset and limit. Fetch further pages until you get fewer records than limit.
async function fetchAllItems(databaseId, filter) {
const items = []
const limit = 100
for (let offset = 0; ; offset += limit) {
const response = await fetch(`https://api.hypris.com/v1/database/${databaseId}/items?limit=${limit}&offset=${offset}`, {
method: 'POST',
headers: {Authorization: AUTH_HEADER, 'Content-Type': 'application/json'},
body: JSON.stringify({filter}),
})
const {data} = await response.json()
items.push(...data.databaseItems)
if (data.databaseItems.length < limit) {
return items
}
}
}Search and selected fields
The search URL parameter searches records by text. The databasePropertyIds field in the body limits the response to selected fields, which speeds up large requests.