websteam v1.0.1
node-websteam
Warning
Steam has banned bots before for buying and selling e.g. TF2 keys for a profit. I am not responsible if anything happens to your Steam account when using this. For support on a ban, do not contact me, instead contact the Steam Support.
Quick and easy
var WebSteam = require('websteam');
var MyUser = new WebSteam.User();
MyUser.Login("MyAccountName", "MyBase64EncryptedPassword", "GUARDCODE", function(err, code) {
if(err) throw err;
if(code === 0) {
// You are already logged in!
} else if(code === 1) {
// You are now logged in
} else if(code === 2) {
// You need a SteamGuard code
} else if(code === 3 || code === 4) {
// Error
}
});WebSteam.User(options)
The user class, required for accessing everything else. Setting the DEBUG environment variable to SteamClass:User (See debug) you will be able to see all errors and debugging messages. No options are required. Options are:
CookieJar- A WebSteam.CookieJar object. Useful when loading cookies from a JSON file using CookieJar.fromJSON(string)Username- The Steam Login name.Currency- The currency integer;1- USD2- GBP3- Euro
User.Login(Username, Password, SteamGuardCode, Callback)
Logs the user in using the given credentials.
Usernameis the username you use to login on Steam.Passwordis the password, which has to be Base64 encoded.SteamGuardCodeis the Steam Guard code, which you receive in your inbox after a failed (code 2) login.Callback(err, code)is the callback after the function is done logging in or has failed. Possible codes are:0- You are already logged in, your cookie jar contains a session which is still valid.1- You are now logged in.2- Either your Steam Guard code is invalid, or you didn't give one but is required.3- The login returned with a readable error message, checkerr.4- An unknown error has shown up, checkerr.
User.GetSteamCommunityID(Callback)
Your Steam Community ID (steamcommunity.com/id/example) is not set after the Login, you need to call this before accessing User.SteamCommunityID.
Callback(err, id)is called when it has found the username or has failed to (err). If it can't find the ID,idreturns0.
User.GetSessionID()
Because, just like the Steam Community ID, User.SessionID is not set yet, you need to call this. This tries to retrieve the Session ID from the CookieJar. The function returns a bool, which is either true if it has successfully found it, or false if it failed to do so.
User.GetMissingCards(AppID, Callback)
Gets the missing cards for crafting a badge from the Game AppID.
AppIDis the App ID which has to have the trading cards feature.Callback(err, items)is called when it has found the required items or has failed. The items variable is an array that contains the item hashes of the missing cards.
User variables
User.CookieJaris aWebSteam.CookieJar.User.rCookieJaris Request's version of the CookieJar (request.jar(User.CookieJar)).User.Usernameis the user's login name.User.SteamCommunityIDis the Steam Community ID. This is empty untilUser.GetSteamCommunityIDfound it.User.LoggedInistrueif the user is logged in,falseotherwise.User.PublicKeyModis the Public Key Modulus, required for encrypting the password for logging in (SteamEncrypt.js).User.PublicKeyExpis the Public Key Exponent, idem.User.SessionIDis the Session ID. SeeUser.GetSessionIDUser.Currencyis the currency the account is using, see above for values. Defaults to1(USD).
WebSteam.MarketItem(options)
Class for using the market for things like checking items or creating buy orders. Setting the DEBUG environment variable to SteamClass:MarketItem (See debug) you will be able to see all errors and debugging messages. Options are:
ItemHash- The item's hash, can be found at the end of the item's url (e.g. steamcommunity.com/market/listings/753/4000-Invasion).AppID- The App ID, can also be found in the url (e.g. steamcommunity.com/market/listings/753/4000-Invasion)User- The User (WebSteam.Userclass) that sees the item.
MarketItem.GetPrice(Callback)
Finds the price and available amount of the item.
Callback(err, success)is called on success or failure.successis true on success.
MarketItem.Buy(Amount, Price, Callback)
Creates a buy order for the item.
Amountis the amount of items you want to buy at once.Priceis the price you pay for this item. Note: this is an integer, this means it cannot have decimals. For e.g. $2.19 use219.Callback(err, buyorderid)is called on success or failure.buyorderidis0if the buy order is not created.
MarketItem variables
MarketItem.SessionIDis the SessionID, retrieved fromWebSteam.UserMarketItem.AppIDis the App ID (Seeoptions)MarketItem.ItemHashis the Item hash (idem)MarketItem.Priceis the price afterMarketItem.GetPrice($2.19 becomes219)MarketItem.Amountis the amount of items available afterMarketItem.GetPriceMarketItem.Currencyis the currency, see above.MarketItem.Useris the User class (WebSteam.User).
