SteamModels 1.1.3
See the version list below for details.
dotnet add package SteamModels --version 1.1.3
NuGet\Install-Package SteamModels -Version 1.1.3
<PackageReference Include="SteamModels" Version="1.1.3" />
paket add SteamModels --version 1.1.3
#r "nuget: SteamModels, 1.1.3"
// Install SteamModels as a Cake Addin
#addin nuget:?package=SteamModels&version=1.1.3
// Install SteamModels as a Cake Tool
#tool nuget:?package=SteamModels&version=1.1.3
SteamModels-DotNet
.NET Models for the Steam API. Available on NuGet.
Usage
The Steam API results can be deserialized into the .NET model classes provided by SteamModels.
Example with SteamUser
:
public class SteamService
{
private readonly string _playerDetailsUrl = "http://steamcommunity.com/id/{0}/?xml=1";
private string _username;
public SteamUser GetSteamUserDetails(string name)
{
HttpClient client = new HttpClient();
this._username = NormalizeUsername(name);
var playerDetailsResponse = client.GetStreamAsync(this._username);
XmlSerializer serializer = new XmlSerializer(typeof(SteamUser));
SteamUser user = (SteamUser)serializer.Deserialize(playerDetailsResponse.Result);
return user;
}
public string NormalizeUsername(string name)
{
return name.Contains("http://") ? name : string.Format(_playerDetailsUrl, name);
}
}
Example with SteamNews
:
public class SteamService
{
private readonly string _steamAppNewsUrl = "http://api.steampowered.com/ISteamNews/GetNewsForApp/v0002/?appid={0}&maxlength=300&format=json";
public async Task<SteamNews> GetSteamAppNewsJSON(int appid)
{
HttpClient client = new HttpClient();
var steamnews = await client.GetStringAsync(string.format(this._steamAppNewsUrl, appid));
SteamNews news = JsonConvert.DeserializeObject<SteamNews>(steamnews);
return news;
}
}
Example with SteamUserStats
:
public class SteamService
{
private readonly string _steamUserStatsUrl = "http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid={0}&key={1}&steamid={2}&format=json";
public static SteamUserStats GetStatsForGame(string username)
{
HttpClient client = new HttpClient();
var statsForGameResponse = client.GetStringAsync(string.Format(_steamUserStatsUrl, SteamInfo.Config.gameId, SteamInfo.Config.steamApiKey, username));
SteamUserStats statsForUser = JsonConvert.DeserializeObject<SteamUserStats>(statsForGameResponse.Result);
return statsForUser;
}
}
Example with CSGOPlayerStats
, which is a superset of SteamUserStats
with specific parsing for some CS:GO stats, like HS%, Accuracy, Top Weapon, Total Kills, etc:
public class SteamService
{
private readonly string _steamUserStatsUrl = "http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid={0}&key={1}&steamid={2}&format=json";
public static CSGOPlayerStats GetStatsForGame(string username)
{
HttpClient client = new HttpClient();
var statsForGameResponse = client.GetStringAsync(string.Format(_steamUserStatsUrl, 730, SteamInfo.Config.steamApiKey, username));
CSGOPlayerStats statsForUser = JsonConvert.DeserializeObject<CSGOPlayerStats>(statsForGameResponse.Result);
return statsForUser;
}
}
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
8.0.0 | 185 | 12/1/2023 |
7.0.0 | 371 | 11/28/2022 |
6.0.0 | 398 | 11/11/2021 |
5.0.3 | 384 | 10/5/2021 |
1.3.1 | 455 | 11/5/2020 |
1.3.0 | 425 | 11/5/2020 |
1.2.3 | 704 | 10/14/2019 |
1.2.2 | 696 | 3/11/2019 |
1.2.1 | 819 | 9/19/2018 |
1.2.0 | 787 | 8/30/2018 |
1.1.3 | 777 | 8/24/2018 |
1.1.2 | 827 | 8/10/2018 |
1.1.1 | 868 | 8/9/2018 |
1.1.0 | 1,082 | 5/2/2017 |
1.0.1 | 1,152 | 4/18/2017 |
1.0.0 | 891 | 4/7/2017 |
Adding SteamNews model. Changing the namespace of CSGO specific models to SteamModels.CSGO. Adding accuracy to the CSGOPlayerStats.