I try to fetch all products in bunches from the REST API in Magento 2.3.1:

GET http://example.local/rest/V1/products?searchCriteria[page_size]=100&searchCriteria[sortOrders][0][field]=updated_at&searchCriteria[sortOrders][0][direction]=ASC&searchCriteria[currentPage]=88000
Content-Type: application/json
Authorization: Bearer mybearer

I have 250 Products in the shop, still this request returns results. Shouldn't such a ridiculously high page number return an error or no results?


1 Answer 1


I my logic I was assuming, that Magento returns empty results in case the page is invalid / empty, so my script was fetching until $result['items'] is empty.

This is not the case.

So I changed my client like this:

if ($result['total_count'] < $result['search_criteria']['page_size'] * ($result['search_criteria']['current_page'] - 1)) {
    return null;

and bail out if null is returned.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.