Get All orders for a store

Highlighted
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?

0 Likes
Highlighted
Shopify Partner
3 0 3

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

2 Likes
Highlighted
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"

 

0 Likes
Highlighted
Shopify Expert
9930 105 1766

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).

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Highlighted
Tourist
8 0 1

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'));
0 Likes