How to use Filter, Sort, Page and PageSize
- sorts is a comma-delimited ordered list of property names to sort by. Adding a – before the name switches to sorting descendingly.
- filters is a comma-delimited list of {Name}{Operator}{Value} where
- {Name} is the name of a property for the given entity.
- You can also have multiple names (for OR logic) by enclosing them in brackets and using a pipe delimiter, eg.
(Phone|Mobile)==90919293 asks if Phone or Mobile equals 90919293
- {Operator} is one of the supported Operators (see below for list of Operators).
- {Value} is the case-insensitive value to use for filtering
- You can also have multiple values (for OR logic) by using a pipe delimiter, eg.
Notes@=new|old will return records with Notes that contain the text ‘new’ or ‘old’.
- Use
| (single pipe) when the OR is on values for the same field and operator (eg. tra==114961|114962). Use || (double pipe) when the OR spans different fields or operators.
- Use
|| between two complete filter expressions to OR them together. Multiple ||-separated expressions inside a single comma-delimited token are grouped and OR’d; separate comma-delimited tokens are AND’d as usual.
- Example:
TrackerObjectID==1||TrackerObjectID==2 returns records where id is 1 or 2. Here we may also use single pipe, as we’re filtering on 2 values of the same field.
- Example:
TrackerObjectID==1||TrackerID==56700 returns records where TrackerObjectID is 1 or TrackerID is 56700.
- page is the number of page to return
- pageSize is the number of items returned per page. Default page size is 200.
GET /Trip
// sort by StartTime descending, then by Distance
?sorts=-StartTime,Distance
// filter by HasExpense equals to true,
// and by Purpose that contains the phrase 'Devinco'
&filters=HasExpense==true, Purpose@=Devinco,
// get the first page
&page=1
// get 10 trip records per page
&pageSize=10
Supported Operators
Operator| Meaning
--------|--------
== | Equals
!= | Not equals
> | Greater than
< | Less than
>= | Greater than or equal to
<= | Less than or equal to
@= | Contains
_= | Starts with
!@= | Does not contain
!_= | Does not start with
Special filters
- IsNull: Use the IsNull filter if you need to find records where a certain property is null. Example query:
https://api.viatracks.com/api/Trip?Filters=IsNull==FuelTypeID&Page=1&Pagesize=50
- IsNotNull: Use the IsNotNull filter if you need to find records where a certain property is not null. Example query:
https://api.viatracks.com/api/Trip?Filters=IsNotNull==FuelTypeID&Page=1&Pagesize=50