Get Orders by a date range returning incorrect results

Ashique_Haque
New Member
3 0 0

Hi guys,

I'm fetching data into klipfolio (web-based BI platform) using orders endpoint and using the following URL request:

https://mydomain.myshopify.com/admin/orders.json?created_at_min=2018-04-22T00:00:00+9:30&created_at_...

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!

0 Likes
Busfox
Shopify Staff
Shopify Staff
619 49 99

Hi there,

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.

Cheers,

0 Likes
Ashique_Haque
New Member
3 0 0

Hi Andrew,

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. 

0 Likes
Busfox
Shopify Staff
Shopify Staff
619 49 99

Hi again,

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!

Cheers,

0 Likes
stevenmunoz
New Member
2 0 0

Hi there!

Did you get this solved? I'm facing the same issue 

0 Likes