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-numberor
The base filter is an object like this:
{ "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
| Operator | Description |
|---|---|
CONTAINS | The field contains the value |
NOT_CONTAINS | The field does not contain the value |
EQUAL | The field is equal to the value |
NOT_EQUAL | The field is not equal to the value |
STARTS_WITH | The field starts with the value |
ENDS_WITH | The field ends with the value |
INCLUDES | The field includes the value |
NOT_INCLUDES | The field does not include the value |
LESSER | The field is lesser than the value |
LESSER_OR_EQUAL | The field is lesser than or equal to the value |
GREATER | The field is greater than the value |
GREATER_OR_EQUAL | The field is greater than or equal to the value |
AND | Use this operator if you want to nest conditions and check that all sub conditions are true |
OR | Use 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. GET /schema returns every filterable type and field for the museum, including custom customer fields — see Get Schema.
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:
{ "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:
{ "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.