Filtering Collections ($filter)

Filtering enables targeting only to items that are important for our implementation, using certain criteria to fetch them.

Getting a collection of resources (e.g. /api/accounts, /api/orders, /api/subscriptions, etc) usually return a large number of items. Fetching only the important items is crucial for the efficiency of any implementation that needs to take into consideration the bandwidth and processing power utilization.

$filter parameter accepts an expression that is evaluated to fetch only the resources matching the provided criteria. The language used for this expression is based on OASIS OData Version 4.01 Protocol.

The following table contains some common use cases of the “$filter” parameter:

Query Description

Example

Select accounts with code equal to ‘ICP1’

/api/accounts$filter=code eq 'ICP1'

Select accounts that ‘test’ word is part of their name

/api/accounts$filter=contains(name, ‘test’)

Select accounts that are enabled for reselling

/api/accounts$filter=resellingEnabled eq true

Select orders that their payment method is Paypal

/api/orders$filter=paymentMethod eq 'Paypal'

Select invoices created after 01/01/2020

/api/invoices$filter=createdAt gt datetime'2020-01-01'

For a full set of operators and built-in functions supported by the interworks.cloud Platform API, please check the following pages:

The following page provides the search criteria available for each resource.