SteamCommunity

Alex Corn edited this page Jul 11, 2018 · 53 revisions

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:

const SteamCommunity = require('steamcommunity');
let community = new SteamCommunity();

Properties

request

v2.1.0 or later is required to use this property

The instance of request used by node-steamcommunity. This will contain your login cookies if you've logged in or set cookies. The version of request that node-steamcommunity uses is defined in package.json and may change at any time.

steamID

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

Methods

Constructor([options])

  • options - Optional. An object containing zero or more of the following properties:
    • request - An instance of request v2.x.x which will be used by SteamCommunity for its HTTP requests. SteamCommunity will create its own if omitted.
    • timeout - The time in milliseconds that SteamCommunity will wait for HTTP requests to complete. Defaults to 50000 (50 seconds). Overrides any timeout option that was set on the passed-in request object.
    • userAgent - The user-agent value that SteamCommunity will use for its HTTP requests. Defaults to Chrome v47's user-agent. Overrides any headers['User-Agent'] option that was set on the passed-in request object.
    • localAddress - The local IP address that SteamCommunity will use for its HTTP requests. Overrides an localAddress option that was set on the passed-in request object.

v3.17.0 or later is required to use the options argument.

Constructs a new instance of SteamCommunity.

Between v3.5.0 and v3.17.0, the constructor took a single localAddress argument. This is still supported, but is deprecated.

login(details, callback)

  • details - An object containing our login details (see below)
  • callback - A function which will be called once we're logged in
    • err - If an error occurred, this is an Error object. Some common failures:
      • SteamGuard - If your login failed due to Steam Guard, the message property will be SteamGuard and there will be an emaildomain property. Login again and provide the email code as authCode to the details object.
      • SteamGuardMobile - If your login failed due to Steam Guard and the user has app-based authentication enabled, the message property will be SteamGuardMobile. Login again and provide the app code as twoFactorCode to the details object.
      • CAPTCHA - If your login failed due to a CAPTCHA being needed, the message property will be CAPTCHA and there will be a captchaurl property. Login again and provide the CAPTCHA solution as captcha to the details object.
    • 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 a string which can be passed to login as the steamguard property of details. You should treat it as an opaque string, but currently it's YourSteamID||YourCookieValue. You can pull YourCookieValue from the value of the steamMachineAuthYourSteamID cookie on an authorized browser if you wish.
    • oAuthToken - An oAuth token. You can use this value along with the steamguard value with oAuthLogin for subsequent passwordless logins.

The structure of details is as follows:

{
    "accountName": "your Steam account name",
    "password": "your Steam password",
    "steamguard": "your Steam Guard 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
    "twoFactorCode": "your Steam Guard app code", // only required if logging in with a Steam Guard app code
    "captcha": "value of prompted captcha", // only required if you have been prompted with a CAPTCHA
    "disableMobile": false // pass `true` here to have node-steamcommunity not use the mobile login flow. This might help keep your login session alive longer, but you won't get an oAuth token in the login response.
}

Read more about how cookies work and interact with other modules.

oAuthLogin(steamguard, oAuthToken, callback)

  • steamguard - The steamguard value from the callback of login
  • oAuthToken - The oAuthToken value from the callback of login
  • callback - Called when the login request completes
    • err - An Error object on failure, or null on success
    • sessionID - Your sessionid value. If an external library prompts for it, you'll need this. Otherwise, you can safely ignore it.
    • cookies - An array containing your cookies. If you're using an external library, you'll need these. Otherwise, you can ignore them.

v3.16.0 or later is required to use this method

Facilitates passwordless login using details received from a previous login request.

Read more about how cookies work and interact with other modules.

loggedIn(callback)

  • callback - Called when the result is available. Has three arguments:
    • err - If an error occurred, this is an Error object. Otherwise, null.
    • loggedIn - true if you're currently logged in, false otherwise
    • familyView - true if you're currently in family view, false otherwise. If true, you'll need to call parentalUnlock with the correct PIN before you can do anything.

v2.6.0 or later is required to use this method.

Use this method to check whether or not you're currently logged into Steam and what your Family View status is.

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-user, for instance).

Read more about how cookies work and interact with other modules.

getWebApiKey(domain, callback)

  • domain - A domain name to associate with your key
  • callback - A function to be called once the key is obtained
    • err - If an error occurred, this is an Error object. The message property will be Access Denied if you attempt to retrieve an API key on a limited account.
    • key - Your API key on success

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.

