Get order details based on latest updated datetime of the order only

yashrastogi2020
Shopify Partner
26 0 1

Hi Team,

Which API can be used to get all order details based on the latest updated datetime of the individual orders? This way, the result set will fetch only unique orders based on the latest updated datetime only, which is our requirement.

 

Regards,

Yash

Replies 14 (14)

Not applicable

Hi Yash,

 

If you're using REST API you can use updated_at_min param with your GET to /orders.json endpoint.

 

updated_at_min

Show orders last updated at or after date (format: 2014-04-25T16:15:47-04:00).

 

https://shopify.dev/docs/admin-api/rest/reference/orders/order?api[version]=2020-07

 

If you're going back 60 days or more you need to request full Orders access through your partner dashboard. 

 

Regards,

Sam Bazargan - Owner

yashrastogi2020
Shopify Partner
26 0 1
Hi Sam,

Lets say, I created an Order on June 20, 2020 at 14:30:00 UTC.

I first updated it on June 25, 2020 at 15:40:00 UTC.

Again I updated this order by creating a fulfillment on June 27, 2020 at
16:00:00 UTC.

Now, when I'll retrieve orders setting updated_at_min = June 15, 2020
00:00:00 UTC, in batches of 5 orders per call, how many times the above
order will appear in my result set?

In my case, I've total 494 orders in my account, first order creation date
being October 07, 2019 12:04:00 UTC.

When I execute the API call (
*/admin/api/2019-10/orders.json?limit=5&updated_at_min=2019-07-19T00:04:46Z&status=any&order=updated_at%20asc*)
inside a for-each loop, I get the total count of orders as 767. How come
this be possible when in total I have only 494 orders only?

Let me know if we can schedule a meeting to check this out together.
yashrastogi2020
Shopify Partner
26 0 1

Hi Team,

Can someone respond back on my query asap?

 

Regards,

Yash

Not applicable

Yash,

 

You can email me directly here: admin@achieveapplabs.com

 

Regards,

Sam

Not applicable

Yash,

 

Make sure you're getting the datetime format correct this works for us:

 

const created_at_min = moment(new Date()).format('llll');

 

 

Also you may have archived orders so you should specify the order status in params as well

Filter orders by their status.

(default: open)

  • open: Show only open orders.
  • closed: Show only closed orders.
  • cancelled: Show only canceled orders.
  • any: Show orders of any status, including archived orders.

 

Regards,

Sam 

Not applicable

Also these params don't look right:

 

*/admin/api/2019-10/orders.json?limit=5&updated_at_min=2019-07-19T00:04:46Z&status=any&order=updated_at%20asc*)

 

Try this:

 

*/admin/api/2019-10/orders.json?limit=5&updated_at_min=2019-07-19T00:04:46Z&status=open*)

 

yashrastogi2020
Shopify Partner
26 0 1
Hi Sam,

Following call should fetch the outcome on ascending order of
updated_at_min time:

*/admin/api/2019-10/orders.json?limit=5&updated_at_min=
2019-07-19T00:04:46Z&status=any&order=updated_at%20asc*)

What is wrong here?
yashrastogi2020
Shopify Partner
26 0 1
Hi Sam,

Date format is correct that we used, and we'd like to retrieve all orders
irrespective of the status of the order.
Not applicable

At the very end the last Params doesn’t look correct try removing it.

yashrastogi2020
Shopify Partner
26 0 1

Hi,

Then what is the way to retrieve the orders in an ascending order of updated_at_min time?

 

Regards,

Yash

yashrastogi2020
Shopify Partner
26 0 1

Hi Sam,

Can I get a quick reply on this, as a live customer is facing issues?

 

Regards,

Yash

yashrastogi2020
Shopify Partner
26 0 1
dancooke
Tourist
7 0 1

Hey Sam, 

 

Any idea how we can do this through Graph API? I'm really struggling to achieve a similar result using updated_at. 

 

Thanks!

 

Dan

 


{
orders (first: 1, query: "updated_at_min='2021-10-21T23:39:20Z'") {
edges {
node {
id
lineItems(first: 1){
edges {
node {
id
name
title
variant {
id
title
}
product {
id
title
}
vendor
sku

Not applicable

Hi @dancooke ,

 

I haven't used GraphQL so I wouldn't be helpful here. 

 

If you're not getting an error like 400 bad request and just getting an empty result set. Remember that without explicit approval from Shopify you will only be searching through orders that have been placed in the last 60 days. 

 

Hope this helps and see you all in 2022!

 

Best,

Sam