Get All orders for a store

Michael_L_
New Member
2 0 0

I'm working with a store that does around 70 - 100k orders a month and when i try to query orders using date collars on "updated_at_min" and "updated_at_max" I only get around 200 orders per day, which doesn't work out. 

 

How would one retrieve all orders for a store?  I'm using 

 

https://<store>.myshopify.com/admin/orders.json?created_at_min=2018-06-19T00:00:00-04:00&created_at_...

 

as an example, and I'm getting 0 orders in response, when if I look at the same orders from ship hero I see 748 orders.

 

How do I get actual API support from shopify? Are these forums the only way?

Replies 9 (9)
Muhammad_Rafi_Q
Shopify Partner
3 0 5

Hi, I am a developer and understand your issue. The Shopify API actually a max of 250 order per request. So you get  250 orders, you have and note the id of the last order. 

Now make another request and put the last id of the previous request in since_id parameter
see example below
let's say you made a request, Shopify returned 250 orders and the id of the last order is 5600250, so now you have to make another request and put this 5600250 in since_Id parameter 
like this

https://{yourapikey}:{yourapikey}@s{yourstore}/admin/orders.json?limit=250&since_id=5600250

Repeat this until you get no order. I can solve your code if you need my help.

Regards 
Muhammad Rafi QureshiDeveloper

DanielTkach
Tourist
4 0 0

I'm getting only 8 random orders regardless of what I try...

 

/admin/orders.json?fields=id,email,line_items?limit=100"

 

Jason
Shopify Expert
10882 190 2180

Let's start with your url formatting to start with. It's wrong as you have two ? in your url. There should be only one to indicate the start of the querystring.
eg:

/admin/orders.json?fields=id,email,line_items&limit=100

 

Now why you're getting 8 is less likely down to that. Consider adding the status parameter in there as well (see the docs).

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★
ChuckWatson
Excursionist
21 2 2

In case someone else is looking here, "page" is not a valid variable to send which is why no results return.

Also note, when pulling orders using date and not using since_id - you get the last 250 orders of the day, not the first.

The way I get data when there are more than 250 orders in a day is get the id of the last order of the day before and run a loop using since_id and limit 250 until I get less than 250 results. I combine the results on each loop for a complete set of orders.

This is using PHP

$orders = $shopify('GET', '/admin/api/2019-10/orders.json', array('status'=>'any','created_at_min'=>PREVIOUS DAY START,'created_at_max'=>PREVIOUS DAY END,'limit'=>1,'fields'=>'id'));

then query using since_id (i use a do while loop to update the since_id and get the next chunk of orders)

$orders = $shopify('GET', '/admin/api/2019-10/orders.json', array('since_id'=>$sinceid,'created_at_min'=>YESTERDAY START,'created_at_max'=>YESTERDAY END,'limit'=>250,'fields'=>'id,order_number,line_items'));
There's no meat in this?
tomboltman
New Member
4 0 0

Hi.

Is there any other way to fetch order list without using shopify API?

If you have a solution, please let me know.

Thank you.

ChuckWatson
Excursionist
21 2 2

no there is not

There's no meat in this?
jw_pei
New Member
13 0 0

您可以用Python编写访问所有订单的代码吗?谢谢

HD_WORK
New Member
20 0 0

@ChuckWatson 

yeah i thick it will be a great way to it so

can you please share a complete code as because i tried but i failed to create a complete set of orders in form of array ???


it will be a great help 

thank you 

abdul81
Excursionist
14 1 0

There is no way to do it! Since all data is stored with Shopify, you have to use secure Shopify endpoints to retrieve any available recourses. Ex: Orders, products, collections etc....

Product Manager at Developer's Capital