---
title: "Returns item statistics for a customer."
url: "https://developer.migros.ch/apis/unified-customer-item-recommender-api-2/versions/99fa4982-90d2-410c-a30b-b658b93762a4/operations/m_recsys.service.recommendations_api.get_customer_item_statistics"
---

> Full API specification: https://developer.migros.ch/apis/unified-customer-item-recommender-api-2/versions/99fa4982-90d2-410c-a30b-b658b93762a4.md

# Returns item statistics for a customer.

`GET` `/migros/customers/v1/recommender/customeritemstatistics/{domain_id}/{customer_id}/{sort_by}`

Operation ID: `m_recsys.service.recommendations_api.get_customer_item_statistics`

Get a customer's purchased items sorted by recency, frequency, or monetary.

## Path parameters

- `domain_id` (string, required)
- `customer_id` (string, required)
- `sort_by` (string, required) - A comma separated list of sorting criteria. Currently, the following sorting criteria are understood: * recency, * frequency, * monetary. The ordering is as follows: * For *recency*, the most recent item comes first, * For *frequency*, the item with highest frequency comes first, * For *monetary*, the item with largest revenue comes first. It is strongly recommended to specify multiple sorting criteria in order to break ties. Example: sort_by=recency,monetary

## Query parameters

- `limit` (integer, optional) - Number of items
- `num_days` (integer, optional) - Number of days to be considered

## Responses

- `200` - OK
- `401` - Unauthenticated
- `403` - Forbidden
- `404` - Unknown domain or unknown customer
- `422` - Customer is not a cumulus user

## OpenAPI definition

```yaml
openapi: 3.0.1
info:
  title: Unified Customer-Item Recommender API
  version: 2.0.0.dev0
servers:
  - description: URL of upstream
    url: https://prod-unified-recommender.service.migros.cloud
paths:
  /migros/customers/v1/recommender/customeritemstatistics/{domain_id}/{customer_id}/{sort_by}:
    get:
      description: Get a customer's purchased items sorted by recency, frequency, or
        monetary.
      operationId: m_recsys.service.recommendations_api.get_customer_item_statistics
      parameters:
        - in: path
          name: domain_id
          required: true
          schema:
            default: Cumulus
            type: string
        - in: path
          name: customer_id
          required: true
          schema:
            $ref: "#/components/schemas/Customer"
        - description: >-
            A comma separated list of sorting criteria. Currently, the following
            sorting criteria are understood:
             * recency,
             * frequency,
             * monetary.

            The ordering is as follows:
             * For *recency*, the most recent item comes first,
             * For *frequency*, the item with highest frequency comes first,
             * For *monetary*, the item with largest revenue comes first.

            It is strongly recommended to specify multiple sorting criteria in
            order to break ties. Example: sort_by=recency,monetary
          in: path
          name: sort_by
          required: true
          schema:
            default: recency,monetary
            pattern: ^(recency|monetary|frequency)(,(recency|monetary|frequency)){0,2}$
            type: string
        - description: Number of items
          in: query
          name: limit
          schema:
            default: 100
            maximum: 700
            minimum: 1
            type: integer
        - description: Number of days to be considered
          in: query
          name: num_days
          schema:
            default: 180
            maximum: 365
            minimum: 1
            type: integer
      responses:
        "200":
          content:
            application/json:
              schema:
                items:
                  properties:
                    frequency:
                      type: number
                    item_id:
                      $ref: "#/components/schemas/Item"
                    monetary:
                      type: number
                    recency:
                      type: number
                  type: object
                type: array
          description: OK
        "401":
          description: Unauthenticated
        "403":
          description: Forbidden
        "404":
          description: Unknown domain or unknown customer
        "422":
          description: Customer is not a cumulus user
      security:
        - apiKeyAuth: []
      summary: Returns item statistics for a customer.
      tags:
        - Online
security:
  - apiKeyAuth: []
components:
  schemas:
    Customer:
      description: e.g. CumulusID, PersonenID or pseudonymized version thereof
      example: 2099XXXXXXX
      pattern: ^[a-zA-Z0-9-]+$
      type: string
    Item:
      description: Migros ArtikelID
      example: "110136400000"
      pattern: ^[a-zA-Z0-9=]+$
      type: string
  securitySchemes:
    apiKeyAuth:
      in: header
      name: X-API-Key
      type: apiKey
      x-apikeyInfoFunc: m_recsys.service.key_auth.check_api_key
```
