A union of curiosity and data science

Knowledgebase and brain dump of a database engineer

Magento 2 API Product Get

Create a token in Magento Admin. System > Integrations > (Create a integration) or edit an existing integration and get the token. 


//Authentication rest API magento2.Please change url accordingly your url
$headers = array("Authorization: Bearer <token value>");

$requestUrl='https://www.site.com/index.php/rest/V1/products/<your sku>';

$ch = curl_init($requestUrl);

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$result = curl_exec($ch);
$result=  json_decode($result);

if (curl_errno($ch)) {
   print curl_error($ch);





Add comment