Magento REST API Search Criteria

Search criterias can be added to GET request API to get required data from magento.

The basic pattern for specifying the criteria is:

 searchCriteria[filter_groups][][filters][][field]=<field_name>
 searchCriteria[filter_groups][][filters][][value]=<search_value>
 searchCriteria[filter_groups][][filters][][condition_type]=<operator>

where:
 field is an attribute name.
 value specifies the value to search for.
 condition_type is one of the following values: 

 CONDITION    NOTES
  eq          Equal
 finset       A value within a set of values
 from         The beginning of a range. Must be used with to.
 gt           Greater than
 gteq         Greater than or equal
 in           In. The value can contain a comma-separated list of values.
 like         Like
 lt           Less than
 lteq         Less than or equal
 moreq        More or equal
 neq          Not equal
 nfinset      A value that is not within a set of values.
 nin          Not in. The value can contain a comma-separated list of values.
 notnull      Not null
 null         Null
 to           The end of a range. Must be used with from.

Sample API:

https://magento-587202-1913612.cloudwaysapps.com/rest/all/V1/orders?searchCriteria[filterGroups][0][filters][0][field]=created_at&searchCriteria[filterGroups][0][filters][0][value]=2021-06-28 00:00:00&searchCriteria[filterGroups][0][filters][0][conditionType]=gt;

This API retrieve the orders created from 28-06-2021 from magento store.

Leave a comment

Your email address will not be published. Required fields are marked *