Sorting and filtering in the IT Glue API

For partners subscribed to the current Enterprise plan.

A lot of the time, when you're making calls to the IT Glue API, there will be a lot of results to return. For that reason, you will sometimes want to filter or sort the results to make sure you're seeing the information you want.

Filtering

Filters are simple methods that modify the output of numbers and strings, like date filtering, using brackets.

For example, this GET request will return all user metrics:

    GET /users_metrics

You will probably find this produces too much information. This next GET request will return all user metrics for a specific time frame (one month):

    GET /users_metrics?filter[date]=2017-02-01,2017-02-28

This will probably still be too much information. To get more specific, you can combine filtering conditions using & (ampersand). For example, this GET request will return all user metrics within a specific time frame for a specified user:

    • GET /users_metrics?filter[date]=2017-02-01,2017-02-28&filter[user_ID]=1234

NOTE  Commas in filters can be escaped with a backslash (\). For example, an organization named Kub, Reynolds and Gibson can be filtered by name by adding a backslash before the comma as demonstrated below:filter[name]=Kub\, Reynolds and Gibson

All supported filter parameters can be found with their relevant GET endpoints in the developer documentation. Note that filtering in nested relationship routes is not possible.

Dates should be provided in RFC3339 format in UTC timezone: YYYY-MM-DDTHH:MM:SSZ. You may omit the time and timezone if desired.

Sorting

You can order the API results using supported resource-specific parameters.

For example, you might need to return all users ordered by creation date. Your GET would look like this:

    GET /users?sort=created_at

To return the results in descending order (recent users on top), use this:

    GET /users?sort=-created_a

You can also add filtering conditions using & (ampersand).

Related articles