getWebApiOauthToken(callback)

  • callback - A function to be called once the token is obtained
    • err - If an error occurred, this is an Error object
    • token - Your oauth token on success

v3.10.0 or later is required to use this method

Gets an oauth access token for those WebAPI methods that need one.

parentalUnlock(pin[, callback])

  • pin - Your 4-digit Family View PIN
  • callback - An optional callback to be invoked on completion
    • err - If an error occurred, an Error object. null otherwise. If your PIN was wrong, the message property will be Incorrect PIN.

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.

getNotifications(callback)

  • callback - Fired when the requested data is available
    • err - null on success, or an Error object 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, gameTurns, moderatorMessages, helpRequestReplies, accountAlerts. 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
    • err - An Error object on failure, null on success

v1.0.7 or later required to use this method

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

getTradeURL(callback)

v3.33.0 or later is required to use this method

Gets your account's trade URL, which can be used by people who aren't your friends on Steam to send you trade offers.

changeTradeURL([callback])

v3.34.0 or later is required to use this method

Invalidates your account's existing trade URL and generates a new token, which is returned in the callback.

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.

In reality, a "session ID" is just a CSRF token. The session ID can be anything, as long as when it's required the session ID you submit in your form matches the session ID in your cookies.

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
    • err - If an error occurred, this is an Error object. null otherwise.
    • user - A CSteamUser instance

Creates and returns a CSteamUser object for a particular user.

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
    • err - If an error occurred, this is an Error object
    • group - A CSteamGroup instance

Creates and returns a CSteamGroup object for a particular group.

getMarketApps(callback)

  • callback - Called when the requested data is available
    • err - null on success, or an Error object on failure
    • apps - An object whose keys are AppIDs and whose values are the names of the apps

v3.4.0 or later is required to use this method

Requests a list of all apps which support the Steam Community Market (this list is scraped from the app buttons on the right side of the market home page).

getMarketItem(appid, hashName, callback)

  • appid - The ID of the app to which this item belongs
  • hashName - The item's market_hash_name
  • callback - Called when the item data is loaded and ready
    • err - If an error occurred, this is an Error object. If the item is not on the market or doesn't exist, the message property will be There are no listings for this item..
    • item - A CMarketItem instance

v2.3.0 or later is required to use this method

Creates and returns a CMarketItem object for a particular item.

marketSearch(options, callback)

  • options - Provide a string to just search for that string, otherwise an object with one or more of the following properties:
    • query - The query string to search for
    • appid - The AppID of the game you're searching for
    • searchDescriptions - true to also search in the descriptions of items (takes longer to search), false or omitted otherwise
  • callback - Called when results are available
    • err - If an error occurred, this will be an Error object. If the item is not on the market or doesn't exist, the message property will be There were no items matching your search. Try again with different keywords.
    • items - An array of CMarketSearchResult instances

v2.5.0 or later is required to use this method

Searches the market for a particular query. If you provide an appid to options, you can also search for tags. Simply add your search tags with the tag's name being the key and the tag's internal value being the value. For example, to search for TF2 decorated weapons, you'd do this:

{
    "appid": 440,
    "Quality": "paintkitweapon"
}

setupProfile([callback])

  • callback - Called when the action is complete
    • err - null on success, or an Error object on failure

v3.3.0 or later is required to use this method.

If your Steam account is new and your profile isn't set up yet, you can call this to create it.

editProfile(settings[, callback])

  • settings - An object containing one or more of the following properties
    • name - Your new profile name
    • realName - Your new profile "real name", or empty string to remove it
    • summary - Your new profile summary
    • country - A country code, like US, or empty string to remove it
    • state - A state code, like FL, or empty string to remove it
    • city - A numeric city code, or empty string to remove it
    • customURL - Your new profile custom URL
    • background - The assetid of an owned profile background which you want to equip, or empty string to remove it
    • featuredBadge - The ID of your new featured badge, or empty string to remove it. Currently game badges aren't supported, only badges whose pages end in /badge/<id>
    • primaryGroup - A SteamID object for your new primary Steam group, or a string which can parse into a SteamID
  • callback - Optional. Called when the request completes.
    • err - An Error object on failure, or null on success

v3.2.0 or later is required to use this method.

Updates one or more parts of your profile.

