It is better to use search API (rest/V1/search
), is faster because based on index tables, and then load full information about products returned from search using product repository (rest/V1/products
).
You would have a list of product IDs returned by search API and in
filter can be used when creating search criteria for rest/V1/products
, this will make URL shorter. However, request URL for Search API would still be long.
There is no way to reduce URL length except for introducing alternative POST
or PUT
endpoing in your module (VendorName/ModuleName/etc/webapi.xml
). Then you should be able to specify filters in request body.
<?xml version="1.0"?>
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">
<route url="/V1/searchProducts" method="POST">
<service class="Magento\Catalog\Api\ProductRepositoryInterface" method="getList"/>
<resources>
<resource ref="anonymous" />
</resources>
</route>
</routes>
Best Answer