Querying

To query a list of objects, you can use the filter parameter. The filter parameter is a uri encoded JSON object, where you can specify the fields you want to query.

Note on Consistency: Filtered queries are eventually consistent, meaning there might be a short delay before newly created or updated data appears in filtered results. If you need immediate access to newly created or updated data, use direct query parameters (like member-number or email for customers) which provide strong consistency guarantees.

The base filter is an object like this:

Copy
{ "operator": "CONTAINS", "fieldName": "NAME", "value": "John" }

So if you want to run this filter on a Customer, then you need to stringify the object and uri encode it. The result will be:

%7B%22operator%22%3A%22CONTAINS%22%2C%22fieldName%22%3A%22NAME%22%2C%22value%22%3A%22John%22%7D

And this needs to be appended to the request, which will look like this:

GET
https://api.loby.io/v1/customers?filter=%7B%22operator%22%3A%22CONTAINS%22%2C%22fieldName%22%3A%22NAME%22%2C%22value%22%3A%22John%22%7D

Operators

OperatorDescription
CONTAINSThe field contains the value
NOT_CONTAINSThe field does not contain the value
EQUALThe field is equal to the value
NOT_EQUALThe field is not equal to the value
STARTS_WITHThe field starts with the value
ENDS_WITHThe field ends with the value
INCLUDESThe field includes the value
NOT_INCLUDESThe field does not include the value
LESSERThe field is lesser than the value
LESSER_OR_EQUALThe field is lesser than or equal to the value
GREATERThe field is greater than the value
GREATER_OR_EQUALThe field is greater than or equal to the value
ANDUse this operator if you want to nest conditions and check that all sub conditions are true
ORUse this operator if you want to nest conditions and check that at least one is true

The fieldName is the field you want to query. The available fields are listed in the resource documentation for each resource.

Nested fields

Some fields refer to other resources. E.g. MEMBERSHIP on Customer refers to a Membership. In this case you can query the nested fields by using the . notation. E.g. if you want to query the VALID_TO field on the Membership from the customer you can do it like this:

Copy
{ "operator": "GREATER", "fieldName": "MEMBERSHIP.VALID_TO", "value": 1646071663704 }

Multiple conditions

If you want to query multiple conditions, you can use the AND or OR operator. E.g. if you want to query all customers that have a membership that is valid for more than 1 month, you can do it like this:

Copy
{ "operator": "AND", "conditions": [ { "operator": "GREATER", "fieldName": "MEMBERSHIP.VALID_TO", "value": 1646071663704 }, ... ] }

You can also nest each condition infinitely and also combine AND and OR operators.

Previous
Pagination
Next
Images