Skip to main content

ShopifyQL with the GraphQL Admin API

You can send ShopifyQL queries via the GraphQL Admin API, allowing you to build reporting directly into your apps or programmatically extract data for further analysis.

Build apps that query analytics data programmatically using the shopifyqlQuery endpoint:

GraphQL query

{
shopifyqlQuery(
query: "FROM sales SHOW total_sales, orders SINCE last_week GROUP BY day ORDER BY day DESC"
) {
tableData {
columns {
name
dataType
displayName
}
rows
}
parseErrors
}
}

Anchor to Required access scopesRequired access scopes

To use the ShopifyQL API, your app requires the following access scopes:

ScopePurpose
read_reportsAccess to analytics and reporting data.
read_customersAccess to customer data in queries.
read_customer_addressAccess to customer address information.
read_customer_emailAccess to customer email addresses.
read_customer_nameAccess to customer names.
read_customer_phoneAccess to customer phone numbers.

The API returns data in a structured JSON format:

JSON response

{
"data": {
"shopifyqlQuery": {
"tableData": {
"columns": [
{
"name": "day",
"dataType": "DAY_TIMESTAMP",
"displayName": "Day"
},
{
"name": "total_sales",
"dataType": "MONEY",
"displayName": "Total sales"
}
],
"rows": [
{ "day": "2024-01-15", "total_sales": "2547.83" },
{ "day": "2024-01-14", "total_sales": "1892.45" }
]
},
"parseErrors": []
}
}
}

The ShopifyQL API uses complexity-based rate limiting rather than fixed queries-per-second. Query complexity is determined by factors including:

  • Number of metrics requested
  • Number of dimensions in GROUP BY
  • Date range size
  • Use of comparisons and modifiers


Was this page helpful?