Advanced Filtering

The basics of filtering are covered here in the core documentation. This tutorial will provide examples of more complex filters to help developers understand the structure and syntax of advanced filtering.

Before We Start

I’ll be using unencoded filters to show the examples more clearly, but don’t forget to encode your URLs before sending them to the API

Here’s an online tool that will encode your URL by turning

filter=created_at<="2021-01-01"

into

filter%3Dcreated_at%3C%3D%222021-01-01%22

Also, any variables in the examples below that are in bold, like {an order ID} or {a status} will need to be replaced with the appropriate ID. Constant values like part types and statuses can be found by querying the respective endpoints (ex: /parttype)

Dates

Example: Filter for objects created before January 1st 2021, but updated after January 1st 2021

GET /salesorder?filter=created_at<="2021-01-01"&&updated_at>="2021-01-01"

Example: Filter for objects created in April 2020 or April 2021

GET /salesorder?filter=(created_at>="2021-04-01"&&created_at<="2021-04-30")||(created_at>="2020-04-01"&&created_at<="2020-04-30")

Example: Filter for orders issued between 8am and 5pm today (April 8, 2021).

GET /salesorder?filter=issue_date>="2021-04-08T08:00:00-07:00"&&issue_date<="2021-04-08T17:00:00-07:00"

Remember that dates are stored and served in UTC, so you’ll either need to convert your times to UTC or provide the appropriate offset. In this example, I’ve added -7:00 to account for my time zone, which is behind 7 hours behind UTC .

Part Lookup Examples

Filter for all light manufactured bundles:

GET /part?filter=parttype_id={inventory-bundle}&&buildtype_id!={build-never}

Filter for all part types except non-light manufactured bundles:

GET /part?filter=parttype_id!={inventory-bundle}||(parttype_id={inventory-bundle}&&buildtype_id!={build-never})

Query for all aliases of a given part:

GET /part?filter=parttype_id={alias}&&parent_part_id={part ID}

Find all BOMs on which a given part appears:

GET /billofmaterial?filter=lines.part_id={part ID}

Other Examples

Filtering for jobs that are either already linked to a specific customer, or not linked to any customer:

GET /job?filter=customer_id={customer ID} || customer_id IS NULL

Checking to see if an order has “ready to pick” lines by querying for lines that are associated to the specific order but not already on a pick:

GET /pickline?filter=pick_id IS NULL &&work.transactionline.transaction_id={order ID}

Filter for active customers whose names or aliases start with “the”:

GET /customer?filter=(name="the%"||aliases.name="the%")&&status_id!={inactive}

Filter for all orders created by Shopify

GET /salesorder?filter=source.name="shopify"

Note: The filter value should be the name of the Shopify service in LOCATE, which might be something like “Shopify Wholesale” or the name of your website. You can also filter on the service ID in case the name ever changes:

GET /salesorder?filter=source.service_id={shopify service ID}

What’s Next?

Now that you have filters down, check out Embedding 101 to learn how to use embeds!

Tip: combine embeds and filters with an ampersand:

GET /part?filter=parttype_id={alias}&&parent_part_id={part ID}&embed=parent_part