public TimeSpan IsCsgoInstalled(long steamId) { SteamIdentity identity = SteamIdentity.FromSteamID(steamId); GetOwnedGamesBuilder gamesBuilder = SteamWebAPI.General().IPlayerService().GetOwnedGames(identity); try { GetOwnedGamesResponse response = gamesBuilder.GetResponse(); if (response != null && response.Data != null) { if (response.Data.Games != null) { var csgo = response.Data.Games.FirstOrDefault(x => x.AppID == 730); if (csgo != null) { return(csgo.PlayTimeTotal); } } } } catch (Exception) { } return(TimeSpan.Zero); }
private async Task <OwnedGamesSummary> GetOwnedGames(string steamId) { GetOwnedGamesResponse oResponse = new GetOwnedGamesResponse(); using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://api.steampowered.com/"); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); //Sending request to find web api REST service resource GetAllEmployees using HttpClient string sAPIKey = _configuration["Steam:ApiKey"]; HttpResponseMessage Res = await client.GetAsync("IPlayerService/GetOwnedGames/v0001/?key=" + sAPIKey + "&steamid=" + steamId + "&format=json&include_appinfo=1"); //Test Call https://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key=573995896871E7891B78DA9E841FCEB5&steamid=76561197960434622&format=json&include_appinfo=1 //Checking the response is successful or not which is sent using HttpClient if (Res.IsSuccessStatusCode) { //Storing the response details recieved from web api var SteamResponse = Res.Content.ReadAsStringAsync().Result; //Deserializing the response recieved from web api and storing into the Employee list oResponse = JsonConvert.DeserializeObject <GetOwnedGamesResponse>(SteamResponse); //Console.WriteLine(oResponse.Response.game_count); } return(oResponse.Response); } }
public bool HasMw2OrMw3(long steamId) { SteamIdentity identity = SteamIdentity.FromSteamID(steamId); GetOwnedGamesBuilder gamesBuilder = SteamWebAPI.General().IPlayerService().GetOwnedGames(identity); try { GetOwnedGamesResponse response = gamesBuilder.GetResponse(); if (response != null && response.Data != null) { if (response.Data.Games != null) { var mw2AndMw3 = response.Data.Games.FirstOrDefault(x => x.AppID == 10180 || x.AppID == 42690); if (mw2AndMw3 != null) { return(true); } } } } catch (Exception) { } return(false); }
public async Task <IActionResult> GetOwnedGamesForSteamIdAsync(string steamId) { GetOwnedGamesResponse response = await _steamClient.GetOwnedGamesForSteamdIdAsync(steamId, true, true); response.Games = response.Games.OrderBy(game => game.Name).ToList(); return(Ok(response)); }
/// <summary> /// Return a list of games owned by the player(GetOwnedGames web api method(version 1)). /// </summary> /// <param name="steamId">The 64 bit SteamID of the player.</param> /// <param name="includeAppInfo">Whether or not to include additional details(name, icon) about each game.</param> /// <param name="IncludeFreeGames">Whether or not to include free games.</param> /// <param name="filters">Restricts results to contain only mentioned appids.</param> /// <returns>Instance of <see cref="GetOwnedGamesResponse"/>.</returns> public GetOwnedGamesResponse GetOwnedGames(ulong steamId, bool includeAppInfo = true, bool IncludeFreeGames = true, params uint[] filters) { SteamUrl url = new SteamUrl { Interface = Interface, Method = "GetOwnedGames", Version = 1, AppendKey = true }; url.Parameters.Add(new Parameter { Name = "steamid", Value = steamId.ToString(CultureInfo.InvariantCulture) }); url.Parameters.Add(new Parameter { Name = "include_appinfo", Value = includeAppInfo.ToString() }); url.Parameters.Add(new Parameter { Name = "include_played_free_games", Value = IncludeFreeGames.ToString() }); for (int i = 0; i < filters.Length; i++) { url.Parameters.Add(new Parameter { Name = "appids_filter[" + i + "]", Value = filters[i].ToString(CultureInfo.InvariantCulture) }); } GetOwnedGamesResponse response = GetParsedResponse <GetOwnedGamesResponse>(url); if (response.ParsedResponse.Games == null) { response.ParsedResponse.Games = new QueryMasterCollection <GetOwnedGamesResponseGame>(new List <GetOwnedGamesResponseGame>()); } else { foreach (var i in response.ParsedResponse.Games) { i.IconUrl = String.IsNullOrWhiteSpace(i.IconUrl) ? string.Empty : "http://media.steampowered.com/steamcommunity/public/images/apps/" + i.AppId + "/" + i.IconUrl + ".jpg"; i.LogoUrl = String.IsNullOrWhiteSpace(i.IconUrl) ? string.Empty : "http://media.steampowered.com/steamcommunity/public/images/apps/" + i.AppId + "/" + i.LogoUrl + ".jpg"; } } return(response); }