I have created a custom REST API that return all review of products based on store id.


it returns output like-

[{"review_id":"345","created_at":"2018-08-16 08:03:19","entity_id":"1","entity_pk_value":"1705","status_id":"1","detail_id":"345","title":"Huge arm holes??","detail":"I don't know why the arm holes are so big. It looked ok in the photo but in person they're really wide. It's really comfortable but that bugs me.","nickname":"Valorie","customer_id":null},{...}..]

Now my question is how to implement search criteria on custom rest api.? actually i previously applied search criteria on predefined rest api but don't know how to implement on custom api.

Any help appreciated.

  • you can check magento CMS Page /V1/cmsPage/search
    – kunj
    Commented Aug 28, 2018 at 11:26

1 Answer 1


After lot of time spends,I solve my problem. In url pass parameter as-


now, in class where method is created use following code. First use \Magento\Framework\App\Request\Http request and initialize in cosnstructor.

protected $request;
    public function __construct(\Magento\Framework\App\Request\Http $request) {
       $this->request = $request;

Then read all parameters from request.It returns an array of parameters.

//Get All parameters from request

Then check each of parameters exist in url or not and apply filter using that parameters like-

                $collection=$collection->addFieldToFilter('entity_pk_value', ['eq' => $allParameters['productId']]);

where $collection is contains all result where filter need to apply.

$collection = $objectManager->get("Magento\Review\Model\ResourceModel\Review\CollectionFactory")->create();

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.