I use this API to fetch the visible products using the filter:
Is there a better way to search from the REST API ? This URL will become really big in case of increased search terms, for instance, If I query for 10 SKU names.
filterhttp-requestmagento2restsearch-criteria
I use this API to fetch the visible products using the filter:
Is there a better way to search from the REST API ? This URL will become really big in case of increased search terms, for instance, If I query for 10 SKU names.
Best Answer
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 forrest/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
orPUT
endpoing in your module (VendorName/ModuleName/etc/webapi.xml
). Then you should be able to specify filters in request body.