Posted in:
Magento REST API
Magento 2 get customer by email using REST API
This Blog instructs you that how to get Customer by email using REST API. In Magento 2, You can get the corresponding Customer details by using following commands.
$magento_url = 'YOUR_MAGENTO_BASE_URL';
$magento_token = 'TOKEN';
If you don’t know how to get token then you must see this blog post Magento 2 GET REST API
$id = "1"; // Magento CUSTOMER_ID
$ch = curl_init($magento_url . "/rest/all/V1/customers/".$id);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Authorization: Bearer " . $magento_token));
$product = curl_exec($ch);
$product = json_decode($product, 1);
print_r($product);
exit;
OutPut
Array
(
[id] => 27
[group_id] => 1
[default_billing] => 76
[default_shipping] => 76
[created_at] => 2020-10-21 07:55:16
[updated_at] => 2021-02-20 10:20:44
[created_in] => Admin
[dob] => 1989-12-12
[email] => [email protected]
[firstname] => Vish
[lastname] => V
[gender] => 1
[store_id] => 1
[taxvat] => 5598756
[website_id] => 1
[addresses] => Array
(
[0] => Array
(
[id] => 76
[customer_id] => 27
[region] => Array
(
[region_code] => ON
[region] => Ontario
[region_id] => 74
)
[region_id] => 74
[country_id] => CA
[street] => Array
(
[0] => Drew Road
)
[telephone] => 1234567890
[postcode] => L4T 2Z2
[city] => Mississauga
[firstname] => Vish
[lastname] => Va
[vat_id] => 111122588
[default_shipping] => 1
[default_billing] => 1
)
)
[disable_auto_group_change] => 0
[extension_attributes] => Array
(
[is_subscribed] =>
)
[custom_attributes] => Array
(
[0] => Array
(
[attribute_code] => authnetcim_profile_version
[value] => 100
)
)
)
February 22, 2021
Did you like this post?