Skip to content

Reporting — Customers (GraphQL)

Returns the aggregate statistics that power the Bagisto admin Reporting → Customers report — new customers, traffic, top spenders, most orders, most reviews and top customer groups.

QuerystatsAdminReportingCustomers
EndpointPOST /api/admin/graphql
ReturnsA single object: { entity, type, dateRange, statistics }

All admin endpoints require an admin Bearer token — see Authentication.

Understanding type — the report is six separate calls

The Customers report screen is not one response. It is assembled from six independent queries, one per panel, and each is selected with the type argument. These six groups are exactly the panels of the admin Reporting → Customers screen — no more, no less.

So a single call returns one panel of the report. To render the full screen, call statsAdminReportingCustomers 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

Report panel (admin)typestatistics is
Total Customers charttotal-customersobject (with over_time series)
Customers Traffic chartcustomers-trafficobject (with over_time series)
Customers With Most Sales listcustomers-with-most-salesarray
Customers With Most Orders listcustomers-with-most-ordersarray
Customers With Most Reviews listcustomers-with-most-reviewsarray
Top Customer Groups listtop-customer-groupsarray

total-customers is the default — if you omit type, you get the "Total Customers" chart.

Arguments

ArgumentTypeRequiredDescription
typeStringNoOne of the six values above. Defaults to total-customers. An unknown value returns a GraphQL errors[] entry (400, invalid-type).
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 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 AdminReportingCustomers($type: String, $start: String, $end: String, $channel: String) {
  statsAdminReportingCustomers(type: $type, start: $start, end: $end, channel: $channel) {
    entity
    type
    dateRange
    statistics
  }
}
  • entity — always "customers" for this report.
  • type — echoes back the requested panel.
  • dateRange — a JSON object { previous, current }, each a human-readable label for the corresponding 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 has no sub-fields to select.

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).

total-customers

KeyShapeMeaning
customers{ previous, current, progress }New customers registered.
over_time{ previous: [{ label, total }], current: [{ label, total }] }Two series — previous and current windows — one bucket per day for the chart line.

customers-traffic

KeyShapeMeaning
total{ previous, current, progress }All customer visits.
unique{ previous, current, progress }Unique customer visits.
over_time{ previous: [{ label, total }], current: [{ label, total }] }Two daily series for the chart.

This panel is chart-only — there is no View Details table for customers-traffic. Traffic figures depend on the Bagisto visitor/analytics tables being populated; on a fresh store the totals are 0 and the over_time series are empty.

customers-with-most-sales

statistics is an array. Each row: id (may be null for guest checkouts), email, full_name, total, orders, progress, formatted_total.

customers-with-most-orders

statistics is an array. Each row: id (may be null for guest checkouts), email, full_name, orders, progress.

customers-with-most-reviews

statistics is an array. Each row: id (may be null for guest reviews), email, full_name, reviews, progress.

top-customer-groups

statistics is an array. Each row: id, group_name, total, progress.

View Details

viewStatsAdminReportingCustomers is the detailed table form of the matching statsAdminReportingCustomers 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. It honors the same type argument.

The table columns per type:

typecolumns (key)
total-customerslabel, total
customers-with-most-salesfull_name, email, formatted_total
customers-with-most-ordersfull_name, email, orders
customers-with-most-reviewsfull_name, email, reviews
top-customer-groupsgroup_name, total

customers-traffic 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 the REST endpoint.

Errors

ConditionResult
Missing / invalid Bearer token401 Unauthenticated
Unknown type valueGraphQL errors[] — "Invalid reporting stat type." (400)

See also

Released under the MIT License.