# Item Properties

> Source: https://docs.recombee.com/api/item-properties

> For the complete documentation index, see [llms.txt](/llms.txt).

# Item Properties

## Item properties definition

Item properties are used for modeling your domain. The following methods allow the definition of item properties. The properties may be thought of as columns in a relational database table.

put

### Add Item Property

Adding an item property is somewhat equivalent to adding a column to the table of items. The items may be characterized by various properties of different types.

```js
client.send(new requests.AddItemProperty(propertyName, type, {
  // optional parameters:
  role: 'title',  // string / Object
  metadata: [],   // array
}));
```

---

#### Parameters

databaseId

String

Located in: **path**

Required: **Yes**

ID of your database.

---

propertyName

String

Located in: **path**

Required: **Yes**

Name of the item property to be created. Currently, the following names are reserved: `id`, `itemid`, case-insensitively. Also, the length of the property name must not exceed 63 characters.

---

type

String

Located in: **body**

Required: **Yes**

Value type of the item property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`, `image` or `imageList`.

* `int` \- Signed integer number.
* `double` \- Floating point number. It uses 64-bit base-2 format (IEEE 754 standard).
* `string` \- UTF-8 string.
* `boolean` \- _true_ / _false_
* `timestamp` \- Value representing date and time. ISO8601-1 pattern (string) or UTC epoch time (number).
* `set` \- Set of strings.
* `image` \- URL of an image (`jpeg`, `png` or `gif`).
* `imageList` \- List of URLs that refer to images.

---

role

String

Object

Located in: **body**

Required: **No**

Since version: **6.3.0**

[Role](https://docs.recombee.com/api/property_roles_metadata#roles) to assign to the property.

---

metadata

Array

Located in: **body**

Required: **No**

Since version: **6.3.0**

List of [metadata](https://docs.recombee.com/api/property_roles_metadata#metadata) entries to assign to the property.

---

#### Responses

201

Successful operation.

---

400

Property name does not match ^\[a-zA-Z0-9\_-:\]+$, or it is a reserved keyword (''id'', ''itemid''), or its length exceeds 63 characters. Type information is missing, or the given type is invalid.

---

409

Property of the given name is already present in the database. In many cases, you may consider this code a success – it only tells you that nothing has been written to the database.

---

delete

### Delete Item Property

Deleting an item property is roughly equivalent to removing a column from the table of items.

```js
client.send(new requests.DeleteItemProperty(propertyName));
```

---

#### Parameters

databaseId

String

Located in: **path**

Required: **Yes**

ID of your database.

---

propertyName

String

Located in: **path**

Required: **Yes**

Name of the property to be deleted.

---

#### Responses

200

Successful operation.

---

400

Property name does not match ^\[a-zA-Z0-9\_-:\]+$.

---

404

Property of the given name is not present in the database. In many cases, you may consider this code a success – it only tells you that nothing has been deleted from the database since the item property was already not present. If there is no additional info in the JSON response, you probably have an error in your URL.

---

get

### Get Item Property Info

Gets information about specified item property.

```js
const result = await client.send(new requests.GetItemPropertyInfo(propertyName));
```

---

#### Parameters

databaseId

String

Located in: **path**

Required: **Yes**

ID of your database.

---

propertyName

String

Located in: **path**

Required: **Yes**

Name of the property about which the information is to be retrieved.

---

#### Responses

200

Successful operation.

```
{
  "name": "num-processors",
  "type": "int"
}
```

---

400

Property name does not match ^\[a-zA-Z0-9\_-:\]+$.

---

404

Property of the given name is not present in the database. If there is no additional info in the JSON response, you probably have an error in your URL.

---

get

### List Item Properties

Gets the list of all the item properties in your database.

```js
const result = await client.send(new requests.ListItemProperties());
```

---

#### Parameters

databaseId

String

Located in: **path**

Required: **Yes**

ID of your database.

---

#### Responses

200

Successful operation.

```
[
  {
    "name": "tags",
    "type": "set"
  },
  {
    "name": "release-date",
    "type": "timestamp"
  },
  {
    "name": "description",
    "type": "string"
  }
]
```

---

404

Invalid URL.

---

## Values of item properties

The following methods allow assigning property values to items in the catalog. Set values are examined by content-based algorithms and used for recommendations, especially in the case of cold-start items that have no interactions yet. Properties are also used in [ReQL](https://docs.recombee.com/reql) for filtering and boosting according to your business rules.

post

### Set Item Values

Sets/updates (some) property values of the given item. The properties (columns) must be previously created by [Add Item Property](https://docs.recombee.com/api/item-properties#add-item-property).

```js
client.send(new requests.SetItemValues(itemId, values, {
  // optional parameters:
  cascadeCreate: true,  // boolean
}));
```

---

#### Parameters

databaseId

String

Located in: **path**

Required: **Yes**

ID of your database.

---

itemId

String

Located in: **path**

Required: **Yes**

ID of the item which will be modified.

---

Object

Located in: **body**

Required: **Yes**

The values for the individual properties.

Example of the body:

```
  {
    "product_description": "4K TV with 3D feature",
    "categories":   ["Electronics", "Televisions"],
    "price_usd": 342,
    "in_stock_from": "2016-11-16T08:00Z",
    "image": "http://myexamplesite.com/products/4ktelevision3d/image.jpg",
    "other_images": ["http://myexamplesite.com/products/4ktelevision3d/image2.jpg",
                     "http://myexamplesite.com/products/4ktelevision3d/image3.jpg"]
  }
