Filtering

All endpoints which return a list of API resources support filtering. The filtering can be performed using the filter query param, e.g.:

curl --request GET \
  --url 'https://api.northpass.com/v2/courses' \
  --header 'Accept: application/json' \
  --header 'X-Api-Key: <INSERT_API_KEY_HERE>' \
  --data-urlencode 'filter[name]=Testing’

Please note the filter param must be URL encoded. In the example above, it’s done by the curl’s —data-urlencode option. You can also do it yourself and pass it as a query param in the URL:

curl --request GET \
  --url 'https://api.northpass.com/v2/courses?filter%5Bname%5D=Testing' \
  --header 'Accept: application/json' \
  --header 'X-Api-Key: <INSERT_API_KEY_HERE>’

Both queries listed above will return all courses which have the string “Testing” in their name. Each endpoint that supports filtering has a list of attributes that can be used to filter the results. Please visit the API reference to get this list for a specific endpoint.

Apart from using different filter attributes, the Northpass API supports multiple filter predicates which correspond to the following operations:

equal

This predicate performs a strict comparison.

curl --request GET \
  --url 'https://api.northpass.com/v2/courses' \
  --header 'Accept: application/json' \
  --header 'X-Api-Key: <INSERT_API_KEY_HERE>' \
  --data-urlencode 'filter[name][eq]=Testing'

does not equal

This predicate performs a strict comparison.

curl --request GET \
  --url 'https://api.northpass.com/v2/courses' \
  --header 'Accept: application/json' \
  --header 'X-Api-Key: <INSERT_API_KEY_HERE>' \
  --data-urlencode 'filter[name][not_eq]=Testing'

contains

This predicate performs a comparison based on the SQL's LIKE operator.

curl --request GET \
  --url 'https://api.northpass.com/v2/courses' \
  --header 'Accept: application/json' \
  --header 'X-Api-Key: <INSERT_API_KEY_HERE>' \
  --data-urlencode 'filter[name][cont]=Testing'

does not contain

This predicate performs a comparison based on the SQL's LIKE operator.

curl --request GET \
  --url 'https://api.northpass.com/v2/courses' \
  --header 'Accept: application/json' \
  --header 'X-Api-Key: <INSERT_API_KEY_HERE>' \
  --data-urlencode 'filter[name][not_cont]=Testing'

one of many

This predicate performs a strict comparison.

curl --request GET \
--url 'https://api.northpass.com/v2/courses' \
--header 'Accept: application/json' \
--header 'X-Api-Key: <INSERT_API_KEY_HERE>' \
--data-urlencode 'filter[name][in][]=Testing' \
--data-urlencode 'filter[name][in][]=Working'

Please note the additional [] after the [in] predicate. The trailing [] is required when providing a list of values. When only providing one value, the trailing [] can be used or not, either is supported. For example, the following are identical:

filter[email][eq][email protected]
filter[email][eq][][email protected]

none of many

This predicate performs a strict comparison.

curl --request GET \
--url 'https://api.northpass.com/v2/courses' \
--header 'Accept: application/json' \
--header 'X-Api-Key: <INSERT_API_KEY_HERE>' \
--data-urlencode 'filter[name][not_in][]=Testing' \
--data-urlencode 'filter[name][not_in][]=Working'

comparing numbers

less than

curl --request GET \
  --url 'https://api.northpass.com/v2/courses' \
  --header 'Accept: application/json' \
  --header 'X-Api-Key: <INSERT_API_KEY_HERE>' \
  --data-urlencode 'filter[enrollments_count][lt]=10'

less than or equal

curl --request GET \
  --url 'https://api.northpass.com/v2/courses' \
  --header 'Accept: application/json' \
  --header 'X-Api-Key: <INSERT_API_KEY_HERE>' \
  --data-urlencode 'filter[enrollments_count][lteq]=10'

greater than

curl --request GET \
  --url 'https://api.northpass.com/v2/courses' \
  --header 'Accept: application/json' \
  --header 'X-Api-Key: <INSERT_API_KEY_HERE>' \
  --data-urlencode 'filter[enrollments_count][gt]=10'

greater than or equal

curl --request GET \
  --url 'https://api.northpass.com/v2/courses' \
  --header 'Accept: application/json' \
  --header 'X-Api-Key: <INSERT_API_KEY_HERE>' \
  --data-urlencode 'filter[enrollments_count][gteq]=10'

Did this page help you?