API query to grab all orders within the last 7 days?

BHemann
Tourist
6 0 2

I am trying to create an api query that will grab all orders within the last 7 days. However, I cannot figure this out. I have found repeated examples of grabbing orders using created_at. But that does not appear to work as I'd need to enter specific dates. 

When I go to my dashboard on Shopify, I can grab orders within the last week and this is the url for that: 

/admin/orders?inContextTimeframe=today&processed_at=past_week

I have been unsuccessful in getting this to work in an api query and am curious if anyone knows a way. 

Replies 2 (2)

designsimply
Tourist
5 1 0

What *exactly* did you try in your api query?

 

I just tested this GraphQL query 

{
  orders(first: 99, query: "processedAt:>=past_week") {
    edges {
      node {
        name
        processedAt
      }
    }
  }
}

at https://shopify.dev/graphiql/admin-graphiql

 

and I also tried also using the same query with curl on my shop locally and it worked in my tests.

Gordon_Chan
Shopify Expert
28 2 22

This shall only return the 99 orders of last week, I believe he wants if there were 99+ orders, what should be done. It shall require to keep query the pagination. (And I am also exploring this as well~)

http://gordon-chan.net
I am a Freelance Web Engineer. Dedicated my life to e-commerce development.