Filtering and Sorting

Several endpoints that return a list of objects have 2 query parameters available to filter the data. These parameters are 'Filters' and 'Sorts' which take a string as an input.

Syntax

  • Filters is a comma-delimited list of {Name}{Operator}{Value} where {Name} is the name of the property you are choosing to filter. {Operator} is one of the Operators in the below table. {Value} is the value to use for filtering. Both {Name} and {Value} can have multiple values making use of OR logic. For {Name} this can be done by enclosing them in brackets and using a pipe delimiter, eg. (LikeCount|CommentCount)>10 asks if LikeCount or CommentCount is >10. For {Value} you would only need to use a pipe delimiter, eg. [email protected]=new|hot will return posts with titles that contain the text "new" or "hot".
  • Sorts is a comma-delimited list of property names to sort by. In case of multiple properties the priority of the sorting depends on the order of the properties in the query. Adding a - before the name switches to sorting in a descending order. eg. -createdBy.
  • Page is the number of the page to return.
  • PageSize is the number of items returned per page.

Notes:

  • You can have spaces anywhere except within {Name} or {Operator} fields.
  • You can use backslashes to escape special characters and sequences:
    • commas: [email protected]=some\,title makes a match with "some,title"
    • pipes: [email protected]=some\|title makes a match with "some|title"
    • null values: [email protected]=\null will search for items with title equal to "null" (not a missing value, but "null"-string literally)

👍

Apply filtering at the server side

It is recommended to request only the specific data that is required by using filters available with the endpoints.

Examples for filtering and sorting

PropertiesParametersWhat it does
?sorts=LikeCount,CommentCount,-createdBySort by likes, then comments, then in descending order by date created
&filters=LikeCount>10, [email protected]=awesome title,Filter properties to only get ones with more than 10 likes and a title that contains the phrase "awesome title"

Operators

OperatorMeaning
==Equals
!=Not equals
>Greater than
<Less than
>=Greater than or equal to
<=Less than or equal to
@=Contains
_=Starts with
_-=Ends with
[email protected]=Does not Contains
!_=Does not Starts with
!_-=Does not Ends with
@=*Case-insensitive string Contains
_=*Case-insensitive string Starts with
_-=*Case-insensitive string Ends with
==*Case-insensitive string Equals
!=*Case-insensitive string Not equals
[email protected]=*Case-insensitive string does not Contains
!_=*Case-insensitive string does not Starts with