```

Set item values can also **cascade create** the item if it's not already present in the database.

For this functionality:

* _When using the client libraries_: Set the optional _cascadeCreate_ parameter to true, just like when creating an interaction.
* _When using directly REST API_: Set special "property" `!cascadeCreate`.  
Example:  
```  
  {  
    "product_description": "4K TV with 3D feature",  
    "!cascadeCreate": true  
  }  
```  
Note the exclamation mark (!) at the beginning of the parameter's name to distinguish it from item property names.

---

#### Responses

200

Successful operation.

---

400

Property name does not match ''^\[a-zA-Z0-9\_-:\]+$'', value does not match the property type.

---

404

Property of the given name is not present in the database. If there is no additional info in the JSON response, you probably have an error in your URL.

---

get

### Get Item Values

Gets all the current property values of the given item.

```js
const result = await client.send(new requests.GetItemValues(itemId));
```

---

#### Parameters

databaseId

String

Located in: **path**

Required: **Yes**

ID of your database.

---

itemId

String

Located in: **path**

Required: **Yes**

ID of the item whose properties are to be obtained.

---

#### Responses

200

Successful operation.

```
{
  "release-date": null,
  "tags": [
    "electronics",
    "laptops"
  ],
  "num-processors": 12,
  "description": "Very powerful laptop",
  "weight": 1.6
}
```

---

400

The _itemId_ does not match ^\[a-zA-Z0-9\_-:@.\]+$

---

404

Item of the given _itemId_ is not present in the catalog. If there is no additional info in the JSON response, you probably have an error in your URL.

---

post

### Update More Items

Updates (some) property values of all the items that pass the filter.

Example: _Setting all the items that are older than a week as unavailable_

```
  {
    "filter": "'releaseDate' < now() - 7*24*3600",
    "changes": {"available": false}
  }
```

```js
const result = await client.send(new requests.UpdateMoreItems(filter, changes));
```

---

Since version

3.3.0

---

#### Parameters

databaseId

String

Located in: **path**

Required: **Yes**

Since version: **3.3.0**

ID of your database.

---

filter

String

Located in: **body**

Required: **Yes**

Since version: **3.3.0**

A [ReQL](https://docs.recombee.com/reql) expression, which returns `true` for the items that shall be updated.

---

changes

Object

Located in: **body**

Required: **Yes**

Since version: **3.3.0**

A dictionary where the keys are properties that shall be updated.

---

#### Responses

200

Successful operation. Returns IDs of updated items and their count.

```
{
  "itemIds": [
    "item-42",
    "item-125",
    "item-11"
  ],
  "count": 3
}
```

---

400

Invalid filter, property name does not match ''^\[a-zA-Z0-9\_-:\]+$'', value does not match the property type.

---

404

Property of the given name is not present in the database.

---