2

I want to access specified product list. for example access all the products in Jacket's category.

1
  • Have you try and code? Or you want know from scratch? Commented Jan 9, 2018 at 13:31

2 Answers 2

8

You can get the list of products of specific categories using search criteria concept of rest api.

Below is the url for that .

www.yoururl/rest/V1/products?searchCriteria[filterGroups][0][filters][0][field]=category_id& searchCriteria[filterGroups][0][filters][0][value]=2& searchCriteria[filterGroups][0][filters][0][conditionType]=eq&searchCriteria[sortOrders][0][field]=created_at& searchCriteria[sortOrders][0][direction]=DESC& searchCriteria[pageSize]=10& searchCriteria[currentPage]=1

Here i am getting products which having category id : 2

Here Id 2 is for jacket.

Same way you can pass your category id with the given criteria.

Authorization Header

Remember to inform the Authorization header.
It must contain Bearer + admin token.
The admin token can be obtained with the following request: curl -X POST 'https://YOURMAGENTOURL.com/index.php/rest/V1/integration/admin/token' \ -H 'Content-Type: application/json' \ --data-raw '{ "username": "YOURADMINUSERNAME", "password": "YOURADMINPASS" }'

2
  • 1
    Can you please elaborate in details..
    – Ashwini
    Commented Jul 30, 2018 at 13:28
  • @AdityaShah - Happy to help and keep helping :) Commented Aug 10, 2018 at 6:23
1

You can use the dedicated REST API from Magento 2. Your need can be satisfied by calling following URL:

http://yoururl/rest/V1/categories/$categoryId/products

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.