The only way to get customers total count by a specific tag using Shopify REST API is to fetch all of them using pagination and then actually count them.
You can also do so without using the API (if it suits you) by filtering customers in the admin panel and then exporting the result using the “search” option in the export dialogue window, view example.
Drip has suggested the right way. but if you have more than 250 results then you will defensively need to loop through the pages.
with the updated Shopify Rest APIs they are facilitating the cursor based pagination and each response header you will get information about the nextPage if it exists.
3
Answers
You can use a query to get all the customers with a specific tag.
Example:
/admin/customers/search.json?query=tag:wholesale
From there you can count the items from the array.
The only way to get customers total count by a specific tag using Shopify REST API is to fetch all of them using pagination and then actually count them.
You can also do so without using the API (if it suits you) by filtering customers in the admin panel and then exporting the result using the “search” option in the export dialogue window, view example.
Drip has suggested the right way. but if you have more than 250 results then you will defensively need to loop through the pages.
with the updated Shopify Rest APIs they are facilitating the cursor based pagination and each response header you will get information about the nextPage if it exists.
For more detail on this read
i can not able to get page_info using shopify Api
and in the coding you can do something like below, you can keep count or push data in empty array.
for whole on cursor based pagination have a look here
How to create pagination in shopify rest api using php