Bug with Abandoned Checkouts REST API - created_at_min & updated_at_min parameters

Shopify Partner
2 0 1

Hello everyone! I have been making a system that imports user's data and shows the import progress, and I've noticed a bug when sending created_at_min and updated_at_min parameters on /checkouts/count.json and /checkouts.json

My last record has:


"created_at": "2021-02-08T18:59:10+01:00",
"updated_at": "2021-02-08T19:00:02+01:00",



When making a request to 

/checkouts/count.json?created_at_min=2021-02-08T18:59:11+01:00 (up until 19:00:01+01:00) I get count == 1
/checkouts.json?created_at_min=2021-02-08T18:59:11+01:00 (and after) I get an empty array of items

This means that calling /count.json on a created_at date actually looks at the updated_at date and cannot return the same amount of items as calling /checkouts.json with the same parameters, which poses an issue to us since the customer can think that their import process is still ongoing, ie. there is still data to be imported although there isn't.

Another issue is with regards to the timezone.

Calling endpoints below returns the same count, 1 (although it is wrong since it is more than created_at date)

Calling endpoints below returns 1 item and 0 items respectively

Has anyone encountered these before and if so, how have they tackled this issue? 

Best regards,

Shopify Staff
Shopify Staff
51 11 9

This is an accepted solution.

Hi Damir,

I'd be happy to throw some light on this issue.

This post on Stack Overflow explains aptly what is going on. You can see from the Google URL with query string examples given in that post that the + is decoded as a space. The same behaviour happens on our end, and the + is converted to a space before it reaches the server side. Hence, the timezone portion is lost, and the time passed in the query of the /checkouts.json endpoint is assumed to be the UTC timezone. The reason for the discrepancy between the 2 endpoints is that /checkouts/counts.json uses the time passed as the shop time whereas as indicated earlier the /checkouts.json assumes the time passed to be UTC. I understand the inconsistency between the 2 endpoints can be confusing and frustrating, and I'm going to reach out to the team in charge so the behaviour across both is consistent.   

To get the expected results, your query would have to be /checkouts/count.json?created_at_min=2021-02-08T18:59:11%2B01:00 so the time is converted to the correct UTC time on our server side.

Hopefully this information is helpful. If you have any additional questions or need clarification about this issue, don't hesitate to get back to me.


syf_ | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog