When we talk about API features, we are referring to the capabilities of the API rather than the resources themselves. This includes the ability to include, filter, sort, and page through data.
meta
field of the response, under the features
key.
Let’s consider the following example as we step through the features:
meta.features
object provides you with the possible query parameters you can use for the endpoint.
The meta.features.params
key indicates that these are query parameters.
For each param, the available feature is the key and within each one, the options
key provides you with the possible field names that you can use.
We’ll go through each param now.
serial
, created_at
or modified_at
fields.
To do so, you can add the sort
query parameter to the request:
https://api.ctrl-hub.com/v3/orgs/{orgId}/assets/equipment?sort=serial
If you would like to reverse the order, you can add a -
to the field name:
https://api.ctrl-hub.com/v3/orgs/{orgId}/assets/equipment?sort=-serial
?sort=serial,created_at
and for the API to return a response, the API will only sort by the first field, so the request is the equivalent of ?sort=serial
.We may change this behaviour in the future, so it is recommended to only specify one sort field for now.filter
feature is available for the endpoint.
You can therefore change the request to filter the equipment items by serial number:
https://api.ctrl-hub.com/v3/orgs/{orgId}/assets/equipment?filter[serial]=ABC123
This performs an exact match on the serial number, so you will only get the equipment item with the serial number ABC123
, albeit in an array within the document data
. That is because the serial is unique. If we were filtering on a non unique field, such as status
, you would get an array of all the resources that match the filter.
https://api.ctrl-hub.com/v3/orgs/{orgId}/assets/equipment?filter[serial]=ABC123&filter[status]=active
When chaining filters, the filters are treated as an AND
operator. Therfore, this will return resources where BOTH the serial number is ABC123
and the status is active
.
OR
), we will add them in the future and update the changelog and this documentation. The implementation will be made in a backwards compatible way.field.since
and field.until
. This allows you to filter resources based on more advanced use cases.
For example, to filter equipment items created since a certain date:
https://api.ctrl-hub.com/v3/orgs/{orgId}/assets/equipment?filter[created_at.since]=2025-01-01T00:00:00Z
This will return all equipment items created since the 1st of January 2025 until now.
You could also filter on resources created until a certain date:
https://api.ctrl-hub.com/v3/orgs/{orgId}/assets/equipment?filter[created_at.until]=2025-01-31T23:59:59Z
This will return all equipment items created up to the 31st of January 2025 since the beginning of time.
You can also filter on a range of dates (windows):
https://api.ctrl-hub.com/v3/orgs/{orgId}/assets/equipment?filter[created_at.since]=2025-01-01T00:00:00Z&filter[created_at.until]=2025-01-31T23:59:59Z
This will return all equipment items created between the 1st and 31st of January 2025.
field.box.bottom_left
and field.box.top_right
. This allows you to filter resources based on their location.
When using geospatial filters, you need to include both the bottom left and top right corners of the box you want to filter on. This is because the filter is a bounding box, and the API will return all resources that are within that box.
For example, to filter for properties within a certain area:
https://api.ctrl-hub.com/v3/governance/properties?filter[location.box.bottom_left]=51.5074,-0.1278&filter[location.box.top_right]=51.5084,-0.1288
bb2e225f-02f0-489a-9494-51d2c3efae04
and is of the equipment model 9b197c72-2b7d-45b6-8a1a-3fa2ebc78fca
:
include
query parameter to the request:
https://api.ctrl-hub.com/v3/orgs/{orgId}/assets/equipment/eea6e732-82be-4194-b722-15408710c4a2?include=vehicle
Which would return:
https://api.ctrl-hub.com/v3/orgs/{orgId}/assets/equipment/eea6e732-82be-4194-b722-15408710c4a2?include=vehicle,vehicle.user
Which would return:
https://api.ctrl-hub.com/v3/orgs/{orgId}/assets/equipment/eea6e732-82be-4194-b722-15408710c4a2?include=vehicle,vehicle.user,vehicle.specification
This will return the vehicle specification in the included
array of the response:
?include=vehicle,vehicle.specification,vehicle.specification.model
And then include the manufacturer of the vehicle with:
?include=vehicle,vehicle.specification,vehicle.specification.model,vehicle.specification.model.manufacturer
An you could include the vehicle categories with:
?include=vehicle,vehicle.specification,vehicle.specification.model,vehicle.specification.model.manufacturer,vehicle.specification.model.categories
limit
/ offset
approach.
limit
restricts the number of resources returned in the data
of the response. If you request includes, this limit does not apply to the included data.
offset
is the number of resources to skip before returning the resources.
For example, to get the first 10 equipment items:
meta
field of the response, under the pagination
key:
counts
key provides you with the total number of pages and resources, and the requested
key provides you with the limit and offset you requested.
meta.pagination.offsets.previous
and meta.pagination.offsets.next
provide you with the offset for the previous and next pages respectively. If you are on the first page, previous
will be a null
value. If you are on the last page, next
will be a null
value.
200
status code and an empty data
array. If you are iterating though pages, you should check the data
array to see if it is empty, and if it is, you should stop iterating.