Skip to content

SteamCommunity @ v1.0.x

Alexander Corn edited this page May 31, 2015 · 1 revision

This page describes the SteamCommunity API at version 1.0.x. For the current version, see SteamCommunity.

node-steamcommunity is split into multiple "classes" for simplicity's sake. This page lists all methods and properties available from the root of the module.

You must first instantiate an instance of node-steamcommunity. Example:

var SteamCommunity = require('steamcommunity');
var community = new SteamCommunity();

Properties

steamID

Contains our SteamID (as a SteamID object) if we're logged in.

Methods

login(details, callback)

  • details - An object containing our login details (see below)
  • callback - A function which will be called once we're logged in

The structure of details is as follows:

{
    "accountName": "your Steam account name",
    "password": "your Steam password",
    "steamID": new SteamCommunity.SteamID('your SteamID'), // only required if logging in with a Steam Guard authorization
    "sentry": "your Steam Guard sentry value", // only required if logging in with a Steam Guard authorization
    "authCode": "your Steam Guard email code" // only required if logging in with a new email auth code
}

If your account is protected by Steam Guard and you don't have a sentry value, simply login with only your accountName and password, and Steam will email you a new code. Then login again and specify that authCode. You'll get your steamID and sentry values in the callback.

The parameters passed to the callback are as follows:

  • err - If an error occurred, this is a string explaining the error. If your login failed due to Steam Guard, this value is SteamGuard.
  • sessionID - Your session ID value. If you're using an external library, it'll know what to do with this. Otherwise, you can ignore it.
  • cookies - An array containing your cookies. If you're using an external library, you'll need these. Otherwise, you can ignore them.
  • steamguard - If your account is protected by Steam Guard, this is an object containing your steamID (as an object) and sentry (as a string). To login with this Steam Guard authorization in the future, save these values in a file or a database or something. You can convert the SteamID object to a string by calling its toString() method, which will return your SteamID as a 64-bit unsigned integer (represented as a string). This value can be passed to the SteamID constructor to get it as an object again.

setCookies(cookies)

  • cookies - An array of cookies (as name=value pair strings)

Use this to resume a previous session or to use a session that was negotiated elsewhere (using node-steam, for instance).

getWebApiKey(domain, callback)

  • domain - A domain name to associate with your key
  • callback - A function to be called once the key is obtained

v1.0.3 or later required to use this method

Retrieves your account's Web API key, and registers one if needed. Usage of this method constitutes agreement to the Steam Web API terms of use.

The callback receives up to two arguments:

  • err - If an error occurred, this is a string explaining what happened. You'll get Access Denied if you attempt to retrieve an API key on a limited account.
  • key - Your API key on success

parentalUnlock(pin[, callback])

  • pin - Your 4-digit Family View PIN
  • callback - An optional callback to be invoked on completion

v1.0.4 or later required to use this method

If your account has Family View enabled, calling this will disable it for your current session.

If provided, the callback receives a single argument which is null in case of success, or a string explaining an error on failure. It will be Incorrect PIN if your PIN is wrong.

getNotifications(callback)

  • callback - Fired when the requested data is available
    • err - null on success, or a string describing an error on failure
    • notifications - An object containing properties for each notification type, see below

v1.0.7 or later required to use this method

Gets your account's notifications (the things under the green envelope button on the top-right).

The object's properties are comments, items, invites, gifts, chat, trades. The values of each property are the number of your notifications of that type.

resetItemNotifications([callback])

  • callback - An optional callback to be invoked on completion

v1.0.7 or later required to use this method

Loads your inventory page, which resets your new items notification to 0.

If provided, the callback received a single argument which is falsy in case of success, or a string explaining an error on failure.

getSessionID()

Returns the session ID of your current session, or generates a new one if you don't have a session yet. You probably won't need to use this.

getSteamUser(id, callback)

  • id - Either a SteamID object or a user's URL (the part after /id/)
  • callback - Called when the user's data is loaded and ready

Creates and returns a CSteamUser object for a particular user. The callback receives two arguments:

  • err - If an error occurred, this is a string explaining what happened
  • user - A CSteamUser instance

getSteamGroup(id, callback)

  • id - Either a SteamID object or a group's URL (the part after /groups/)
  • callback - Called when the group's data is loaded and ready

Creates and returns a CSteamGroup object for a particular group. The callback receives two arguments:

  • err - If an error occurred, this is a string explaining what happened
  • group - A CSteamGroup instance
Clone this wiki locally