Jump to content

backpack.tf API


klenium

Recommended Posts

I tried to use backpack.tf api on my website. I want to get the player's backpack value with Javascript. But when I tried to use this simple code in console (Chrome):

$.get("http://backpack.tf/api/IGetUsers/v2/?steamids=76561198045802942");
then I only got this error message:
XMLHttpRequest cannot load http://backpack.tf/api/IGetUsers/v2/?steamids=76561198045802942. Origin http://mywebsite.com is not allowed by Access-Control-Allow-Origin.

So, how can I use this api? Do I need an api key, like "IGetPrices"? What did I do wrong?
Link to comment
Share on other sites

But then why is there this api...? I think, everyone can use it from his website.. If I can't get these informations from my website, then what can I do? :D There's a search field, if you just want to find someone from this (backpack.tf) site.

Link to comment
Share on other sites

Your server-side script should load that, not the client - it's a browser security feature as the other person above pointed out.

Link to comment
Share on other sites

Your server-side script should load that, not the client - it's a browser security feature as the other person above pointed out.

 

Didn't the API, at least v1, support JSONP? Don't remember where I read it, since it's not documented with the API description.

But since you need an API Key, I guess that feature is no longer available...

Link to comment
Share on other sites

Some of the API functions support jsonp -- but not all of them. Anyway, like I said this should be a server-side request with some caching on your end. If the person refreshes their page on their website every 5 seconds you don't want to hit the backpack.tf server every 5 seconds.

Link to comment
Share on other sites

  • 2 months later...

Again me. What's wrong with the names?

backpack.tf/api/IGetPrices/v3/?key=apikey&names=1

This doesn't include the names, only the prices.

Link to comment
Share on other sites

Again me. What's wrong with the names?

backpack.tf/api/IGetPrices/v3/?key=apikey&names=1

This doesn't include the names, only the prices.

 

Should be ok now, let me know if you notice anything odd.

Link to comment
Share on other sites

  • 7 months later...

Australium weapons aren't in the API. When are you going to add them? Will you add an unique quantity like 1100 for strange uncraftables?

 

And take a look at the alt_defindex. Fire Axe has it, but Bat doesn't.

Link to comment
Share on other sites

  • Administrators

Internally, backpack.tf no longer uses item defindexes when storing price data for a few reasons:

 

  • There are a few items which appear multiple times in the schema (e.g. keys and stock weapons) and this saves on having to remap by defindex
  • Uncraftability and untradability are now stored as separate branches. It's kind of like this:
[Kritzkrieg]
    [6]
        [Tradable]
            [Craftable]
                [Priceindex] <-- used for crate series, unusual effect IDs, etc. 0 otherwise.
                     [0]
                         {price info}
            [Non-Craftable]
                [Priceindex]
                     [0]
                         {price info}
    [11]
        [...]

Ergo we won't have to use numbers like 600 or 1100 any more to signify non-craftability.

 

I will start work on IGetPrices v4 which will use this format so it gets shipped in the next update. Supporting australium stuff should also be simple.

Link to comment
Share on other sites

  • Administrators

That was fun. This is what IGetPrices v4 will look like:

{
    "response": {
        "success": 1,
        "current_time": 1392752280,
        "items": {
            "A Brush with Death": {
                "defindex": {
                    "0": 30186
                },
                "prices": {
                    "6": {
                        "Tradable": {
                            "Craftable": {
                                "0": {
                                    "currency": "metal",
                                    "value": 4,
                                    "last_update": 1384656665,
                                    "difference": -0.165
                                }
                            }
                        }
                    }
                }
            },
            [...]

Australium support was simple. It was just commented out of v3 since the API wasn't built for it.

I just have to polish this up and make some new documentation, it'll be ready for the upcoming update.

Link to comment
Share on other sites

  • 1 month later...

Bat, kukri, shovel and some other stock weapons haven't included their 2 defindexes yet, unlike others. Why? Could you add all pls?

Link to comment
Share on other sites

  • 4 weeks later...

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...