Get a Total number of customers in the store using GraphQl Admin API

I’m trying to get a total number of customers in the store or all the customer list id’s in the store using GraphQl admin API, Can anyone give solution for this?

Hi @bootsgridDev

graphql does not have such an api, use the rest api.

https://shopify.dev/docs/api/admin-rest/2024-10/resources/customer#get-customers-count

Hi,there

all the customer list ids. pls refer to below code

query GetAllCustomerIDs {
     customers(first: 250) {
       edges {
         node {
           id
         }
       }
       pageInfo {
         hasNextPage
         endCursor
       }
     }
   }

hi @Eric-HAN

const res = await fetch(‘shopify:admin/api/graphql.json’, {
method: ‘POST’,
body: JSON.stringify({
query: query { customersCount{ count } }
}),
});
const data= await res.json();
const customerCount= data.data.customersCount.count;

I have got total number of customers using this query , IT might help someone. thank you.

Hi @Kyle_liu

Thankyou, Please refer my solution.