Skip to content

Reporting — Sales (GraphQL)

Returns the aggregate statistics that power the Bagisto admin Reporting → Sales screen — total sales, average order value, order counts, the purchase funnel, abandoned carts, refunds, tax and shipping collected, and the top payment methods.

Stats querystatsAdminReportingSales
View Details queryviewStatsAdminReportingSales
EndpointPOST /api/admin/graphql
ReturnsA single object: { entity, type, dateRange, statistics }

All admin endpoints require an admin Bearer token — see Authentication. Reporting has no permission gate; any authenticated admin can read it.

Understanding type — the Sales report is ten separate calls

This is the most important thing to understand about this API.

The Bagisto admin Sales report is not one response. The page is assembled from ten independent queries, one per panel, and each is selected with the type argument. These ten groups are exactly the panels of the admin Sales report screen — no more, no less.

So a single call returns one panel of the report. To render the full screen, query statsAdminReportingSales once per type (or only for the panels you need). The statistics payload changes shape per type — sometimes an object, sometimes a flat array — so always branch on type when consuming it.

Which type maps to which panel

Sales report panel (admin)typestatistics is
Total Sales charttotal-salesobject (with over_time series)
Average Sales chartaverage-salesobject (with over_time series)
Total Orders charttotal-ordersobject (with over_time series)
Purchase Funnelpurchase-funnelobject (no series; chart-only)
Abandoned Cartsabandoned-cartsobject (with a products list)
Refunds chartrefundsobject (with over_time series)
Tax Collectedtax-collectedobject (with top_categories + over_time)
Shipping Collectedshipping-collectedobject (with top_methods + over_time)
Top Payment Methodstop-payment-methodsarray
Sales By Couponsales-by-couponarray

total-sales is the default — if you omit type, you get the "Total Sales" panel.

Arguments

ArgumentTypeRequiredDescription
typeStringNoOne of the ten values above. Defaults to total-sales.
startString (YYYY-MM-DD)NoLower bound of the reporting window. Defaults to 30 days ago.
endString (YYYY-MM-DD)NoUpper bound. Defaults to today.
channelStringNoChannel code to scope the figures to a single channel. Defaults to all channels.

start / end drive both the current figures and the previous baseline used for each progress percentage — the previous period is the same-length window immediately before start.

Selection set

graphql
query AdminReportingSales($type: String, $start: String, $end: String, $channel: String) {
  statsAdminReportingSales(type: $type, start: $start, end: $end, channel: $channel) {
    entity
    type
    dateRange
    statistics
  }
}
  • entity — always "sales" for this query.
  • type — echoes back the requested panel.
  • dateRange — an object { previous, current } with a human-readable label for each window. This resolves correctly over GraphQL for the reporting queries.
  • statistics — a JSON scalar whose shape depends on type (documented below). Query it bare — it is a scalar, not a sub-selectable object.

Response shapes by type

Figures with a previous / current / progress shape are period comparisons: current is the chosen window, previous is the preceding window of equal length, and progress is the percentage change (can be negative). The over_time series is split into a previous and a current array, each carrying one bucket per day with { label, total, count }.

total-sales

KeyShapeMeaning
sales{ previous, current, formatted_total, progress }Gross sales for the window.
over_time{ previous: [{ label, total, count }], current: [...] }Per-day series for the chart. total is sales, count is order count.

average-sales

KeyShapeMeaning
sales{ previous, current, formatted_total, progress }Average order value for the window.
over_time{ previous: [{ label, total, count }], current: [...] }Per-day series for the chart.

total-orders

KeyShapeMeaning
orders{ previous, current, progress }Order count for the window (no formatted_total).
over_time{ previous: [{ label, total, count }], current: [...] }Per-day series for the chart.

purchase-funnel

Object only — no over-time series and no table (viewStatsAdminReportingSales) form.

KeyShapeMeaning
visitors{ total, progress }Store visitors.
product_visitors{ total, progress }Visitors who viewed a product.
carts{ total, progress }Carts created.
orders{ total, progress }Orders placed.

Each stage carries a single running total plus progress — there is no previous / current split here.

abandoned-carts

KeyShapeMeaning
sales{ previous, current, formatted_total, progress }Value left in abandoned carts.
carts{ previous, current, progress }Abandoned-cart count.
rate{ previous, current, progress }Abandonment rate (percent).
productsarray of { id, name, count, progress }Products most often left in abandoned carts.

refunds

KeyShapeMeaning
refunds{ previous, current, formatted_total, progress }Refunded amount for the window.
over_time{ previous: [{ label, total, count }], current: [...] }Per-day series for the chart.

tax-collected

KeyShapeMeaning
tax_collected{ previous, current, formatted_total, progress }Tax collected for the window.
top_categoriesarray of { id, tax_category_id, name, total, progress, formatted_total }Tax categories ranked by collected amount.
over_time{ previous: [{ label, total, count }], current: [...] }Per-day series for the chart.

shipping-collected

KeyShapeMeaning
shipping_collected{ previous, current, formatted_total, progress }Shipping charges collected for the window.
top_methodsarray of { id, title, total, progress, formatted_total }Shipping methods ranked by collected amount.
over_time{ previous: [{ label, total, count }], current: [...] }Per-day series for the chart.

top-payment-methods

statistics is an array (one row per payment method, ranked by collected amount). Each row: id, method, method_title, title, total, base_total, progress, formatted_total.

sales-by-coupon

statistics is an array (one row per coupon code used, ranked by discount given). Each row: coupon_code, cart_rule_id, total (orders using the coupon), base_total, base_discount_total, formatted_total, formatted_discount_total, link (admin cart-rule edit URL, null if the rule was deleted), progress, datetime.

View Details

viewStatsAdminReportingSales is the detailed table form of the matching statsAdminReportingSales query — its statistics carries columns ({ key, label }) and records (the row data behind a panel's View Details link), rather than the rolled-up headline figures.

The table shape is uniform across every type (columns + records); only the column set and row keys change. It honors the same type, start, end and channel arguments as the stats query. (The purchase-funnel type is chart-only and has no table form.)

The CSV Export is REST only (a binary text/csv download); there is no GraphQL equivalent — see Reporting — Sales (REST).

Errors

ConditionResult
Missing / invalid Bearer token401 Unauthenticated

See also

Released under the MIT License.