Skip to content
AngelCMHxD edited this page May 23, 2022 · 10 revisions

Scroll down to Documentation.

Installation

npm i steamweb.js
yarn add steamweb.js
pnpm i steamweb.js

Example usage

const SteamWeb = require("steamweb.js")
const steam = new SteamWeb("<steam web api token here>")

(async () => {
    const playerSummaries = await steam.getPlayerSummaries("76561198999221230")
    console.log(playerSummaries)
})()

⚠️ Updating from 3.x to 4 ⚠️

The only thing that changed was the way how the module is imported.

New:

const SteamWeb = require("steamweb.js")
const steam = new SteamWeb("<steam web api token here>")

Old:

const steam = require("steamweb.js")
const steamWeb = new steam.SteamWeb("<steam web api token here>")

Documentation

Before starting:

More info:

  • You can use Steam Names instead of Steam ids, but only if that's the username in his custom url, ex: You can use "AngelCMHxD" if his community profile url is https://steamcommunity.com/id/AngelCMHxD/
  • Arguments followed by a "*" are optional.

Table of Contents

  1. getNewsForApp
  2. getGlobalAchievementPercentagesForApp
  3. getPlayersSummaries
  4. getPlayerSummaries
  5. getFriendList
  6. getPlayerAchievements
  7. getUserStatsForGame
  8. getOwnedGames
  9. getRecentlyPlayedGames
  10. convertUsernameToId
  11. convertIdToUsername

getNewsForApp(appId: string, count?: number, maxLength?: number)

Arguments:

  1. appId - The id of the steam app.
  2. count* - Maximum number of news to return.
  3. maxLength* - Max number of characters that the content of the news will have.

Returns: A array containing json objects, each object is a different news, each object contains the following:

  • gId - The id of the news.
  • title - The title of the news.
  • url - The url that redirects you to the news.
  • author - The person that made the news. (null if there isn't one)
  • contents - A string with the content of the news (Is html code)
  • feedLabel - The label of the feed.
  • feedName - The name of the feed.
  • date - A DateConstructor with the date when the news was created.
  • appId - The id of the steam app.

getGlobalAchievementPercentagesForApp(appId: string)

Arguments:

  1. appId - The id of the steam app.

Returns: A array containing json objects, each object has the following:

  • apiName - The api name of the achievement.
  • percent - The percentage of people that have achieved this achievement.

getPlayersSummaries(userId: string[])

Arguments:

  1. userId - A array of steam user ids.

Returns: A array with json objects, each object related to each user id you provided, each object has the following:

  • steamId - The id of the steam user.
  • name - The username of that user.
  • profileUrl - The url to that user's profile.
  • avatarUrl - The url to that user's avatar. (32x32px)
  • avatarUrlMedium - The url to that user's avatar. (64x64px)
  • avatarUrlFull - The url to that user's avatar. (184x184px)
  • personaState - A string with the actual state of the player (It can be: Offline, Online, Busy, Away, Snooze, Looking to trade, Looking to play)
    • It's only visible if the player set it to public.
  • realname - A string with the real name of the player.
    • It's only visible if the player set it to public.
  • primaryClanId - The id of the primary clan set by the player.
    • It's only visible if the player set it to public.
  • lastLogOff - A DateConstructor with the date of the last time the player was online/loggued off.
  • timeCreated - A DateConstructor with the date when the account was create.
    • It's only visible if the player set it to public.
  • locCountryCode - The country code of the player. (2-character code)
    • It's only visible if the player set it to public.
  • locStateCode - The player's state of residence.
    • It's only visible if the player set it to public.
  • locCityId - The internal id of the city used by Steam.
    • It's only visible if the player set it to public.
  • locCity - The name of the city.
    • It's only visible if the player set it to public.

getPlayerSummaries(userId: string)

It returns a json containing the summaries of that player, like getPlayersSummaries

Doing:

const summaries = await getPlayerSummaries("AngelCMHxD")
console.log(summaries)

is the same as doing:

const summaries = await getPlayersSummaries(["AngelCMHxD"])
console.log(summaries[0])

getFriendList(userId: string)

Arguments:

  1. userId - The id of a steam user.

Returns: If the friends of that user are private or if the user doesn't has any friends, it will return false (boolean). If the user has any friends and are public, it will return a array of friends (objects), each object containing the following:

  • steamId - The steam id of the friend.
  • friendsSince - A DateConstructor with the date of when they became friends.

getPlayerAchievements(userId: string, appId: string, filterByAchieved?: boolean, lang?: string)

Arguments:

  1. userId - The id of the steam user.
  2. appId - The id of the steam app/game you want to check achievements.
  3. filterByAchieved* - If true, it will only return the achievements that the user have actually achieved.
  4. lang* - The language (2 letter) in the name and description of the achievements. If not found in that language, it will be in english.

Returns: A array with the achievements objects, each achievement object has the following:

  • name - The name of the achievement.
  • description - The description of the achievement.
  • apiName - The name that the api recognizes as the achievement.
  • unlockTime - A date constructor with the date when the player got the achievement.

getUserStatsForGame(userId: string, appId: string)

Arguments:

  1. userId - The id of the user you want to check the stats of.
  2. appId - The id of the app/game where you want to check the stats.

Returns: A object containing the folowing:

  • gameName - The name of the game.
  • stats - A array containing stats objects, each object contains the following:
    • name - The name of the stat.
    • value - The value that stat has.

getOwnedGames(userId: string, includeAppInfo?: boolean, includeFreeGames?: boolean)

Arguments:

  1. userId - The steam id of a user.
  2. includeAppInfo* - If you set it to false, you will not get name or hasCommunityVisibleStats.
  3. includeFreeGames* - If set to true, it will include free games on the game list.

Returns: A object containing the following:

  • gameCount - The number of games that the user owns.
  • games - A array containing game objects, each object contains the following:
    • appId - The id of the app/game.
    • name - The name of the app/game.
    • playtimeForever - The playtime the user has on that game.
    • imgIconUrl - The url to the icon of the game.
    • hasCommunityVisibleStats - Is true if the game contains other stats visible in community page.
    • playtimeWindowsForever - The playtime the user has on that game. (Only in Windows)
    • playtimeMacForever - The playtime the user has on that game. (Only in Mac)
    • playtimeLinuxForever - The playtime the user has on that game. (Only in Linux)

getRecentlyPlayedGames(userId: string, count?: number)

Arguments:

  1. userId - The steam id of a user.
  2. count* - The maximun count of games to return.

Returns: False if there isn't recent played games, Otherwise:

A object containing the following:

  • gameCount - The number of games that the user has played recently.
  • games - A array containing game objects, each object contains the following:
    • appId - The id of the app/game.
    • name - The name of the app/game.
    • playtimeForever - The playtime the user has on that game.
    • playtime2Weeks - The playtime the user has on that game during the last 2 weeks.
    • imgIconUrl - The url to the icon of the game.
    • hasCommunityVisibleStats - Is true if the game contains other stats visible in community page.
    • playtimeWindowsForever - The playtime the user has on that game. (Only in Windows)
    • playtimeMacForever - The playtime the user has on that game. (Only in Mac)
    • playtimeLinuxForever - The playtime the user has on that game. (Only in Linux)

convertUsernameToId(username: string)

Arguments:

  1. username - The username of that steam user (only if that's the username in his custom url, ex: You can put "AngelCMHxD" there if his community profile url is https://steamcommunity.com/id/AngelCMHxD/)

Returns: String with the id of the user

convertIdToUsername(userId: string)

Arguments:

  1. id - The id of the steam user.

Returns: String with the username of that user.