Skip to main content

Send score

Description

Every time a user finishes a game or similar, use this endpoint to send the user's score. GameRank maintains the user's personal best, the leaderboard podium, etc.

Endpoint

POST https://api.gamerank.io/leaderboard/score

Request JSON body

FieldTypeOptionalDescription
scoreintUser's score
usernamestringDisplayable user's name
useridstringYesUser's unique identifier. Alpha-numerical ASCII characters only. If not provided: a random id is generated.
return_bestboolYesIf set to true, the response will contain the player's current best score and current best position in the leaderboard.

Example

{
"score": 3340,
"username": "John Doe",
"userid": "1289",
"return_best": false
}

Response JSON body

FieldTypeDescription
useridstringUser id used to store this score.
best_positionintBest position of the user in the leaderboard.
Only present if return_best is set to true in the request.
best_scoreintUser's best score in the leaderboard.
Only present if return_best is set to true in the request.
best_score_creation_timemillisecond timestampUTC timestamp in millisecond at which the player did their best score.
Only present if return_best is set to true in the request.
is_new_bestbooltrue if the score just sent is the new personal best of the user.
Only present if return_best is set to true in the request.
{
"userid": "1289",

// Following fields are only present if `return_best` is set
// to `true` in the request.

"best_position": 43,
"best_score": 328716,
"best_score_creation_time": 1730026754899,
"is_new_best": false
}

HTTP status code

HTTP statusReason(s)
200• OK, score processed
400• Malformed JSON
• Empty username
• Invalid user ID format
404• Unknown API key / leaderboard
500• Server Error, please contact support@gamerank.io