---
title: "Get revenue by product"
description: "Revenue, units and orders from back-in-stock alerts per variant (or product), as the dashboard's revenue table."
url: https://docs.stoqapp.com/v2-reference/back-in-stock-reports/get-revenue-by-product/
api: "API v2 reference"
method: GET
path: "/back_in_stock/reports/product_revenue"
---

# Get revenue by product

`GET https://app.stoqapp.com/api/v2/external/back_in_stock/reports/product_revenue`

Revenue, units and orders from back-in-stock alerts per variant (or product), as the dashboard's revenue table.

**Note:** revenue is the line revenue of the alerted items only (not whole orders), so rows add up to the total without overlap. units_sold is item quantity; orders is distinct orders containing the item. image_url is the variant's stored image, else the product's (null if none is stored).

## Query parameters

- `group_by` (string): Return a row per variant or per product. Default variant. One of: `variant`, `product`.
- `from` (string): Start of the window, an ISO 8601 date or date-time; a bare date starts at midnight in the shop's time zone. Default 30 days ago.
- `to` (string): End of the window, an ISO 8601 date or date-time; a bare date runs to the end of that day in the shop's time zone. Default today.
- `range` (string): Set to all_time for the shop's whole history instead of from/to. One of: `all_time`.
- `sort_by` (string): Column to sort rows by. Default revenue. One of: `revenue`, `units_sold`, `orders`, `product_title`.
- `direction` (string): Sort direction. Default desc. One of: `asc`, `desc`.
- `page` (integer): Page of results to return, starting at 1.
- `per_page` (integer): Rows per page, 1 to 100. Default 25.

## Returns

- `window` (object): The date range the figures cover. Null when range is all_time.
  - `from` (string): Start of the range, ISO 8601.
  - `to` (string): End of the range, ISO 8601.
- `group_by` (string): e.g. `string`
- `sort_by` (string): e.g. `string`
- `direction` (string): e.g. `string`
- `currency` (null): ISO 4217 code of the currency the money amounts in this response are in: the order's for an order, else the shop's. Null when it is not known.
- `rows` (array of objects)
  - `shopify_product_id` (string): e.g. `string`
  - `product_title` (string): e.g. `string`
  - `image_url` (string, nullable): e.g. `string`
  - `shopify_variant_id` (string): e.g. `string`
  - `variant_title` (string): e.g. `string`
  - `units_sold` (integer): e.g. `1`
  - `orders` (integer): e.g. `1`
  - `revenue` (string): e.g. `string`
- `meta` (object): Pagination for the list.
  - `total_count` (integer): Items matching the filters, across all pages.
  - `page` (integer): Page returned, starting at 1.
  - `per_page` (integer): Most items per page.
  - `total_pages` (integer): Pages available at this per_page; 0 when nothing matches.

Rate limit: this call costs 1 point ([rate limits](https://docs.stoqapp.com/docs/rate-limits/)).

## Examples

### Get revenue by product

```sh
curl "https://app.stoqapp.com/api/v2/external/back_in_stock/reports/product_revenue" \
  -H "X-Auth-Token: $STOQ_API_KEY"
```

### Get revenue by product filtered by group_by, range and sort_by

```sh
curl "https://app.stoqapp.com/api/v2/external/back_in_stock/reports/product_revenue?group_by=variant&range=all_time&sort_by=revenue" \
  -H "X-Auth-Token: $STOQ_API_KEY"
```

## 200

Success: the requested resource.

```json
{
  "window": {
    "from": "2026-01-15T09:30:00Z",
    "to": "2026-01-15T09:30:00Z"
  },
  "group_by": "string",
  "sort_by": "string",
  "direction": "string",
  "currency": null,
  "rows": [
    {
      "shopify_product_id": "string",
      "product_title": "string",
      "image_url": "string",
      "shopify_variant_id": "string",
      "variant_title": "string",
      "units_sold": 1,
      "orders": 1,
      "revenue": "string"
    }
  ],
  "meta": {
    "total_count": 1,
    "page": 1,
    "per_page": 1,
    "total_pages": 1
  }
}
```

## 401

Missing or invalid `X-Auth-Token`.

```json
{
  "errors": [
    "Invalid API key"
  ],
  "code": "auth_invalid",
  "details": [
    {
      "code": "auth_invalid",
      "message": "Invalid API key",
      "path": null,
      "value": null,
      "expected": null
    }
  ]
}
```

## 422

The request failed validation.

```json
{
  "errors": [
    "name is required"
  ],
  "code": "validation_failed",
  "details": [
    {
      "code": "validation_failed",
      "message": "name is required",
      "path": null,
      "value": null,
      "expected": null
    }
  ]
}
```

## 429

Rate limited: cost-weighted per token (read 1, write 2; 360 points / 60s). Check `Retry-After`.

```json
{
  "errors": [
    "Rate limit exceeded"
  ],
  "code": "rate_limited",
  "details": [
    {
      "code": "rate_limited",
      "message": "Rate limit exceeded",
      "path": null,
      "value": null,
      "expected": null
    }
  ]
}
```

