Retrieve Leaderboard Data
When wanting to retrieve and show leaderboard data we have a few scenarios:
    Show the top of the leaderboards
    Show a single entry on the leaderboards
    Show a single entry score + surrounding entries score
    Show scores for some specific members

Show the top of the leaderboards

Unity
REST
1
int leaderboardID = 123;
2
int count = 50;
3
int after = 0;
4
5
LootLockerSDKManager.GetScoreList(leaderboardID, count, after, (response) =>
6
{
7
if (response.statusCode == 200) {
8
Debug.Log("Successful");
9
} else {
10
Debug.Log("failed: " + response.Error);
11
}
12
});
Copied!
1
curl -X GET "https://api.lootlocker.io/game/leaderboards/1/list?count=10"
Copied!

Show a single entry on the leaderboards

Unity
REST
1
int leaderboardID = 123;
2
string memberID = "50";
3
4
LootLockerSDKManager.GetMemberRank(leaderboardID, memberID, (response) =>
5
{
6
if (response.statusCode == 200) {
7
Debug.Log("Successful");
8
} else {
9
Debug.Log("failed: " + response.Error);
10
}
11
});
Copied!
1
curl -X GET "https://api.lootlocker.io/game/leaderboards/1/member/1"
Copied!

Show a single entry score + surrounding entries score

Here we do 2 calls, first we get the single entry for the member we're looking for, then we do another call to get the rest.
Unity
REST
1
int leaderboardID = 123;
2
string memberID = "50";
3
4
LootLockerSDKManager.GetMemberRank(leaderboardID, memberID, (response) =>
5
{
6
if (response.statusCode == 200)
7
{
8
int rank = response.rank;
9
int count = 10;
10
int after = rank < 6 ? 0 : rank - 5;
11
12
LootLockerSDKManager.GetScoreList(leaderboardID, count, after, (response) =>
13
{
14
if (response.statusCode == 200)
15
{
16
Debug.Log("Successful");
17
}
18
else
19
{
20
Debug.Log("failed: " + response.Error);
21
}
22
});
23
}
24
else
25
{
26
Debug.Log("failed: " + response.Error);
27
}
28
});
Copied!
1
curl -X GET "https://api.lootlocker.io/game/leaderboards/1/member/1"
2
3
# player gets returned with rank 55
4
5
curl -X GET "https://api.lootlocker.io/game/leaderboards/1/list?count=10&after=49"
Copied!

Show scores for some specific members

This can be used for doing things like friend leaderboards.
Unity
1
int leaderboardID = 123;
2
string[] memberIDs = new string[3]{"50", "105", "999"};
3
4
LootLockerSDKManager.GetByListOfMembers(leaderboardID, memberIDs, (response) =>
5
{
6
if (response.statusCode == 200) {
7
Debug.Log("Successful");
8
} else {
9
Debug.Log("failed: " + response.Error);
10
}
11
});
Copied!
Last modified 5d ago
Copy link