---
title: "Get products in demand"
description: "The Products in demand table: variants (or products) ranked by back-in-stock demand, with signups created in the window, how many of them are still waiting, and the last request."
url: https://docs.stoqapp.com/v2-reference/back-in-stock-reports/get-products-in-demand/
api: "API v2 reference"
method: GET
path: "/back_in_stock/reports/products_in_demand"
---

# Get products in demand

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

The Products in demand table: variants (or products) ranked by back-in-stock demand, with signups created in the window, how many of them are still waiting, and the last request.

**Note:** The same rows as the dashboard table. total counts signups created in the window; pending counts those of them not yet notified. count_by=customers counts a shopper signed up on several channels once; omitted, it follows the dashboard default, and the response's count_by says which. group_by=product ranks products instead of variants. search matches product title or SKU; vendors, tags and shopify_market_ids are comma-separated lists, as the table's filters. Deleted variants are hidden when the shop's dashboard hides them. image_url is the variant's image, else the product's. Variant rows only: include_inventory=true adds inventory_available, the stock available in the locations the shop's market or location filter allows (summed, null when Shopify has no level), and include_prices=true adds price and compare_at_price in the shop's currency, as the table's Inventory and Price columns. Each asks Shopify once per page. include_totals=true adds totals { pending, total }, the pending and total columns summed over every row the filters keep, not just this page.

## Query parameters

- `group_by` (string): Return a row per variant or per product. Default variant. One of: `variant`, `product`.
- `sort_by` (string): Column to sort rows by. Default pending. One of: `pending`, `total`, `last_requested_at`.
- `direction` (string): Sort direction. Default desc. One of: `asc`, `desc`.
- `count_by` (string): Count a shopper signed up on several channels once (customers) or each signup (signups). Default is the shop's dashboard setting. One of: `customers`, `signups`.
- `include_inventory` (boolean): When true, variant rows include the available stock. Variant rows only.
- `include_prices` (boolean): When true, variant rows include price and compare-at price. Variant rows only.
- `include_totals` (boolean): When true, the response adds pending and total summed over every row the filters keep.
- `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`.
- `shopify_market_ids` (string): Comma-separated Shopify market gids or numeric ids to keep.
- `search` (string): Only rows whose product title or SKU contains this text.
- `vendors` (string): Comma-separated product vendors to keep.
- `tags` (string): Comma-separated product tags to keep.
- `page` (integer): Page of results to return, starting at 1.
- `per_page` (integer): Rows per page, 1 to 500. Default 25.

## Returns

- `window` (object, nullable): 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. `variant`
- `sort_by` (string): e.g. `pending`
- `direction` (string): e.g. `desc`
- `count_by` (string): e.g. `customers`
- `rows` (array of objects)
  - `shopify_variant_id` (string): e.g. `gid://shopify/ProductVariant/47284734423096`
  - `shopify_product_id` (string): e.g. `gid://shopify/Product/8784906035384`
  - `variant_title` (string, nullable): e.g. `Blue / Medium`
  - `product_title` (string, nullable): e.g. `Classic Sneaker`
  - `sku` (string, nullable): e.g. `CS-BLU-M`
  - `image_url` (string, nullable)
  - `deleted` (boolean)
  - `variants_count` (integer)
  - `pending` (integer): e.g. `47`
  - `total` (integer): e.g. `89`
  - `last_requested_at` (string): e.g. `2026-06-25T11:30:00Z`
  - `inventory_available` (integer, nullable)
  - `price` (string, nullable)
  - `compare_at_price` (string, nullable)
- `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 products in demand

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

### Get products in demand filtered by group_by, sort_by and direction

```sh
curl "https://app.stoqapp.com/api/v2/external/back_in_stock/reports/products_in_demand?group_by=variant&sort_by=pending&direction=desc" \
  -H "X-Auth-Token: $STOQ_API_KEY"
```

## 200

Success: example response shown.

```json
{
  "window": {
    "from": "2026-05-26T00:00:00Z",
    "to": "2026-06-25T23:59:59Z"
  },
  "group_by": "variant",
  "sort_by": "pending",
  "direction": "desc",
  "count_by": "customers",
  "rows": [
    {
      "shopify_variant_id": "gid://shopify/ProductVariant/47284734423096",
      "shopify_product_id": "gid://shopify/Product/8784906035384",
      "variant_title": "Blue / Medium",
      "product_title": "Classic Sneaker",
      "sku": "CS-BLU-M",
      "pending": 47,
      "total": 89,
      "last_requested_at": "2026-06-25T11:30:00Z"
    },
    {
      "shopify_variant_id": "gid://shopify/ProductVariant/47284734455864",
      "shopify_product_id": "gid://shopify/Product/8784906035384",
      "variant_title": "Red / Large",
      "product_title": "Classic Sneaker",
      "sku": "CS-RED-L",
      "pending": 23,
      "total": 56,
      "last_requested_at": "2026-06-25T09:15:00Z"
    }
  ],
  "meta": {
    "total_count": 287,
    "page": 1,
    "per_page": 50,
    "total_pages": 6
  }
}
```

## 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
    }
  ]
}
```

