Orion Advisor’s API: Using OData query syntax

OData query syntax is a standard way of querying RESTful APIs using a pre-defined syntax that allows the calling client to define the sort order, filter parameters and pages of data that is returned. The full syntax can be found in section 5 of the OData Version 4.0 Part 2 specification.

Here are a few examples on the syntax use:

The $select option specifies a subset of properties to include in the response body.

  • /Portfolio/Accounts?hasValue=true&$select=Id,CurrentValue : Returns just the account id and the current account value.

The $top 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.

  • /Portfolio/Accounts?hasValue=true&$top=10&$skip=10Returns items 11>21

The $filter query option specifies an expression or function that must evaluate to true for a record to be returned in the collection.

  • /Portfolio/Accounts?hasValue=true&$filter=CurrentValue gt 0 : Returns all accounts greater than 0.
  • /Portfolio/Accounts?hasValue=true&$filter=IsActive eq false : Returns all inactive accounts.

The $orderby option sorts the results.

  • /Portfolio/Accounts?hasValue=true&$orderby=CurrentValue : Returns results sorted by current value in ascending order.

I hope this post shows that OData query options can be extremely powerful to supplement your api calls especially for optimization.

Let's discuss your project .... Give us a call or drop us a line