d
Topic
jsaya Member
Posts:
22
12 days ago

Getting 550+ orders for net 30 days.

Hello does anyone have an efficent way to get bulk orders for the last 30 days?

We are using this informaiton to structure our billing and the time it takes to retrieve the amount of orders on big stores makes it seem like the app loads are going to time out. 

We are currently using the following:

 

        for p in range(1, 4):
            order_get = shopify.Order.find(created_at_min=start_date, page=p, status='any', limit=250)
            total_orders += len(order_get)

Any help would be awesome thanks!

i
Replies
Busfox Shopify Employee
Posts:
304
12 days ago

Hi Jsaya,

Finding orders by created_at is going to be fairly inefficient from a performance view. I'd recommend using since_id. Basically, you want to use an existing known order_id as a start point. Order created since the one you are including will be returned. You can then use the last order_id as the new since_id value. It can be used like so: 

/admin/orders.json?since_id=123

If the last id returned is 173, then your next call would look like this:

/admin/orders.json?since_id=173

This way you don't need to worry about pagination.

Cheers,

Andrew McCauley | Developer Experience @ Shopify | 1-888-746-7439