Skip to content
Documentation
Stats API

Get revenue

Read payments, refunds, paying customers, and source reports in one selected currency.

Request

GET/api/v1/stats/revenue

Call this endpoint from your server with a website-scoped Stats API bearer key. Follow Get started to create a key. The key selects your website; do not send a website ID.

request.sh
curl 'https://talvess.vercel.app/api/v1/stats/revenue?days=7' \
  -H "Authorization: Bearer $TALVESS_STATS_KEY"

Query parameters

ParameterAccepted values
days1, 7, 30, or 90. Defaults to 30. Use this or a pair of explicit dates.
startDateInclusive UTC date in YYYY-MM-DD format. Requires endDate.
endDateInclusive UTC date in YYYY-MM-DD format. Requires startDate.
intervalhourly or daily. Defaults to hourly for days=1, otherwise daily.
currencySupported uppercase ISO currency code, such as USD. Required when the website has multiple currencies.

Explicit ranges cover up to 365 days through today. Hourly ranges cover at most seven days. Do not combine days with explicit dates. Unknown or repeated parameters return 400 INVALID_QUERY.

Response

A successful response contains data with the report and meta.generatedAt and meta.expiresAt with its cache timestamps. The report contains these fields:

period
The reporting interval, UTC boundaries, and calculation time.
currency, availableCurrencies
The selected currency and the currencies available for the website.
moneyUnit, minorUnitDigits
Amounts use minor units. The digits describe how to display them in major units.
summary, previous
Gross revenue, refunded amounts, net revenue, payment counts, and paying customer counts for both periods.
summary.payments, previous.payments
The number of recorded payments that occurred in each period in the selected currency.
summary.payingCustomers, previous.payingCustomers
Distinct customers with a payment in each period in the selected currency. Repeated payments by one customer count once.
series, previousSeries, sources
Revenue over time and up to 50 aggregate source rows.

Money amounts are integer strings in minor units. Keep them as strings or use BigInt for calculations, then apply minorUnitDigits when formatting. Do not combine currencies.

Matching reports are cached for 900 seconds. Each key allows 60 requests per minute, including cache hits. Read the shared freshness and limits and errors and retries before integrating. An empty report is a successful response; a failed calculation returns an error.