This section will walk you though all the automatically configured request parameters and their use cases.
Some endpoints return information describing a single identified item but many return information on a list of items. Such list endpoints support query parameters to filter the list to only include some items. In most cases these filters take the form:
prop1.prop2...propn=value
Here, the props are the short property names that appear in the JSON format and the value is the value that the property is required to have. The value might be a number, a string, a date or a URI. In the case of the URI then you can often use the last segment of the URI on its own. If the same filter is used twice with different values then the API will return results for both values (i.e. it acts as a disjunction).
You can apply prefixes to the parameter in order to apply standard filters to your query:
| Prefix | Meaning |
|---|---|
| min- | Applies a strictly greater than filter. |
| mineq- | Applies a greater than or equal to filter. |
| max- | Applies a strictly less than filter. |
| maxeq- | Applies a less than or equal to filter. |
An example would be min-dob=12/03/1993 to query resources with date
of birth after 12/03/1993.
You are also allowed to set a range filter using parenthesis, i.e. (
and ) for setting an exclusive bound and (* and *) to sent an
inclusive bound. Make sure to separate values with .. . Be aware that
you can also mix and match the boundaries having one inclusive and one
exclusive. For example friends=(4..17*) which will match all resources
that have more than 4 friends and less than or equal to 17.
You can also filter based on whether the resource has any values for a given property path.
Set the value of the exists-{path} query parameter to true to include only items which have one or more values for that path,
or false to include only items which have no value.
You can also filter query results by specifying text fragments to search for in the data.
This feature uses Apache Lucene to perform a text search on certain fields, determined by
the API and the database configuration. Use the search query parameter to specify the
text fragments to search for. If multiple terms are given, each term can be separated by a space, ^ or %,
and only results whose text contains all of the terms will be returned.
You can also request a fuzzy search by supplying the fuzzy query parameter in addition to the search query parameter.
| Query | Meaning |
|---|---|
search={term} |
Return only results whose text contains the given term. |
search={term1%term2} |
Return only results whose text contains the given terms. |
search={term}&fuzzy |
Return only results whose text is similar to the given term. |
List endpoints also support view modification parameters. These are distinguished by starting with an underscore character. The commonly supported modifiers are:
| Query | Meaning |
|---|---|
_view={viewName} |
An alternative view of the items. Allows for switching between configured views on each endpoint. See API documentation for available views. |
_limit={x} |
Return only x items from the list, some endpoints may impose a default limit and/or a maximum to which the limit can be set. |
_offset={x} |
Return the list of items starting with the xth item, together with _limit this enables paging through a long set of results. |
_sort=prop.prop... |
Reorder the list of results in ascending order of the given property (or property chain). To sort in descending order use _sort=-prop. More than one sort can be included in which case they will be applied in order. |
If a limit or offset is applicable, whether explicit in the query or implicitly imposed by the API, then the metadata object will include a limit or offset field to show what limits were applied.
List endpoints support aggregate query parameters, _count and _groupBy.
You can use these to request a summarised view of the data that would normally be returned by that endpoint.
Each parameter takes similar values, in the form of dot-separated view paths (eg. friend.name), or the root path @id.
You can specify each parameter multiple times to perform any number of aggregations and groupings.
When aggregation parameters are supplied, parameters which alter the view of the results (eg. _projection, _view) will not be applied.
However, parameters which alter the result set, such as filters, can be applied in conjunction.
To count the total number of records in a list:
/path?_count=@id
JSON response:
items: [{
"count": 142
}]
To count the number of children of each record:
/path?_groupBy=@id&_count=incomingConnection
JSON response:
items: [{
"@id": "http://training.epimorphics.com/transport/london-underground/station/upney",
"incomingConnection.count": 2
}, {
...
}]
The soft record limit that is defined by the endpoint does not apply to aggregate requests, so they may
consume more resources than similar requests to the same endpoint. You can mitigate this by supplying a _limit
query parameter.
This feature currently supports the JSON and CSV result formats. Other formats are available but are experimental and should not be relied upon.
Each endpoint can configure a mapping of parameter aliases to the names of the parameters they represent.
You can set this by setting the aliases property on the endpoint spec.
This allows users to send the aliased parameters either in their original form, or using an alias.
This may be useful for shortening the names of commonly used filter parameters, for example.
| Parameter | Value | Usage | Endpoints |
|---|---|---|---|
_view |
String | Name of a view | All |
{path} |
Any | Exact value filter or encoded range | List |
exists-{path} |
Boolean | Value existence filter | List |
min-{path} |
Any | Minimum value filter | List |
mineq-{path} |
Any | Minimum or equal value filter | List |
max-{path} |
Any | Maximum value filter | List |
maxeq-{path} |
Any | Maximum or equal value filter | List |
_limit |
Integer | Result limit | List |
_offset |
Integer | Result offset | List |
_projection |
String | Projection on view | List |
_sort |
String | Sort on given paths | List |
search |
String | Text search fragment | List |
fuzzy |
None | Fuzzy text search flag | List |
{variable} |
Any | Bind template variable | List, Template |
_count |
String | Perform a count on values of the given path | List |
_groupBy |
String | Group by the values of the given path | List |
easting |
Decimal | Specify OS easting of geo point | List |
northing |
Decimal | Specify OS northing of geo point | List |
lat |
Decimal | Specify latitude of geo point | List |
long |
Decimal | Specify longitude of geo point | List |
dist |
Decimal | Filter by distance from specified geo point | List |
within |
JSON | Filter by bounds of the given polygon | List |
with-geometry |
Boolean | Include associated geometry in response | Item, List |