An ERP integration with the shop via REST API was getting slower over time. Fetching the orders list via API took 45 seconds. The endpoint was returning the entire order history instead of the last 24 hours. Fix time: 3 hours.
Symptoms
- GET
/rest/V1/orderstakes more than 30 seconds - JSON response size is 50MB+
- ERP integration times out
Cause
API call without a date filter and without pageSize was fetching all orders from the shop’s history. 500,000 records serialised to JSON = 50MB response, 45 seconds processing.
Solution
# Always use filters and pageSize
GET /rest/V1/orders?searchCriteria[filter_groups][0][filters][0][field]=created_at
&searchCriteria[filter_groups][0][filters][0][value]=2026-07-24T00:00:00
&searchCriteria[filter_groups][0][filters][0][condition_type]=gteq
&searchCriteria[pageSize]=100
&searchCriteria[currentPage]=1
<?php
$searchCriteria = $this->searchCriteriaBuilder
->addFilter('created_at', date('Y-m-d', strtotime('-24 hours')), 'gteq')
->addFilter('status', ['pending', 'processing'], 'in')
->setPageSize(100)
->setCurrentPage(1)
->create();
$orders = $this->orderRepository->getList($searchCriteria);
Takeaways
Every Magento REST API request must have pageSize and filters. No pageSize = loading the entire table. Monitor API response sizes – if it exceeds 1MB that is a signal something is wrong with filtering.
