Giter Club home page Giter Club logo

steam-inventory's Introduction

Get Steam Inventories

Get a users steaminventory of any game. It's easy to use!

Install

npm install get-steam-inventory --save

Import

const steaminventory = require('get-steam-inventory');

Versions before 2.0 doesn't support promises.

Have you got a question? Please submit an issue here.

Methods

steaminventory.getinventory(appid, steamid, contextid, tradeable);
  • appid: This is the appid for the game that you want to load the inventory items for.
  • steamid: This is the steam64 id of the user that you want to load.
  • contextid: Context id is an id set by the game. For valve games it's usually 2.
  • tradeable: This a boolean to filter the items which can be traded.

Data resolve

  • data.raw: Raw information recieved from the servers.
  • data.items: All the information about the items. (Like icon urls, descriptions, name colors ect)
  • data.marketnames: All the market names of the items in the inventory returned as a javascript object.
  • data.assets: All the information about the assets in the inventory
  • data.assetids: Every assetid in the inventory

Examples

Get the item names

const steaminventory = require('./index.js');
const steamid = '76561198089544929';
steaminventory.getinventory(730, steamid, '2', true).then(data => {
    console.log(data.marketnames);
}).catch(err => console.log(err));

Output

[ 'Sealed Graffiti | NaCl (Shark White)',
  'Glove Case',
  'Gamma 2 Case',
  'Chroma 2 Case',
  'AND LOTS OF MORE INFORMATION OR NAMES :)']

Well, using that example may not be the best thing if you are trying to get something useful out of it. We recommend this instead:

Get raw

const steaminventory = require('./index.js');
const steamid = '76561198089544929';
steaminventory.getinventory(730, steamid, '2', true).then(data => {
    console.log(data.raw);
}).catch(err => console.log(err));
//This one logs EVERY name of the items in the inventory.

Output

{ appid: 730,
       classid: '1989274437',
       instanceid: '302028390',
       currency: 0,
       background_color: '',
       icon_url: 'IzMF03bi9WpSBq-S-ekoE33L-iLqGFHVaU25ZzQNQcXdB2ozio1RrlIWFK3Uf'

Get assets

const steaminventory = require('./index.js');
const steamid = '76561198089544929';
steaminventory.getinventory(730, steamid, '2', true).then(data => {
    console.log(data.assets);
}).catch(err => console.log(err));
//This one logs EVERY name of the items in the inventory.

Output

{ appid: 730,
    contextid: '2',
    assetid: '13106527064',
    classid: '1989315922',
    instanceid: '302028390',
    amount: '1' },
  { appid: 730,
    contextid: '2',

Contribute

Feel free to open pullrequests or issues on the github page.

License

MIT License

Copyright (c) 2018 Olle Thunberg

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

steam-inventory's People

Contributors

thunbergolle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

steam-inventory's Issues

Problem with getting an items tags

i have

const steaminventory = require('get-steam-inventory');
const fs = require('fs');
var id = "76561198076819824";
var steamid = id
console.log(steamid)
appid = 440
contextid = 2

steaminventory.getinventory(appid, steamid, function(err, data){
    var marketnames = data.raw
    console.log(marketnames);
}, 2);

and when it get the data.raw the tags adn descriptions of an item are either[object] or [array]

No duplicates in JSON

Hey,

maybe I oversaw something in the code but it appears that the JSON data only gets every item in my steam inventory once and doesn't show the duplicates. For example, I have one specific item 15 times in my inventory but the JSON file shows the item just once. I understand that the amount is located in the array of assets but even there no item is listed with an amount more than 1.

This issue probably has to do with the way steam posts the data but is there a way to get the whole inventory data (with duplicates) in the JSON file.

If it's an issue with my code and working just fine for you please tell me.

Have a nice day

Only Tradeables

Possible to add an option like TradeManager has to show only the items that are tradeable?

//EDIT:

Solved through pull request

Match assetid with the exact item it belongs to

I have been looking into it for some tiime and I am not sure how am I supose to match an assetid to specific item. It seems to me in data.assetids not all asset ids are really represented while data.assets seem to have too many and in random order. Basically I need to know if i take randomly an item from data.items how do I match its assetid to it?

Only the first 500 items or so of inventories are being returned by this endpoint

as this user noted, the response from the server does not return the entire users inventory. I suspect this to be a limitation with the deprecated 'request' dependency, but I am not sure. Any help would be greatly appreciated.


Hey,
i can confirm that i have the same issue. I also recognized that only all Steam Inventory Items up to page 20 are listed in that JSON file. Every item beyond page 20 is not listed anymore.

Kind regards

Originally posted by @nerzlakai96 in #9 (comment)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.