Majid Majid - 1 year ago 521
PHP Question

get CSGO inventory with steam API

OK, i need to get csgo inventory with steam API . i use this url$api_key&steamids=$steamid

and i use this url for access to all csgo items.

problem 1, is i cant understand the returned value in first url. there is no item name, image and ... .
this is how it will return

"id": 547938992,
"original_id": 547938992,
"defindex": 13,
"level": 1,
"quality": 4,
"inventory": 53,
"quantity": 1,
"rarity": 1,

problem 2, when is use second url to get all of csgo skins. it just returns vanilla skins. how can i get full skins like other websites : opskins , bitskins, csgolounge and .... .

I know there is alot of question like this in Stackoverflow but none of them answer the way i can understand.

and I am sorry for my poor English.

Answer Source

For my project I use another url for steam's API,

"*insert steamId*/inventory/json/730/2"

You can try to use your steamID and paste it into your browser and you will see how the response looks like. This is what you will be working with.

If you make a request with this url you will get a response with a json object which have two parts. One part is called rgInventory(ie. data.rgInventory)and contains ids for each skin in the users csgo-inventory. The second part is called rgDescriptions(ie. data.rgDescriptions) and contains info/name/img url for each skin. To add the info to the skins the user have in rgInventory you need to compare the classId for each item on both the rgInventoryand rgDescriptions. The classIdis the id which decide which type of weapon it is, therefore the classid is not unique.

So what Im doing is using two for-loops, and compares the ids so I can add the item_url, market_name etc. To the rgInventory array which I then I send away as the callback. Like this (javascript):

            var ids = getID(data.rgInventory);
            var item = getItems(data.rgDescriptions);

            for (var i = 0; i < ids.length; i++) {
                for (var k = 0; k < item.length; k++) {
                    if (ids[i].classid == item[k].classid) {
                        ids[i].market_name = item[k].market_name;
                        ids[i].icon_url = item[k].icon_url;
                        ids[i].tradable = item[k].tradable;

So if the classids of both items is the same I will add the information I want to the variable "ids" which in this case is a copy of rgInventory. When the for-loops are done I send away the ids-variable as my callback.

Feel free to ask questions, and sorry if this is confusing. Remember to type the url I linked with your steam-profile in your browser and see the result.

Hope it helps!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download