Filter

The "Filter" params is the simplest way and powerful way to filter items in your GET all responses. This are a lot of use: table column filters, ecommerce filters, general search.

Params

KeyValue
filterstring

Combine filters with a pseudocode syntax to retrieve the best filtered response.

Conditional Filters

To understand filters, we can start with the simplest use, filter item by ID. The code syntax to apply this filter it will be:

eq(id,12345)

We note that we have a Conditional operator eq (equal) as function that has the key of parameter ID as first param, and the value as second params.

We have a lot of available conditional operators:

MethodString KeyDescription
EQ"eq"Elements that are equal a specified value
CONTAINS"contains"Elements that contains a specified value (sensitive search)
ICONTAINS"icontains"Elements that contains a specified value (insensitive search)
STARTSWITH"startswith"Elements that start with a specified value (sensitive search)
ISTARTSWITH"istartswith"Elements that start with a specified value (insensitive search)
ENDSWITH"endswith"Elements that end with a specified value (sensitive search)
IENDSWITH"iendswith"Elements that end with a specified value (insensitive search)
LT"lt"Elements that are Lower than a specified value
LTE"lte"Elements that are Lower than equal a specified value
GT"ge"Elements that are greater than a specified value
GTE"get"Elements that are greater than equal a specified value
IN"in"Elements that are included in a specified value
ISNULL"isnull"Element that is null
NOT"not"Denied elements filters

Relational operator

You can create more complex filters composing the Relational operator AND/OR.

MethodString KeyDescription
AND"and"Concatenate filters by logical operator AND
OR"or"Concatenate filters by logical operator OR

The code syntax to apply this filter is will be:

and(eq(id,12345),contains(label,test))
Response samples for initial data
GET
/api/lib/{arke_id}/unit
{
    "content": {
        "count": 100,
        "items": [{...},{...},{...}],
    },
    "messages": []
}

Response samples when apply "Simple Filter"
GET
/api/lib/{arke_id}/unit
filter=eq(id=12345)
{
    "content": {
        // Total items that respect filter
        "count": 1,
        // Filtered items
        "items": [
            {
                "id": "12345"
                ...
            }
        ],
    },
    "messages": []
}

Response samples when apply "Complex Filter"
GET
/api/lib/{arke_id}/unit
filter=and(gte(date,01-01-2024),contains(label,test))
{
    "content": {
        // Total items that respect filter
        "count": 3,
        "items": [
            {
                "date": "2024-01-02T20:13:00.645Z",
                "label": "test"
                ...
            },
            {
                "date": "2024-01-12T20:13:00.645Z",
                "label": "Test item"
                ...
            },
            {
                "date": "2024-05-12T20:13:00.645Z",
                "label": "123 Test item"
                ...
            }
        ],
    },
    "messages": []
}