Being able to search and filter data is an important part of any API. In newly added endpoints, we've made it possible to search information, by defining filters presented in a query string, that conforms to a schema we created and support.
While we will endeavour to update existing endpoints to support search criteria, it will take some time and effort. Until then, only endpoints that explicitly mention support will have the ability to use it.
A lot of the time, when you're making calls to the Cabinetry.Online API, there'll be a lot of results to return. For that reason, we paginate the results to make sure responses are performant and easier to handle.
Let's say your initial call is asking for all the customers; the result could be a massive response with hundreds of thousands of pages. That's not a good place to start.
Rather than that, we've built in a default limit on results, but we recommend you always explicitly set the page_size
parameter to ensure you know how many results per page you'll get. Don't rely on the defaults as they'll be different
depending on what parts of the response you're expanding, so the response you get might not be what you expected.
For example, you might need to request all customers associated with your account, but you only want the results 5 at a time. Your GET request would look something like this:
curl -X GET 'https://cabinetry.online/api/admin/customers?page_size=5' -H 'X-GC-API-KEY: xxxxxxxxxxxx'
Note the page_size parameter in this call is set to 5, so the response would show items 0 through to 5.
{
"success": 1,
"items": [
{
"id": 1234,
"manufacturer_id": 7891,
"name": "John Doe Kitchens",
"email": "john@example.com",
"telephone": "0480123456",
"cc_email": "harry@example.com",
"price_adjustment": 0,
"minimum_charge": 30,
"minimum_freight": 0,
"address": {
"street": [
"123 Summer St"
],
"suburb": "Boggy Creek",
"state": "Victoria",
"postcode": "3268",
"country": "Australia"
},
"settings": {
"assembly_enabled": false,
"is_beta": true,
"is_premium": true
}
},
{},
{},
{},
{}
],
"pagination": {
"current_page": 1,
"page_count": 10,
"page_size": 5,
"total_count": 46
}
}
In the above response, you may notice it contains pagination information helping to iterate further over records.
You can assume if the current_page is less than page_count, further information is available. To retrieve the next
page of results, your GET request would look something like this:
curl -X GET 'https://cabinetry.online/api/admin/customers?current_page=2&page_size=5' -H 'X-GC-API-KEY: xxxxxxxxxxxx'
Filter groups are defined as part of the query string, which wraps the filters wanting to be applied.
curl -X GET 'https://cabinetry.online/api/admin/customers?filter_groups=((<field>:<condition>:<value>))' -H 'X-GC-API-KEY: xxxxxxxxxxxx'
Often, when wanting to search or narrow down the results, multiple or complex criteria is required. Filter groups allow compounding filters to be applied, to the same field or and entirely different field. As an example, lets assume we are searching for any customer with the name John, who resides in the state of Victoria. Your GET request would look something like this:
curl -X GET 'https://cabinetry.online/api/admin/customers?page_size=5&filter_groups=((name:contains:John) AND (state:equals:Victoria))' -H 'X-GC-API-KEY: xxxxxxxxxxxx'
Note multiple filters are separated with the word AND between parenthesis.
{
"success": 1,
"items": [
{
"id": 1234,
"manufacturer_id": 7891,
"name": "John Doe Kitchens",
"email": "john@example.com",
"telephone": "0480123456",
"cc_email": "harry@example.com",
"price_adjustment": 0,
"minimum_charge": 30,
"minimum_freight": 0,
"address": {
"street": [
"123 Summer St"
],
"suburb": "Boggy Creek",
"state": "Victoria",
"postcode": "3268",
"country": "Australia"
},
"settings": {
"assembly_enabled": false,
"is_beta": true,
"is_premium": true
}
}
],
"pagination": {
"current_page": 1,
"page_count": 1,
"page_size": 5,
"total_count": 1
}
}
A filter consists of:
field is an attribute name.condition one of many filter conditions available.value specifies the value to search for.Below is a list of conditions available along with their example usage.
| Condition | Description | Example |
|---|---|---|
| equals | Exact match for the given value | (id:equals:13) |
| not_equals | Not an exact match for the given value | (name:not_equals:John Daly) |
| starts_with | Starting with the given value | (name:starts_with:John) |
| ends_with | Ending with the given value | (email:ends_with:gmail.com) |
| contains | Contains the given value at any position | (email:contains:gmail) |
| not_contains | Does not contain the given value at any position | (email:not_contains:outlook) |
| either | Exact match for either comma-separated list of values | (id:either:1,2,3,4,5) |
| not_either | Not an exact match for either comma-separated list of values | (id:not_either:6,7,8,9,10) |
| empty | Target field is empty/null | (telephone:empty) |
| not_empty | Target field is not empty/null | (postcode:not_empty) |
| greater_than | Greater than the given value | (cost:greater_than:100) |
| greater_or_equal | Greater or equal to the given value | (cost:greater_or_equal:300) |
| less_than | Less than the given value | (discount:less_than:50) |
| less_or_equal | Less or equal to the given value | (discount:less_or_equal:100) |
| between | Between a given range, comma-separated list of values | (subtotal:between:500,1000) |
| not_between | Not between a given range, comma-separated list of values | (postcode:not_between:3100,3200) |
| date_preset | Uses a preset type to search by date relative in time | (created:date_preset:after_this_year_start) |
| json_contains | Contains the given value in JSON string value | (external_id:json_contains:456) |
| json_not_contains | Does not contains the given value in JSON string value | (external_id:json_not_contains:456) |
| json_empty | Target JSON field is empty | (external_id:json_empty) |
| json_has_key | Contains an exact key match in JSON string | (external_id:json_has_key:ABC) |
| json_has_no_key | Does not contains a key match in JSON string | (external_id:json_has_no_key:ABC) |
| json_key_has_value_equals | Key contains the exact value in JSON string | (external_id:json_key_has_value_equals:ABC=123) |
| json_key_has_value_not_equals | Key doesn't contains the exact value in JSON string | (external_id:json_key_has_value_not_equals:ABC=123) |
Below is a list of date presets available. They can be quite useful when fetching information or generating reports by a date relative in time. For example, generating reports for accounts/invoices between financial years or quarterly.
Note: Regarding the before and after prefixes. Presets prefixed with before will search for values
less or equal to the field value. Whereas presets prefixed with after will search for values greater or
equal to the field value.
Note: Regarding the start and end suffixes. Presets suffixed with start automatically have the
date adjusted to the beginning of its period (day, week, month, year) with time set as 00:00.
Whereas presets suffixed with end automatically have the date adjusted to the end of its period
(day, week, month, year) with time set as 23:59.
| Type |
|---|
| before_today_start |
| before_today_end |
| after_today_start |
| after_today_end |
| before_yesterday_start |
| before_yesterday_end |
| after_yesterday_start |
| after_yesterday_end |
| before_this_week_start |
| before_this_week_end |
| after_this_week_start |
| after_this_week_end |
| before_last_week_start |
| before_last_week_end |
| after_last_week_start |
| after_last_week_end |
| before_this_month_start |
| before_this_month_end |
| after_this_month_start |
| after_this_month_end |
| before_last_month_start |
| before_last_month_end |
| after_last_month_start |
| after_last_month_end |
| after_this_quarter_start |
| after_this_quarter_end |
| after_this_quarter_start |
| after_this_quarter_end |
| after_last_quarter_start |
| after_last_quarter_end |
| after_last_quarter_start |
| after_last_quarter_end |
| before_this_year_start |
| before_this_year_end |
| after_this_year_start |
| after_this_year_end |
| before_last_year_start |
| before_last_year_end |
| after_last_year_start |
| after_last_year_end |
| before_2_days_ago_start |
| before_2_days_ago_end |
| after_2_days_ago_start |
| after_2_days_ago_end |
| before_3_days_ago_start |
| before_3_days_ago_end |
| after_3_days_ago_start |
| after_3_days_ago_end |
| before_4_days_ago_start |
| before_4_days_ago_end |
| after_4_days_ago_start |
| after_4_days_ago_end |
| before_5_days_ago_start |
| before_5_days_ago_end |
| after_5_days_ago_start |
| after_5_days_ago_end |
| before_6_days_ago_start |
| before_6_days_ago_end |
| after_6_days_ago_start |
| after_6_days_ago_end |
| before_7_days_ago_start |
| before_7_days_ago_end |
| after_7_days_ago_start |
| after_7_days_ago_end |
| before_14_days_ago_start |
| before_14_days_ago_end |
| after_14_days_ago_start |
| after_14_days_ago_end |
| before_30_days_ago_start |
| before_30_days_ago_end |
| after_30_days_ago_start |
| after_30_days_ago_end |
| before_60_days_ago_start |
| before_60_days_ago_end |
| after_60_days_ago_start |
| after_60_days_ago_end |
| before_90_days_ago_start |
| before_90_days_ago_end |
| after_90_days_ago_start |
| after_90_days_ago_end |
| before_365_days_ago_start |
| before_365_days_ago_end |
| after_365_days_ago_start |
| after_365_days_ago_end |