Happening now | Office Hours: Customizing Your Theme With Moeed | Ask your questions now!
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

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

Solved

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

bootsgridDev
Shopify Partner
32 1 3

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?

Accepted Solution (1)
bootsgridDev
Shopify Partner
32 1 3

This is an accepted solution.

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.

View solution in original post

Replies 4 (4)

Kyle_liu
Shopify Partner
437 55 80

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 

If this is helpful, please Like and Accept the solution.
Want to modify or custom changes on store? Let me help.
- Feel free to contact me Email Me Buy Me A Coffee
bootsgridDev
Shopify Partner
32 1 3

Hi @Kyle_liu 

 

Thankyou, Please refer my solution.

Eric-HAN
Shopify Partner
297 30 32

Hi,there

 

all the customer list ids. pls refer to below code

   query GetAllCustomerIDs {
     customers(first: 250) {
       edges {
         node {
           id
         }
       }
       pageInfo {
         hasNextPage
         endCursor
       }
     }
   }
- Helpful? Please hit Like and mark it as a solution
Want to modify or custom changes on store? Let me help.
- Feel free to Email Me    Buy Me A Coffee
bootsgridDev
Shopify Partner
32 1 3

This is an accepted solution.

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.