How can I retrieve all customer emails from API with specific name criteria?

Hi,

I am new at shopify, I need to get all the customers email who’s first name contain “www”. I have more than 4000 customers. I am using following query.

[Storename].myshopify.com/admin/customers/search.json?query=www.cutt&fields=email,id,first_name,last_name

Regards
Saleem

Hey @ksaleem

Search API allows you to do only a full-text search (in all customer fields). In this case, your request URI has to look like this:

https://test.myshopify.com/admin/api/2021-07/customers/search.json?query=www&fields=email,id,first_name,last_name

Alternatively, you can do a search in the first name, but it only return results that are full-match to your query (case insensitive). So you will get only customers whose first name is www. The request URI looks like this:

https://test.myshopify.com/admin/api/2021-07/customers/search.json?query=first_name:www&fields=email,id,first_name,last_name

Also, keep in mind that customer search API endpoint uses pagination.