Filtering and sorting

A filter tree with AND and OR groups, operators for each field type, sorting and pagination.

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.

Status “New” and amount above PLN 1,000
{
  "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 fieldMeaning
typeAlways property
idThe field ID
operator.typeAn operator from the tables below
payload.typestatic for a fixed value or dynamic for a value calculated at request time
payload.valueThe value or the name of a dynamic value
isDisabledtrue disables the condition without removing it from the tree

Operators

KindOperators
Comparisonequals, not-equals, greater-than, greater-than-or-equal, less-than, less-than-or-equal
Textcontains, not-contains, starts-with, ends-with, regexp
Setsin, not-in
Emptinessempty, not-empty, start-or-end-date-empty, start-or-end-date-not-empty
Datesbetween-dates, on-or-after-date, on-or-before-date, after-date, before-date, is-relative-to-today
Listsarray-includes, array-not-includes, array-contains, array-not-contains, array-empty, array-not-empty
Locationfurther-than, no-further-than
Checklistchecklist-completed, checklist-not-completed
Booleantruthy, 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.

ValueMeaning
meThe person sending the request
one-of-my-groupsAny of that person's groups
today, yesterday, tomorrow, nowA day or moment relative to today
this-month, last-month, next-monthMonths
this-year, last-year, next-yearYears
start-of-this-week, end-of-this-weekWeek boundaries
start-of-this-month, end-of-this-monthMonth boundaries
start-of-this-year, end-of-this-yearYear boundaries
My tasks
{
  "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).

URL
POST /database/:databaseId/items?sort=<field id>&sortDirection=-1

Pagination

Use offset and limit. Fetch further pages until you get fewer records than limit.

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