Related pages

HTTP API

Queries

Some endpoints in the HTTP API support querying using a custom JSON query format. Such a query is composed of criteria that must all match with support for sorting the result. Example of a query that can be used with the Content API:

{
  "criteria": [
    {
      "type": "state",
      "criteria": "completed"
    },
    {
      "type": "completed"
      "criteria": {
        "from": "2018-02-17T04:19:03.636Z"
      }
    }
  ],
  "sortBy": [ "completed" ]
}

Queries can include the following properties:

Name Type Description
criteria Array[Criteria] Array of criteria, uses and between the criteria so all must match. Required
sortBy Array[String] Array of strings defining the properties to sort on and their order.

Criteria

Each criteria consists of two properties type and criteria, where criteria depends on the type.

Name Type Description
type String The type of the criteria.
criteria Dynamic Dynamic value depending on the type.

The exact types of criteria depend on the type of query used by the endpoint. The criteria property on the query object uses and matching meaning every criteria used must match.

or criteria

Multiple criteria can be combined with an or operator. For such a case only one of the sub-criterias must match. The criteria property should be an array of other criterias:

{
  "type": "or",
  "criteria": [ ... ]
}

and criteria

Multiple criteria can be combined with an and operator. This works the same as the main criteria, where all of them must match. The criteria property should be an array of other criterias:

{
  "type": "and",
  "criteria": [ ... ]
}

Sorting

The query format supports setting the sorting via the property sortBy that can contain an array of properties to sort on. The actual properties depend on the exact type of query. Properties can be sorted in descending order by appending :desc or :descending to them.

{
  "criteria": ...,
  "sortBy": [ "property", "otherProperty:desc" ]
}