Skip to main content
Version: 5.15.0

GetLeaderboard

public BackendUserLeaderboardReturnObject GetLeaderboard(string leaderboardUuid);
public BackendUserLeaderboardReturnObject GetLeaderboard(string leaderboardUuid, int limit);
public BackendUserLeaderboardReturnObject GetLeaderboard(string leaderboardUuid, int limit, int offset);

Parameters

ValueTypeDescriptionDefault
leaderboardUuidstringuuid of the ranking to look up-
limitintNumber of rank holders to look up (1 - 50)10
offsetintStarting point of the ranking to look up (0 or more)0

The leaderboardUuid value can be checked using the following methods:

Description

Looks up the list of rank holders in your group using a uuid value.

  • In the case of users that do not belong to any groups, NULL group's leaderboard is looked up.

    In the case of joint ranks, gamer_ids (member numbers) are sorted lexicographically according to the set rank-sorting criteria (ascending/descending order).

  • This method cannot be called via SendQueue.

BackendUserLeaderboardReturnObject

namespace BackEnd.Leaderboard
{
public class UserLeaderboardItem
{
public string gamerInDate;
public string nickname = string.Empty;
public string score;
public string index;
public string rank;
public string extraData = string.Empty;
public string extraName = string.Empty;
}

public class BackendUserLeaderboardReturnObject : BackendReturnObject
{
public long GetTotalCount();
public List<UserLeaderboardItem> GetUserLeaderboardList();
}
}

Example

Synchronous

BackEnd.Leaderboard.BackendUserLeaderboardReturnObject bro = null;

// Look up the 1st - 10th rank holders in the leaderboardUuid ranking
bro = Backend.Leaderboard.User.GetLeaderboard("leaderboardUuid");
// Look up the 1st - 50th rank holders in the leaderboardUuid ranking
bro = Backend.Leaderboard.User.GetLeaderboard("leaderboardUuid", 50);
// Look up the 11th - 20th rank holders in the leaderboardUuid ranking
bro = Backend.Leaderboard.User.GetLeaderboard("leaderboardUuid", 10, 10);

if(bro.IsSuccess() == false) {
return;
}

Debug.Log("Total number of users registered to the leaderboard : " + bro.GetTotalCount());

foreach(BackEnd.Leaderboard.UserLeaderboardItem item in bro.GetUserLeaderboardList())
{
Debug.Log($"Rank {item.rank} : {item.nickname}");
Debug.Log(item.ToString());
}

Asynchronous

// Look up the 1st - 10th rank holders in the leaderboardUuid ranking
Backend.Leaderboard.User.GetLeaderboard("leaderboardUuid", callback=> {
if(callback.IsSuccess() == false) {
return;
}

Debug.Log("Total number of user registrations to leaderboard : " + callback.GetTotalCount());

foreach(BackEnd.Leaderboard.UserLeaderboardItem item in callback.GetUserLeaderboardList())
{
Debug.Log($"Rank {item.rank} : {item.nickname}");
Debug.Log(item.ToString());
}
});

// Look up the 1st - 50th rank holders in the leaderboardUuid ranking
Backend.Leaderboard.User.GetLeaderboard("leaderboardUuid", 50, callback=> {
// Post-process
});
// Look up the 11th - 20th rank holders in the leaderboardUuid ranking
Backend.Leaderboard.User.GetLeaderboard("leaderboardUuid", 10, 10, callback=> {
// Post-process
});

ReturnCase

Success cases

When the lookup is successful
statusCode : 200
message : Success
returnValue : refer to GetReturnValuetoJSON

When the lookup is successful but the rank holder is not in the lookup range
statusCode : 200
message : Success
returnValue : {"rows":[]}

Error cases

When the leaderboardUuid is null or string.Empty
statusCode : 400
errorCode : ValidationException
message : leaderboardUuid is null or empty

When the uuid does not exist
StatusCode : 404
ErrorCode : NotFoundException
Message : leaderboard not found, leaderboard cannot be found

GetReturnValuetoJSON

{
"rows": [
{
"gamerInDate": "2024-08-20T05:58:07.391Z",
"nickname": "user99",
"rank": 1,
"index": 0,
"score": 99
// When additional field exists
"Additional field column name": "Data"
},
{
"gamerInDate": "2024-08-20T05:58:06.281Z",
"nickname": "user98",
"rank": 2,
"index": 1,
"score": 98
}
],
"totalCount": 99
}