3

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

asked Sep 17, 2018 at 11:18

1 Answer 1

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][email protected]&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 [email protected] 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://developer.adobe.com/commerce/webapi/rest/use-rest/performing-searches/

I hope this helps.

answered Sep 18, 2018 at 8:30
4
  • 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][email protected] it works fine Commented Sep 18, 2018 at 10:46
  • Do you know how to get wish list of specific user in magento 2 REST API Commented Sep 18, 2018 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. Commented Sep 18, 2018 at 11:40
  • Remember to add the admin auth token on the request. And also note that this doesn't work for a customer's token. Commented Sep 14, 2022 at 1:34

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.