Filter Results in the API

New Feature

Customers using the Assetbots API can now find records more easily using our new filtering support.

Our API has always supported list operations, for finding all records in your database, as well as get operations, for getting specific records by ID. What has been missing until now is filtering list operations, which allow you to get specific records by fields other than their ID.

A common request from customers has been to get an asset by its serial number, or to get a person by their email address. These operations are now possible with this enhancement.

Filtering in the Assetbots API is based on the OData filter options, and while we do not support the complete specification, we support the most common use cases.

To get started, make sure you have generated an API key for your database. To do so, visit Settings > API Keys. You can use our interactive documentation to experiment with your queries as you follow along.

Filters are defined in the $filter query parameter. To construct a filter, you create clauses based on field keys, which are unique to your database. For example, if you have a Text field called Serial Number with key serialNumber, you can find records with Serial Number equal to 123456 with the following filter:

serialNumber eq 123456

Adding this to the query string, the full URL becomes:

https://api.assetbots.com/v1/assets?%24filter=serialNumber%20eq%20123456

You can combine multiple clauses using and and or, and you can use any one of the following comparison operators:

  • eq (equal)
  • gt (greater-than)
  • ge (greater-than-or-equal)
  • lt (less-than)
  • le (less-than-or-equal)
  • nq (not-equal)

Finally, you can use paths if you would like to filter on a nested value. For example, if you would like to find all assets that cost more than $2,500 and you have a Money field with the key cost, you would use:

cost.amount gt 250000

Note in the filter above that we use 250000 instead of 2500. That is because USD is a currency with a scale of 2. You can query your database to see how the currency you use is stored by Assetbots if you’re not using USD.

Filtering is available today in the Assetbots API and can be used with assets, people, and locations.

We hope this enhancement makes working with our API much easier for your organization. If you need any help or have any questions, please open a ticket with our team in your account dashboard.

Happy tracking!