Search code examples
square-connect

Square api: filter ListOrders by date not working


I am doing the following call (minus my locationId):

GET https://connect.squareup.com/v1/xxxxxxxxx/orders?begin_time=2016-04-12T00:00:00Z

But in the response I get an order from 2016-03-29

{
    "buyer_note": "Ship fast, please!",
    "total_discount_money": {
        "currency_code": "USD",
        "amount": 0
    },
    "created_at": "2016-03-14T23:44:46Z",
    "id": "LLVH1OON",
    "total_shipping_money": {
        "currency_code": "USD",
        "amount": 1
    },
    "total_price_money": {
        "currency_code": "USD",
        "amount": 11
    },
    "merchant_token": "xxxxxxxxxxx",
    "expires_at": "2016-03-21T23:45:08Z",
    "recipient_name": "Buyer McPhee",
    "subtotal_money": {
        "currency_code": "USD",
        "amount": 10
    },
    "updated_at": "2016-03-21T23:45:33Z",
    "state": "COMPLETED"
}

Does the filter by order date work?


Solution

  • Unfortunately, the list orders endpoint does not support date filters. The documentation on API conventions for working with dates implies that all list endpoints take date filters, but it is intended to be general advice for working with those types of parameters (and should be updated to not imply that). However, not all list endpoints do. If you look at the specific documentation for the list orders endpoint it does not show support for begin_time and end_time parameters. For an example of an endpoint that does, the list payment endpoint specifically mentions support for the begin_time and end_time parameters.