3

In Magento2 How can i get the list of orders placed by specific user using REST API ?

2

http://yourdomain/rest/V1/orders?searchCriteria[filterGroups][0][filters][0][field]=customer_id&searchCriteria[filterGroups][0][filters][0][value]=2&searchCriteria[filterGroups][0][filters][0][conditionType]=eq

OK, so what is this?

The endpoint for getting orders is: http://yourdomain/rest/V1/orders

Make sure you change "yourdomain" to your actual domain.

This endpoint is reached by GET.

Next, the so called searchCriteria is a mandatory field to send to this endpoint.

So, the rest of the URL pretty much sets

  • filter groups: [filterGroups][0] means this is the filterGroup with id 0, i.e. the first one
  • filters: [filters][0] means this is the first filter within the filterGroup
  • and for each filter we set [field], [value] and [conditionType]. By this triplet in my example I have set that the filter be based on the customer_id and that it should try to match it (using:eq) to value 2

Another example

http://yourdomain/rest/V1/orders?searchCriteria[filterGroups][0][filters][0][field]=customer_email&searchCriteria[filterGroups][0][filters][0][value]=myname@gmail.com&searchCriteria[filterGroups][0][filters][0][conditionType]=eq

Here, the query is to look for a customer by email. field is set to customer_email, value to myname@gmail.com and conditionType to eq

You can, of course, do combinations of multiple filters and logical AND, and logical OR are possible for different fields.

This link gives even more details

https://devdocs.magento.com/guides/v2.2/rest/performing-searches.html

I hope this helps.

  • iam using http://www.depoto.com/Beta/rest/V1/orders?searchCriteria[filter_groups][0][filters][0][field]=customer_email&searchCriteria[filter_groups][0][filters][0][value]=test@gmail.com it works fine – Pratap Penmetsa Sep 18 '18 at 10:46
  • Do you know how to get wish list of specific user in magento 2 REST API – Pratap Penmetsa Sep 18 '18 at 10:51
  • It's hard for me to believe as well, but the Wishlist module has no web api at all. This link show what is available per module devdocs.magento.com/guides/v2.2/rest/rest_endpoints.html. So, you will need to build your own service to query for wishlist items. – Marjan Sep 18 '18 at 11:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.