Unable to retrieve all orders

Hi,

I am trying to retrieve a complete list of orders using the python API. changing the sort order gives me a different number of results but I am unable to get them all to return, I should get around 1000 orders returned

Order ASC = 295 orders returned
Order DESC = 257 orders returned

result_orders = client.orders.search_orders(
    body = {
      "location_ids": [
        "L3YY0HJW9MGXS"
      ],
      "query": {
        "filter": {
          "state_filter": {
            "states": [
              "COMPLETED",
              "OPEN",
            ]
          },
          "date_time_filter": {
            "created_at": {
              "start_at": "2022-01-01T20:00:00+00:00",
              "end_at": "2022-12-31T21:54:45+00:00"
            }
          }
        },
        "sort": {
          "sort_field": "CREATED_AT",
          "sort_order": "ASC"
        }
      },
      "limit": 5000,
      "return_entries": False
    }
  )

This is expected with the Orders API limit. The limit is the maximum number of results to be returned in a single page. It is possible to receive fewer results than the specified limit on a given page. The default is 500 which is the maximum it will return for a single call. :slightly_smiling_face:

1 Like