Leaderboards and Tournaments Country Restrictions
The Country Restriction feature allows you to set geographical restrictions when you create a competition. You can set the country restriction using the API or the Leaderboards and Tournaments Console.
Overview
The default configuration for a competition is to be available world-wide. For a world-wide competition, Leaderboards and Tournaments does not check the player's country, so you do not need to include this information in the API request.
If you do configure a competition to be available only in certain countries or regions, your game needs to determine the location of the player. For example, you can use an Android API to query the locale of the device.
If your game cannot determine the country for a player, the player cannot enter a country-restricted competition.
Example
Using the Leaderboards and Tournaments Console, you create Competition1 to be available only in USA, Germany and Great Britain. Player A in the United States can enter Competition1 and submit a score. Player B in France cannot see Competition1, and cannot enter the competition or submit a score.
API Changes
-
A number of methods in the Game API and the Admin API now include a country-code parameter in the request or the response. The country code values conform to standard ISO 3166 Alpha-2 codes, as documented in ISO 3166 Country Codes. For example, the codes for USA, Germany and Great Britain are US, DE and GB.
Note: Ensure that you enter the country codes as two upper-case letters. -
AddIndividualTournamentRequest
has a new optional parameter calledcountryCodes
. Use this parameter to specify a list of the countries where you want to run the competition. For additional details, see AddIndividualTournamentRequest in the Game API reference. -
GetTournaments
andGetMatches
(in the game API) show or hide restricted tournaments/matches, depending on the home country of the player. In the request, you need to provide a country value in theplayerAttributes
to display the tournaments or matches that are available in that country. For additional details, see GetTournaments and GetMatches in the Game API reference.For example,
GET /v1/tournaments?playerAttributes={"country":"US"}
will return all unrestricted tournaments and all tournaments that include US in their country list. -
EnterTournament
andEnterMatch
(in the game API) verify the value inplayerAttributes["country"]
. In the body of the POST request, you need to supply a valid value of the player's home country to enter a tournament with country restrictions. If your game does not send a valid country value in the playerAttributes field, the player cannot enter the tournament. For additional details, see EnterTournamentRequest and EnterMatchRequest in the Game API reference.Example of how to set the player attributes:
{ "playerAttributes": { "country": "US" } }
Leaderboards and Tournaments Console
When you create a new competition, use the Countries panel to limit the competition to specific countries or Amazon marketplaces.
When you restrict a competition to specific countries, the Competition Details displays a count of the countries that you selected. Click the carat to display the selected countries.