# Legacy Storage

#### Retrieve Player Storage

To view Player storage in the web console, go to the player and select the storage tab. From here it's possible to view and edit the data for the player.

![](https://534367586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVu1MPzezO-NgvC98xh%2Fuploads%2Fgit-blob-f3ffc1e5f5a7e17198b75c396a21901b12784074%2Fplayer-storage.png?alt=media)

**Retrieve Entire Player Storage From Game**

{% tabs %}
{% tab title="Unity" %}

```csharp
LootLockerSDKManager.GetEntirePersistentStorage((response) =>
{
    if (response.success)
    {
        Debug.Log("Successfully retrieved player storage: " + response.payload.Length);
    } else
    {
        Debug.Log("Error getting player storage");
    }
});
```

{% endtab %}

{% tab title="Unreal" %}

<figure><img src="https://534367586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVu1MPzezO-NgvC98xh%2Fuploads%2Fgit-blob-e3f16476975014c222e769a2abfab15ca9dd2acc%2Fimage%20(60).png?alt=media" alt=""><figcaption><p><a href="https://blueprintue.com/blueprint/d_kdttxo/">Blueprint example of retrieving entire player storage</a></p></figcaption></figure>
{% endtab %}

{% tab title="REST" %}

```bash
curl -X GET "https://api.lootlocker.io/game/v1/player/storage" \
  -H "x-session-token: your_token_here"
```

Example response:

```json
{
  "success": true,
  "payload": [
    {
      "key": "user.answer",
      "value": "42",
      "is_public": false
    }
  ]
}
```

{% endtab %}
{% endtabs %}

**Retrieve Single Storage Value From Game**

{% tabs %}
{% tab title="Unity" %}

```csharp
string key = "some-key";
LootLockerSDKManager.GetSingleKeyPersistentStorage(key, (response) =>
{
    if (response.success)
    {
        if (response.payload != null)
        {
            Debug.Log("Successfully retrieved player storage with value: " + response.payload.value);
        } else
        {
            Debug.Log("Item with key " + key + " does not exist");
        }
    } else
    {
        Debug.Log("Error getting player storage");
    }
});
```

{% endtab %}

{% tab title="Unreal" %}

<figure><img src="https://534367586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVu1MPzezO-NgvC98xh%2Fuploads%2Fgit-blob-55c08a322a6433faab8fa56f36e032e9ebc6cbc4%2Fimage%20(47).png?alt=media" alt=""><figcaption><p><a href="https://blueprintue.com/blueprint/xntq6m5x/">Blueprint example of retrieving a single storage value</a></p></figcaption></figure>
{% endtab %}

{% tab title="REST" %}

```bash
curl -X GET "https://api.lootlocker.io/game/v1/player/storage?key=user.something" \
  -H "x-session-token: your_token_here"
```

Example response:

```json
{
  "success": true,
  "payload": {
    "key": "user.answer",
    "value": "42",
    "is_public": false
  }
}
```

{% endtab %}
{% endtabs %}

#### Update Player Storage

To update a single value for a key

{% tabs %}
{% tab title="Unity" %}

```csharp
LootLockerSDKManager.UpdateOrCreateKeyValue("some-key", "some new value", (getPersistentStoragResponse) =>
{
    if (getPersistentStoragResponse.success)
    {
        Debug.Log("Successfully updated player storage");
    }
    else
    {
        Debug.Log("Error updating player storage");
    }
});
```

{% endtab %}

{% tab title="Unreal" %}

<figure><img src="https://534367586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVu1MPzezO-NgvC98xh%2Fuploads%2Fgit-blob-062e91cfa4f8a22326178023944ba2ea11b8ce1a%2Fimage%20(54).png?alt=media" alt=""><figcaption><p><a href="https://blueprintue.com/blueprint/t5ustnxr/">Blueprint example of updating a single value</a></p></figcaption></figure>
{% endtab %}

{% tab title="REST" %}

```bash
curl -X POST "https://api.lootlocker.io/game/v1/player/storage" \
  -H "x-session-token: your_token_here" \
  -H "Content-Type: application/json" \
  -d '
[
  {
    "key": "totalDeaths",
    "value": "124",
    "is_public": true,
    "order": 1
  }
]'
```

{% endtab %}
{% endtabs %}

To update or create multiple keys at the same time

{% tabs %}
{% tab title="Unity" %}

```csharp
LootLockerGetPersistentStorageRequest data = new LootLockerGetPersistentStorageRequest();
data.AddToPayload(new LootLockerPayload { key = "some-key", value = "Some new value" });
data.AddToPayload(new LootLockerPayload { key = "some-other-key", value = "Some other new value" });

LootLockerSDKManager.UpdateOrCreateKeyValue(data, (getPersistentStoragResponse) =>
{
    if (getPersistentStoragResponse.success)
    {
        Debug.Log("Successfully updated player storage");
    }
    else
    {
        Debug.Log("Error updating player storage");
    }
});
```

{% endtab %}

{% tab title="Unreal" %}

<figure><img src="https://534367586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVu1MPzezO-NgvC98xh%2Fuploads%2Fgit-blob-4f443419f447f3fcbcea539a700f9c1141ccde77%2Fimage%20(48).png?alt=media" alt=""><figcaption><p><a href="https://blueprintue.com/blueprint/eu7ddj9-/">Blueprint example of creating or updating multiple keys</a></p></figcaption></figure>
{% endtab %}

{% tab title="REST" %}

```bash
curl -X POST "https://api.lootlocker.io/game/v1/player/storage" \
  -H "x-session-token: your_token_here" \
  -H "Content-Type: application/json" \
  -d '
[
  {
    "key": "totalDeaths",
    "value": "124",
    "is_public": true,
    "order": 1
  },
  {
    "key": "animal",
    "value": "Sheep",
    "order": 2
  }
]'
```

{% endtab %}
{% endtabs %}

#### Remove Player Storage Item

{% tabs %}
{% tab title="Unity" %}

```csharp
LootLockerSDKManager.DeleteKeyValue("some-key", (getPersistentStoragResponse) =>
{
    if (getPersistentStoragResponse.success)
    {
        Debug.Log("Successfully removed key from player storage");
    }
    else
    {
        Debug.Log("Error removing key from player storage");
    }
});
```

{% endtab %}

{% tab title="Unreal" %}

<figure><img src="https://534367586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVu1MPzezO-NgvC98xh%2Fuploads%2Fgit-blob-fbc1fda70a57abdf7cf20ebe409ee7af7f5a1b85%2Fimage.png?alt=media" alt=""><figcaption><p><a href="https://blueprintue.com/blueprint/wzfkq1zb/">Blueprint example of deleting key</a></p></figcaption></figure>
{% endtab %}

{% tab title="REST" %}

```bash
curl -X DELETE "https://api.lootlocker.io/game/v1/player/storage?key=fruit" \
  -H "x-session-token: your_token_here"
```

{% endtab %}
{% endtabs %}

#### Get Other Players Public Storage

For this you need the public UID of the other player.

{% tabs %}
{% tab title="Unity" %}

```csharp
LootLockerSDKManager.GetOtherPlayersPublicKeyValuePairs("92AR9254", (response) =>
{
    if (response.success)
    {
        Debug.Log("Successfully retrieved storage for other player " + response.payload.Length);
    }
    else
    {
        Debug.Log("Error retrieving storage for other player");
    }
});
```

{% endtab %}

{% tab title="Unreal" %}

<figure><img src="https://534367586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVu1MPzezO-NgvC98xh%2Fuploads%2Fgit-blob-7aa04b48c1246b82f3b695892ce9bab5cf5b4d72%2Funreal-bp-get-other-players-storage.png?alt=media" alt=""><figcaption><p><a href="https://blueprintue.com/blueprint/wzfkq1zb/">Blueprint example of deleting key</a></p></figcaption></figure>
{% endtab %}

{% tab title="REST" %}

#### Get by Player ID

```bash
curl -X GET "https://api.lootlocker.io/game/v1/player/1234/storage" \
  -H "x-session-token: your_token_here"
```

#### Get by Player Public UID

```bash
curl -X GET "https://api.lootlocker.io/game/v1/player/A1B2C3D4/storage" \
  -H "x-session-token: your_token_here"
```

Example response:

```json
{
  "success": true,
  "payload": [
    {
      "key": "user.answer",
      "value": "42",
      "is_public": true
    }
  ]
}
```

{% endtab %}
{% endtabs %}
