Jimmy A. León
Jimmy A. León

Reputation: 561

Get specific product with id via Rest API Magento 2

I want to get the information from an specific product.

I am using this reference in this moment, and get all the products in given searchCriteria:

http://www.mysite.co/rest/V1/products-render-info?storeId=1&currencyCode=cop

Is there a way I can send the product id in the url and get only all its information?

Upvotes: 2

Views: 4417

Answers (2)

Sagar Pise
Sagar Pise

Reputation: 887

You can add the filter

http://www.mysite.co/rest/V1/products?searchCriteria[filterGroups][0][filters][0][field]=entity_id&searchCriteria[filterGroups][0][filters][0][value]=1&searchCriteria[filterGroups][0][filters][0][condition_type]=eq

use field entity_id instead of id, value is product id here 1, condition_type is equal to here eq.

Upvotes: 1

Milan Chandro
Milan Chandro

Reputation: 2483

You can fetch product info by SKU, not ID.

API endpoint (get method) will pull product info. vendor/magento/module-catalog/etc/webapi.xml

/V1/products/:sku

So, your rest API calling URL should be like this

http://www.mysite.co/rest/V1/products/productsku

Note: If you want to fetch product info by id, you probably need to create a simple rest API. you can check this out. https://magento.stackexchange.com/questions/282480/i-am-new-here-i-want-to-know-how-can-i-create-my-own-simple-api/282730

Upvotes: 0

Related Questions