Filtering
Discover how to refine API responses with specific criteria.
Filtering allows you to retrieve specific subsets of data based on certain criteria. Our API v2 uses the Left-Hand side (LHS) bracket notation in query parameters for filtering. This notation helps you specify which fields to filter, which operators to apply, and which values to look for.
The available filters differ by endpoint. To find the specific filter parameters, supported operators, and expected value formats for each endpoint, refer to the QUERY PARAMS section in the API reference.
For example, List all courses is a paginated endpoint that can return 500 courses per page. You can filter these results by creation date, modification date, status, and type. Each field uses specific operators for filtering. You can combine filters to refine your results as needed.
Filter syntax
Filters are added as query parameters to specify the criteria for retrieving data. The format for filters is: field[operator]=value
, where:
-
field
: The property you want to filter by. -
operator
: The condition you want to apply to the filter, enclosed in square brackets. -
value
: The value you want to compare against.
Example
For the query ?status[eq]=active
:
-
status
: The field being filtered. -
eq
: The operator indicating that the status must equal the specified value. -
active
: The value used for filtering.
This query returns items where the status is "active".
In the reference documentation, you may see an index included in code examples when filtering by multiple values with the
in
andnin
operators (e.g.,?type[in][0]=course&type[in][1]=path
).The index indicates the position of each value in the list, but it is optionalโyou can omit it if you prefer.
Supported data types and operators
The API supports filters for string, ObjectId, date, and boolean fields. Each of these has specific operators that define the type of comparison applied to the field values.
String filters
String filters let you match values based on equality, exclusion, or membership in a set.
Operator | Action | Example |
---|---|---|
eq | Filters values equal to the given one. | ?status[eq]=active |
ne | Filters values not equal to the given one. | ?status[ne]=active |
in | Includes any of the specified values. | ?status[in]=active |
nin | Excludes all of the specified values. | ?status[nin]=inactive |
ObjectId filters
ObjectId filters are used for fields containing unique identifiers.
Operator | Action | Example |
---|---|---|
eq | Filters values equal to the given ObjectId. | ?_id[eq]=507f1f77bcf86cd799439011 |
ne | Filters values not equal to the given ObjectId. | ?_id[ne]=507f1f77bcf86cd799439011 |
in | Includes any of the specified ObjectIds. | ?_id[in]=507f1f77bcf86cd799439011 |
nin | Excludes all of the specified ObjectIds. | ?_id[nin]=507f1f77bcf86cd799439011 |
Date filters
Date filters use dates formatted as YYYY-MM-DD
for comparisons.
Operator | Action | Example |
---|---|---|
lt | Filters for dates before the given date. | ?createdAt[lt]=2023-01-01 |
gte | Filters for dates from and including the given date. | ?createdAt[gte]=2023-01-01 |
Boolean filters
Boolean fields can be filtered using the following operator:
Action | Operator | Example |
---|---|---|
eq | Filters values equal to the given boolean value. | ?active[eq]=true |
Boolean values must be either true
or false
.
Advanced filtering
The API supports advanced filtering options to help you get precise results for your queries. You can apply multiple filters to refine your search based on various criteria.
Combine multiple filters on different fields
Refine your search by combining filters on different fields. Use &
to apply multiple filters, which works like a logical AND operation.
For example, the following query retrieves items that are both marked as published and created before January 1, 2023.
curl --request GET \
--url 'https://app.360learning.com/api/v2/courses?createdAt[lt]=2023-01-01&status[eq]=published' \
--header 'accept: application/json' \
--header '360-api-version: v2.0' \
--header 'authorization: Bearer your_access_token'
In this example:
status[eq]=published
: Filters items with a status of "published".createdAt[lt]=2023-01-01
: Filters items created before January 1, 2023.
This query returns items that meet both criteria.
Combine multiple filters on the same field
Apply multiple filters with different operators on the same field to define ranges or more complex conditions.
Apply range filters
You can apply multiple filters with different operators on the same field to define ranges or complex conditions. Use &
to combine them, which acts as a logical AND.
For example, the following query retrieves items created between April 1, 2022, and January 1, 2023:
curl --request GET \
--url 'https://app.360learning.com/api/v2/courses?createdAt[lt]=2023-01-01&createdAt[gte]=2022-04-01' \
--header 'accept: application/json' \
--header '360-api-version: v2.0' \
--header 'authorization: Bearer your_access_token'
In this example:
createdAt[lt]=2023-01-01
: Filters items created before January 1, 2023.createdAt[gte]=2022-04-01
: Filters items created on or after April 1, 2022
Combining these filters defines a specific date range for retrieval.
Include specific values with the in
operator
in
operatorThe in
operator retrieves items where the field matches at least one of the specified values. This acts as a logical OR, meaning that any item that meets one or more of the in
criteria will be included in the results.
When combining multiple in
filters, use &
to chain them together. Each in
filter expands the set of acceptable values.
For example, the following query retrieves external IDs that are linked to resources with the type
of either course
or path
:
curl --request GET \
--url 'https://app.360learning.com/api/v2/external-ids?type[in]=course&type[in]=path' \
--header 'accept: application/json' \
--header '360-api-version: v2.0' \
--header 'authorization: Bearer your_access_token'
In this example:
type[in]=course
: Includes resources with the typecourse
.type[in]=path
: Includes resources with the typepath
.
The result will include resources that have a type of course
, path
, or both. Each value acts as a logical OR, so if a resource matches any of the specified values, it will be returned.
Exclude specific values with the nin
operator
nin
operatorCombine multiple nin
filters using &
between them to exclude items that match any of the specified values. This acts as a logical AND, meaning that items will be excluded if they match any of the specified values. Each nin
filter removes resources that meet one or more of the exclusion criteria.
For example, to exclude resources of type classroom"
and registrationRequest
:
curl --request GET \
--url 'https:/app.360learning.com/api/v2/external-ids?type[nin]=classroom&type[nin]=registrationRequest' \
--header 'accept: application/json' \
--header '360-api-version: v2.0' \
--header 'authorization: Bearer your_access_token'
In this example:
type[nin]=classroom
: Excludes resources with the typeclassroom
.type[nin]=registrationRequest
: Excludes resources with the typeregistrationRequest
.
The result excludes resources that have a type of classroom
, registrationRequest
, or both. Each value acts as a logical AND, so any resource that matches any of the exclusion criteria will not be included in the results.
Combine advanced filters
You can also combine various advanced filtering scenarios for even more complex queries.
For example, the following query returns courses created between April 1, 2023, and January 1, 2024, which are marked as deleted and of type SCORM.
curl --request GET \
--url 'https://app.360learning.com/api/v2/courses?createdAt[lt]=2024-01-01&createdAt[gte]=2023-04-01&status[eq]=deleted&type[eq]=scorm' \
--header 'accept: application/json' \
--header '360-api-version: v2.0' \
--header 'authorization: Bearer your_access_token'
Updated 8 months ago