Exemplo n.º 1
0
        /// <summary>
        /// Gets global stats(GetGlobalStatsForGame web api method(version 1)).
        /// </summary>
        /// <param name="appId">Application ID</param>
        /// <param name="StartDate">Start date for daily totals (unix epoch timestamp).</param>
        /// <param name="EndDate">End date for daily totals (unix epoch timestamp).</param>
        /// <param name="names">Names of stat to get data for.</param>
        /// <returns>Instance of <see cref="GetGlobalStatsForGameResponse"/>.</returns>
        public GetGlobalStatsForGameResponse GetGlobalStatsForGame(uint appId, uint?StartDate = null, uint?EndDate = null, params string[] names)
        {
            var url = new SteamUrl {
                Interface = Interface, Method = "GetGlobalStatsForGame", Version = 1
            };

            url.Parameters.Add(new Parameter {
                Name = "appid", Value = appId.ToString(CultureInfo.InvariantCulture)
            });
            url.Parameters.Add(new Parameter {
                Name = "count", Value = names.Length.ToString(CultureInfo.InvariantCulture)
            });
            for (var i = 0; i < names.Length; i++)
            {
                url.Parameters.Add(new Parameter {
                    Name = "name[" + i + "]", Value = names[i]
                });
            }
            if (StartDate != null)
            {
                url.Parameters.Add(new Parameter {
                    Name = "startdate", Value = StartDate.ToString()
                });
            }
            if (EndDate != null)
            {
                url.Parameters.Add(new Parameter {
                    Name = "enddate", Value = EndDate.ToString()
                });
            }
            return(GetParsedResponse <GetGlobalStatsForGameResponse>(url));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets information about a player's recently played games(GetRecentlyPlayedGames web api method(version 1)).
        /// </summary>
        /// <param name="steamId">The 64-bit SteamID of the player.</param>
        /// /// <param name="count">The number of games to return.</param>
        /// <returns>Instance of <see cref="GetRecentlyPlayedGamesResponse"/>.</returns>
        public GetRecentlyPlayedGamesResponse GetRecentlyPlayedGames(ulong steamId, uint count = 0)
        {
            var url = new SteamUrl {
                Interface = Interface, Method = "GetRecentlyPlayedGames", Version = 1, AppendKey = true
            };

            url.Parameters.Add(new Parameter {
                Name = "steamid", Value = steamId.ToString(CultureInfo.InvariantCulture)
            });
            url.Parameters.Add(new Parameter {
                Name = "count", Value = count.ToString(CultureInfo.InvariantCulture)
            });
            var response = GetParsedResponse <GetRecentlyPlayedGamesResponse>(url);

            if (response.ParsedResponse.Games == null)
            {
                response.ParsedResponse.Games = new QueryMasterCollection <GetRecentlyPlayedGamesResponseGame>(new List <GetRecentlyPlayedGamesResponseGame>());
            }
            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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Calls GetNewsForApp web api method(version 2).
        /// </summary>
        /// <param name="appId">Game/item to retrieve news for. This can be any valid app ID as seen in the Steam store.</param>
        /// <param name="maxLength">Max length of the contents field.</param>
        /// <param name="endDate">Unix timestamp, returns posts before this date.</param>
        /// <param name="count">Max number of news items to retrieve. Default: 20. </param>
        /// <param name="feeds">Comma-seperated list of feed names to return news for.</param>
        /// <returns>Instance of <see cref="GetNewsForAppResponse"/>.</returns>
        public GetNewsForAppResponse GetNewsForApp(UInt32 appId, UInt32?maxLength = null, UInt32?endDate = null, UInt32?count = null, string feeds = null)
        {
            SteamUrl url = new SteamUrl {
                Interface = Interface, Method = "GetNewsForApp", Version = 2
            };

            url.Parameters.Add(new Parameter {
                Name = "appid", Value = appId.ToString(CultureInfo.InvariantCulture)
            });
            if (maxLength != null)
            {
                url.Parameters.Add(new Parameter {
                    Name = "maxlength", Value = maxLength.ToString()
                });
            }
            if (endDate != null)
            {
                url.Parameters.Add(new Parameter {
                    Name = "enddate", Value = endDate.ToString()
                });
            }
            if (count != null)
            {
                url.Parameters.Add(new Parameter {
                    Name = "count", Value = count.ToString()
                });
            }
            if (feeds != null)
            {
                url.Parameters.Add(new Parameter {
                    Name = "feeds", Value = feeds.ToString()
                });
            }
            return(GetParsedResponse <GetNewsForAppResponse>(url));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets WebAPI server time and checks server status(GetServerInfo web api method(version 1)).
        /// </summary>
        /// <returns>Instance of <see cref="GetServerInfoResponse"/>.</returns>
        public GetServerInfoResponse GetServerInfo()
        {
            var url = new SteamUrl {
                Interface = Interface, Method = "GetServerInfo", Version = 1
            };

            return(GetParsedResponse <GetServerInfoResponse>(url, true));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Full list of every publicly facing program in the store/library(GetAppList web api method(version 2)).
        /// </summary>
        /// <returns>Instance of <see cref="GetAppListResponse"/>.</returns>
        public GetAppListResponse GetAppList()
        {
            var url = new SteamUrl {
                Interface = Interface, Method = "GetAppList", Version = 2
            };

            return(GetParsedResponse <GetAppListResponse>(url));
        }
Exemplo n.º 6
0
        internal T GetParsedResponse <T>(SteamUrl url, bool AddRootObject = false, params JsonConverter[] jsonConverters) where T : SteamResponse, new()
        {
            string reply    = GetResponse(url);
            T      response = ParseResponse <T>(reply, AddRootObject, jsonConverters);

            response.RequestUrl = url;
            return(response);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Lists all available WebAPI interfaces(GetSupportedAPIList web api method(version 1)).
        /// </summary>
        /// <param name="appendKey">if true then response would include all available methods and interfaces allowed for that key.</param>
        /// <returns>Instance of <see cref="GetSupportedAPIListResponse"/>.</returns>
        public GetSupportedAPIListResponse GetSupportedAPIList(bool appendKey = false)
        {
            var url = new SteamUrl {
                Interface = Interface, Method = "GetSupportedAPIList", Version = 1, AppendKey = appendKey
            };

            return(GetParsedResponse <GetSupportedAPIListResponse>(url));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Lists Group ID(s) linked with 64 bit-ID(GetUserGroupList web api method(version 1)).
        /// </summary>
        /// <param name="steamId">SteamID</param>
        /// <returns>Instance of <see cref="GetUserGroupListResponse"/>.</returns>
        public GetUserGroupListResponse GetUserGroupList(ulong steamId)
        {
            SteamUrl url = new SteamUrl {
                Interface = Interface, Method = "GetUserGroupList", Version = 1, AppendKey = true
            };

            url.Parameters.Add(new Parameter {
                Name = "steamid", Value = steamId.ToString(CultureInfo.InvariantCulture)
            });
            return(GetParsedResponse <GetUserGroupListResponse>(url));
        }
Exemplo n.º 9
0
        /// <summary>
        /// Statistics showing how much of the player base have unlocked various achievements(GetGlobalAchievementPercentagesForApp web api method(version 2)).
        /// </summary>
        /// <param name="gameId">The ID of the game to retrieve achievement percentages for. This can be the ID of any Steamworks game with achievements available.</param>
        /// <returns>Instance of <see cref="GetGlobalAchievementPercentagesForAppResponse"/>.</returns>
        public GetGlobalAchievementPercentagesForAppResponse GetGlobalAchievementPercentagesForApp(ulong gameId)
        {
            var url = new SteamUrl {
                Interface = Interface, Method = "GetGlobalAchievementPercentagesForApp", Version = 2
            };

            url.Parameters.Add(new Parameter {
                Name = "gameid", Value = gameId.ToString(CultureInfo.InvariantCulture)
            });
            return(GetParsedResponse <GetGlobalAchievementPercentagesForAppResponse>(url));
        }
Exemplo n.º 10
0
        /// <summary>
        /// Returns the current number of players for an app(GetNumberOfCurrentPlayers web api method(version 1)).
        /// </summary>
        /// <param name="appId">AppID that we're getting user count for.</param>
        /// <returns>Instance of <see cref="GetNumberOfCurrentPlayersResponse"/>.</returns>
        public GetNumberOfCurrentPlayersResponse GetNumberOfCurrentPlayers(uint appId)
        {
            var url = new SteamUrl {
                Interface = Interface, Method = "GetNumberOfCurrentPlayers", Version = 1
            };

            url.Parameters.Add(new Parameter {
                Name = "appid", Value = appId.ToString(CultureInfo.InvariantCulture)
            });
            return(GetParsedResponse <GetNumberOfCurrentPlayersResponse>(url));
        }
Exemplo n.º 11
0
        /// <summary>
        /// Calls GetServersAtAddress web api method(version 1).
        /// </summary>
        /// <param name="ipEndPoint">IP EndPoint of server.</param>
        /// <returns>Instance of <see cref="GetServersAtAddressResponse"/>.</returns>
        public GetServersAtAddressResponse GetServersAtAddress(IPEndPoint ipEndPoint)
        {
            var url = new SteamUrl {
                Interface = Interface, Method = "GetServersAtAddress", Version = 1
            };

            url.Parameters.Add(new Parameter {
                Name = "addr", Value = ipEndPoint.ToString()
            });
            return(GetParsedResponse <GetServersAtAddressResponse>(url));
        }
Exemplo n.º 12
0
        /// <summary>
        /// Resolve vanity URL parts to a 64 bit ID(ResolveVanityURL web api method(version 1)).
        /// </summary>
        /// <param name="vanityUrl">The user's vanity URL.(eg:-Vanity Url for "http://steamcommunity.com/id/abcd" will be abcd). </param>
        /// <returns>Instance of <see cref="ResolveVanityURLResponse"/>.</returns>
        public ResolveVanityURLResponse ResolveVanityURL(string vanityUrl)
        {
            SteamUrl url = new SteamUrl {
                Interface = Interface, Method = "ResolveVanityURL", Version = 1, AppendKey = true
            };

            url.Parameters.Add(new Parameter {
                Name = "vanityurl", Value = vanityUrl
            });
            return(GetParsedResponse <ResolveVanityURLResponse>(url));
        }
Exemplo n.º 13
0
        /// <summary>
        /// calls IsPlayingSharedGame web api method(version 1)).
        /// </summary>
        /// <param name="steamId">The 64 bit SteamID of the player.</param>
        /// <returns>Instance of <see cref="IsPlayingSharedGameResponse"/>.</returns>
        public IsPlayingSharedGameResponse IsPlayingSharedGame(ulong steamId)
        {
            var url = new SteamUrl {
                Interface = Interface, Method = "IsPlayingSharedGame", Version = 1, AppendKey = true
            };

            url.Parameters.Add(new Parameter {
                Name = "steamid", Value = steamId.ToString(CultureInfo.InvariantCulture)
            });
            return(GetParsedResponse <IsPlayingSharedGameResponse>(url));
        }
Exemplo n.º 14
0
        /// <summary>
        /// calls GetCommunityBadgeProgress web api method(version 1)).
        /// </summary>
        /// <param name="steamId">The 64 bit SteamID of the player.</param>
        /// <returns>Instance of <see cref="GetCommunityBadgeProgressResponse"/>.</returns>
        public GetCommunityBadgeProgressResponse GetCommunityBadgeProgress(ulong steamId)
        {
            var url = new SteamUrl {
                Interface = Interface, Method = "GetCommunityBadgeProgress", Version = 1, AppendKey = true
            };

            url.Parameters.Add(new Parameter {
                Name = "steamid", Value = steamId.ToString(CultureInfo.InvariantCulture)
            });
            return(GetParsedResponse <GetCommunityBadgeProgressResponse>(url));
        }
Exemplo n.º 15
0
        /// <summary>
        /// Gets the friend list (GetFriendList web api method(version 1)).
        /// </summary>
        /// <param name="steamId">The 64 bit ID of the user to retrieve a list for.</param>
        /// <param name="relationship">Filter by a given role.</param>
        /// <returns>Instance of <see cref="GetFriendListResponse"/>.</returns>
        /// <remarks>Returns the list of friends if the profile is public or there are entries for the given relationship.</remarks>
        public GetFriendListResponse GetFriendList(ulong steamId, GetFriendListRelationship relationship = GetFriendListRelationship.All)
        {
            SteamUrl url = new SteamUrl {
                Interface = Interface, Method = "GetFriendList", Version = 1, AppendKey = true
            };

            url.Parameters.Add(new Parameter {
                Name = "steamid", Value = steamId.ToString(CultureInfo.InvariantCulture)
            });
            url.Parameters.Add(new Parameter {
                Name = "relationship", Value = relationship.ToString()
            });
            return(GetParsedResponse <GetFriendListResponse>(url));
        }
Exemplo n.º 16
0
        /// <summary>
        /// Gets the game schema(GetSchemaForGame web api method(version 2)).
        /// </summary>
        /// <param name="appId">Application Id.</param>
        /// <param name="language">localized language to return.</param>
        /// <returns>Instance of <see cref="GetSchemaForGameResponse"/>.</returns>
        public GetSchemaForGameResponse GetSchemaForGame(uint appId, string language = "English")
        {
            var url = new SteamUrl {
                Interface = Interface, Method = "GetSchemaForGame", Version = 2, AppendKey = true
            };

            url.Parameters.Add(new Parameter {
                Name = "appid", Value = appId.ToString(CultureInfo.InvariantCulture)
            });
            url.Parameters.Add(new Parameter {
                Name = "l", Value = language
            });
            return(GetParsedResponse <GetSchemaForGameResponse>(url));
        }
Exemplo n.º 17
0
        /// <summary>
        /// Gets user's stats for a game(GetUserStatsForGame web api method(version 2)).
        /// </summary>
        /// <param name="steamId">64 bit Steam ID.</param>
        /// <param name="appId">Application Id.</param>
        /// <returns>Instance of <see cref="GetUserStatsForGameResponse"/>.</returns>
        public GetUserStatsForGameResponse GetUserStatsForGame(ulong steamId, uint appId)
        {
            var url = new SteamUrl {
                Interface = Interface, Method = "GetUserStatsForGame", Version = 2, AppendKey = true
            };

            url.Parameters.Add(new Parameter {
                Name = "steamid", Value = steamId.ToString(CultureInfo.InvariantCulture)
            });
            url.Parameters.Add(new Parameter {
                Name = "appid", Value = appId.ToString(CultureInfo.InvariantCulture)
            });
            return(GetParsedResponse <GetUserStatsForGameResponse>(url));
        }
Exemplo n.º 18
0
        /// <summary>
        /// GetCMList web api method(version 1).
        /// </summary>
        /// <param name="cellId">Client's Steam cell ID</param>
        /// <param name="maxCount">Max number of servers to return.</param>
        /// <returns>Instance of <see cref="GetCMListResponse"/>.</returns>
        public GetCMListResponse GetCMList(uint cellId, uint maxCount = 10)
        {
            var url = new SteamUrl {
                Interface = Interface, Method = "GetCMList", Version = 1
            };

            url.Parameters.Add(new Parameter {
                Name = "cellid", Value = cellId.ToString(CultureInfo.InvariantCulture)
            });
            url.Parameters.Add(new Parameter {
                Name = "maxcount", Value = maxCount.ToString(CultureInfo.InvariantCulture)
            });
            return(GetParsedResponse <GetCMListResponse>(url));
        }
Exemplo n.º 19
0
        /// <summary>
        /// Calls UpToDateCheck web api method(version 1).
        /// </summary>
        /// <param name="appId">Application Id of the game</param>
        /// <param name="version">The installed version of the game.</param>
        /// <returns>Instance of <see cref="UpToDateCheckResponse"/>.</returns>
        public UpToDateCheckResponse UpToDateCheck(uint appId, uint version)
        {
            var url = new SteamUrl {
                Interface = Interface, Method = "UpToDateCheck", Version = 1
            };

            url.Parameters.Add(new Parameter {
                Name = "appid", Value = appId.ToString(CultureInfo.InvariantCulture)
            });
            url.Parameters.Add(new Parameter {
                Name = "version", Value = version.ToString(CultureInfo.InvariantCulture)
            });
            return(GetParsedResponse <UpToDateCheckResponse>(url));
        }
Exemplo n.º 20
0
        /// <summary>
        /// Get Player ban/probation status.
        /// </summary>
        /// <param name="steamIds">SteamIDs</param>
        /// <returns>Instance of <see cref="GetPlayerBansResponse"/>.</returns>
        public GetPlayerBansResponse GetPlayerBans(params ulong[] steamIds)
        {
            if (steamIds.Length == 0)
            {
                throw new SteamException("Please pass 64-bit steamid(s)");
            }
            SteamUrl url = new SteamUrl {
                Interface = Interface, Method = "GetPlayerBans", Version = 1, AppendKey = true
            };

            url.Parameters.Add(new Parameter {
                Name = "steamids", Value = string.Join(",", steamIds)
            });
            return(GetParsedResponse <GetPlayerBansResponse>(url, true));
        }
Exemplo n.º 21
0
        /// <summary>
        /// Gets Users' profile data(GetPlayerSummaries web api method(version 2)).
        /// </summary>
        /// <param name="steamIds">SteamIDs</param>
        /// <returns>Instance of <see cref="GetPlayerSummariesResponse"/>.</returns>
        public GetPlayerSummariesResponse GetPlayerSummaries(params ulong[] steamIds)
        {
            if (steamIds.Length == 0)
            {
                throw new SteamException("Please pass 64-bit steamid(s)");
            }
            SteamUrl url = new SteamUrl {
                Interface = Interface, Method = "GetPlayerSummaries", Version = 2, AppendKey = true
            };

            url.Parameters.Add(new Parameter {
                Name = "steamids", Value = string.Join(",", steamIds)
            });
            return(GetParsedResponse <GetPlayerSummariesResponse>(url, jsonConverters: new JsonConverter[] { new StringIpEndPointConverter(), new IntegerUnixTimeStampConverter() }));
        }
Exemplo n.º 22
0
        /// <summary>
        /// Gets game achievements(GetPlayerAchievements web api method(version 1)).
        /// </summary>
        /// <param name="steamId">64 bit Steam ID.</param>
        /// <param name="appId">Application Id.</param>
        /// <param name="language">localized language to return.</param>
        /// <returns>Instance of <see cref="GetPlayerAchievementsResponse"/>.</returns>
        public GetPlayerAchievementsResponse GetPlayerAchievements(ulong steamId, uint appId, string language = "English")
        {
            var url = new SteamUrl {
                Interface = Interface, Method = "GetPlayerAchievements", Version = 1, AppendKey = true
            };

            url.Parameters.Add(new Parameter {
                Name = "steamid", Value = steamId.ToString(CultureInfo.InvariantCulture)
            });
            url.Parameters.Add(new Parameter {
                Name = "appid", Value = appId.ToString(CultureInfo.InvariantCulture)
            });
            url.Parameters.Add(new Parameter {
                Name = "l", Value = language
            });
            return(GetParsedResponse <GetPlayerAchievementsResponse>(url));
        }
Exemplo n.º 23
0
        /// <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)
        {
            var 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 (var i = 0; i < filters.Length; i++)
            {
                url.Parameters.Add(new Parameter {
                    Name = "appids_filter[" + i + "]", Value = filters[i].ToString(CultureInfo.InvariantCulture)
                });
            }
            var 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);
        }
Exemplo n.º 24
0
 private static string GetResponse(SteamUrl url) => new SteamSocket().GetResponse(url.ToString());
Exemplo n.º 25
0
 internal string GetResponse(SteamUrl url)
 {
     return(new SteamSocket().GetResponse(url.ToString()));
 }