I'm fetching data into klipfolio (web-based BI platform) using orders endpoint and using the following URL request:
This is returning 1100 orders but in Shopify analytics reports I've got 1105 orders for the same date range. I've added a timezone offset of +09:30 as timezone is set to Australian time in my shop settings. If I remove the timezone offset then also I get incorrect results. There is always a discrepancy in the count of orders returned from API and in Shopify for the same date range.
Any help on this would be highly appreciated.
Thanks in advance!
Andrew here from the Shopify Developer Experience Team.
Using created_at filters will result in some issues with pagination. These issues were addressed by using the indexed filter param since_id. This will return resources in order by when they were created. Essentially, you pick an order id as your starting point and fetch products since that id. Grab the last id in the results, and replace the since_id value with that id to get the next page of results.
Thanks for the response.
But this does not seem to be the problem of pagination as I'm handling pagination in my BI platform (Klipfolio) itself. I believe it could be because of timezone issue here. Can you please explain in which timezone orders are returned and how we should set the offset while making the call.
Any help here would be appreciated as I just cannot return the correct number of orders for a date range through API calls.
You are using the correct time format for the Adelaide Australia timezone, that shouldn't be the issue. I'd highly recommend adding since_id to your calls to fetch orders as you have the potential to get duplicate/missing records returned if there are orders with the same timestamp. In this case, you may receive an order at the bottom of a page of results and at the top of the next page of results. Using since_id will ensure your results are always in order based on created at. I recommend this as best practice in all cases when fetching pages of results.
Another thing to point out is that unless you specify the status, only open (unarchived) orders will show up in results. There's a chance the five missing orders are simply archived.
Hope that helps!