JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2056
  • Score
    100M100P100Q163885F

Steam WebAPI wrapper

Package Exports

  • steam-webapi

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (steam-webapi) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Steam WebAPI library for node.js

Supports Node v0.8.26 (or newer) but might work on older versions

A Steam API Key is needed for many of the methods in the API.

All the methods are created at runtime (available after Steam.ready, which fetches list), rather than compile-time, so this should theoretically support all (future) Steam API methods. No need to worry about calling the correct API version, as it will always be the latest. If you must use a different version simply pass in {'version'}.

List of methods

To install:

npm install steam-webapi

Example

    var Steam = require('steam-webapi');

    var steamAPIKey = "YOUR API KEY";

    Steam.ready(steamAPIKey, function(err) {
        if (err) return console.log(err);

        var steam = new Steam({key: steamAPIKey});

        // Retrieve the steam ID from a steam username/communityID
        steam.resolveVanityURL({vanityurl:'jonbo'}, function(err, data) {
            console.log(data);
            // data -> { steamid: '76561197968620915', success: 1 }

            // Get the Player's TF2 Backpack items
            data.gameid = Steam.TF2;

            // getPlayerItems requires { gameid, steamid }
            steam.getPlayerItems(data, function (err, data) {
                console.log(data);
                // data -> { status: 1, num_backpack_slots: 1100, items: [...], ...}

            });
        });

    });

Example with generators and promises

    // Requires node 0.11+ and "node --harmony"

    var Steam = require('steam-webapi');
    var Promise = require('bluebird');

    var steamAPIKey = "YOUR API KEY";

    Steam.ready(steamAPIKey, Promise.coroutine(function*(err) {
        if (err) return console.log(err);

        // Creates an promise wielding function for every method (with Async attached at the end)
        Promise.promisifyAll(Steam.prototype);

        var steam = new Steam({key: steamAPIKey});

        // Retrieve the steam ID from a steam username/communityID
        var data = yield steam.resolveVanityURLAsync({vanityurl:'jonbo'});
        console.log(data);
        // data -> { steamid: '76561197968620915', success: 1 }

        // Get the Player's TF2 Backpack items
        data.gameid = Steam.TF2;
        data = yield steam.getPlayerItemsAsync(data);
        console.log(data);
        // data -> { status: 1, num_backpack_slots: 1100, items: [...], ...}

    }));

If you plan on only using this for TF2 data only (or just want to default to it), the first example can be rewritten.

    var steam = new Steam({key: steamAPIKey, gameid: Steam.TF2, appid:Steam.TF2});

    steam.resolveVanityURL({vanityurl:'jonbo'}, function(err, data) {

        // No need for data.gameid = Steam.TF2; here

        steam.getPlayerItems(data, function (err, data) {
            console.log(data);
            // data -> { status: 1, num_backpack_slots: 1100, items: [...], ...}
        });
    });

It works the same for 'key' and other fields.

Todo

  • Support WebAPI HTTP Post methods
  • Support WebAPI methods with array arguments
  • Tests

License

MIT