Skip to content

Common Use Examples

Justin Skiles edited this page Apr 17, 2020 · 6 revisions

Get a Player's Steam Profile

var steamUserInterface = webInterfaceFactory.CreateSteamWebInterface<SteamUser>();
var playerSummaryResponse = await steamInterface.GetPlayerSummaryAsync(<steam id here>);
var playerSummaryData = playerSummaryResponse.Data;

Here is an example response serialized to JSON.

{
  "SteamId": 76561197960361544,
  "ProfileVisibility": 3,
  "ProfileState": 1,
  "Nickname": "aro",
  "LastLoggedOffDate": "2020-04-16T02:03:11",
  "CommentPermission": 1,
  "ProfileUrl": "https://steamcommunity.com/id/aro/",
  "AvatarUrl": "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/a9/a9e5bf672bb4c7837b9fbec8a76bc1184fb3b99f.jpg",
  "AvatarMediumUrl": "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/a9/a9e5bf672bb4c7837b9fbec8a76bc1184fb3b99f_medium.jpg",
  "AvatarFullUrl": "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/a9/a9e5bf672bb4c7837b9fbec8a76bc1184fb3b99f_full.jpg",
  "UserStatus": 1,
  "RealName": null,
  "PrimaryGroupId": "103582791435784710",
  "AccountCreatedDate": "2003-09-12T14:47:23",
  "CountryCode": null,
  "StateCode": null,
  "CityCode": 0,
  "PlayingGameName": null,
  "PlayingGameId": null
}

Get a Player's Friends List

var steamUserInterface = webInterfaceFactory.CreateSteamWebInterface<SteamUser>();
var friendListResponse = await steamUserInterface.GetFriendsListAsync(<steam id here>);
var friendList = friendListResponse.Data;

This will return a 401 Unauthorized if the player's profile is private.

Here is an example response serialized to JSON.

[
  {
    "SteamId": 76561197960461463,
    "Relationship": "friend",
    "FriendSince": "1970-01-01T00:00:00"
  },
  {
    "SteamId": 76561197960503439,
    "Relationship": "friend",
    "FriendSince": "2014-08-17T02:52:46"
  },
  {
    "SteamId": 76561197960511559,
    "Relationship": "friend",
    "FriendSince": "1970-01-01T00:00:00"
  }
]

Get Player's Owned Games

var steamPlayerInterface = webInterfaceFactory.CreateSteamWebInterface<PlayerService>();
var ownedGames = await steamPlayerInterface.GetOwnedGamesAsync(<steam id here>, includeAppInfo: true);
  • This will return a 401 Unauthorized if the player's profile is private.
  • The second parameter includeAppInfo provides more details in the API response (see below).
  • PlaytimeForever is a TimeSpan and doesn't serialize naturally to JSON.
  • ImgIconUrl and ImgLogoUrl used to be URLs but now appear to be image identifiers which are merely part of the following URL structure: https://steamcdn-a.akamaihd.net/steamcommunity/public/images/apps/<app_id>/<image_id>.jpg
  • Example ImgLogoUrl for Deus Ex: Human Revolution

Here is an example response serialized to JSON.

[
    {
      "AppId": 28050,
      "Name": "Deus Ex: Human Revolution",
      "PlaytimeForever": "1.06:53:00",
      "ImgIconUrl": "6c7ccd62c124ae63820e06ed9b24d4559c5b0b1f",
      "ImgLogoUrl": "93705ac83aa363ce6ead3f6aad7fa4292d3cd80f",
      "HasCommunityVisibleStats": true,
      "PlaytimeLastTwoWeeks": null
    },
    {
      "AppId": 105600,
      "Name": "Terraria",
      "PlaytimeForever": "04:06:00",
      "ImgIconUrl": "858961e95fbf869f136e1770d586e0caefd4cfac",
      "ImgLogoUrl": "783399da7d865b7b5b1560891b1e9463345e8fa9",
      "HasCommunityVisibleStats": true,
      "PlaytimeLastTwoWeeks": null
    },
    {
      "AppId": 20920,
      "Name": "The Witcher 2: Assassins of Kings Enhanced Edition",
      "PlaytimeForever": "1.02:38:00",
      "ImgIconUrl": "62dd5c627664df1bcabc47727c7dcd7ccab353e9",
      "ImgLogoUrl": "f0274a91931ed39f7c69dca9f907ceae6450785c",
      "HasCommunityVisibleStats": true,
      "PlaytimeLastTwoWeeks": null
    }
]