We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Re: How to Use ShopifyQL via GraphQL API for Analytics?

How to Use ShopifyQL via GraphQL API for Analytics?

ag05
Shopify Partner
7 0 1

Hi everyone,

I’m building a Shopify app and want to use ShopifyQL for analytics data. I’m familiar with running Shopify GraphQL queries (using Insomnia), but I’m unsure how to properly query ShopifyQL through the API.

Specifically, I’d like to know:

  1. What GraphQL endpoint should I use for ShopifyQL queries?
  2. How should the query structure look (e.g., variables, syntax differences from standard GraphQL)?
  3. Are there any examples or best practices for querying ShopifyQL via GraphQL?

Here’s an example of a ShopifyQL query I’d like to run for sales over time

 

 

query {
  shopifyqlQuery(query: "FROM sales SHOW total_sales BY day SINCE -30d") {
    results {
      data
    }
  }
}

 

I’d appreciate any insights or examples!

Thanks in advance!

Replies 3 (3)

ag05
Shopify Partner
7 0 1

Does this way is possible ?

AlexTo93
Visitor
1 0 0

I have a same question like yours but couldnt find any relevant source.

marvinbaltazar
Shopify Partner
10 0 0

Same problem I am having right now. We just want to get the monthly totals for the Gross Sales, Discounts, and Returns.

Currently we have to use the Admin API to fetch individual Order data, then aggregate the numbers from there.

 

It feels like doing order-based fetching is a waste of resources on Shopify's end (and the API consumer) since we only need the totals. In the Admin Analytics UI, you can query using ShopifyQL, but from searching I don't think this is possible using the Admin GraphQL API.