In Magento2 How can i get the list of orders placed by specific user using REST API ?
1 Answer 1
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_idand that it should try to match it (using:eq) to value2
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.
-
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 finePratap Penmetsa– Pratap Penmetsa2018年09月18日 10:46:07 +00:00Commented Sep 18, 2018 at 10:46 -
Do you know how to get wish list of specific user in magento 2 REST APIPratap Penmetsa– Pratap Penmetsa2018年09月18日 10:51:43 +00:00Commented 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.Marjan– Marjan2018年09月18日 11:40:52 +00:00Commented 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.Ricardo Martins– Ricardo Martins2022年09月14日 01:34:27 +00:00Commented Sep 14, 2022 at 1:34