cancel
Showing results for 
Search instead for 
Did you mean: 

REST API Get customer by email

REST API Get customer by email

Hi, 

I'd like to get the profile of a customer from their email address. 

 

The REST API doc says I can do this:

GET http://magentohost/api/rest/customers

 

Is it possible to use filters to get the customer using the email? For instance something like this: 

GET http://magentohost/api/rest/customers?email=name@company.com

 

 

Thanks! 

 

2 REPLIES 2

Re: REST API Get customer by email

Hi Romain, Yes, definitely you can dot that add customer email filter. Actually this is not included in Magento2 default rest api, you have to create your own or feel free to contact us for any customization in Magento2.

Re: REST API Get customer by email

Yes, I think you can.

in http://devdocs.magento.com/swagger/index_20.html#/

go to:

customerCustomerRepositoryV1

and use:

GET /V1/customers/search

 

This retrieve customers with match a specified criteria.

For criteria parameters, you should use:

searchCriteria[filtergroups][][filters][][field]   - > Name of the field (in your case 'email')  

searchCriteria[filtergroups][][filters][][value]   - > Name of the field (in your case 'mail@domain.com')  - > field value

searchCriteria[filtergroups][][filters][][conditiontype]   - > Name of the field (in your case 'eq')  - > equals

 

The code depends on if you are using PHP, C# or ASP.NET...

 

Good Luck!