Making Requests - Cenngo/R6Stats-Sharp GitHub Wiki

Requesting Data from the API

There are a total of 6 generic request types

Getting the Response

The main client class exposes a method for all of the request types mentioned above. Every method (other than GetLeaderboard()) returns a generic type APIResponse<T>, which contains the status code for the response, the payload (if the request was successful), the error string (if the request was unsuccessful). Before processing the payload you need to check if the request was successful.

ex.

var response = await client.GetGenericStats("<username>", Platform.PC);
if(response.IsSuccessful){
     //do stuff
}
else{
     Console.WriteLine(response.Error);
}

Disclaimer: Currently there is no in-depth documentation provided by the R6Stats team for this API, the following text contains the information I infered by cross referencing the API response to some known data, hence there might be some inaccuracies.


Generic Stats

Generic stats contains the general information about a player like; player's past aliases, stats for different gamemodes, stats for different queue types (ie. ranked, casual...), total distance travelled, total number of DBNOs... etc. Although this type of response contains the overall stats for ranked queue, it does not contain the current rank information. To get current/past rank information refer to Seasonal Stats


Seasonal Stats

Seasonal Stats contains the ranked information for every season the player participated in. Current and past ranked data can be obtained using this request type.

The API returns the seasonal stats separatelywith their respective region. Although the ranked data has been unified since the "Shadow Legacy", because the past season data was stored seperatly this kind of response is necessary to get the true game information for the older seasons. With that said, if you are only concerned with the recent season datas, you can use whatever region data you want, they are all the same.

The player information is synced to the database at some intervals and the API returns every save state thats is available in the database. This data is parsed into a Dictionary<DateTime, RegionStat>. Every version is keyed with their respective time stampt, representing the Date/Time the stats were queried at.

For accessing the current ranked data, the library has a built in method which retrieves the most recent version of the player data from the NA region(which is currently identical to EU and AS). Current ranked data can be accessed through CurrentRankedData property in the seasonal stats.

var response = await client.GetSeasonalStats("<username>", Platform.PC);
if(response.IsSuccessful){
     IRankedData curentRankedData = response.Payload.CurrentRankedData;
} 

The past seasons are included in SeasonalStats and keyed with their corresponding season's name. Then you can just get the ranked data from any one of the regions,

var response = await client.GetSeasonalStats("<username>", Platform.PC);
if(response.IsSuccessful){
     // season data for Neon Dawn
     var season = response.Payload.SeasonalStats["neon_dawn"];

     // get the most recently synced data
     var dataSync = season.Regions.NCSA.ElementAt(0).Values;
     // time stampt of data sync
     DateTime syncTime = dataSync.Key;
     // stored player data
     RegionStat data = dataSync.Value;
}

Operator Stats

Operator Stats include the detaied information about operators. The stats are ranging from the total kills the player scored with the operator to the number of times the player used the operators special ability. Operator data is stored in a IReadOnlyDictionary<string, OperatorStat> and every operator is keyed with its name. Every operator name is normalized to only feature lower case letters and '_' instead of spaces to make it easier to search. ex.

var response = await client.GetOperatorStats("<username>", Platform.PC);
if(response.IsSuccessful){
     var sledge = response.Payload.Operators["sledge"];
}

Every OperatorStat has an IReadOnlyDictionary<string, int> that stores operator abilities with the number activation times for the said ability. The following is the JSON eq. of the OperatorAbilities:

"abilities": [
                {
                    "ability": "Gadgets jammed",
                    "value": 315
                },
                {
                    "ability": "Jammers deployed",
                    "value": 673
                }
            ]

Weapon Stats

Weapon Stats include game statistics for every individual weapon in the game, number of kills scored with a weapon, Headshot percetage... Every weapon data is stored in a IReadOnlyDictionary<string, WeaponStat> with its name as the key. Every weapon name is normalized to only feature lower case letters and '_' instead of spaces to make it easier to search. ex.

var response = await client.GetWeaponStats("<username>", Platform.PC);
if(response.IsSuccessful){
     var l85a2 = response.Payload.Weapons["l85a2"];
}

In general if you are not looking for a specific weapon data, an use case like the following example will be much more usefull,

var response = await client.GetWeaponStats("<username>", Platform.PC);
if(response.IsSuccessful){
     var highestKillCount = stats.Payload.Weapons.OrderBy(x => x.Value.Kills).ElementAt(0).Key;
     Console.WriteLine($"{response.Payload.Username}'s got the most kills with {highestKillCount}");
}

Weapon Category Stats

Weapon Category Stats store the game statistics for every weapon category, like "Assault Riffle", "Submachine Gun"... Every weapon category is stored in a IReadOnlyDictionary<string, WeaponCategoryStat> and keyed with its name. Every weapon category name is normalized to only feature lower case letters and '_' instead of spaces.

var response = await client.GetWeaponStats("<username>", Platform.PC);
if(response.IsSuccessful){
     var assaultRifle = response.Payload.WeaponCategories["assault_rifle"];
}

Leaderboard

Leaderboards are, as you can guess, feature the top players in every platform of the game. You can request different platform leaderboard by changing the platform parameter of the GetLeaderboard() method. Every request yields a custom Leaderboard class which is a readonly IEnumerable<LeaderboardSlot> in its basis. Player information is stored with the same order as the leaderboard data starting from the first place.

var response = await client.GetLeaderboard(Platform.PC);
if(response.IsSuccessful){
     var leaderboard = response.Payload;

     // first person on the leaderboard
     var first = leaderboard[0];
}

A leaderboard's top 10 can be access from the Top10 property of the Leaderboard. This class also features indexers for both integer and string. String indexer can be used to search for a player safely.(This indexer is not case sensitive). It yields the search players information if the search was successful, else it returns null. ex.

var response = await client.GetLeaderboard(Platform.PC);
if(response.IsSuccessful){
     var leaderboard = response.Payload;

     // Player Search for "Ddot."
     var player = leaderboard["ddot."];
     if(player != null){
          // do stuff
     }
}
⚠️ **GitHub.com Fallback** ⚠️