# Data Management API

## Overview

Manage recommendations DB using Data Management API

Management API updates the latest client’s product information on the product DB and creates the search indexes for the Recommendation API. However, the actual recommendation API indexes are updated on the following day.

* **GET** / : Check the current DB information
* **POST** /?action=update : Data Update
* **POST** /?action=delete : Data Delete

## Endpoint&#x20;

We currently support two LENS API versions

**Version 1.1:**

{% embed url="<https://api.omnious.com/lens/v1.1/db>" %}

**Version 1.2: Recommended for new LENS users**

{% embed url="<https://api.omnious.com/lens/v1.2/db>" %}

## GET /

Check the current DB information.

### Request

#### Header

| **Name**     | **Description**                                     |
| ------------ | --------------------------------------------------- |
| Content-Type | application/json                                    |
| x-api-key    | API Key for authentication from Omnious \[Required] |

### Response

#### Response Data

| **Name**   | **Type** | **Description**                                                  |
| ---------- | -------- | ---------------------------------------------------------------- |
| name       | String   | name of the search DB                                            |
| updateDate | Datetime | date the item of search DB was last changed                      |
| indexDate  | Datetime | date when the items of the search DB were reflected in the Index |
| totalCount | Int      | Total number of products in search DB                            |

**Example. DB information inquiry**

```javascript
{
  "status": "ok",
  "error": null,
  "data": {
    "name": "ABCD mall recommendation DB",
    "updateDate": "2020-01-08 20:00:23",
    "indexDate": "2020-01-08 23:39:17",
    "totalCount": 655000
  }
}
```

## POST /?action=update

Insert new data or update existing data. If the product code already exists, it is updated with the newly registered information.

{% hint style="info" %}
**Up to 1,000 products can be updated per request. (Number may vary depending on the network environment.)**
{% endhint %}

### **Request**

#### **Header**

| **Name**     | **Description**                                     |
| ------------ | --------------------------------------------------- |
| Content-Type | application/json                                    |
| x-api-key    | API Key for authentication from Omnious \[Required] |

#### **Body**

In the form of JSON Object Array, insert the product information to be exposed for recommendations as shown below.

| **Name** | **Type**         | **Description**                                 |
| -------- | ---------------- | ----------------------------------------------- |
| products | Array of Objects | List of product information to insert or update |

#### **Product Object Attributes**

| **Name**                      | **Type** | **Description**                                           |
| ----------------------------- | -------- | --------------------------------------------------------- |
| id                            | String   | As a product code, it is used as a Unique Key in the DB.  |
| url                           | String   | URL of product page                                       |
| image.detection               | String   | Select one of the detection information values. (ex; TOP) |
| image.content                 | String   | URL of product cover image                                |
| context.name                  | String   | Product name                                              |
| context.gender                | String   | Gender (one of MAN / WOMEN / UNISEX)                      |
| context.brand                 | String   | Brand                                                     |
| context.price.currency        | String   | Currency unit of product price (ex: USD)                  |
| context.price.value           | Float    | Product price                                             |
| context.price.discounted      | Float    | Discounted price                                          |
| context.mobiePrice.currency   | String   | Currency unit of product price (ex: USD)                  |
| context.mobiePrice.value      | Float    | Product price                                             |
| context.mobiePrice.discounted | Float    | Discounted price                                          |

#### **Detection Attributes**

Select one of the following values ​​to specify the items to be used for recommendations on the image.

| **Field** | **Description**                        |
| --------- | -------------------------------------- |
| SHOES     | shoes                                  |
| BAG       | bags                                   |
| HAT       | hats                                   |
| GLASSES   | glasses, sun-glasees                   |
| BELT      | belts                                  |
| WATCH     | watch                                  |
| TOP       | tops (blouses, shirts, knitwear, etc)  |
| OUTWEAR   | coats, jackets, jumpers, paddings, etc |
| SKIRT     | skirts                                 |
| PANTS     | pants                                  |
| WHOLEBODY | dresses, jumpsuits                     |
| JEWELRY   | jewelries (rings, necklaces, etc)      |
| ACCESSORY | hair accessories                       |

**Example. insert one product**

```javascript
{
  "products": [
    {
      "id": "AT000123FB",
      "url": "http://asdfmall/product?id=AT00123FB",
      "image": {
        "detection": "TOP",
        "content": "http://some/image.jpg"
      },
      "context": {
        "name": "Zipup Hoodie",
        "gender": "MAN",
        "brand": "GAP",
        "price": {
          "currency": "USD",
          "value": 12.00,
          "discounted": 9.99
        }
        "mobilePrice": {
          "currency": "USD",
          "value": 11,
          "discounted": 8.99
        }
      }
    }
  ]
}
```

**Example. insert multiple products**

```javascript
{
  "products": [
    {
      "id": "AT000123FB",
      "url": "http://asdfmall/product?id=AT00123FB",
      "image": {
        "detection": "TOP",
        "content": "http://some/image.jpg"
      },
      "context": {
        "name": "Zipup Hoodie"
        "gender": "MAN",
        "brand": "GAP",
        "price": {
          "currency": "USD",
          "value": 12,
          "discounted": 9.99
        }
        "mobilePrice": {
          "currency": "USD",
          "value": 11,
          "discounted": 9.99
        }
      }
    },
    {
      "id": "AT280143GQ",
      "url": "http://asdfmall/product?id=AT280143GQ",
      "image": {
        "detection": "SHOES",
        "content": "http://some/image.jpg"
      },
      "context": {
        "name": "Airmax Sneakers",
        "gender": "MAN",
        "brand": "NIKE",
        "price": {
          "currency": "USD",
          "value": 120,
          "discounted": 99
        }
        "mobilePrice": {
          "currency": "USD",
          "value": 110,
          "discounted": 99
        }
      }
    }
  ]
}
```

### **Response**

#### Example. **Accept insert request** (**HTTP Status Code: 200)**

```javascript
{
  "status": "ok",
  "error": null,
  "data": {
    "update": 2
  }
}
```

### **POST /?action=delete**

Deletes the product registered in the DB given a product code.

### **Request**

**Header**

| **Name**     | **Description**                                     |
| ------------ | --------------------------------------------------- |
| Content-Type | application/json                                    |
| x-api-key    | API Key for authentication from Omnious \[Required] |

### **Body**

Enter the product code to be deleted in the form of a JSON Array Object as shown below.

**Example. Request for deletion of 2 product information**

```javascript
{
  "ids": [
    "AT000123FB",
    "AT059253WA"
  ]
}
```

### **Response**

**Example. Accept deletion request (HTTP Status Code: 200)**

Returns the number of products requested for deletion.

```javascript
{
  "status": "ok",
  "error": null,
  "data": {
    "delete": 2
  }
}
```
