A query option is a set of query string parameters applied to a resource that can help control the amount of data being returned for the resource in the URL. Essentially, a query option requests that a service perform a set of transformations, such as filtering or sorting, on its data before returning the results.
Filter
The filter query option allows clients to filter a collection of resources addressed by a request URL. The expression specified with $filter is evaluated for each resource in the collection, and only items where the expression evaluates to true are included in the response. Resources for which the expression evaluates to false or null, or which reference properties unavailable due to permissions, are omitted from the response. You can find details on filter specification in the OData spec filter options section.
Examples:
All CDRs with a caller equal to ‘101’: http://host/api/cdrs?filter=caller eq '101'
All CDRs with a caller not equal to ‘101’: http://host/api/cdrs?filter=caller ne '101'
All CDRs with a caller greater than ‘101’: http://host/api/cdrs?filter=caller gt '101'
All CDRs with a caller greater than or equal to ‘101’: http://host/api/cdrs?filter=caller ge '101'
All CDRs with a caller less than ‘101’: http://host/api/cdrs?filter=caller lt '101'
All CDRs with a caller less than or equal to ‘101’: http://host/api/cdrs?filter=caller le '101'
All CDRs with the caller ‘101’ that also have a start time greater than ‘2022-01-01T00:00:00Z’: http://host/api/cdrs?filter=caller eq '101' and started_at gt '2022-01-01T00:00:00Z'
All CDRs that either have the caller ‘101’ or have a start time less than ‘2022-01-01T00:00:00Z’: http://host/api/cdrs?filter=caller eq '101' or started_at lt '2022-01-01T00:00:00Z'
All CDRs that have a caller that starts with ‘10’: http://host/api/cdrs?filter=startswith(caller,'10')
All CDRs that have a caller that ends with ‘01’: http://host/api/cdrs?filter=endswith(caller,'01')
All CDRs that have a caller that contains ‘0’: http://host/api/cdrs?filter=contains(caller,'0')
OrderBy
The orderby system query option allows clients to request resources in a particular order.
Example:
Return all CDRs ordered by caller in ascending order, then by start time in descending order: GET http://host/api/cdrs?orderby=caller asc, started_at desc
Top and Skip
The top system query option requests the number of items in the queried collection to be included in the result. The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result. A client can request a particular page of items by combining top and skip. Note that skip numbering is 1-based and that omitting the skip parameter will return the first page.
Examples:
Get top 100 CDRs: http://host/api/cdrs?top=100
Skip first 100 items: http://host/api/cdrs?$skip=100
Count
The count system query option allows clients to request a count of the matching resources included with the resources in the response. The count query option has a Boolean value of true or false.
Example:
Return, along with the results, the total number of CDRs in the collection: http://host/api/cdrs?count=true
Search
The search system query option allows clients to request items within a collection matching a free-text search expression. The search query option can be applied to a URL representing a collection of entity, complex, or primitive typed instances. If both search and filter are applied to the same request, the results include only those items that match both criteria.
Example:
All CDRs that are 101 or 102. It is up to the service to decide what makes a CDR 101 or 102: http://host/api/cdrs?search=101 or 102