- Pages
- /
- Dealers
- /
- Data Depot
- /
- Version 4
- /
- API
- /
- Services
- /
- Filters
- Downloads
- API Documentation
- Support
API News and Updates
Subscribe to stay alert on the API.
Filters
Filters give the ability to narrow down the results of a request to specific subset of data based on properties of the service.
The parameter syntax structure is: ?filter[field][operator]=value
.
Operators | |
---|---|
[eq]
|
Equal* |
[ne]
|
Not equal |
[lt]
|
Less than |
[lte] or [le]
|
Less than or equal to |
[gt]
|
Greater than |
[gte] or [ge]
|
Greater than or equal to |
[pre]
|
Prefix / Starts with |
* Default behavior if an operator is not sent.
The thing to remember about filters is that you can filter by any of the properties of a particular service. If you're making a request to the
/items
service, you can filter by things like sku, list_price, name, etc. Any of the properties of the Items entity are available to be used as filters. By the same token, if you are making a request to
the /images
service, you can filter by the properties of THAT service. Things like filename, size, mime, alt, etc. That is why we don't
document every single filter that is available. It is/should be a given and assumed. Any property on a particular endpoint is filter-able.
The [field]
and value
will depend on the endpoint and what you are trying to
filter. The easiest way to explain Filters is to just give examples.
Examples
Bear in mind that these are only a few examples; we can't possibly document examples of every possible filter technique. Be adventurous and experiment on your own to see what you can come up with to meet the needs of your business.
Items
Get all FLY Racing Items.
In this example, only Items with a [brand_id]
of 135
(FLY Racing) would be returned. As you can see, the operator has not been specified, so [eq]
is assumed.
https://api.wps-inc.com/items?filter[brand_id]=135
Get all Items that have a MSRP less than $200.
In this next example, only Items with a [list_price]
of [lt]
(less than) 200
dollars would be returned.
https://api.wps-inc.com/items?filter[list_price][lt]=200
Get all Items that have a MSRP between $200 and $400.
You can also combine multiple filters to produce even more powerful queries.
In this example, only Items with a [list_price]
of [gt]
(greater than) 200
dollars and [lt]
(less than) 400
dollars would be returned.
https://api.wps-inc.com/items?filter[list_price][gt]=200&filter[list_price][lt]=400
Get all Items where the WPS Item number (SKU) starts with "87-4".
In this example, only Items with a [sku]
that are [pre]
(prefixed with) 87-4
would be returned.
https://api.wps-inc.com/items?filter[sku][pre]=87-4
Get all Items that were updated in the last 2 weeks.
In this example, only Items with a [updated_at]
date that is
[gt]
(greater than) 2024-10-26
would be returned.
https://api.wps-inc.com/items?filter[updated_at][gt]=2024-10-26
Products
Get all Products where the name starts with "GM5".
In this example, only Products with a [name]
that are [pre]
(prefixed with) GM5
would be returned.
https://api.wps-inc.com/products?filter[name][pre]=GM5
Get all the Tags of a particular Product that start with "Popu".
You can also filter the associations of a Product.
In this example, only a Products associated Tags
with a [name]
that are [pre]
(prefixed with) Popu
would be returned. Since the following request ultimately returns Tags, what we are filtering is the Tags.
https://api.wps-inc.com/products/208016/tags?filter[name][pre]=Popu