FROM CACHE - en_header

admin api can't get more than last 500 orders

New Member
2 0 0

I'm working on creating two reports.

  1. daily orders for any date range given by our users ( here I see we can only get the last 60 days)
  2. daily sales from orders for any date range (we only expect to get 60 days worth of data because of same reason mentioned above)

We highly prefer to not have to store all orders for our users as there's more room for error which will make inconsistencies between our product and yours. We essentially just want to mimic the reporting functionality of /admin/dashboards of a shopify account. Specifically we're interested in mimicking the data shown in Total Sales and Total Orders. Our customers don't want to only have to look in their Shopify dashboard because we report on other analytics their business might find useful outside of shopify.


We are having trouble successfully getting more than 500 orders using /admin/api/2020-04/orders.json?status=any endpoint. I've tried with and without status parameter as well as using created_at_max and created_at_min. I've also tried paginating using the since_id parameter as well as using the response header which links to the next data set.


According to API documentation the response header link is the preferred way to currently paginate, so I will go over our issue doing this.

The first endpoint we hit is /admin/api/2020-04/orders.json?status=any&limit=250 (I've tried without status param and same result). The response successfully gives us the next link which we use to query another 250 set of orders. At this point everything is working as expected, but when we use the new link header (yes it says rel="next") in the following request (this would be 3rd request) we get a response with orders that are identical to what we received from our first response. Then when we grab header link and make another request we get the same values as second request. Paginating is essentially looping us through the first 500 orders over and over again. 


I see there is also the endpoint /admin/api/2020-04/orders/count.json but it doesn't give the daily breakdown for the date range given. (This would be a very useful addition) Since we have customers who make anywhere from 0-10,000+ orders a day, having to make an API request for each day seemed like it was unneeded and a bad practice for using the API endpoint. Also, this endpoint wouldn't help with #2 above of what we're trying to accomplish. 


Is it known you can't paginate more than 500 orders without being looped? I can put my code below for proof and then it can be tested with as needed. 


$obj = array();
	$page = 1;
	$continue = true;
    $endpointo = "https://<shopifystore>";

	while($page <= $pages && $continue)
	    $continue = false;

		$output = process_curl(array(
			CURLOPT_URL => $endpointo,
			CURLOPT_HEADER => true,
			CURLOPT_HTTPHEADER => array('X-Shopify-Access-Token: '.$token),

            $lines = explode("\r\n", $output);

            foreach($lines as $index => $line)
                if(strpos($line, 'link:') !== false && strpos($line, 'rel="next"') !== false)
                    $endpointo = $line;
                    $endpointo = substr($endpointo, strpos($endpointo, '<')+1);
                    $endpointo = substr($endpointo, 0, strpos($endpointo, '>'));

                    $continue = true;
                elseif($index === count($lines) - 1)
                    $obj[$page] = json_decode($line);
			return false;


	return $obj;




Replies 4 (4)
New Member
2 0 0

I'm having the same problem using 2021-01; less than 500 depending on whether I set a limit lower than 250 in my query string. 

My setup is a private app synching shopify sales down to brick and mortar store database, which is the system of record for inventory management. Normally this won't be a problem, as the synch process will happen multiple times daily and bump the updated_at_min value with every synch, but based on some cursory testing, the orders are not sequenced by the updated_at value, so there isn't a way to guess the missed orders, and bumping my updated_at value to the max returned timestamp means they're just missed.

Is there a better place to report the bug?

New Member
2 0 0

Could I please get some direction? It's been almost a year and we still can't figure out the best way to get all orders. As person above said we'd really not like to store them. Since this data is easily available in Shopify UI I'd expect getting this data via the API would also be very easy. It's odd that these endpoints used to work fine for reporting but now they don't

New Member
1 0 0

Shopify API are so bad when you need to fetch all records, I tried doing it with since ID it worked nicely for items but for customers it just kept me looping through the records

8 0 1


It took some time for me as well to get this going... but I got it working in the end. It was a few months back and we have a backend in Typescript, but this is what we do:

First request:
"https://" + SHOP_URL + "/admin/api/" + SHOP_VERSION + "/orders.json?limit=250&created_at_min=2021-02-01T00:00:00Z";

Then in response:

if(headers['Link']) {
links = headers['Link'].split("page_info=");
pageInfo = links[(links.length-1)].split(">;")[0];

In the next response our URL is:
"https://" + SHOP_URL + "/admin/api/" + SHOP_VERSION + "/orders.json?limit=250&page_info=" + pageInfo;
See the pageInfo variable above...

So without the created_at_min, but with the limit... I think that was the trick....

Regards, Peter