Skip to main content

Leaderboard APIs

note

Leaderboards must be enabled on a per-game basis. If you'd like to enable them for your games, head to the Leaderboards page.

$msstart.submitGameResultsAsync

The submitGameResultsAsync API is used to report the result/score that a user achieves during a gameplay session. The API works asynchronously and returns a promise that resolves with a boolean of whether or not the result was succesfully submitted.

This function should be called at the end of a user's gameplay session, or if this is not possible, when they reach a checkpoint/milestone.

The score must be passed as an integer value:

  • For leaderboards with a score_type of Numeric and a non-zero score_decimal_places, the integer value should include all decimal places as if a decimal were inserted at the score_decimal_places position. For example, if you have configured 3 decimal places, submit a raw score of 1.337 as 1337.
  • For leaderboards with a score_type configured as Duration, values should be reported in milliseconds.

Usage

To use the submitGameResultsAsync API, simply call the function and it will return a promise that resolves to a boolean.

$msstart.submitGameResultsAsync(score).then(result => {
// result will be true if result submitted successfully
});