The Liftoff OData API is a powerful way to fine-tune your API queries to return only the data you need.
The OData standard supports multiple query options that may be appended to requests. These query options may be combined and adjusted to return whatever data you need. Examples include:
$expand: Specifies related entities to include in the results. Multiple values may be specified as a comma-separated list. For example, the following Order query includes the items and shipments associated with each order:
https://odata.liftoff.shop/odata/v1/Order?$expand=Items,ShipmentsTo expand a child entity, use syntax such as the following:
https://odata.liftoff.shop/odata/v1/Budget?$expand=BudgetTransactions($expand=Admin)$filter: Filters a query to only include entities that match the specified expressions. For example, the following Order query includes only in process orders that were submitted in September 2019:
https://odata.liftoff.shop/odata/v1/Order?$filter=Status eq 'InProcess' and year(SubmissionDate) eq 2019 and month(SubmissionDate) eq 9$orderby: Sorts the results according to the specified property and in the specified direction. For example, the following Customer query returns customers sorted by last login date, starting with the most recent login date:
https://odata.liftoff.shop/odata/v1/Customer?$orderby=LastLoginDate desc$select: Specifies a limited subset of properties to include in the results. Multiple properties may be specified as a comma-separated list. For example, the following Order query returns only the order ID, order number, and submission date for each order:
https://odata.liftoff.shop/odata/v1/Order?$select=Id,OrderNumber,SubmissionDate$skip: Specifies the number of entities to skip in the returned results. This can be useful since Liftoff OData API responses are limited to a maximum of 100 entities. For example, the following Order query returns the second 100 orders:
https://odata.liftoff.shop/odata/v1/Order?$skip=100
$skip vs. $filter
$skipmay perform poorly when specifying a large number of entities to skip. When paging through a large number of entities,$filter=Id gt [previous Id]performs much better than$skip=[entities to skip]. Please see Pagination for details.
$top: Specifies the maximum number of entities to include in the returned results. For example, the following Order query returns only the first 10 orders:
https://odata.liftoff.shop/odata/v1/Order?$top=10
Learn more about OData.
