• Stars
    star
    169
  • Rank 217,602 (Top 5 %)
  • Language
    C#
  • License
    MIT License
  • Created over 12 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Library for C# giving access to the functionality of the Steam Web API.

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.

public enum LoginStatus
{
	LoginFailed,
	LoginSuccessful,
	SteamGuard
}

UserStatus

Status of a user.

public enum UserStatus
{
	Offline = 0,
	Online = 1,
	Busy = 2,
	Away = 3,
	Snooze = 4
}

ProfileVisibility

Visibility of a user's profile.

public enum ProfileVisibility
{
	Private = 1,
	Public = 3,
	FriendsOnly = 8
}

AvatarSize

Available sizes of user avatars.

public enum AvatarSize
{
	Small,
	Medium,
	Large
}

UpdateType

Available update types.

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.

public class Friend
{
    public String steamid;
    public bool blocked;
    public DateTime friendSince;
}

User

Structure containing extensive user info.

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.

public class Group
{
    public String steamid;
    public bool inviteonly;
}

GroupInfo

Structure containing extensive group info.

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.

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.

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.

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!" );
            }
        }
    }
}

More Repositories

1

outrun

Execute a local command using the processing power of another Linux machine.
Python
3,104
star
2

VulkanTutorial

Tutorial for the Vulkan graphics and compute API
C++
2,927
star
3

vramfs

VRAM based file system for Linux
C++
1,228
star
4

openstreetmap-tile-server

Docker file for a minimal effort OpenStreetMap tile server
Shell
1,143
star
5

Open.GL

The source code and content of Open.GL.
PHP
1,059
star
6

MineAssemble

A tiny bootable Minecraft clone written partly in x86 assembly
Assembly
1,028
star
7

OOGL

Object-oriented C++ wrapper for OpenGL.
C
400
star
8

WebCraft

Minecraft clone written in Javascript.
JavaScript
381
star
9

MantleHelloTriangle

An implementation of Hello Triangle using the Mantle API on Windows
C
89
star
10

TheWitnessSolver

Solver for The Witness puzzles
JavaScript
72
star
11

JSGL

A software implementation of OpenGL 1.1 for Javascript.
JavaScript
69
star
12

ColorScatterPlot

Visualization of colors in an image through a 3D scatterplot
HTML
60
star
13

bf

Brainfuck interpreter in Rust
Rust
34
star
14

lambda

Compile anonymous functions based on C# lambda expressions at runtime.
C
25
star
15

raycraft

Minecraft clone using ray tracing for rendering.
C++
16
star
16

gitlabfs

Mount all projects in a company's GitLab instance as a file system.
Python
15
star
17

TrayLightControl

Windows tray application for controlling Milight/LimitlessLED LED lamps (currently bridge v5 only!)
C#
14
star
18

Raytracer

Very basic raytracer to experiment with
C++
12
star
19

pqpp

Simple PostgreSQL bindings for modern C++
C++
10
star
20

BFC

Standalone brainfuck compiler
Python
5
star
21

rest.d

A lightweight web framework for RESTful web applications written in D
D
4
star
22

BoggleSaga

A Java implementation of the Boggle game.
Java
2
star
23

CalculateExactly

University assignment about implementing arbitrary precision arithmetic in Java.
Java
2
star