Advanced queries

WCEA API supports advanced querying on endpoints, as well as parameterization and partial fields.

However, this is not available on all endpoints.

  • On endpoints that support these advanced features, searches can be performed using a ?q= parameter on the GET endpoint.
  • Results can be parameterized using ?limit= and ?offset= parameters on the GET endpoint.
  • Partial data can be obtained using a ?fields= parameter on the GET endpoint.

All of the above options can be combined to make even more complex queries.

More Advanced Queries

Endpoints that are searchable, have a list of fields that can be searched against, in their respective documentation.

Within the q parameter, more fine-grained queries can be issued.

For example: ?q=(name[lk]:Bob)
In this example, [lk] means find results where name is LIKE Bob

Below is a list of all possible types of operators:

[eq] Equality operator, e.g: ?q=(name[eq]:Bob), equality operator is the default operator, so ?q=(name:Bob) will produce the same results.
[xeq] Inequality operator, e.g: ?q=(name[xeq]:Bob), analogous to name <> Bob
[gt] Greater-than operator, e.g: ?q=(number[gt]:10), analogous to number > 10
[gte] Greater-than-or-equal-to operator, e.g: ?q=(number[gte]:10), analogous to number >= 10
[lt] Less-than operator, e.g: ?q=(number[lt]:10), analogous to number < 10
[lte] Less-than-or-equal-to operator, e.g: ?q=(number[lte]:10), analogous to number <= 10
[lk] Like or Contains operator, e.g: ?q=(name[lk]:Bob), analogous to name LIKE %Bob%
[xlk] Not-Like or Not-Contains operator, e.g: ?q=(name[xlk]:Bob), analogous to name NOT LIKE %Bob%
[bw] Begins-With operator, e.g: ?q=(name[bw]:Bob), analogous to name LIKE Bob%
[xbw] Not-Begins-With operator, e.g: ?q=(name[xbw]:Bob), analogous to name NOT LIKE Bob%
[ew] Ends-With operator, e.g: ?q=(name[ew]:Bob), analogous to name LIKE %Bob
[xew] Not-Ends-With operator, e.g: ?q=(name[xew]:Bob), analogous to name NOT LIKE %Bob
[null] Null operator, e.g: ?q=(name[null]:true), analogous to name IS NULL.
The same operator can be used for checking NOT NULL values, e.g: ?q=(name[null]:false), analogous to name IS NOT NULL

Searching example

This query will return all users whose first and last names are Bob and Smith.

curl http://wceaapi.org/v1.1/user/?q=(name:Bob, surname:Smith)

Parameterization example

This query will return 20 users starting from the 10th user.

curl http://wceaapi.org/v1.1/user/?limit=20&offset=10

Partial Fields example

This query will return only the id and name fields for all users.

curl http://wceaapi.org/v1.1/user/?fields=(id, name)

Combined example

This query will return only the id and name of 20 users, whose first and last names are Bob and Smith, starting from the 10th user.

curl http://wceaapi.org/v1.1/user/?fields=(id, name)\
   &q=(name:Bob, surname:Smith)
   &limit=20&offset=10