I want to access specified product list. for example access all the products in Jacket's category.
2 Answers
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" }'
-
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