Leaderboard
Leaderboards are key for building communities around your application. A leaderboard is an aggregation of player scores. Leaderboards are retrieved, assembled, and sorted on the server. brainCloud provides fast real-time access to leaderboards.
Multiple leaderboards can be configured for the application. Leaderboards can be configured as to how posted scores will be handled (e.g. player's highest score only, accumulate player's score, current posting, …) and how the leaderboard resets (daily, weekly, monthly, yearly, or not at all).
Leaderboards can be viewed from a global perspective or a social perspective. The global perspective comprises the entire leaderboard with an order imposed on it. Each posted score will have a zero-based index and a one-based rank based on the imposed order. The social perspective comprises a subset of the overall leaderboard consisting of the player, the player's friends, and the pacers configured for the leaderboard.
Leaderboard tournaments are supported and are applied to the social perspective after the leaderboard resets.
Pacers provide a set of "pseudo-friends" with pre-defined scores for the social leaderboard perspective and are useful for motivating players at the beginning of the reset period (before enough new scores have been posted).
There are five categories of leaderboard APIs:
- those relating to leaderboard score postings
- those for retrieving a player's social leaderboard
- those for retrieving global leaderboard entries
- those for retrieving historical versions of global leaderboards
- those relating to tournaments
Note that brainCloud also supports the concept of dynamically created leaderboards – which are leaderboards that are created on the fly via client code, instead of ahead-of-time via the design portal. Dynamic leaderboards can be useful if your game has a leaderboard for each level, and has so many levels that datafilling them via the tool would be cumbersome!
The leaderboard APIs are detailed below in order of the categories list above.
Valid sort keys for the retrieval APIs:
- "HIGH_TO_LOW" – returns leaderboard entries in standard order (high scores at the top, lower scores at the bottom)
- "LOW_TO_HIGH" – returns leaderboard entries in reverse order (lower scores at the top, higher scores at the bottom)
Keys for posting to dynamic leaderboards:
Leaderboard type – defines how the leaderboard will behave and be interpreted.
- "HIGH_VALUE" – player's score is posted only if it is higher than the player's previously posted score
- "LOW_VALUE" – player's score is posted only if it is lower than the player's previously posted score
- "CUMULATIVE" – player's score is added to the player's previously posted score
- "LAST_VALUE" – player's score replaces the player's previously posted score
- "ARCADE_LOW" – multiple player's scores are allowed to post and ranked in ascending order (i.e. lower scores are better)
- "ARCADE_HIGH" – multiple player's scores are allowed to post and ranked in descending order (i.e. higher scores are better)
Rotation type – defines when the leaderboard will reset. At reset, the leaderboard becomes the most recent retained version.
- "NEVER" – leaderboard does not reset (i.e. perpetual)
- "DAILY" – leaderboard resets once per day at the defined reset timestamp
- "WEEKLY" – leaderboard resets once per week at the defined reset timestamp
- "MONTHLY" – leaderboard resets once per month at the defined reset timestamp
- "YEARLY" – leaderboard resets once per year at the defined reset timestamp
Rotation reset – Timestamp at which the leaderboard will next reset. The reset timestamp is applicable only to a leaderboard that has been configured to reset (i.e. rotation types other than "NEVER"). The timestamp is specified as a formatted - string and can be provided in either of two formats: "dd-MM-yyyy" or "dd-MM-yyyy HH:mm" (note: all numeric digits).
Retained count – the number of leaderboard versions (including the current leaderboard) that will be retained (e.g. set to 1 will keep only the current period's leaderboard). The maximum is 8, which will keep the current period's leaderboard, - plus the 7 previous periods' leaderboards. Retained count is only applicable to a leaderboard that resets.
Notes regarding the data returned by the leaderboard calls:
- timeBeforeReset – returns the time until the next leaderboard reset in milliseconds.
API Summary
Global Leaderboard Views
- GetGlobalLeaderboardView - view the global leaderboard centered around this user's score
- GetGlobalLeaderboardPage - view a page of the global leaderboard
- GetGlobalLeaderboardEntryCount - returns the # of entries in the leaderboard
- GetGlobalLeaderboardVersions() - Retrieve information about the retained versions for the leaderboard (sorted newest to oldest).
Social Leaderboard Views
- GetSocialLeaderboard - retrieve a leaderboard filtered to this user's friends
- GetMultiSocialLeaderboard - retrieve the results of several leaderboards, filtered to this user's friends. Handy for Candy Crush-style maps.
- GetGroupSocialLeaderboard - retrieve a leaderboard filtered to the specified group
- GetPlayersSocialLeaderboard - retrieve a leaderboard filtered to a specific set of players
- GetPlayersSocialLeaderboardByVersion() - Retrieve a sorted, social leaderboard of the specified list of players by version.
Posting Scores
- GetPlayerScore - retrieves the player's score in the leaderboard
- GetPlayerScoresFromLeaderboards - retrieves the players score from multiple leaderboards
- PostScoreToLeaderboard - post a score to the specified leaderboard
- PostScoreToDynamicLeaderboardUTC - post a score to a leaderboard (creating the leaderboard if it doesn't already exist)
- PostScoreToDynamicLeaderboardDaysUTC - post a score to a leaderboard (creating the leaderboard if it doesn't already exist) based on an arbitrary number of days rotation
- PostScoreToLeaderboardOnBehalfOf - post score to another player's score
- PostScoreToDynamicLeaderboardUsingConfig - Post the player's score to the given social leaderboard, dynamically creating the leaderboard if it does not exist yet. To create new leaderboard, configJson must specify leaderboardType, rotationType, resetAt, and retainedCount, at a minimum, with support to optionally specify an expiry in minutes.
- RemovePlayerScore - Remove the players
Group Leaderboards
- GetGroupLeaderboardView - leaderboard results (of version) that centers on the current group
- GetGroupLeaderboardViewByVersion - leaderboard results that centers on the current group
- PostScoreToGroupLeaderboard - post the group score to the given group leaderboard
- PostScoreToDynamicGroupLeaderboardUTC - post the group score to the given group leaderboard (creating the leaderboard if it doesn't already exist)
- PostScoreToDynamicGroupLeaderboardUsingConfig - Post the group's score to the given social leaderboard, dynamically creating the group leaderboard if it does not exist yet. To create new leaderboard, configJson must specify leaderboardType, rotationType, resetAt, and retainedCount, at a minimum, with support to optionally specify an expiry in minutes.
- RemoveGroupScore - removes the group's score data from the specified group leaderboard
Leaderboard Managerment
- ListAllLeaderboards - retrieves a list of all leaderboards
- CreateLeaderboard - creates a leaderboard
- EditLeaderboard - updates a leaderboard
- DeleteLeaderboards - deletes a leaderboard
- SysResetNeverLeaderboard - manually reset a never-rotating leaderboard
- SysCreateLeaderboard - Create a new player or group entry leaderboard configuration.
- SysEditLeaderboard - Edit a player or group entry leaderboard configuration.
- SysCreateLeaderboardConfig - Creates a leaderboard configuration, with support for tournament leaderboards.
- SysEditLeaderboardConfig - Edits a leaderboard configuration, with support for tournament leaderboards.
- SysGetLeaderboardConfig - Returns leaderboard configuration information, including tournament settings, for future and current (active) version of the specified leaderboard.
- SysListLeaderboardConfigs - Returns list of applicable leaderboards, with summary leaderboard configuration information, including tournament flags, if applicable. Any supported optionsJson flag not specified will default to false.
- SysEditTournamentSettingsForFuturePeriodsOnly - Updates the tournament settings for the leaderboard configuration, for future recurring periods only (does not affect current rotation). Supported tSettingsJson settings include: 'tTournament' (with 'tConfigs' to configure tournament templates, 'tAutoJoin' flag, 'tAutoClaim' flag), and 'tPhases' (to schedule 'enrolMins', 'announcementMins', 'disallowMins' and 'bufferMins' minutes).
- SysEditTournamentSettingsIncludingCurrentPeriod - Updates the tournament settings for the leaderboard configuration, for the current period in progress, as well as the future periods if recurring periods (not ADHOC). Supported tSettingsJson settings include: 'tTournament' (with 'tConfigs' to configure tournament templates, 'tAutoJoin' flag, 'tAutoClaim' flag), and 'tPhases' (to schedule 'enrolMins', 'announcementMins', 'disallowMins' and 'bufferMins' minutes), and, if ADHOC tournament in progress, API also supports 'tPeriod' duration settings ('durationDays', 'durationDays', 'durationDays').
- SysCreateAdhocTournamentPeriod - Schedules a new tournament period for the ADHOC leaderboard configuration. Tournament must be scheduled in the future. Tournament settings ('tSettingsJson') must include tournament period ('tPeriod'), tournament configs and associated flags ('tTournament') and tournament phases ('tPhases').
- SysEditAdhocTournamentPeriod - Updates a future ADHOC tournament period scheduled for the leaderboard configuration, identified by the existing period's UTC startingAt time, in milliseconds. Period being edited must be scheduled in the future, not in-progress. Tournament settings may include tournament period ('tPeriod'), tournament configs and associated flags ('tTournament') and tournament phases ('tPhases').
- SysDeleteAdhocTournamentPeriod - Deletes a future ADHOC tournament period scheduled for the leaderboard configuration, identified by the existing period's UTC startingAt time, in milliseconds. Period being edited must be scheduled in the future, not in-progress. Tournament settings may include tournament period ('tPeriod'), tournament configs and associated flags ('tTournament') and tournament phases ('tPhases').
- SysGetLeaderboardConfigsPage - Returns a page of leaderboard configurations from the server based on the specified context.
- SysGetLeaderboardConfigsPageOffset - Gets the page of leaderboard configuration information from the server based on the encoded context and specified page offset.
📄️ CreateLeaderboard
WARNING: This call, CreateLeaderboard(), has been deprecated and replaced with SysCreateLeaderboardConfig().
📄️ DeleteLeaderboards
Deletes the specified leaderboards from server.
📄️ EditLeaderboard
WARNING: This call, EditLeaderboard(), will be deprecated and replaced with SysEditLeaderboard().
📄️ GetGlobalLeaderboardEntryCount
Method returns the number of entries in a global leaderboard.
📄️ GetGlobalLeaderboardEntryCountByVersion
Method returns the number of entries in a global leaderboard.
📄️ GetGlobalLeaderboardPage
NOTE: The friend summary data is returned for each record in the leaderboard.
📄️ GetGlobalLeaderboardPageByVersion
NOTE: The friend summary data is returned for each record in the leaderboard.
📄️ GetGlobalLeaderboardPageByVersionIfExists
Method returns a view of global leaderboard results that centers on the current player, if the leaderboard exists. By using a non-current version id, the user can retrieve a historical leaderboard. Silently fails, if leaderboard does not exist, just returns null and success, instead of an error.
📄️ GetGlobalLeaderboardPageIfExists
Retrieve a page of the global leaderboard specified, if it exists, by the start and end indexes (0-based). Silently fails, if leaderboard does not exist, just returns null and success, instead of an error.
📄️ GetGlobalLeaderboardVersions
Method returns version information about the global leaderboard and some configuration information for the leaderboard.
📄️ GetGlobalLeaderboardView
Method returns a view of global leaderboard results that centers on the current player.
📄️ GetGlobalLeaderboardViewByVersion
Method returns a view of global leaderboard results that centers on the current player. By using a non-current version id, the user can retrieve a historical leaderboard.
📄️ GetGlobalLeaderboardViewByVersionIfExists
Method returns a view of global leaderboard results that centers on the current player, if the leaderboard exists. By using a non-current version id, the user can retrieve a historical leaderboard. Silently fails, if leaderboard does not exist, just returns null and success, instead of an error.
📄️ GetGlobalLeaderboardViewIfExists
Retrieve a view of the global leaderboard, if it exists, surrounding the current player. Silently fails, if leaderboard does not exist, just returns null and success, instead of an error.
📄️ GetGroupLeaderboardView
Retrieve a view of the group leaderboard surrounding the current group score.
📄️ GetGroupLeaderboardViewByVersion
Method returns a view of group leaderboard results that centers on the current group. By using a non-current version id, the user can retrieve a historical group leaderboard.
📄️ GetGroupSocialLeaderboard
Retrieve the social leaderboard for a group.
📄️ GetGroupSocialLeaderboardByVersion
Retrieve the social leaderboard by version, for a group.
📄️ GetMultiSocialLeaderboard
Reads multiple social leaderboards.
📄️ GetPlayerScore
Gets a player's score from a leaderboard. If the player does not have a score in a leaderboard this method returns an error.
📄️ GetPlayerScores
Retrieves up to maxResults scores data for user for arcade-style leaderboard.
📄️ GetPlayerScoresFromLeaderboards
Gets a player's score from multiple leaderboards. Will only return scores if they exist.
📄️ GetPlayersSocialLeaderboard
Retrieve the social leaderboard for a list of players.
📄️ GetPlayersSocialLeaderboardByVersion
Retrieve the social leaderboard by version, for a list of players.
📄️ GetPlayersSocialLeaderboardByVersionIfExists
Retrieve a sorted, social leaderboard of the specified list of players by version, if leaderboard exists. Silently fails, if leaderboard does not exist, just returns null and success, instead of an error.
📄️ GetPlayersSocialLeaderboardIfExists
Retrieve a sorted, social leaderboard of the specified list of players, if leaderboard exists. Silently fails, if leaderboard does not exist, just returns null and success, instead of an error.
📄️ GetSocialLeaderboard
Note that friend summary data is returned for each record in the leaderboard.
📄️ GetSocialLeaderboardByVersion
Note that friend summary data is returned for each record in the leaderboard.
📄️ GetSocialLeaderboardByVersionIfExists
Retrieve the social leaderboard by version, if leaderboard exists. Optional parameters: replaceName. Silently fails, if leaderboard does not exist, just returns null and success, instead of an error.
📄️ GetSocialLeaderboardIfExists
Retrieve the social leaderboard, if it exists. Optional parameters: replaceName. Silently fails, if leaderboard does not exist, just returns null and success, instead of an error.
📄️ ListAllLeaderboards
Method returns list of all the leaderboards from the server based on gameId of the user.
📄️ PostScoreToDynamicGroupLeaderboardDaysUTC
Post the group score to the given group leaderboard with a rotation type of DAYS and dynamically create if necessary.
📄️ PostScoreToDynamicGroupLeaderboardUsingConfig
Post the group's score to the given social leaderboard, dynamically creating the group leaderboard if it does not exist yet. To create new leaderboard, configJson must specify leaderboardType, rotationType, resetAt, and retainedCount, at a minimum, with support to optionally specify an expiry in minutes.
📄️ PostScoreToDynamicGroupLeaderboardUTC
Post the group score to the given group leaderboard and dynamically create if necessary. LeaderboardType, rotationType, rotationReset, and retainedCount are required.
📄️ PostScoreToDynamicLeaderboardDaysUTC
Post the players score to the given social leaderboard with a rotation type of DAYS. You can optionally send a user-defined JSON string of data with the posted score. This string could include information relevant to the posted score.
📄️ PostScoreToDynamicLeaderboardUsingConfig
Post the player's score to the given social leaderboard, dynamically creating the leaderboard if it does not exist yet. To create new leaderboard, configJson must specify leaderboardType, rotationType, resetAt, and retainedCount, at a minimum, with support to optionally specify an expiry in minutes.
📄️ PostScoreToDynamicLeaderboardUTC
Post the players score to the given social leaderboard. You can optionally send a user-defined json string of data with the posted score. This string could include information relevant to the posted score.
📄️ PostScoreToGroupLeaderboard
Post the group score to the given group leaderboard. Optional parameters: data.
📄️ PostScoreToLeaderboard
Post the players score to the given social leaderboard.
📄️ PostScoreToLeaderboardOnBehalfOf
Post score to another player's score.
📄️ RemoveGroupScore
Removes the group's score data from the specified group leaderboard. Optional parameters: versionId
📄️ RemovePlayerScore
Removes a player's score from the leaderboard.
📄️ SysCreateAdhocTournamentPeriod
Schedules a new tournament period for the ADHOC leaderboard configuration. Tournament must be scheduled in the future. Tournament settings ('tSettingsJson') must include tournament period ('tPeriod'), tournament configs and associated flags ('tTournament') and tournament phases ('tPhases').
📄️ SysCreateLeaderboard
WARNING: This call, SysCreateLeaderboard(), has been deprecated and replaced with SysCreateLeaderboardConfig().
📄️ SysCreateLeaderboardConfig
Creates a leaderboard configuration, with support for tournament leaderboards.
📄️ SysDeleteAdhocTournamentPeriod
Deletes a future ADHOC tournament period scheduled for the leaderboard configuration, identified by the existing period's UTC startingAt time, in milliseconds. Period being edited must be scheduled in the future, not in-progress. Tournament settings may include tournament period ('tPeriod'), tournament configs and associated flags ('tTournament') and tournament phases ('tPhases').
📄️ SysDeleteLeaderboardConfig
Delete a leaderboard config, with support for tournament leaderboards. Note that a leaderboard configured as a tournament template-only cannot be deleted if any division set configuration is referencing it.
📄️ SysEditAdhocTournamentPeriod
Updates a future ADHOC tournament period scheduled for the leaderboard configuration, identified by the existing period's UTC startingAt time, in milliseconds. Period being edited must be scheduled in the future, not in-progress. Tournament settings may include tournament period ('tPeriod'), tournament configs and associated flags ('tTournament') and tournament phases ('tPhases').
📄️ SysEditLeaderboard
Edit a player or group entry leaderboard configuration.
📄️ SysEditLeaderboardConfig
Edits a leaderboard configuration, with support for tournament leaderboards.
📄️ SysEditTournamentSettingsForFuturePeriodsOnly
Updates the tournament settings for the leaderboard configuration, for future recurring periods only (does not affect current rotation). Supported tSettingsJson settings include: 'tTournament' (with 'tConfigs' to configure tournament templates, 'tAutoJoin' flag, 'tAutoClaim' flag), and 'tPhases' (to schedule 'enrolMins', 'announcementMins', 'disallowMins' and 'bufferMins' minutes).
📄️ SysEditTournamentSettingsIncludingCurrentPeriod
Updates the tournament settings for the leaderboard configuration, for the current period in progress, as well as the future periods if recurring periods (not ADHOC). Supported tSettingsJson settings include: 'tTournament' (with 'tConfigs' to configure tournament templates, 'tAutoJoin' flag, 'tAutoClaim' flag), and 'tPhases' (to schedule 'enrolMins', 'announcementMins', 'disallowMins' and 'bufferMins' minutes), and, if ADHOC tournament in progress, API also supports 'tPeriod' duration settings ('durationDays', 'durationDays', 'durationDays').
📄️ SysGetLeaderboardConfig
Returns leaderboard configuration information, including tournament settings, for future and current (active) version of the specified leaderboard.
📄️ SysGetLeaderboardConfigsPage
Returns a page of leaderboard configurations from the server based on the specified context.
📄️ SysGetLeaderboardConfigsPageOffset
Gets the page of leaderboard configuration information from the server based on the encoded context and specified page offset.
📄️ SysListLeaderboardConfigs
Returns list of applicable leaderboards, with summary leaderboard configuration information, including tournament flags, if applicable. Option 'filterType' defaults to 'standard', with additional supported filter types of 'all', 'tournament', 'divisions' and 'templates'.
📄️ SysResetNeverLeaderboard
Resets a leaderboard configured with rotation strategy NEVER by incrementing its version.