Apply filters to API requests
You can filter collections using the filter
query parameter, which supports standard comparison operators such as =, >=, and !=. You can specify multiple filter
parameters by joining filter
statements with an ampersand (&).
To determine the parameters that can be filtered for a given method, see the API Reference. The filterable fields are also returned with the request in the X-Clover-Allowed-Filter-Fields
header.
Example 1—Request filtered by clientCreatedTime
clientCreatedTime
This request retrieves orders for a specific merchant within a given time range, defined by the clientCreatedTime
field.
curl
-s "https://apisandbox.dev.clover.com/v3/merchants/{mId}/orders?filter=clientCreatedTime>=[unix-time]&filter=clientCreatedTime<=[unix-time]"
--header "Authorization: Bearer {API_Token}"
Example 2—Request filtered by total
and payType
total
and payType
This request is to retrieve orders that meet specific criteria, such as having a total amount greater than 1000 and a payment type other than "FULL." This can help analyze high-value transactions and understand different payment methods used.
curl
-s "https://apisandbox.dev.clover.com/v3/merchants/{mId}/orders?filter=total>1000&filter=payType!=FULL"
--header "Authorization: Bearer {API_Token}"
{
"elements": [
{
"clientCreatedTime": 1401286267000,
"createdTime": 1401286268000,
"currency": "USD",
"employee": {
"id": "QT0DES4CXR572"
},
"groupLineItems": true,
"href": "https://apisandbox.dev.clover.com/v3/merchants/{mId}/orders/8WAD6KV8D90KR",
"id": "8WAD6KV8D90KR",
"isVat": false,
"manualTransaction": false,
"modifiedTime": 1401286463000,
"payType": "SPLIT_CUSTOM",
"state": "locked",
"taxRemoved": false,
"testMode": false,
"total": 5293
},
{
"clientCreatedTime": 1400106245000,
"createdTime": 1400106245000,
"currency": "USD",
"employee": {
"id": "QT0DES4CXR572"
},
"groupLineItems": true,
"href": "https://apisandbox.dev.clover.com/v3/merchants/{mId}/orders/0S0JJYG231462",
"id": "0S0JJYG231462",
"isVat": false,
"manualTransaction": false,
"modifiedTime": 1400106366000,
"payType": "SPLIT_CUSTOM",
"state": "locked",
"taxRemoved": false,
"testMode": false,
"total": 2829
}
],
"href": "https://apisandbox.dev.clover.com/v3/merchants/{mId}/orders?filter=total%3E1000&filter=payType!%3DFULL&limit=100"
}
Updated 19 days ago