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
Unreal Engine
REST
Unity
int leaderboardID = 123;
int count = 50;
int after = 0;
LootLockerSDKManager.GetScoreList(leaderboardID, count, after, (response) =>
{
if (response.statusCode == 200) {
Debug.Log("Successful");
} else {
Debug.Log("failed: " + response.Error);
}
});
Unreal Engine
REST
curl -X GET "https://api.lootlocker.io/game/leaderboards/1/list?count=10"

Show a single entry on the leaderboards

Unity
Unreal Engine
REST
Unity
int leaderboardID = 123;
string memberID = "50";
LootLockerSDKManager.GetMemberRank(leaderboardID, memberID, (response) =>
{
if (response.statusCode == 200) {
Debug.Log("Successful");
} else {
Debug.Log("failed: " + response.Error);
}
});
Unreal Engine
REST
curl -X GET "https://api.lootlocker.io/game/leaderboards/1/member/1"

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
Unreal Engine
REST
Unity
int leaderboardID = 123;
string memberID = "50";
LootLockerSDKManager.GetMemberRank(leaderboardID, memberID, (response) =>
{
if (response.statusCode == 200)
{
int rank = response.rank;
int count = 10;
int after = rank < 6 ? 0 : rank - 5;
LootLockerSDKManager.GetScoreList(leaderboardID, count, after, (response) =>
{
if (response.statusCode == 200)
{
Debug.Log("Successful");
}
else
{
Debug.Log("failed: " + response.Error);
}
});
}
else
{
Debug.Log("failed: " + response.Error);
}
});
Unreal Engine
REST
curl -X GET "https://api.lootlocker.io/game/leaderboards/1/member/1"
# player gets returned with rank 55
curl -X GET "https://api.lootlocker.io/game/leaderboards/1/list?count=10&after=49"

Show scores for some specific members

This can be used for doing things like friend leaderboards.

Unity
Unity
int leaderboardID = 123;
string[] memberIDs = new string[3]{"50", "105", "999"};
LootLockerSDKManager.GetByListOfMembers(leaderboardID, memberIDs, (response) =>
{
if (response.statusCode == 200) {
Debug.Log("Successful");
} else {
Debug.Log("failed: " + response.Error);
}
});