profileSettings(settings[, callback])

  • settings - An object containing one or more of the following properties
    • profile - A value from SteamCommunity.PrivacyState for your desired profile privacy state
    • comments - A value from SteamCommunity.PrivacyState for your desired profile comments privacy state
    • inventory - A value from SteamCommunity.PrivacyState for your desired inventory privacy state
    • inventoryGifts - true to keep your Steam gift inventory private, false otherwise
    • gameDetails - A value from SteamCommunity.PrivacyState for your desired privacy level required to view games you own and what game you're currently playing
    • playtime - true to keep your game playtime private, false otherwise
  • callback - Optional. Called when the request completes.
    • err - An Error object on failure, or null on success

v3.36.0 or later is required to use this method.

Updates one or more parts of your profile settings.

uploadAvatar(image[, format][, callback])

  • image - A Buffer containing the image, a string containing a URL to the image, or a string containing the path to the image on the local disk
  • format - Optional. The format of the image. See below.
  • callback - Optional. Called when the upload is complete or fails.
    • err - An Error object on failure or null on success
    • url - The URL to the new image on Steam's CDN

v3.6.0 or later is required to use this method.

Replaces your current avatar image with a new one. format is required if image is a Buffer, else it will be detected from the Content-Type header (if image is a URL) or the file extension (if image is a local path). If provided, format should be one of jpg (or jpeg), gif, or png. These are the only supported image formats.

The only supported protocols for URLs are http:// and https://. Any other string will be treated as a local path.

postProfileStatus(statusText[, options], callback)

  • statusText - A string containing your new status update's content (can contain BBCode and emoticons)
  • options - Optional. Can be omitted if no options are desired. An object containing zero or more of the following properties:
    • appID - An integer appID if you want this status update to be tagged with a specific game
  • callback - Required. Called when request completes.
    • err - null on success, an Error object on failure
    • postID - The ID of this new post

v3.37.0 or later is required to use this method.

Posts a status update to your profile feed.

deleteProfileStatus(postID[, callback])

  • postID - The ID of the post you want to delete
  • callback - Optional. Called when request completes.
    • err - null on success, an Error object on failure

v3.37.0 or later is required to use this method.

Removes a status update from your profile feed.

getInventoryHistory([options, ]callback)

  • options - Optional. An object containing any or all of the following properties:
    • direction - Either the string past to get trades that occurred further in the past than startTime, or future to get trades that occurred closer to the present than startTime. Has no effect if startTime is not set. Defaults to past.
    • startTime - Either a Unix timestamp or a Date object where you want Steam to start displaying trades (see direction)
    • startTrade - If startTime is set, then start at the trade following the one with this trade ID if it's the first entry (for direction past) or last entry (for direction future)
    • resolveVanityURLs - The inventory history page doesn't give Steam IDs for users who have configured a custom profile URL. If this is specified, then node-steam-inventoryhistory will request the XML profile of each unique trader to get their Steam IDs. Defaults to false.
  • callback - Called when the requested data is available.
    • err - An Error object on failure, or null if success
    • history - An object containing the data on the requested history page:
      • firstTradeTime - If the first entry in the trades array is not your most recently completed trade, then this is a Date object containing the first entry's (more precise) timestamp. Not defined otherwise.
      • firstTradeID - If the first entry in the trades array is not your most recently completed trade, then this is a string containing the trade ID of the first entry. Not defined otherwise.
      • lastTradeTime - If the last entry in the trades array is not your first-ever completed trade, then this is a Date object containing the last entry's (more precise) timestamp. Not defined otherwise.
      • lastTradeID - If the last entry in the trades array is not your first-ever completed trade, then this is a string containing the trade ID of the last entry. Not defined otherwise.
      • trades - An array containing the trades on this page. Regardless of inputs, this array is always sorted with the most-recently-completed trade first, and the completed-longest-ago trade last.
        • onHold - true if this trade is on hold (in escrow), false if not
        • date - A Date object for the date and time when this trade took place.
        • partnerName - The current profile name of the person you traded with.
        • partnerSteamID - A SteamID object for the person you traded with. This will be null if they have a custom URL and you didn't specify resolveVanityURLs.
        • partnerVanityURL - The custom profile URL of the person you traded with, if it exists. null if they don't have one.
        • itemsReceived - An array of CEconItem items you received.
        • itemsGiven - An array of CEconItem items you lost.

v3.24.0 or later is required to use this method. It was added in v3.9.0 but broken by a Steam backend change until v3.24.0.

Gets a page of trades from your inventory history. This was originally provided by node-steam-inventoryhistory (now deprecated and non-functional). There are 30 items per page.

This is deprecated and will be removed in the near future. Use the GetTradeHistory WebAPI method instead.

As of August 16, 2016, inventory history no longer uses page numbers and instead uses a "cursor" style of pagination. Here's a (high-level overview) how it works:

