# Inventory

**URL:** https://heroiclabs.com/docs/hiro/unreal/inventory/
**Keywords:** inventory, hiro
**Categories:** hiro, unreal, inventory

---


# Inventory

Read more about the Inventory system in Hiro [here](../../concepts/inventory/).

## List items

List all inventory items defined in the codex, optionally filtered by category.

```cpp
FHiroInventoryListRequest Request;
Request.ItemCategory = TEXT("weapons");

FHiroOnInventoryList OnInventoryList;
OnInventoryList.AddDynamic(this, &AMyActor::OnInventoryList);
FOnError OnError;

HiroClient->InventoryList(Session, Request, OnInventoryList, OnError);

void AMyActor::OnInventoryList(const FHiroInventoryList& InventoryList)
{
    UE_LOG(LogTemp, Log, TEXT("%s"), *InventoryList.ToJson());
}
```

## List user inventory items

List all inventory items owned by the player, optionally filtered by category.

```cpp
FHiroInventoryListRequest Request;
Request.ItemCategory = TEXT("weapons");

FHiroOnInventoryListInventory OnInventoryListInventory;
OnInventoryListInventory.AddDynamic(this, &AMyActor::OnInventoryListInventory);
FOnError OnError;

HiroClient->InventoryListInventory(Session, Request, OnInventoryListInventory, OnError);

void AMyActor::OnInventoryList(const FHiroInventoryList& InventoryList)
{
    UE_LOG(LogTemp, Log, TEXT("%s"), *InventoryList.ToJson());
}
```

## Consume inventory items

Consume one or more inventory items owned by the player.

```cpp
FHiroInventoryConsumeRequest Request;
Request.Items.Add(TEXT("health_potion"), 1);

FHiroOnInventoryConsume OnInventoryConsume;
OnInventoryConsume.AddDynamic(this, &AMyActor::OnInventoryConsume);
FOnError OnError;

HiroClient->InventoryConsume(Session, Request, OnInventoryConsume, OnError);

void AMyActor::OnInventoryConsume(const FHiroInventoryConsumeRewards& InventoryConsumeRewards)
{
    UE_LOG(LogTemp, Log, TEXT("%s"), *InventoryConsumeRewards.ToJson());
}
```

## Grant inventory items

Grant one or more inventory items to the player.

```cpp
FHiroInventoryGrantRequest Request;
Request.Items.Add(TEXT("bronze_sword"), 1);

FHiroOnInventoryGrant OnInventoryGrant;
OnInventoryGrant.AddDynamic(this, &AMyActor::OnInventoryGrant);
FOnError OnError;

HiroClient->InventoryGrant(Session, Request, OnInventoryGrant, OnError);

void AMyActor::OnInventoryConsume(const FHiroInventoryUpdateAck& InventoryUpdateAck)
{
    UE_LOG(LogTemp, Log, TEXT("%s"), *InventoryUpdateAck.ToJson());
}
```

### Remove inventory items

To remove items from a user's inventory, without consuming them, use a negative grant value.

```cpp
FHiroInventoryGrantRequest Request;
Request.Items.Add(TEXT("bronze_sword"), -1);

FHiroOnInventoryGrant OnInventoryGrant;
OnInventoryGrant.AddDynamic(this, &AMyActor::OnInventoryGrant);
FOnError OnError;

HiroClient->InventoryGrant(Session, Request, OnInventoryGrant, OnError);

void AMyActor::OnInventoryConsume(const FHiroInventoryUpdateAck& InventoryUpdateAck)
{
    UE_LOG(LogTemp, Log, TEXT("%s"), *InventoryUpdateAck.ToJson());
}
```

## Update inventory items

Update the properties on one or more inventory items owned by the player.

```cpp
FHiroInventoryUpdateItemsRequest Request;

FHiroInventoryUpdateItemProperties ItemProperties;
ItemProperties.StringProperties.Add(TEXT("example_property"), TEXT("example_value"));
ItemProperties.NumericProperties.Add(TEXT("numeric_property"), 10);

Request.ItemUpdates.Add(TEXT("bronze_sword"), ItemProperties);

FHiroOnInventoryUpdate OnInventoryUpdate;
OnInventoryUpdate.AddDynamic(this, &AMyActor::OnInventoryUpdate);
FOnError OnError;

HiroClient->InventoryUpdate(Session, Request, OnInventoryUpdate, OnError);

void AMyActor::OnInventoryConsume(const FHiroInventoryUpdateAck& InventoryUpdateAck)
{
    UE_LOG(LogTemp, Log, TEXT("%s"), *InventoryUpdateAck.ToJson());
}
```