Repository: Overv/SteamWebAPI
Branch: master
Commit: d122c7705317
Files: 8
Total size: 37.3 KB
Directory structure:
gitextract_ui8iz4yt/
├── .gitignore
├── LICENSE
├── Properties/
│ └── AssemblyInfo.cs
├── README.md
├── SteamAPISession.cs
├── SteamWebAPI.csproj
├── SteamWebAPI.sln
└── packages.config
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
# Discard binaries
obj/
bin/
SteamWebAPI/packages/
.gitattributes
packages/
================================================
FILE: LICENSE
================================================
Copyright (c) 2015 Alexander Overvoorde
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
================================================
FILE: Properties/AssemblyInfo.cs
================================================
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle( "SteamAPI" )]
[assembly: AssemblyDescription( "" )]
[assembly: AssemblyConfiguration( "" )]
[assembly: AssemblyCompany( "" )]
[assembly: AssemblyProduct( "SteamAPI" )]
[assembly: AssemblyCopyright( "Copyright © 2012" )]
[assembly: AssemblyTrademark( "" )]
[assembly: AssemblyCulture( "" )]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible( false )]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid( "8678fb2c-d7d6-42d3-8011-6190f0463716" )]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion( "1.0.0.0" )]
[assembly: AssemblyFileVersion( "1.0.0.0" )]
================================================
FILE: README.md
================================================
This project is no longer actively maintained. You are advised to use a different library.
========
Steam Web API library
========
#### Description ####
This is a .NET library that makes it easy to use the Steam Web API. It conveniently wraps around all of the JSON data and ugly API details with clean methods, structures and classes.
The primary goal of this project is to support Steam Friends functionality. Other possible functionality like purchasing games and item trading may follow later. In short, it will contain
everything needed to write a custom, cross-platform Steam Friends messenger in C#.
#### Reference ####
### Enumerations ###
**LoginStatus**
Enumeration of possible authentication results.
```c#
public enum LoginStatus
{
LoginFailed,
LoginSuccessful,
SteamGuard
}
```
**UserStatus**
Status of a user.
```c#
public enum UserStatus
{
Offline = 0,
Online = 1,
Busy = 2,
Away = 3,
Snooze = 4
}
```
**ProfileVisibility**
Visibility of a user's profile.
```c#
public enum ProfileVisibility
{
Private = 1,
Public = 3,
FriendsOnly = 8
}
```
**AvatarSize**
Available sizes of user avatars.
```c#
public enum AvatarSize
{
Small,
Medium,
Large
}
```
**UpdateType**
Available update types.
```c#
public enum UpdateType
{
UserUpdate,
Message,
Emote,
TypingNotification
}
```
### SteamAPISession ###
This is the main class you will be using. It manages the session of a single Steam user and all requests are issued through methods in this class.
Below follows a description of every method.
**LoginStatus Authenticate( String username, String password, String emailauthcode = "" )**
Authenticate with a username and password. Sends the SteamGuard e-mail if it has been set up and an e-mail code has not been passed.
**LoginStatus Authenticate( String accessToken )**
Authenticate with an access token previously retrieved with a username and password (and SteamGuard code).
**List<Friend> GetFriends( String steamId = null )**
Fetch basic info for all friends of a given user.
**List<User> GetUserInfo( List<String> steamids )**
**List<User> GetUserInfo( List<Friend> friends )**
**User GetUserInfo( String steamid = null )**
Retrieve information about the specified users. Pass null for self.
**Bitmap GetUserAvatar( User user, AvatarSize size = AvatarSize.Small )**
Retrieve the avatar of the specified user as bitmap.
**List<Group> GetGroups( String steamid = null )**
Fetch basic group info for a given user.
**List<GroupInfo> GetGroupInfo( List<String> steamids )**
**List<GroupInfo> GetGroupInfo( List<Group> groups )**
**GroupInfo GetGroupInfo( String steamid )**
Retrieve information about the specified groups.
**Bitmap GetGroupAvatar( Group group, AvatarSize size = AvatarSize.Small )**
Retrieve the avatar of the specified group as bitmap.
**bool SendTypingNotification( User user )**
Let a user know you're typing a message. Should be called periodically.
**bool SendMessage( User user, String message )**
Send a text message to the specified user.
**List<Update> Poll()**
Check for updates and new messages.
**ServerInfo GetServerInfo()**
Returns info about the server, as specified in the *ServerInfo* class. This is the only call besides *Authenticate* that does not require a valid user session.
### Subclasses ###
**Friend**
Structure containing basic friend info.
```c#
public class Friend
{
public String steamid;
public bool blocked;
public DateTime friendSince;
}
```
**User**
Structure containing extensive user info.
```c#
public class User
{
public String steamid;
public ProfileVisibility profileVisibility;
public int profileState;
public String nickname;
public DateTime lastLogoff;
public String profileUrl;
public String avatarUrl;
public UserStatus status;
public String realName;
public String primaryGroupId;
public DateTime joinDate;
public String locationCountryCode;
public String locationStateCode;
public int locationCityId;
}
```
*Note that some of these fields can be empty!*
**Group**
Basic group info.
```c#
public class Group
{
public String steamid;
public bool inviteonly;
}
```
**GroupInfo**
Structure containing extensive group info.
```c#
public class GroupInfo
{
public String steamid;
public DateTime creationDate;
public String name;
public String headline;
public String summary;
public String abbreviation;
public String profileUrl;
internal String avatarUrl;
public String locationCountryCode;
public String locationStateCode;
public int locationCityId;
public int favoriteAppId;
public int members;
public int usersOnline;
public int usersInChat;
public int usersInGame;
public String owner;
}
```
**Update**
Structure containing information about a single update.
```c#
public class Update
{
public DateTime timestamp;
public String origin;
public bool localMessage;
public UpdateType type;
public String message;
public UserStatus status;
public String nick;
}
```
**ServerInfo**
Structure containing server info.
```c#
public class ServerInfo
{
public DateTime serverTime;
public String serverTimeString;
}
```
### Example ###
Here's how to log in with a username and password, ask for the SteamGuard code if necessary and display the amount of friends the user has.
```c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
using SteamWebAPI;
namespace SteamWebAPI
{
class Program
{
static void Main( string[] args )
{
SteamAPISession session = new SteamAPISession();
Console.Write( "Username: " );
String username = Console.ReadLine();
Console.Write( "Password: " );
String password = Console.ReadLine();
SteamAPISession.LoginStatus status = session.Authenticate( username, password );
if ( status == SteamAPISession.LoginStatus.SteamGuard )
{
Console.Write( "SteamGuard code: " );
String code = Console.ReadLine();
status = session.Authenticate( username, password, code );
}
if ( status == SteamAPISession.LoginStatus.LoginSuccessful )
{
List<SteamAPISession.Friend> friends = session.GetFriends();
int blockedFriends = friends.Count( f => f.blocked == true );
Console.WriteLine( "You have " + ( friends.Count - blockedFriends ) + " friends and " + blockedFriends + " fiends!" );
}
else
{
Console.WriteLine( "Failed to log in!" );
}
}
}
}
```
================================================
FILE: SteamAPISession.cs
================================================
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Net;
using System.Text;
using Newtonsoft.Json.Linq;
namespace SteamWebAPI {
/// <summary>
/// Class allowing you to use the Steam Web API to log in and use Steam Friends functionality.
/// </summary>
///
public class SteamAPISession {
private String accessToken;
private String umqid;
private String steamid;
private int message = 0;
/// <summary>
/// Enumeration of possible authentication results.
/// </summary>
public enum LoginStatus {
LoginFailed,
LoginSuccessful,
SteamGuard
}
/// <summary>
/// Status of a user.
/// </summary>
public enum UserStatus {
Offline = 0,
Online = 1,
Busy = 2,
Away = 3,
Snooze = 4
}
/// <summary>
/// Visibility of a user's profile.
/// </summary>
public enum ProfileVisibility {
Private = 1,
Public = 3,
FriendsOnly = 8
}
/// <summary>
/// Available sizes of user avatars.
/// </summary>
public enum AvatarSize {
Small,
Medium,
Large
}
/// <summary>
/// Available update types.
/// </summary>
public enum UpdateType {
UserUpdate,
Message,
Emote,
TypingNotification
}
/// <summary>
/// Structure containing basic friend info.
/// </summary>
public class Friend {
public String steamid;
public bool blocked;
public DateTime friendSince;
}
/// <summary>
/// Structure containing extensive user info.
/// </summary>
public class User {
public String steamid;
public ProfileVisibility profileVisibility;
public int profileState;
public String nickname;
public DateTime lastLogoff;
public String profileUrl;
internal String avatarUrl;
public UserStatus status;
public String realName;
public String primaryGroupId;
public DateTime joinDate;
public String locationCountryCode;
public String locationStateCode;
public int locationCityId;
}
/// <summary>
/// Basic group info.
/// </summary>
public class Group {
public String steamid;
public bool inviteonly;
}
/// <summary>
/// Structure containing extensive group info.
/// </summary>
public class GroupInfo {
public String steamid;
public DateTime creationDate;
public String name;
public String headline;
public String summary;
public String abbreviation;
public String profileUrl;
internal String avatarUrl;
public String locationCountryCode;
public String locationStateCode;
public int locationCityId;
public int favoriteAppId;
public int members;
public int usersOnline;
public int usersInChat;
public int usersInGame;
public String owner;
}
/// <summary>
/// Structure containing information about a single update.
/// </summary>
public class Update {
public DateTime timestamp;
public String origin;
public bool localMessage;
public UpdateType type;
public String message;
public UserStatus status;
public String nick;
}
/// <summary>
/// Structure containing server info.
/// </summary>
public class ServerInfo {
public DateTime serverTime;
public String serverTimeString;
}
/// <summary>
/// Authenticate with a username and password.
/// Sends the SteamGuard e-mail if it has been set up.
/// </summary>
/// <param name="username">Username</param>
/// <param name="password">Password</param>
/// <param name="emailauthcode">SteamGuard code sent by e-mail</param>
/// <returns>Indication of the authentication status.</returns>
public LoginStatus Authenticate(String username, String password, String emailauthcode = "") {
String response = steamRequest("ISteamOAuth2/GetTokenWithCredentials/v0001",
"client_id=DE45CD61&grant_type=password&username=" + Uri.EscapeDataString(username) + "&password=" + Uri.EscapeDataString(password) + "&x_emailauthcode=" + emailauthcode + "&scope=read_profile%20write_profile%20read_client%20write_client");
if (response != null) {
JObject data = JObject.Parse(response);
if (data["access_token"] != null) {
accessToken = (String) data["access_token"];
return login() ? LoginStatus.LoginSuccessful : LoginStatus.LoginFailed;
} else if (((string) data["x_errorcode"]).Equals("steamguard_code_required"))
return LoginStatus.SteamGuard;
else
return LoginStatus.LoginFailed;
} else {
return LoginStatus.LoginFailed;
}
}
/// <summary>
/// Authenticate with an access token previously retrieved with a username
/// and password (and SteamGuard code).
/// </summary>
/// <param name="accessToken">Access token retrieved with credentials</param>
/// <returns>Indication of the authentication status.</returns>
public LoginStatus Authenticate(String accessToken) {
this.accessToken = accessToken;
return login() ? LoginStatus.LoginSuccessful : LoginStatus.LoginFailed;
}
/// <summary>
/// Fetch all friends of a given user.
/// </summary>
/// <remarks>This function does not provide detailed information.</remarks>
/// <param name="steamid">steamid of target user or self</param>
/// <returns>List of friends or null on failure.</returns>
public List<Friend> GetFriends(String steamid = null) {
if (umqid == null) return null;
if (steamid == null) steamid = this.steamid;
String response = steamRequest("ISteamUserOAuth/GetFriendList/v0001?access_token=" + accessToken + "&steamid=" + steamid);
if (response != null) {
JObject data = JObject.Parse(response);
if (data["friends"] != null) {
List<Friend> friends = new List<Friend>();
foreach (JObject friend in data["friends"]) {
Friend f = new Friend();
f.steamid = (String) friend["steamid"];
f.blocked = ((String) friend["relationship"]).Equals("ignored");
f.friendSince = unixTimestamp((long) friend["friend_since"]);
friends.Add(f);
}
return friends;
} else {
return null;
}
} else {
return null;
}
}
/// <summary>
/// Retrieve information about the specified users.
/// </summary>
/// <remarks>This function doesn't have the 100 users limit the original API has.</remarks>
/// <param name="steamids">64-bit SteamIDs of users</param>
/// <returns>Information about the specified users</returns>
public List<User> GetUserInfo(List<String> steamids) {
if (umqid == null) return null;
String response = steamRequest("ISteamUserOAuth/GetUserSummaries/v0001?access_token=" + accessToken + "&steamids=" + String.Join(",", steamids.GetRange(0, Math.Min(steamids.Count, 100)).ToArray()));
if (response != null) {
JObject data = JObject.Parse(response);
if (data["players"] != null) {
List<User> users = new List<User>();
foreach (JObject info in data["players"]) {
User user = new User();
user.steamid = (String) info["steamid"];
user.profileVisibility = (ProfileVisibility) (int) info["communityvisibilitystate"];
user.profileState = (int) info["profilestate"];
user.nickname = (String) info["personaname"];
user.lastLogoff = unixTimestamp((long) info["lastlogoff"]);
user.profileUrl = (String) info["profileurl"];
user.status = (UserStatus) (int) info["personastate"];
user.avatarUrl = info["avatar"] != null ? (String) info["avatar"] : "";
if (user.avatarUrl != null) user.avatarUrl = user.avatarUrl.Substring(0, user.avatarUrl.Length - 4);
user.joinDate = unixTimestamp(info["timecreated"] != null ? (long) info["timecreated"] : 0);
user.primaryGroupId = info["primaryclanid"] != null ? (String) info["primaryclanid"] : "";
user.realName = info["realname"] != null ? (String) info["realname"] : "";
user.locationCountryCode = info["loccountrycode"] != null ? (String) info["loccountrycode"] : "";
user.locationStateCode = info["locstatecode"] != null ? (String) info["locstatecode"] : "";
user.locationCityId = info["loccityid"] != null ? (int) info["loccityid"] : -1;
users.Add(user);
}
// Requests are limited to 100 steamids, so issue multiple requests
if (steamids.Count > 100)
users.AddRange(GetUserInfo(steamids.GetRange(100, Math.Min(steamids.Count - 100, 100))));
return users;
} else {
return null;
}
} else {
return null;
}
}
public List<User> GetUserInfo(List<Friend> friends) {
List<String> steamids = new List<String>(friends.Count);
foreach (Friend f in friends) steamids.Add(f.steamid);
return GetUserInfo(steamids);
}
public User GetUserInfo(String steamid = null) {
if (steamid == null) steamid = this.steamid;
return GetUserInfo(new List<String>(new String[] { steamid }))[0];
}
/// <summary>
/// Retrieve the avatar of the specified user in the specified format.
/// </summary>
/// <param name="user">User</param>
/// <param name="size">Requested avatar size</param>
/// <returns>The avatar as bitmap on success or null on failure.</returns>
public Bitmap GetUserAvatar(User user, AvatarSize size = AvatarSize.Small) {
if (user.avatarUrl.Length == 0) return null;
try {
WebClient client = new WebClient();
Stream stream;
if (size == AvatarSize.Small)
stream = client.OpenRead(user.avatarUrl + ".jpg");
else if (size == AvatarSize.Medium)
stream = client.OpenRead(user.avatarUrl + "_medium.jpg");
else
stream = client.OpenRead(user.avatarUrl + "_full.jpg");
Bitmap avatar = new Bitmap(stream);
stream.Flush();
stream.Close();
return avatar;
} catch (Exception e) {
return null;
}
}
/// <summary>
/// Retrieve the avatar of the specified group in the specified format.
/// </summary>
/// <param name="group">Group</param>
/// <param name="size">Requested avatar size</param>
/// <returns>The avatar as bitmap on success or null on failure.</returns>
public Bitmap GetGroupAvatar(GroupInfo group, AvatarSize size = AvatarSize.Small) {
User user = new User();
user.avatarUrl = group.avatarUrl;
return GetUserAvatar(user, size);
}
/// <summary>
/// Fetch all groups of a given user.
/// </summary>
/// <param name="steamid">SteamID</param>
/// <returns>List of groups.</returns>
public List<Group> GetGroups(String steamid = null) {
if (umqid == null) return null;
if (steamid == null) steamid = this.steamid;
String response = steamRequest("ISteamUserOAuth/GetGroupList/v0001?access_token=" + accessToken + "&steamid=" + steamid);
if (response != null) {
JObject data = JObject.Parse(response);
if (data["groups"] != null) {
List<Group> groups = new List<Group>();
foreach (JObject info in data["groups"]) {
Group group = new Group();
group.steamid = (String) info["steamid"];
group.inviteonly = ((String) info["permission"]).Equals("2");
if (((String) info["relationship"]).Equals("Member"))
groups.Add(group);
}
return groups;
} else {
return null;
}
} else {
return null;
}
}
/// <summary>
/// Retrieve information about the specified groups.
/// </summary>
/// <param name="steamids">64-bit SteamIDs of groups</param>
/// <returns>Information about the specified groups</returns>
public List<GroupInfo> GetGroupInfo(List<String> steamids) {
if (umqid == null) return null;
String response = steamRequest("ISteamUserOAuth/GetGroupSummaries/v0001?access_token=" + accessToken + "&steamids=" + String.Join(",", steamids.GetRange(0, Math.Min(steamids.Count, 100)).ToArray()));
if (response != null) {
JObject data = JObject.Parse(response);
if (data["groups"] != null) {
List<GroupInfo> groups = new List<GroupInfo>();
foreach (JObject info in data["groups"]) {
GroupInfo group = new GroupInfo();
group.steamid = (String) info["steamid"];
group.creationDate = unixTimestamp((long) info["timecreated"]);
group.name = (String) info["name"];
group.profileUrl = "http://steamcommunity.com/groups/" + (String) info["profileurl"];
group.usersOnline = (int) info["usersonline"];
group.usersInChat = (int) info["usersinclanchat"];
group.usersInGame = (int) info["usersingame"];
group.owner = (String) info["ownerid"];
group.members = (int) info["users"];
group.avatarUrl = (String) info["avatar"];
if (group.avatarUrl != null) group.avatarUrl = group.avatarUrl.Substring(0, group.avatarUrl.Length - 4);
group.headline = info["headline"] != null ? (String) info["headline"] : "";
group.summary = info["summary"] != null ? (String) info["summary"] : "";
group.abbreviation = info["abbreviation"] != null ? (String) info["abbreviation"] : "";
group.locationCountryCode = info["loccountrycode"] != null ? (String) info["loccountrycode"] : "";
group.locationStateCode = info["locstatecode"] != null ? (String) info["locstatecode"] : "";
group.locationCityId = info["loccityid"] != null ? (int) info["loccityid"] : -1;
group.favoriteAppId = info["favoriteappid"] != null ? (int) info["favoriteappid"] : -1;
groups.Add(group);
}
// Requests are limited to 100 steamids, so issue multiple requests
if (steamids.Count > 100)
groups.AddRange(GetGroupInfo(steamids.GetRange(100, Math.Min(steamids.Count - 100, 100))));
return groups;
} else {
return null;
}
} else {
return null;
}
}
public List<GroupInfo> GetGroupInfo(List<Group> groups) {
List<String> steamids = new List<String>(groups.Count);
foreach (Group g in groups) steamids.Add(g.steamid);
return GetGroupInfo(steamids);
}
public GroupInfo GetGroupInfo(String steamid) {
return GetGroupInfo(new List<String>(new String[] { steamid }))[0];
}
/// <summary>
/// Let a user know you're typing a message. Should be called periodically.
/// </summary>
/// <param name="steamid">Recipient of notification</param>
/// <returns>Returns a boolean indicating success of the request.</returns>
public bool SendTypingNotification(User user) {
if (umqid == null) return false;
String response = steamRequest("ISteamWebUserPresenceOAuth/Message/v0001", "?access_token=" + accessToken + "&umqid=" + umqid + "&type=typing&steamid_dst=" + user.steamid);
if (response != null) {
JObject data = JObject.Parse(response);
return data["error"] != null && ((String) data["error"]).Equals("OK");
} else {
return false;
}
}
/// <summary>
/// Send a text message to the specified user.
/// </summary>
/// <param name="steamid">Recipient of message</param>
/// <param name="message">Message contents</param>
/// <returns>Returns a boolean indicating success of the request.</returns>
public bool SendMessage(User user, String message) {
if (umqid == null) return false;
String response = steamRequest("ISteamWebUserPresenceOAuth/Message/v0001", "?access_token=" + accessToken + "&umqid=" + umqid + "&type=saytext&text=" + Uri.EscapeDataString(message) + "&steamid_dst=" + user.steamid);
if (response != null) {
JObject data = JObject.Parse(response);
return data["error"] != null && ((String) data["error"]).Equals("OK");
} else {
return false;
}
}
public bool SendMessage(String steamid, String message) {
User user = new User();
user.steamid = steamid;
return SendMessage(user, message);
}
/// <summary>
/// Check for updates and new messages.
/// </summary>
/// <returns>A list of updates.</returns>
public List<Update> Poll() {
if (umqid == null) return null;
String response = steamRequest("ISteamWebUserPresenceOAuth/Poll/v0001", "?access_token=" + accessToken + "&umqid=" + umqid + "&message=" + message);
if (response != null) {
JObject data = JObject.Parse(response);
if (((String) data["error"]).Equals("OK")) {
message = (int) data["messagelast"];
List<Update> updates = new List<Update>();
foreach (JObject info in data["messages"]) {
Update update = new Update();
update.timestamp = unixTimestamp((long) info["timestamp"]);
update.origin = (String) info["steamid_from"];
String type = (String) info["type"];
if (type.Equals("saytext") || type.Equals("my_saytext") || type.Equals("emote")) {
update.type = type.Equals("emote") ? UpdateType.Emote : UpdateType.Message;
update.message = (String) info["text"];
update.localMessage = type.Equals("my_saytext");
} else if (type.Equals("typing")) {
update.type = UpdateType.TypingNotification;
update.message = (String) info["text"]; // Not sure if this is useful
} else if (type.Equals("personastate")) {
update.type = UpdateType.UserUpdate;
update.status = (UserStatus) (int) info["persona_state"];
update.nick = (String) info["persona_name"];
} else {
continue;
}
updates.Add(update);
}
return updates;
} else {
return null;
}
} else {
return null;
}
}
/// <summary>
/// Retrieves information about the server.
/// </summary>
/// <returns>Returns a structure with the information.</returns>
public ServerInfo GetServerInfo() {
String response = steamRequest("ISteamWebAPIUtil/GetServerInfo/v0001");
if (response != null) {
JObject data = JObject.Parse(response);
if (data["servertime"] != null) {
ServerInfo info = new ServerInfo();
info.serverTime = unixTimestamp((long) data["servertime"]);
info.serverTimeString = (String) data["servertimestring"];
return info;
} else {
return null;
}
} else {
return null;
}
}
/// <summary>
/// Helper function to complete the login procedure and check the
/// credentials.
/// </summary>
/// <returns>Whether the login was successful or not.</returns>
private bool login() {
String response = steamRequest("ISteamWebUserPresenceOAuth/Logon/v0001",
"?access_token=" + accessToken);
if (response != null) {
JObject data = JObject.Parse(response);
if (data["umqid"] != null) {
steamid = (String) data["steamid"];
umqid = (String) data["umqid"];
message = (int) data["message"];
return true;
} else {
return false;
}
} else {
return false;
}
}
/// <summary>
/// Helper function to perform Steam API requests.
/// </summary>
/// <param name="get">Path URI</param>
/// <param name="post">Post data</param>
/// <returns>Web response info</returns>
private String steamRequest(String get, String post = null) {
System.Net.ServicePointManager.Expect100Continue = false;
HttpWebRequest request = (HttpWebRequest) WebRequest.Create("https://api.steampowered.com/" + get);
request.Host = "api.steampowered.com:443";
request.ProtocolVersion = HttpVersion.Version11;
request.Accept = "*/*";
request.Headers[HttpRequestHeader.AcceptEncoding] = "gzip, deflate";
request.Headers[HttpRequestHeader.AcceptLanguage] = "en-us";
request.UserAgent = "Steam 1291812 / iPhone";
if (post != null) {
request.Method = "POST";
byte[] postBytes = Encoding.ASCII.GetBytes(post);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = postBytes.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(postBytes, 0, postBytes.Length);
requestStream.Close();
message++;
}
try {
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
if ((int) response.StatusCode != 200) return null;
String src = new StreamReader(response.GetResponseStream()).ReadToEnd();
response.Close();
return src;
} catch (WebException e) {
return null;
}
}
private DateTime unixTimestamp(long timestamp) {
DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
return origin.AddSeconds(timestamp);
}
}
}
================================================
FILE: SteamWebAPI.csproj
================================================
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{D846D108-D95B-4488-BA01-E487DA220C17}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SteamAPI</RootNamespace>
<AssemblyName>SteamAPI</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>
</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>
</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>packages\Newtonsoft.Json.8.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SteamAPISession.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
================================================
FILE: SteamWebAPI.sln
================================================
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SteamWebAPI", "SteamWebAPI.csproj", "{D846D108-D95B-4488-BA01-E487DA220C17}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D846D108-D95B-4488-BA01-E487DA220C17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D846D108-D95B-4488-BA01-E487DA220C17}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D846D108-D95B-4488-BA01-E487DA220C17}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D846D108-D95B-4488-BA01-E487DA220C17}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
================================================
FILE: packages.config
================================================
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net40" />
</packages>
gitextract_ui8iz4yt/ ├── .gitignore ├── LICENSE ├── Properties/ │ └── AssemblyInfo.cs ├── README.md ├── SteamAPISession.cs ├── SteamWebAPI.csproj ├── SteamWebAPI.sln └── packages.config
SYMBOL INDEX (32 symbols across 1 files)
FILE: SteamAPISession.cs
class SteamAPISession (line 14) | public class SteamAPISession {
type LoginStatus (line 23) | public enum LoginStatus {
type UserStatus (line 32) | public enum UserStatus {
type ProfileVisibility (line 43) | public enum ProfileVisibility {
type AvatarSize (line 52) | public enum AvatarSize {
type UpdateType (line 61) | public enum UpdateType {
class Friend (line 71) | public class Friend {
class User (line 80) | public class User {
class Group (line 100) | public class Group {
class GroupInfo (line 108) | public class GroupInfo {
class Update (line 131) | public class Update {
class ServerInfo (line 144) | public class ServerInfo {
method Authenticate (line 157) | public LoginStatus Authenticate(String username, String password, Stri...
method Authenticate (line 183) | public LoginStatus Authenticate(String accessToken) {
method GetFriends (line 194) | public List<Friend> GetFriends(String steamid = null) {
method GetUserInfo (line 229) | public List<User> GetUserInfo(List<String> steamids) {
method GetUserInfo (line 277) | public List<User> GetUserInfo(List<Friend> friends) {
method GetUserInfo (line 283) | public User GetUserInfo(String steamid = null) {
method GetUserAvatar (line 294) | public Bitmap GetUserAvatar(User user, AvatarSize size = AvatarSize.Sm...
method GetGroupAvatar (line 324) | public Bitmap GetGroupAvatar(GroupInfo group, AvatarSize size = Avatar...
method GetGroups (line 335) | public List<Group> GetGroups(String steamid = null) {
method GetGroupInfo (line 371) | public List<GroupInfo> GetGroupInfo(List<String> steamids) {
method GetGroupInfo (line 422) | public List<GroupInfo> GetGroupInfo(List<Group> groups) {
method GetGroupInfo (line 428) | public GroupInfo GetGroupInfo(String steamid) {
method SendTypingNotification (line 437) | public bool SendTypingNotification(User user) {
method SendMessage (line 457) | public bool SendMessage(User user, String message) {
method SendMessage (line 471) | public bool SendMessage(String steamid, String message) {
method Poll (line 481) | public List<Update> Poll() {
method GetServerInfo (line 532) | public ServerInfo GetServerInfo() {
method login (line 556) | private bool login() {
method steamRequest (line 582) | private String steamRequest(String get, String post = null) {
method unixTimestamp (line 618) | private DateTime unixTimestamp(long timestamp) {
Condensed preview — 8 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (40K chars).
[
{
"path": ".gitignore",
"chars": 77,
"preview": "# Discard binaries\n\nobj/\nbin/\nSteamWebAPI/packages/\n.gitattributes\npackages/\n"
},
{
"path": "LICENSE",
"chars": 1083,
"preview": " Copyright (c) 2015 Alexander Overvoorde\n\n Permission is hereby granted, free of charge, to any person\n obtaining a copy"
},
{
"path": "Properties/AssemblyInfo.cs",
"chars": 1413,
"preview": "using System.Reflection;\nusing System.Runtime.CompilerServices;\nusing System.Runtime.InteropServices;\n\n// General Infor"
},
{
"path": "README.md",
"chars": 6819,
"preview": "This project is no longer actively maintained. You are advised to use a different library.\n========\n\nSteam Web API libra"
},
{
"path": "SteamAPISession.cs",
"chars": 25179,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Drawing;\nusing System.IO;\nusing System.Net;\nusing System.T"
},
{
"path": "SteamWebAPI.csproj",
"chars": 2614,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"4.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microso"
},
{
"path": "SteamWebAPI.sln",
"chars": 889,
"preview": "\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio 2012\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C"
},
{
"path": "packages.config",
"chars": 137,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<packages>\n <package id=\"Newtonsoft.Json\" version=\"8.0.3\" targetFramework=\"net4"
}
]
About this extraction
This page contains the full source code of the Overv/SteamWebAPI GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 8 files (37.3 KB), approximately 8.2k tokens, and a symbol index with 32 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.