If you don't provide a startTime, then Steam will insert the cursor into the timeline at the present time and read backwards (into the past) for 30 entries.

If you provide a startTime, omit startTrade, and omit direction or provide past for direction, then Steam will insert the cursor into the timeline after (closer to the present) the most-recently-completed trade which completed at the provided timestamp, and read backwards (into the past) for 30 entries.

If you provide a startTime and a startTrade, and you omit direction or provide past for direction, then Steam will first (internally) pull a list of all your trades that completed at that timestamp. It will then read that list backwards (into the past) until it finds the trade with the provided ID, and then discard that list. If found, it will insert the cursor into the timeline before (further into the past) the matched trade and read backwards (into the past) for 30 entries. If the trade is not found in the small list, then behavior is identical to if startTrade was ommitted.

If you provide a startTime, omit startTrade, and provide future for direction, then Steam will insert the cursor into the timeline before (further into the past) the first-completed trade which completed at the provided timestamp, and read forwards (closer to the present) for 30 entries.

If you provide a startTime and a startTrade, and you provide future for direction, then Steam will first (internally) pull a list of all your trades that completed at that timestamp. It will then read that list forwards (toward the present) until it finds the trade with the provided ID, and then discard that list. If found, it will insert the cursor into the timeline after (closer to the present) the matched trade and read forwards (closer to the present) for 30 entries. If the trade is not found in the small list, then behavior is identical to if startTrade was omitted.

enableTwoFactor(callback)

  • callback - Called when the request completes
    • err - An Error object on failure, or null on success
    • response - The entire response from Steam

v3.11.0 or later is required to use this method

Starts the process to turn on TOTP for your account. You must have a phone number already linked with and verified on your account.

You'll be sent an SMS with an activation code that you'll need to provide to finalizeTwoFactor.

You should save the entire response object somewhere secure. You can use JSON.stringify on it safely.

Properties of note in the response object:

  • status - A value from EResult. If this is not OK (1), then the request failed.
  • shared_secret - This is your secret that's used for two-factor authentication.
  • identity_secret - This is your secret that's used for confirming trades.
  • revocation_code - You will need this in the future to disable two-factor authentication.

NOTE: If you didn't login directly through node-steamcommunity (that is, you used setCookies instead of login), there is a chance that Steam will deny access to this method. This is because some accounts (we don't know why) are being denied access to web chat, despite being unlimited. The WebAPI request to enable 2FA requires an oAuth token, which is either accessible via mobile login or via webchat. If you're receiving an access denied error, either use login directly with your account name/password/Steam Guard code, or use node-steam-user's 2FA methods.

finalizeTwoFactor(shared_secret, activationCode, callback)

  • shared_secret - shared_secret that you received in enableTwoFactor response
  • activationCode - The activation code you received in your SMS
  • callback - Called when the request completes
    • err - An Error object on failure, or null on success

v3.11.0 or later is required to use this method

Finishes the process of enabling TOTP two-factor authentication for your account. You can use steam-totp in the future when logging on to get a code.

If TOTP two-factor authentication is enabled, a code will be required on every login.

disableTwoFactor(revocationCode, callback)

  • revocationCode - Your two-factor revocation code, which has the format Rxxxxx, where x is a number
  • callback - Called when the request completes
    • err - An Error object on failure, or null on success. In some failures, there may be an eresult property defined.

v3.10.0 or later is required to use this method

Disables two-factor authentication on your account given a revocation code. Unlike the revocation procedure on the support site, this will not invalidate all your account's outstanding Steam Guard authorizations.

getConfirmations(time, key, callback)

  • time - The Unix timestamp with which the following key was generated
  • key - The confirmation key that was generated using the preceeding time and the tag "conf" (this key can be reused). You can use steam-totp to generate this.
  • callback - Called when the request completes
    • err - An Error object on failure, or null on success
    • confirmations - An array of CConfirmation objects

v3.12.1 or later is required to use this method

Get your account's outstanding confirmations. Only works if you're using two-factor authentication.

getConfirmationOfferID(confID, time, key, callback)

  • confID - The confirmation's ID
  • time
  • key
  • callback

v3.12.1 or later is required to use this method

Procedural-style version of CConfirmation#getOfferID

respondToConfirmation(confID, confKey, time, key, accept, callback)

  • confID - The confirmation's ID
  • confKey - The confirmation's key
  • time
  • key
  • accept
  • callback

v3.12.1 or later is required to use this method

