# Work with Player Names

When possible, LootLocker will attach a name to the player when starting a session.\
This however, is only possible for platforms where the player has a name already, such as Steam or PlayStation Network.

**Platforms Supporting Automatic Names**

Platforms where the name is automatically retrieved when starting a session:

* Steam
* PlayStation Network

If you're using a platform without automatic player names, or want to update the name LootLocker has stored for the player, it's possible to change the name using the SDK or API.

Player names can also be viewed in the web console:

![Players with names in the web console](/files/-Mk2_BSZutL5Tdlqvn3I)

#### Unique Player Names

If you want to ensure that no two players in your game has the same name, you can use the `Unique Player Names` setting in your [games settings](https://console.lootlocker.com/settings/game).

Enabling this toggle, will return an error when updating a players name, if that name is already taken.

#### Update Player Name in Game

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

```csharp
LootLockerSDKManager.SetPlayerName("Some other name", (response) =>
{
    if (response.success)
    {
        Debug.Log("Successfully set player name");
    } else
    {
        Debug.Log("Error setting player name");
    }
});
```

{% endtab %}

{% tab title="Unreal" %}

<figure><img src="/files/2J5N2C5VD27lwmkchATv" alt=""><figcaption><p><a href="https://blueprintue.com/blueprint/dv4kl079/">Blueprint example of updating player name</a></p></figcaption></figure>
{% endtab %}

{% tab title="Godot" %}

```gdscript

var response = await LL_Players.SetPlayerName.new("a-new-name").send()
if(!response.success) :
    # Request failed, handle errors
    pass
else:
    # Request succeeded, use response as applicable in your game logic
    pass
```

{% endtab %}

{% tab title="REST" %}

```bash
curl -X PATCH "https://api.lootlocker.io/game/player/name" \
  -H "x-session-token: your_token_here" \
  -H "LL-Version: 2021-03-01" \
  -H "Content-Type: application/json" \
  -d "{\"name\": \"Player Name\"}"
```

Example response:

```json
{
  "name": "Player Name"
}
```

{% endtab %}
{% endtabs %}

#### Retrieve Player Name in Game

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

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

{% endtab %}

{% tab title="Unreal" %}

<figure><img src="/files/X8QcA2GnahfXAR8G4Nhm" alt=""><figcaption><p><a href="https://blueprintue.com/blueprint/rl9x4o8g/">Blueprint example of getting player name</a></p></figcaption></figure>
{% endtab %}

{% tab title="Godot" %}

```gdscript

var response = await LL_Players.GetPlayersActiveName.new().send()
if(!response.success):
    # Request failed, handle errors
    pass
else:
    # Request succeeded, use response as applicable in your game logic
    pass
```

{% endtab %}

{% tab title="REST" %}

```bash
curl -X GET "https://api.lootlocker.io/game/player/name" \
  -H "x-session-token: your_token_here" \
  -H "LL-Version: 2021-03-01"
```

Example response:

```json
{
  "name": "Player Name"
}
```

{% endtab %}
{% endtabs %}

#### Lookup Multiple Player Names using Player IDs

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

```csharp
ulong player1ID = 1;
ulong player2ID = 2;
ulong player3ID = 3;

LootLockerSDKManager.LookupPlayerNamesByPlayerIds(new ulong[] { player1ID, player2ID, player3ID }, response =>
{
    if (response.success)
    {
        foreach (var player in response.players)
        {
            Debug.Log(player.player_id);
            Debug.Log(player.player_public_uid);
            Debug.Log(player.name);
            Debug.Log(player.last_active_platform);
            Debug.Log(player.platform_player_id);
        }
    } else
    {
        Debug.Log("Error looking up player names");
    }
});
```

{% endtab %}

{% tab title="Unreal" %}

<figure><img src="/files/hOGdISLjpX47NoibSDDL" alt=""><figcaption><p><a href="https://blueprintue.com/blueprint/m4kdbavd/">Blueprint example of getting multiple player names</a></p></figcaption></figure>
{% endtab %}

{% tab title="REST" %}

```bash
curl -G "https://api.lootlocker.io/game/player/lookup/name" \
  -H "x-session-token: your_token_here" \
  -H "LL-Version: 2021-03-01" \
  -d player_id=1 \
  -d player_id=2 \
  -d player_public_uid=JARL7PGR \
  -d player_guest_login_id=a270686a-7dd7-482f-89b6-9b2a634f46fb \
  -d steam_id=9465748036854778475 \
  -d psn_id=1234567890 \
  -d xbox_id=E51D19530BBE721286F75C03B934E5EB7CA23B99
```

Example response:

```json
{
  "players": [
    {
      "player_id": 1,
      "player_public_uid": "6DDXH947",
      "name": "Player 1 Name",
      "last_active_platform": "xbox_one"
    },
    {
      "player_id": 2,
      "player_public_uid": "4FDGF738",
      "name": "Player 2 Name",
      "last_active_platform": "xbox_one"
    },
    {
      "player_id": 3,
      "player_public_uid": "JARL7PGR",
      "name": "Player 3 Name",
      "last_active_platform": "guest"
    },
    {
      "player_id": 4,
      "player_public_uid": "9HDK4F5Y",
      "name": "Player 4 PSN Name",
      "last_active_platform": "psn",
      "platform_player_id": "1234567890"
    },
    {
      "player_id": 5,
      "player_public_uid": "3XTMHFS3",
      "name": "Player 5 Steam Name",
      "last_active_platform": "steam",
      "platform_player_id": "9465748036854778475"
    },
    {
      "player_id": 6,
      "player_public_uid": "9RKPSRRT",
      "name": "Player 6 XBox Name",
      "last_active_platform": "xbox_one",
      "platform_player_id": "E51D19530BBE721286F75C03B934E5EB7CA23B99"
    },
    {
      "player_id": 7,
      "player_public_uid": "T4HV7G5D",
      "name": "Player 7 GuestLogin Name",
      "last_active_platform": "guest",
      "platform_player_id": "a270686a-7dd7-482f-89b6-9b2a634f46fb"
    }
  ]
}
```

{% endtab %}
{% endtabs %}

Multiple platforms and public UID is also supported:

```csharp
- LookupPlayerNamesByPlayerPublicUIds(string[] playerPublicUIds, Action onComplete)
- LookupPlayerNamesBySteamIds(ulong[] steamIds, Action onComplete)
- LookupPlayerNamesBySteamIds(string[] steamIds, Action onComplete)
- LookupPlayerNamesByPSNIds(ulong[] psnIds, Action onComplete)
- LookupPlayerNamesByPSNIds(string[] psnIds, Action onComplete)
- LookupPlayerNamesByXboxIds(string[] xboxIds, Action onComplete)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.lootlocker.com/players/names/how-to/player-names.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
