Fetch leaderboard entries by rank / create cursor for specified rank

I am using Defold (latest) and Nakama (3.19) for my game development project. The overall setup works just great. However, when implementing a leaderboard screen, I haven’t found a solution yet to fetch data for a given range of ranks.

Suppose we have a scrollable list of leaderboard entries, initially centered around the players current rank. This works because it is possible to fetch the data around owner. Now, when the player scrolls or jumps to another range in the leaderboard list, it seems there is no possibility to fetch data for a given range of ranks. The only way I see here is to use the prev/next cursors in a loop until I reach/cover the rank range of interest. Moreover, I see that when using the limit option > 1, the next cursor works as expected, because it gives the next entry from the last returned entry. For the prev cursor, i get the previous entry of the first returned entry. this seems somehow logically correct, but: When paging backwords in the list, I have to fetch entries one-by-one, instead of fetching a page of e.g. 100 entries.

I was just wondering, if anyone here has a better and more efficient idea.

Also, is it possible to filter the results on the server side to reduce network load? I mean, I just want to have rank, score, and username for each rank. I am not interested in timestamps,metadata,owner_id as well as the leaderboard_id and the max_num_score. The latter is always the same, so i don’t see any reason to transmit this information with each item.

Thank you

Hello @0xbeefbeef,

From Nakama 3.18 a LeaderboardRecordsListCursorFromRank function was introduced, it should cover your needs.

The only way to filter data from the results would be to create a custom RPC.

Hope this helps.

Hi @sesposito ,

Yep, found this function, and yes, it does the job pretty well. Fortunately, Nakama is pretty flexible on the server side.

Thank you!