Procedural-style version of CConfirmation#respond

As of v3.23.0, you can supply arrays to confID and confKey to act on multiple confirmations at once. The arrays should be of the confirmation IDs and confirmation keys you want to act on, in order. For example, if you have two confirmations whose id/key pairs are 12345/55555555 and 12346/56565656, then your input would be:

community.respondToConfirmation([12345, 12346], ["55555555", "56565656"], time, key, accept, callback);

Note that multi-action works on all confirmation types, including trade sending and trade acceptance. However, because it can take a long time to confirm a trade offer acceptance, you may experience timeouts when multi-acting on many of those confirmations. It might be better for you to just confirm trade acceptances one by one. Multi-confirming offer sending shouldn't be an issue.

acceptConfirmationForObject(identitySecret, objectID, callback)

  • identitySecret - Your account's identity_secret, as base64, hex, or a Buffer
  • objectID - The ID of the thing you want to confirm (either a trade offer ID or a market listing ID)
  • callback - Called when the task completes
    • err - An Error object on failure, or null on success

v3.27.0 or later is required to use this method

This is a convenience method that simply accepts a confirmation for a given object. Under the hood, it grabs the list of confirmations, picks out the correct one, and then accepts it. It tries to avoid re-using the same timestamp for confirmation as a previous call to this method so it should be safe to call this method twice in the same second, assuming Steam doesn't rate-limit the requests to the confirmation list page.

It's recommended that you use this as needed over the automatic confirmation checker so you aren't sending unnecessary requests to Steam, and getting yourself rate-limited.

acceptAllConfirmations(time, confKey, allowKey, callback)

  • time - Should be a unix timestamp
  • confKey - Should be a base64-encoded key for the "conf" tag, generated using the supplied time
  • allowKey - Should be a base64-encoded key for the "allow" tag, generated using the supplied time
  • callback - Called when the request completes
    • err - An Error object on failure, or null on success
    • confs - An array of the confirmations that were just accepted. May be empty if there were no pending confirmations.

v2.23.0 or later is required to use this method

Accept all outstanding confirmations on your account all at once.

getGemValue(appid, assetid, callback)

  • appid - The AppID of the game to which the item in question belongs
  • assetid - The AssetID of the item in question
  • callback - A function to be called when the requested data is available
    • err - An Error object on failure, or null on success
    • res - An object containing these properties:
      • promptTitle - A string containing the title which goes in the prompt shown in the Steam UI, e.g. "Turn into gems?"
      • gemValue - How many gems you'd get if you gemified this item

v3.35.0 or later is required to use this method

Use this method to see how many gems you'd get if you gemified a Steam Community item. Note that the AppID you need to provide is the AppID of the game to which the item belongs, not 753 (which is the AppID to which Steam Community items actually belong).

turnItemIntoGems(appid, assetid, expectedGemsValue, callback)

  • appid - The AppID of the game to which the item in question belongs
  • assetid - The AssetID of the item in question
  • expectedGemsValue - How many gems you should get for this item (from getGemValue)
  • callback - A function to be called when the request completes
    • err - An Error object on failure, or null on success
    • res - An object containing these properties:
      • gemsReceived - How many gems you got for this item
      • totalGems - How many gems you have now

v3.35.0 or later is required to use this method

Gemify a Steam Community item.

getGiftDetails(giftID, callback)

  • giftID - A string containing the assetid of the gift in your inventory
  • callback - A function to be called when the requested data is available
    • err - An Error object on failure, or null on success
    • res - An object containing these properties:
      • giftName - The name of this gift
      • packageID - The ID of the Steam package that you'll be granted if you redeem this gift
      • owned - A bool indicating whether your account already owns this package (if true, you can't redeem it because you own it already)

v3.35.0 or later is required to use this method

Get details about a gift in your Steam Gifts inventory.

redeemGift(giftID, callback)

  • giftID - A string containing the assetid of the gift in your inventory
  • callback - A function to be called when the request completes
    • err - An Error object on failure, or null on success

v3.35.0 or later is required to use this method

Redeem a gift in your Steam Gifts inventory and add it to your library.

Events

sessionExpired

  • err - An Error object

v3.19.0 or later is required to use this event

Emitted when an HTTP request is made which requires a login, and Steam redirects us to the login page (i.e. we aren't logged in). You should re-login when you get this event.

Note that this will be emitted continuously until you log back in. This event being emitted doesn't stop the module from attempting further requests (as a result of method calls, timers, etc) so you should ensure that you limit your logins.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.