Shopify API - Searches for customers that match a supplied query using Postman

Shopify API – Searches for customers that match a supplied query using Postman

During the process of taking care of customers, the owner always needs the data of customers that match a supplied query like country, city, order count, etc. This data will help every shop owner know where the customers are, what the customers want, and the customers’ shopping habits. Thanks to this data, store owners will have better strategies to attract customers. Because of the reasons above, Beehexa will show you how to search for customers that match a supplied query. 

Now, let’s explore this subject a little deeper. 

If this is the first time you make a call in the Postman, you must generate API credentials from the Shopify admin

Step 1: Generate API Credentials From Shopify Admin

Follow the process in How to build a custom app for Shopify in 2022? to know how to access Shopify API. 

  • After creating an app, remember the Admin API access token and the API key to send a GET request in the Postman. 

Step 2: Searches for customers that match a supplied query using Postman

In Shopify API, you can query multiple customers’ information in one call. The API will return all customers that match many supplied queries. 

The list below are supported queries:

accepts_marketing, activation_date, address1, address2, city, company, country, customer_date, customer_first_name, customer_id, customer_last_name, customer_tag, email, email_marketing_state, first_name, first_order_date, id, last_abandoned_order_date, last_name, multipass_identifier, orders_count, order_date, phone, province, shop_id, state, tag, total_spent, updated_at, verified_email, product_subscriber_status. All other queries returns all customers.

Now, we are ready to search for customers that match a supplied query using Postman. 

  • Log in to your Postman and create a new workspace
  • Then, create a new GET with this URL:
https://{API_key}:{admin_API_access_token}@{shop}.myshopify.com/admin/api/{api-version}/{resource}
Code language: JavaScript (javascript)
  1. {API_key} – The API key that you generated.
  2. {admin_API_access_token} – The admin API access token that you generated.
  3. {shop} – The name of your development store.
  4. {api-version} – The supported API version that you want to use.
  5. {resource} – A resource endpoint from the REST Admin API.

In this example, Beehexa will search for customers with an address in Viet Nam and the name “Hoai”.

You can copy this example, remember to change [resource] to [customers/search.json?query=Hoai+country:vietnam]:

https://ed86d512a2c95387ffa25f67074a222b:[email protected]/admin/api/2021-10/customers/search.json?query=Hoai+country:vietnam
Code language: JavaScript (javascript)
searches for customers that match a supplied query using postman

The maximum number of results to show ≤ 250, default 50

Then clicks on send

Response: The API will return the data like this. 

{ "customers": [ { "id": 5484387270719, "email": "[email protected]", "accepts_marketing": false, "created_at": "2021-11-08T18:13:34+09:00", "updated_at": "2022-03-18T18:28:36+09:00", "first_name": "Hoai", "last_name": "Lam", "orders_count": 5, "state": "enabled", "total_spent": "200315.20", "last_order_id": 4341526331455, "note": null, "verified_email": false, "multipass_identifier": null, "tax_exempt": false, "phone": null, "tags": "", "last_order_name": "#1247", "currency": "AUD", "addresses": [ { "id": 6705218158655, "customer_id": 5484387270719, "first_name": "Hoai", "last_name": "Lam", "company": "Beehexa", "address1": "20 Le Loi", "address2": "", "city": "Hue", "province": null, "country": "Vietnam", "zip": "52000", "phone": "0373289426", "name": "Hoai Lam", "province_code": null, "country_code": "VN", "country_name": "Vietnam", "default": false }, { "id": 6833735827519, "customer_id": 5484387270719, "first_name": "Yushin", "last_name": "Lam", "company": "Beehexa", "address1": "1925 Washington Street", "address2": "", "city": "Hollywood", "province": "Florida", "country": "United States", "zip": "33020", "phone": "(361) 386-5113", "name": "Yushin Lam", "province_code": "FL", "country_code": "US", "country_name": "United States", "default": false }, { "id": 6925741523007, "customer_id": 5484387270719, "first_name": "Hoai", "last_name": "Lam", "company": "ABC", "address1": "2089 Hidden Pond Road", "address2": "", "city": "Vanleer", "province": "Tennessee", "country": "United States", "zip": "37181", "phone": "6157634093", "name": "Hoai Lam", "province_code": "TN", "country_code": "US", "country_name": "United States", "default": false }, { "id": 6925959004223, "customer_id": 5484387270719, "first_name": "Hoai", "last_name": "Lam", "company": "ABC", "address1": "2089 Hidden Pond Road", "address2": "", "city": "Vanleer", "province": "Tennessee", "country": "United States", "zip": "37181", "phone": "(615) 763-4093", "name": "Hoai Lam", "province_code": "TN", "country_code": "US", "country_name": "United States", "default": false }, { "id": 6947645325375, "customer_id": 5484387270719, "first_name": "Yushin", "last_name": "Lam", "company": "Beehexa", "address1": "1921 Washington Street", "address2": "", "city": "Corpus Christi", "province": "Texas", "country": "United States", "zip": "78476", "phone": "13613865113", "name": "Yushin Lam", "province_code": "TX", "country_code": "US", "country_name": "United States", "default": false }, { "id": 6955568398399, "customer_id": 5484387270719, "first_name": "Yushin", "last_name": "Lam", "company": "Beehexa", "address1": "1921 Washington Street", "address2": "", "city": "Corpus Christi", "province": "Texas", "country": "United States", "zip": "78476", "phone": "1 (361) 386-5113", "name": "Yushin Lam", "province_code": "TX", "country_code": "US", "country_name": "United States", "default": true } ], "accepts_marketing_updated_at": "2021-11-08T18:13:35+09:00", "marketing_opt_in_level": null, "tax_exemptions": [], "sms_marketing_consent": null, "admin_graphql_api_id": "gid://shopify/Customer/5484387270719", "default_address": { "id": 6955568398399, "customer_id": 5484387270719, "first_name": "Yushin", "last_name": "Lam", "company": "Beehexa", "address1": "1921 Washington Street", "address2": "", "city": "Corpus Christi", "province": "Texas", "country": "United States", "zip": "78476", "phone": "1 (361) 386-5113", "name": "Yushin Lam", "province_code": "TX", "country_code": "US", "country_name": "United States", "default": true } } ] }
Code language: JSON / JSON with Comments (json)
searches for customers using postman

The above are all steps to search for customers that match a supplied query using Postman with Shopify API. If you have any questions, please leave a comment below or refer to our Shopify api documentation.

These steps will be shown visually in the video below.

Shopify API – Searches for customers that match a supplied query using Postman

Hopefully, you can do it!

Shopify API - Searches for customers that match a supplied query using Postman

Shopify API – Searches for customers that match a supplied query using Postman

Join The Ride

Subscribe to our fortnightly newsletter with stories from our latest adventures and the best travel tips

Table of Contents