Skip to content

Reporting — Customers

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.

EndpointGET /api/admin/reporting/customers
ReturnsA JSON array with a single element: [ { 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 requests, one per panel, and each is selected with the ?type= query parameter. 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 the endpoint 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.

Query parameters

ParamTypeRequiredDescription
typeenumNoOne of the six values above. Defaults to total-customers. An unknown value returns 400 (invalid-type).
startdate (YYYY-MM-DD)NoLower bound of the reporting window. Defaults to 30 days ago.
enddate (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.

Response envelope

The endpoint always returns a single-element array: [ { entity, type, dateRange, statistics } ].

  • entity — always "customers" for this report.
  • type — echoes back the requested panel.
  • dateRange — an object { previous, current }, where each value is a human-readable label for the corresponding window (e.g. "10 May 2026 - 09 Jun 2026").
  • statistics — an object or array whose shape depends on type (documented below).

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 / Export 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

GET /api/admin/reporting/customers/view returns the same statistics as the summary stats endpoint, but in a detailed table form — the full list that sits behind a panel's View Details link. It honors the same ?type= parameter. The statistics object carries:

  • columns — an ordered list of { key, label } describing each table column.
  • records — the row data, each keyed by the column key values (records may carry extra fields beyond the displayed columns).

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.

Export (CSV)

GET /api/admin/reporting/customers/export streams the same detailed table as a csv, xls or xlsx attachment (the Export button). It honors the same ?type=. The header row is built from the column labels, followed by one line per record. Send the Accept header matching the requested format and save the response to a file.

?format= accepts csv (the default), xls and xlsx — any other value returns HTTP 422. Send an Accept header matching the format: text/csv, application/vnd.ms-excel or application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.

Both View Details and Export require only authentication; reporting has no permission gate.

Errors

ConditionHTTPBody
Missing / invalid Bearer token401{ "message": "Unauthenticated.", "error": "unauthenticated" }
Unknown type value400{ ... "Invalid reporting stat type." }
format other than csv on Export422{ ... "Unsupported export format." }

See also

Released under the MIT License.