I'm using the eBay Fulfillment API to retrieve orders in JSON format. I've been running into an issue with the "total" field included in the response: It's consistently 1 too large when my date range includes a specific time (around 10:07 UTC today).
Here's a PHP/Xdebug var_dumpof a json_decoded example response, trimmed of the actual (irrelevant) order data. Note the difference between 'total' and size:
object(stdClass)[22]
public 'href' => string 'https://api.ebay.com/sell/fulfillment/v1/order?filter=lastmodifieddate:%5B2020-10-12T14:44:56.000Z..%5D,orderfulfillmentstatus:%7BIN_PROGRESS%7CNOT_STARTED%7D&limit=200&offset=0' (length=177)
public 'total' => int 177
public 'limit' => int 200
public 'offset' => int 0
public 'orders' =>
array (size=176)
...
I've tried using the defaults for limit and offset, in that case the last page will have 1 too few orders (offset+size(array)==total+1). I've also run this quite a few times with different starting dates to make sure it's not a weird timing issue. As long as the lastmodifieddate is more recent than 10:08 UTC today, the numbers fit, otherwise they don't.
Is this just a bug in the eBay API or is there some deeper meaning to this? I would assume this number to tell me the total amount of orders included in my current query (disregarding limit and offset), but this inconsistency makes me believe it counts some orders that aren't included (such as fulfilled orders or unpaid orders).
Weirdly enough, it actually includes a "next" field when I tweak the limit and offset to fit the actual array size exactly, and using that field's value to retrieve the "next page" (which would be the last order) results in this:
object(stdClass)[22]
public 'href' => string 'https://api.ebay.com/sell/fulfillment/v1/order?filter=lastmodifieddate:%5B2020-10-13T09:29:03.000Z..%5D,orderfulfillmentstatus:%7BIN_PROGRESS%7CNOT_STARTED%7D&limit=78&offset=78' (length=177)
public 'total' => int 79
public 'prev' => string 'https://api.ebay.com/sell/fulfillment/v1/order?filter=lastmodifieddate:%5B2020-10-13T09:29:03.000Z..%5D,orderfulfillmentstatus:%7BIN_PROGRESS%7CNOT_STARTED%7D&limit=78&offset=0' (length=176)
public 'limit' => int 78
public 'offset' => int 78
public 'orders' =>
array (size=0)
empty
Is there any explanation for this behaviour?
Side note: I haven't tagged the question as php because the issue is with the json response I get from the REST API, irrespective of the language I use to process it.