
# Service Category


[Link to swagger documentation](https://service-category.sandbox.infra.metro-markets.cloud/public/api/api-doc)

1. [Introduction](#Introduction)
2. [How to find out the category id?](#how-to-find-out-the-category-id)
3. [How to get the attributes specific to a category?](#how-to-find-out-the-category-id)
4. [Markets](#markets)

### Introduction

This part of the API will give you the information regarding the `categories` and their `attributes`, `VAT` and `commission fees` per market.

To prepare your product data file, you need to know to which METRO Markets `categoryID` your product belongs to and which attributes are needed.

Please take into consideration the following:

- There are general attributes which are needed for all products (regardless of the category).
- There are general attributes which are specific per market (example product name, description, key feature).
- There are attributes which are specific to a category.
- A specific category attribute can be mandatory in category A and optional in category B.
- Some attributes are localizable (that means they need to be provided for every indicated market. You will get the info in `requiredLanguages`).
- `Categoryids` are the same on all markets.

Please check the information about the general attributes in the Product & Offer Data Guidelines in the [Seller Help Center](https://www.metro-selleroffice.com/en/help-center/guidelines/product-data/overview-general-attributes). You can see there which of them are mandatory and which are optional.

### How to find out the category id?

The `GET /public/api/v2/{market}/categories` request provides a full list of all `categoriesIDs`. You can see the main category (parent) and subcategories inside (children). Please, select the `categoryIDs` from the lowest level inside each category.  
You can get all supported `{market}` values [here](/docs/multimarkets/index.md#which-markets-are-available)

Example: `GET`request sent to `https://service-category.sandbox.infra.metro-markets.cloud/public/api/v2/DE/categories`

In the snippet of the response you can see that the lowest category for Smoker is `f0442c89-82c0-481b-be5b-a2b992ac4360`, as it doesn´t have more subcatgories (children). This is the `category id` you need to use on you product data. You can also see the applied `comissionFee` and the `VAT`.

Snippet response

```
[
    {
        "children": [
            {
                "children": [
                    {
                        "children": [
                            {
                                "children": [],
                                "id": "f0442c89-82c0-481b-be5b-a2b992ac4360",
                                "name": "Smoker",
                                "commissionFee": 10,
                                "parentIds": [
                                    "1070ec46-c3bd-4d0d-b709-ead9600dcc8f"
                                ],
                                "taxes": [
                                    {
                                        "type": "VAT",
                                        "amount": 16
                                    }
                                ]
                            }
                        ],
              ......
```

### How to get the attributes specific to a category?

To get a list of all `attributes` of that `category id` you need to use `GET /public/api/v2/{market}/categories/{id}`.

Example with the id previously obtained:

`GET` sent to `https://service-category.sandbox.infra.metro-markets.cloud/public/api/v2/DE/categories/f0442c89-82c0-481b-be5b-a2b992ac4360` and in the response you will see the `attributes` which are specific to that `category`.

Here you can see a snippet of the response.  
In this case the categoryid `f0442c89-82c0-481b-be5b-a2b992ac4360` the following specific attributes `Length`, `Length Unit`, `Color` need to be provided in the headers.

```
{
  "attributes": [
    {
      "type": {
        "value": 1,
        "text": "List of value",
        "baseUnit": null,
        "possibleUnits": null,
        "possibleValues": [
          "lila",
          "rot",
          "weiss",
          "gelb"
        ]
      },
      "id": "50dae0e4-f391-4195-bd19-54b2d12b53b7",
      "code": "color",
      "name": "Farbe",
      "csvHeaderLabel": "Color",
      "description": "Gibt die Haupt- oder dominante Farbe des Produkts an. (LOV: Bitte verwenden Sie den Wert aus der Dropdown-Liste)",
      "example": "Beige, Schwarz, Grau, Grün, Rot, Silber...",
      "required": false,
      "requiredLanguages": null,
      "localizable": false
    },
    {
      "type": {
        "value": 6,
        "text": "Decimal",
        "baseUnit": "m",
        "possibleUnits": [
          "mm",
          "cm",
          "m",
          "in"
        ],
        "possibleValues": null
      },
      "id": "b4547557-2f3d-448d-92a8-f8395a8f4e6a",
      "code": "length_depth_product",
      "name": "Länge/Tiefe",
      "csvHeaderLabel": "Length",
      "description": "Gibt die horizontalen Maße des Produkts von vorne nach hinten an. (Dezimalwert: Zahl mit einer Nachkommastelle, Punkt oder Komma; die Einheit ggf. in einem separaten Feld angeben.)",
      "example": "10.5",
      "required": false,
      "requiredLanguages": null,
      "localizable": false
    },
    {
      "type": {
        "value": 3,
        "text": "Text",
        "baseUnit": null,
        "possibleUnits": null,
        "possibleValues": null
      },
      "id": "c904fe13-9b20-4315-9391-413aa13b27b5",
      "code": "accessories",
      "name": "Accessories",
      "csvHeaderLabel": "Accessories",
      "description": "Kennzeichnet zusätzliche, im Lieferumfang des Produkts enthaltene Artikel, die Funktion erweitern oder ergänzen können, für den Grundbetrieb jedoch nicht erforderlich sind. (Freitext: max. 250 Zeichen)",
      "example": "Zusätzliche Ablagen. zusätzliche Klingen. Aufsätze …",
      "required": false,
      "requiredLanguages": [
          "DE",
          "ES",
          "FR",
          "HR",
          "IT",
          "NL",
          "PT"
          ],
      "localizable": true
       },
..... 
```

Explanation of the values:

- `id`: internal attribute’s id number
- `code`: internal attribute’s name
- `name`: attribute’s name in the specific language of that market
- `csvHeaderLabel`: this is the header name, please use it inside your **product data file**
- `description`: brief explanation
- `example`: examples of values
- `required`: boolean value to check whether attribute is mandatory or not
- `requiredLanguages`: Specifies the languages for which a value must be provided. If null, no language-specific value is required.
- `localizable:` Specifies whether the attribute supports different values for different languages. For example, if localizable is true and requiredLanguages contains DE and ES, localized values such as `Accessories DE` and `Accessories ES` must be provided.
- `type`: it´s an array which informs you about the type of attribute (`value` and `text`), the `possibleUnits` and `possibleValues`. In the example above a Decimal is given with possibleUnits, so you need to provide two columns: `Length` decimal number | `Length Unit` indicating one of the `possibleUnits` values.

|       |                |                                                               |
|-------|----------------|---------------------------------------------------------------|
| Value | Text           | Comment                                                       |
| 1     | List of values | Provide a value from the possible options list                |
| 2     | Boolean        |                                                               |
| 3     | Text           | localizable                                                   |
| 4     | Integer        | a number + add measure unit in a separate column if necessary |
| 5     | File           | url to the file                                               |
| 6     | Decimal        | a decimal + add measure unit in separate column if necesarry  |
| 7     | Image          | url to the image                                              |
| 8     | LongText       | localizable                                                   |

### Markets

You can get all supported `{market}` values [here](/docs/multimarkets/index.md#which-markets-are-available).
