I’m writing up a little script that grabs these orders and processes them into an excel sheet. I’m trying to replicate the frontend function in the Order API by using the Search Orders call, however, it doesn’t appear there is an easy way to do that with the parameters available.
The closest call I can make is:
curl https://connect.squareup.com/v2/orders/search
-X POST
-H ‘Square-Version: 2020-12-16’
-H ‘Authorization: Bearer REDACTED’
-H ‘Content-Type: application/json’
-d ‘{
“location_ids”: [
“ALocationIDHere”
],
“query”: {
“filter”: {
“state_filter”: {
“states”: [
“OPEN”
]
},
“fulfillment_filter”: {}
}
}
}’
This of course, returns a lot more than the six entries seen here, as apparently the Open state covers a lot more than just these.
I did notice in the URL on the frontend that for “Active” passing in an orderGroup of 1 returns the expected results, but there doesn’t seem to be a way to do this in the API.
How is the status being filtered on, (not the state) and is there an API call that matches the frontend? I’ve gone through the Order documentation, but it’s a little unclear to me.
You would want to use the fulfillment_filter instead; currently you’re searching for all open orders, not open fulfillments. If an order is open without fulfillments, it won’t show up in your dashboard.
The fulfillment_filter has fulfillment_states array of strings, that you can pass in several values. I think for “Active” you would want to search for “PROPOSED”, “RESERVED”, and “PREPARED”.
Ah, shoot sorry, I missed an important piece here. In order for the order to show up on your dashboard, it must also be paid for, which this query doesn’t search for. There’s no way to query for paid orders explicitly, unfortunately, so after doing the above query, you would need to also narrow it down further by checking to see if there’s any tenders associated, and if so, is it equal to the full amount of the order (completely paid for). If there’s no tenders, then you can rule it out, as those won’t show up on the dashboard.