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:
| Scope | Purpose |
|---|---|
read_reports | Access to analytics and reporting data. |
read_customers | Access to customer data in queries. |
read_customer_address | Access to customer address information. |
read_customer_email | Access to customer email addresses. |
read_customer_name | Access to customer names. |
read_customer_phone | Access to customer phone numbers. |
Anchor to API response formatAPI response format
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": []
}
}
}
Anchor to Rate limitingRate limiting
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
Anchor to Next stepsNext steps
Was this page helpful?