Skip to main content
This topic provides example code for basic leaderboard display, getting a specified page of results, skipping to a specified player in the leaderboard, and getting the next page of leaderboards. This topic covers the following:

Getting the top of a leaderboard

Use XblLeaderboardGetLeaderboardAsync to return the leaderboard values for the specified leaderboard, starting from the top of the leaderboard. When querying a leaderboard backed by an event-based User Stat, be sure to set the queryType field to XblLeaderboardQueryType::UserStatBacked.

Basic leaderboard display (flat C API)

Flat C API

For more information, see the following:

Getting a leaderboard around a specified rank

Replace the 4-line code block that instantiates and configures the leaderboard query in the previous Basic leaderboard query (flat C API) example with the following code block to get a specified page of results from a leaderboard query.

Get a specified page of results (C)

Flat C API

For more information, see XblLeaderboardQuery.

Getting a leaderboard around a specified player

Replace the 4-line code block that instantiates and configures the leaderboard query in the previous Basic leaderboard query (flat C API) example with the following code block to get a leaderboard around a specified player.

Flat C API

For more information, see XblLeaderboardQuery.

Getting the next page of leaderboards

To get the next page of a previous leaderboard result, call XblLeaderboardResultGetNextAsync as shown in the following example code.

Flat C API

For more information, see the following:
Last modified on August 20, 2026