question

teemu77 avatar image
teemu77 asked

Efficient way of getting a player's standings in multiple leaderboards

Hello,

I currently have around 10 (and counting) leaderboards and every player is in every one of them. I'd like the player to be able to view their or another players standings in each leaderboard, but it doesn't look like there's a way to do that without doing a call for each leaderboard separately, which seems less than ideal. Please do correct me if I've missed something.

I'm wondering if I should just limit the amount of players shown in leaderboards to 1k-10k for example, and then just load the top X players in each leaderboard once when the player begins their session to avoid an excessive amount of calls to the PlayFab API. Then I'd store the results on my client and do all of the leaderboards handling locally from there on out.

Any suggestions what a good workflow would be? Are there any downsides in having "MaxResultsCount" leaderboards queries be a larger number like 1000-10000?

Thanks!

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Made Wang avatar image
Made Wang answered

PlayFab does not provide an API to get multiple leaderboards at once, you need to get them separately.

If you just need to get the rank of a player on a leaderboard, you can call GetLeaderboardAroundPlayer.

Referring to Player Data Management - Get Leaderboard - REST API (PlayFab Client) | Microsoft Docs, the maximum value of MaxResultsCount is only 100. It is used to set the number of entries in the acquired leaderboard. The larger the value, the more entries are acquired, the more time is required, and the more resources are consumed.

Does dealing with leaderboards mean giving rewards based on rank? If so, PlayFab has prize tables to implement this feature. Refer to Using Prize Tables - PlayFab | Microsoft Docs.

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

teemu77 avatar image teemu77 commented ·

Ah, I missed MaxResultsCount having a maximum value of 100. That's unfortunate.

I'll give a more concrete example for the usage I'm looking for:

Currently my game has around 10 skills that players can level up in, and each of them have a dedicated leaderboard on PlayFab. Works great when only displaying the top 100 members of each skill - but I'd like for players to be able to view see what their (or a friends) rank is in all existing skills.

Having to make a call to PlayFab for each leaderboard to get a players rank in it seems like it could be problematic. That would need to be done every time a player wants to get their "main profile", or search for the profile of another player. Do you think it's a viable option or should I scrap that idea all together?

I don't intend to have any rewards attached to the leaderboards. Purely a visual feature to track your progress against other players.

0 Likes 0 ·
Made Wang avatar image Made Wang teemu77 commented ·

As I said above, you can call GetLeaderboardAroundPlayer to get the rank of a specified player, and if you set MaxResultsCount to 1, then the returned result will only contain data entries for the specified player. And if you want to get the ranking of each leaderboard, then you need to call the API once for each leaderboard.

If you only need to get the ranking of the specified player, then it is feasible to get 10 rankings in a row.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.