# Use Player Leaderboards

### Submitting Score

Submit a score to a player leaderboard.

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

```csharp
string leaderboardKey = "my_leaderboard";
int score = 1000;

LootLockerSDKManager.SubmitScore("", score, leaderboardKey, (response) =>
{
    if (!response.success) {
        Debug.Log("Could not submit score!");
        Debug.Log(response.errorData.ToString());
        return;
    } 
    Debug.Log("Successfully submitted score!");
   
});
```

Check out our [Reference Documentation](https://ref.lootlocker.com/game/api-5291505) for a more in-depth understanding of the endpoint.
{% endtab %}

{% tab title="Unreal" %}

<figure><img src="/files/ZpIkXntUxqhpHknykhov" alt="" width="563"><figcaption><p><a href="https://blueprintue.com/blueprint/8xnu73ja/">Blueprint example of submitting scores</a></p></figcaption></figure>

To copy and paste the above example into your editor, [look here](https://blueprintue.com/blueprint/8xnu73ja/).

**Input**

You need to exchange the `TriggerSubmitScore` event for whatever event you want to use to trigger this flow.

Replace the input variables with the data you want to submit to the leaderboard.

**Output**

We recommend branching the completed events on the success flag in the response, and if you do this, you will probably want to add error handling in case the request fails as well as what (if any) continued actions you want on success.

\
Check out our [Reference Documentation](https://ref.lootlocker.com/game/api-5291505) for a more in-depth understanding of the endpoint.
{% endtab %}

{% tab title="Godot" %}

```gdscript

var leaderboardKey : String = "my_leaderboard";
var score : int = 1000;
var response = await LL_Leaderboards.SubmitScore.new(leaderboardKey, score).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 POST "https://api.lootlocker.io/game/leaderboards/1/submit" \
-d "{\"score\": 1000}" \
-H "Content-Type: application/json"
```

Check out our [Reference Documentation](https://ref.lootlocker.com/game/api-5291505) for a more in-depth understanding of the endpoint.
{% endtab %}
{% endtabs %}

### Get Leaderboard Entries

Retrieve the first 50 player leaderboard entires.

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

```csharp
string leaderboardKey = "my_leaderboard";
int count = 50;

LootLockerSDKManager.GetScoreList(leaderboardKey, count, 0, (response) =>
{
    if (!response.success) {
        Debug.Log("Could not get score list!");
        Debug.Log(response.errorData.ToString());
        return;
    } 
    Debug.Log("Successfully got score list!");
});
```

Check out our [Reference Documentation](https://ref.lootlocker.com/game/api-5291504) for a more in-depth understanding of the endpoint.
{% endtab %}

{% tab title="Unreal" %}

<figure><img src="/files/jjcIjAAJYrAXrBtLAtuZ" alt=""><figcaption><p><a href="https://blueprintue.com/blueprint/dszhz35d/">Blueprint example of getting top scores</a></p></figcaption></figure>

To copy and paste the above example into your editor, [look here](https://blueprintue.com/blueprint/dszhz35d/).

**Input**

You need to exchange the `TriggerGetScores` event for whatever event you want to use to trigger this flow. Replace the input variables with your leaderboard key, and how many items you want to get.

**Output**

We recommend branching the completed events on the success flag in the response, and if you do this, you will probably want to add error handling in case the request fails as well as what (if any) continued actions you want on success. If you want to fetch more items on the score list, you'll want to save the pagination information for later use.

Check out our [Reference Documentation](https://ref.lootlocker.com/game/api-5291504) for a more in-depth understanding of the endpoint.
{% endtab %}

{% tab title="Godot" %}

```gdscript

var leaderboardKey : String = "my_leaderboard";
var count : int = 50;

var response = await LL_Leaderboards.GetScoreList.new(leaderboardKey, count).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/leaderboards/1/list?count=50"
```

Check out our [Reference Documentation](https://ref.lootlocker.com/game/api-5291504) for a more in-depth understanding of the endpoint.
{% endtab %}
{% endtabs %}

### Get Single Entry on Leaderboard

Retrieve a single entry on a player leaderboard.

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

```csharp
string leaderboardKey = "my_leaderboard";
string memberID = "50";

LootLockerSDKManager.GetMemberRank(leaderboardKey, memberID, (response) =>
{
    if (!response.success) {
        Debug.Log("Could not get the entry!");
        Debug.Log(response.errorData.ToString());
        return;
    } 
    Debug.Log("Successfully got entry!");
});
```

{% endtab %}

{% tab title="Unreal" %}

<figure><img src="/files/WM3cr2i4cFMgiLT7RzqN" alt=""><figcaption><p><a href="https://blueprintue.com/blueprint/3vwg3gfs/">Blueprint example of getting score for a member</a></p></figcaption></figure>

To copy and paste the above example into your editor, [look here](https://blueprintue.com/blueprint/3vwg3gfs/).

**Input**

You need to exchange the `TriggerGetScores` event for whatever event you want to use to trigger this flow. Replace the input variables with your leaderboard key and what member you want to fetch.

**Output**

We recommend branching the completed events on the success flag in the response, and if you do this, you will probably want to add error handling in case the request fails as well as what (if any) continued actions you want on success.
{% endtab %}

{% tab title="Godot" %}

```gdscript

var leaderboardKey : String = "my_leaderboard";
var memberId : String = "a_member_id";

var response = await LL_Leaderboards.GetMemberRank.new(leaderboardKey, memberId).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/leaderboards/1/member/1"
```

{% endtab %}
{% endtabs %}


---

# 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/game-systems/leaderboards/how-to/use-player-leaderboards.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.
