Filter Your Requests

You can do filtering queries towards our endpoints that returns more than one object in response!

This means that you don’t have to get all the data and filter on your side, you can now let the API handle all the filtering. This is done by applying the $filter query string parameter. We use the oData V4 standard. You can filter using a few different operands, here are the operands we recommend, followed by some examples from the articles endpoint:

  • Greater than
    $filter= Number gt 1337

  • Less than
    $filter= Number lt 1337

  • Greater than or equal to
    $filter= Number ge 1337

  • Less than or equal to
    $filter= Number le 1337

  • Equals
    $filter= Number eq 1337

  • Not equal
    $filter= Number ne 1337

  • Starts with (select property and value)
    $filter=startswith(Number, ‘13’)

  • Ends with (select property and value)
    $filter=endswith(Number, ‘37’)

  • Contains (return properties that contains the value)
    $filter=contains(Name, ‘bakery’)

  • Length (combined with other operand)
    $filter=length(Name) gt 16

The filtering for Datetimes are a bit more specific:

  • The DateTime format for filtering: yyyy-MM-ddTHH-mm-ss-FFZ
    $filter=ChangedUtc gt 2016-12-31T23:59:59.00Z

  • Year (combined with other operand)
    $filter=year(ChangedUtc) eq 2017

  • Month (combined with other operand)
    $filter=month(ChangedUtc) eq 12

  • Day (combined with other operand)
    $filter=day(ChangedUtc) eq 31

  • Hour (combined with other operand)
    $filter=hour(ChangedUtc) eq 23

  • Minute (combined with other operand)
    $filter=minute(ChangedUtc) eq 59

  • Second (combined with other operand)
    $filter=second(ChangedUtc) eq 59

Combined queries:

  • And
    $filter=Number gt 1337 and ChangedUtc gt 2016-12-31T23:59:59.00Z

  • Or
    $filter=Netprice lt 1240 or StockBalance ge 15

Note that string values must be delimited by single quotation marks. Numeric values require no delimiters.

These are examples of the filtering types that we find useful for the API, but there are a few more that you can use. To find out more, here’s a link to the complete list of filter expressions in oData