Skip to main content

Leaderboard

Idem generates a leaderboard for your game which you can query via API.

POST /games/{game_id}/leaderboard

You can extract the leaderboard in three ways:

  • From-top Extracts the first n records starting from above {"count": "int"}
  • From-rank Gives you a number n of records starting at a rank. This can also be used to extract the leaderboard page-wise (e.g. 1-50, 51-100 etc.) {"count": "int", "fromRank": "int"}
  • Around-player Returns a number of players around a player of your choice. Used generally to show a players immediate sourrounding in the ranking table. {"count": "int", "playerId": "str"}

Below is simple demo of how to retrieve your leaderboard data:

import pull_leaderboard


# Credentials
secret = {
"websocket_url": "wss://ws.beta.idem.gg",
"api_url": "https://api.beta.idem.gg",
"client_id": "3ns1sc0lkrdqh25qvrqb9k3a80",
"username": "YOUR_USERNAME",
"password": "YOUR_PASSWORD",
}


game_id = "1v1"


def main():
# From top
print("-- Leaderboard from top --")
leaderboard_from_top = pull_leaderboard.get_leaderboard_from_top(
game_id=game_id, count=10, secret=secret
)
pull_leaderboard.print_leaderboard(leaderboard_from_top)

# From rank
print("-- Leaderboard from specified rank --")
leaderboard_from_rank = pull_leaderboard.get_leaderboard_from_rank(
game_id=game_id, count=10, from_rank=5, secret=secret
)
pull_leaderboard.print_leaderboard(leaderboard_from_rank)

# Around player
print("-- Leaderboard around specified player --")
leaderboard_around_playerid = pull_leaderboard.get_leaderboard_around_playerid(
game_id=game_id, count=10, player_id="#someUser", secret=secret
)
pull_leaderboard.print_leaderboard(leaderboard_around_playerid)


if __name__ == "__main__":

main()

Retrival limits

The size of the return of each request is limited by default. If you want to retrieve larger chunks of the leaderboard, we recommend From-Rank. That way you can iterate in steps through larger sets of the leaderboard

MethodLimit
Overall limit500
From-top500
From-rank100
Around-player50