Jump to content

How do I use the backpack.tf api?


JNeb900ThePeril

Recommended Posts

Im in the process of learning how to/creating a website for tf2, which you will need to see your inventory and see the prices with them. I can't figure out how to use the "get community prices" thing. I tried getting multiple different keys to use when clicking the GET /api/IGetPrices/v4 button and it hasn't done anything for me. Is there a good guide or anything on how to use this?

Link to comment
Share on other sites

First, dont post ur api key in public places, cuz people can do bad thing (for example, they can scam u ), second, u need wait when elevated access will be confirmed by bp admins. it usually takes 1-2 days

Link to comment
Share on other sites

7 hours ago, JNeb900ThePeril said:

-

You should probably remove your api key here https://backpack.tf/developer/apikey/view

and request a new one (and request elevated access to use the IGetPrices API) since you shared it in a public place. Like Versal said, now other people could potentially use it.

 

What kind of tf2 website do you want to use the bptf api for?

Link to comment
Share on other sites

12 hours ago, JNeb900ThePeril said:

Im in the process of learning how to/creating a website for tf2, which you will need to see your inventory and see the prices with them. I can't figure out how to use the "get community prices" thing. I tried getting multiple different keys to use when clicking the GET /api/IGetPrices/v4 button and it hasn't done anything for me. Is there a good guide or anything on how to use this?

Are you having difficulty with being able to access the information upon the Backpack.tf API (e.g not getting like what is below when you click on "GET /api/IGetPrices/v4), or is it to do with how to implement it for your website?

5b5f2e69c0776_ScreenShot2018-07-30at16_27_03.thumb.png.79fb7a856447355929e5382a624683ab.png

 

Link to comment
Share on other sites

On ‎7‎/‎30‎/‎2018 at 9:30 AM, Mengh facepalms. said:

Are you having difficulty with being able to access the information upon the Backpack.tf API (e.g not getting like what is below when you click on "GET /api/IGetPrices/v4), or is it to do with how to implement it for your website?

5b5f2e69c0776_ScreenShot2018-07-30at16_27_03.thumb.png.79fb7a856447355929e5382a624683ab.png

 

Well, both. At the moment my elevated access requests keep getting rejected, and then I also don't know how to implement into my site.

Link to comment
Share on other sites

On ‎7‎/‎30‎/‎2018 at 4:12 AM, Zeus_Junior said:

You should probably remove your api key here https://backpack.tf/developer/apikey/view

and request a new one (and request elevated access to use the IGetPrices API) since you shared it in a public place. Like Versal said, now other people could potentially use it.

 

What kind of tf2 website do you want to use the bptf api for?

I want to make a site where 2 people put up some items at stake and then they go into an mge server to duel, and the winner takes all the items.

 

Im trying to figure out the deposit system right now. Im guessing that you first have to get the user's backpack with steamapi, then put it through a whitelist or something so it only shows certain items (so you cant deposit crates/cases) then youd use the bp.tf api to show the prices of those remaining items in the users backpack that you could deposit. I just don't know how to do this yet

Link to comment
Share on other sites

2 hours ago, JNeb900ThePeril said:

Well, both. At the moment my elevated access requests keep getting rejected, and then I also don't know how to implement into my site.

It's most likely that there's a reason for it being declined, being that such an idea of a site where people duel for each other's goods sounds like it could be considered gambling (even if it doesn't share the aspects of normal gambling games) and it could be that Backpack.tf doesn't want its data to be affiliated with such a site, from how I see it.

 

I would suggest you try to contact @Teeny Tiny Cat for the exact reason why you was rejected elevated access, and probably rethink your idea or business model.

Link to comment
Share on other sites

  • Administrators
9 hours ago, JNeb900ThePeril said:

I want to make a site where 2 people put up some items at stake and then they go into an mge server to duel, and the winner takes all the items.

 

Im trying to figure out the deposit system right now. Im guessing that you first have to get the user's backpack with steamapi, then put it through a whitelist or something so it only shows certain items (so you cant deposit crates/cases) then youd use the bp.tf api to show the prices of those remaining items in the users backpack that you could deposit. I just don't know how to do this yet

 

It was rejected because your web address sounds like a standard gambling site and you didn't describe any of this in the comment. Have accepted it now.

Link to comment
Share on other sites

Sounds like a pretty interesting idea, are you planning to use bots for it so theres no 'running' like with spycrabs?

Link to comment
Share on other sites

18 hours ago, JNeb900ThePeril said:

I want to make a site where 2 people put up some items at stake and then they go into an mge server to duel, and the winner takes all the items.

 

Im trying to figure out the deposit system right now. Im guessing that you first have to get the user's backpack with steamapi, then put it through a whitelist or something so it only shows certain items (so you cant deposit crates/cases) then youd use the bp.tf api to show the prices of those remaining items in the users backpack that you could deposit. I just don't know how to do this yet

 

As you're learning about how to make a deposit system, as well as a website for this, I'll try to explain the thought process and help break down the first sort of steps for you and provide some suggestions, assuming you have some knowledge of JavaScript and/or PHP, alongside HTML and CSS. If not, I'd probably suggest you try to run through some tutorials in those programming languages until you've understood the fundamentals of them. This somewhat-of-a-guide I've made will try to offer some coverage of breaking down how to build a deposit system in general, so that you can then research the necessary technologies / languages as to be able to integrate the building of an MGE server onto this.

 

There are some case studies that you may want to look at first, such as FACEIT, ELOPLAY and (the now-gone) Kickback.com and see how they implement their similar systems.

 

 

I: Breaking down the general system

When breaking down your idea, you've got to think ahead and think of the potential questions and problems that you may have have in the future. For example, when "2 people put up some items at stake", would it be fair for one player to put more at stake than the other, say a $6.00 item when the other item is wagering a $5.50-valued item? There would be two ways to think about this, being that you would either have to use:

  1. the internal TF2 currency of keys and metal as to value items, where players can deposit items onto the site and they will immediately be put up for wager / be held in an inventory on the site to be wagered later, where another player must offer the same refined value as of Backpack.tf community prices.
  2. the $ dollar pricing to value items, where players can deposit items on the site, and get a specified amount of currency upon the site (i.e coins) as to be able to then use that on the site. Users win coins depending on the result of their duels, and then can use those coins to withdraw items from the bot inventory system you have on the site.

The idea of number 1 is the most straightforward and least resource-heavy, given that you wouldn't need to hold additional data for each user for how much currency they have on the site, however, number 2 offers the chance to profit more off commission, simply because the ability to initiate duels for a user is greater as one wouldn't need to always deposit an item every single time. I'd probably suggest option 1, as it's much easier to program.

 

As you've stated, the user's backpack will need to be obtained with the SteamAPI, with items whitelisted and then use the backpack.tf API as to price check all the other items and allow them to deposit those items. Of course, you'll need to create a user interface, such as through a website page, or either you could have users just send in trade offers to the bot and value them accordingly upon the site when it receives the items. For a user to be able to retrieve their own inventory, no matter before or after depositing, this would require the user to login first to the site through steam authentication. You can find applicable modules (other people's pre-built and pre-tested code) online that help provide this service to you if you search for "steam <Programming Language> login", where searching "steam php login" on Google will provide you with the necessary modules when building a site in PHP.

 

 

II: Usage of an API

Such a module can provide you with the user's identification details such as their unique SteamID64 number that is often used for finding that specific profile, and you'll be able to use this for access the user's backpack through the public SteamAPI as you've said. An API is, to put it simply in the context of this guide, a place you can access through a URL on a website that will provide you with information in a programmatically-formatted way so that your application can then take that information and interpret it. One of the most popular formats used is called JSON, which uses arrays and objects (programming language data structures - you may need to go more in-depth with some programming tutorials), as to present this information, like shown before.

 

Some APIs are public, meaning that the information is publicly available to anyone who visits the link to retrieve the require information, and others are private, meaning that they require a key as to access it. For example, to access my TF2 inventory from the SteamAPI in the JSON format, anyone can simply go on this link. I should warn you that it is very long and may be hard to understand, but when you put it into an application, it is much easier to understand and decompose.

 

https://steamcommunity.com/inventory/76561198081082634/440/2?l=english&count=5000

 

You can check on other people's TF2 inventories (as long as they're not private) by changing the SteamID64 just in between "...inventory/" and "/440...". You'll notice that 440 is the appid of TF2, and yes, you can change that to other appids such as 730 (for CS:GO inventories), provided the given game has an item system like TF2's. You'll notice at the end of the URL that it ends with "l=english&count=5000", which are pieces of information known as "queries" or "URL queries", which are required to change what sort of information is presented and how it is presented. For example, you can infer that "l" denotes the language you want the JSON to be in, whereas the "count" is the maximum number of inventory items that you want presented. Some APIs allow for this functionality to choose how you pick to have the data, so that you can integrate it into your system better or for when it is necessary, and will tell you what queries may or may not be needed in their documentation, as well as how the information will be presented to you.

 

For some APIs like the backpack.tf api, the information is not publicly available as some of it is personal data or data that should only be used by the owner of the key. Hence, it is required for you to enter your backpack.tf api key as one of the queries of the URL to be verify who you are and allow you access to the data. Now that you have elevated access, you can now access all of the latest community prices of the backpack.tf API, when you go on the respective link when you replace the Xs with your API key:

 

https://backpack.tf/api/IGetPrices/v4?key=XXXXXXXXXXXXXXXXXX

 

You now know how to use the API, so you'll be able to now integrate it with your application.

 

 

III: Implementing API data into your system

 

The idea behind the SteamAPI inventory url is the fact that you'll be able to 'build' your own URL links to be able to access people's information, when needed. When someone is logged into your site through Steam Authentication and is on the deposit page, their SteamID information can be used to build the necessary URL as to get the correct information of the person's inventory. You can tell your website as to get this information from the website, without you having to be directed to that API page and doing it yourself. This is done by using an appropriate function in the programming language you're using, where you input the URL (after building it) that your site will search and retrieve the 'file' of the information that is presented upon going to that URL.

In PHP, this is file_get_contents(), NodeJS requires the https module to "get()" the API information, however, you may wish to use other technologies such as AJAX that you can look into.

 

Once you get the file of information from the API, you can then use a relevant function as to decode the JSON file into an object that your programming language recognises. You can then access the relevant information as if it was coded in the programming language you're using.

 

https://steamcommunity.com/inventory/76561198081082634/440/2?l=english&count=5000

 

For example, after decoding the information of my inventory from the SteamAPI, you can then access the items in it by accessing the information in the "rgDescriptions" object key as to get all the necessary items from my inventory.

 

You can then filter out the items from there by searching through each item and checking their name / other details and whether they're whitelisted, and then provide the list of applicable items as text, or images (requires more work). You can then use the market_hash_name's, craft status, quality as to align each inventory item with its respective price in the Backpack.tf API, but that'll probably be after you are able to create your interface first as to make it useful.

 

 

=====

Overall, it's quite an adventurous project, however, it requires a lot of work and learning for someone of your experience. I'd definitely suggest that you try to learn NodeJS and/or PHP (and other languages as well) first as to be able to create a deposit system with a working bot, before working on expanding it to implementing it similar to a coin flip site and then add on the MGE server functionalities to determine who wins. It's definitely quite a big project, but I would suggest you don't take that negatively if you're fully committed to doing it. I'd definitely make sure you know the fundamentals first before jumping right on in, so here are some links to help lead you in the right direction.

 

Learning the fundamentals of JavaScript - https://www.codecademy.com/learn/introduction-to-javascript

Learning PHP - https://www.tutorialspoint.com/php/index.htm

Using JSONs in JavaScript - https://www.w3schools.com/js/js_json.asp | https://www.w3schools.com/js/js_json_intro.asp

An assortment of Steam Modules - https://github.com/scholtzm/awesome-steam

Learning NodeJS - https://www.youtube.com/playlist?list=PL55RiY5tL51oGJorjEgl6NVeDbx_fO5jR

 

Creating SteamBots and implementing them for a website - https://github.com/andrewda/node-steam-guide

Working with APIs - https://www.youtube.com/watch?v=Az-EvazsFfo

 

IGetPrices API Documentation - https://backpack.tf/api/docs/IGetPrices

Kickback.com - https://www.youtube.com/watch?v=_TNGitOh22g

 

 

I don't have all the time in the world to write this, but feel free to message me through the forums or add me on Steam for any help whenever, or just leave a post here for others to see and help as well.

Link to comment
Share on other sites

On 8/1/2018 at 9:08 AM, Mengh facepalms. said:

 

As you're learning about how to make a deposit system, as well as a website for this, I'll try to explain the thought process and help break down the first sort of steps for you and provide some suggestions, assuming you have some knowledge of JavaScript and/or PHP, alongside HTML and CSS. If not, I'd probably suggest you try to run through some tutorials in those programming languages until you've understood the fundamentals of them. This somewhat-of-a-guide I've made will try to offer some coverage of breaking down how to build a deposit system in general, so that you can then research the necessary technologies / languages as to be able to integrate the building of an MGE server onto this.

 

There are some case studies that you may want to look at first, such as FACEIT, ELOPLAY and (the now-gone) Kickback.com and see how they implement their similar systems.

 

 

I: Breaking down the general system

When breaking down your idea, you've got to think ahead and think of the potential questions and problems that you may have have in the future. For example, when "2 people put up some items at stake", would it be fair for one player to put more at stake than the other, say a $6.00 item when the other item is wagering a $5.50-valued item? There would be two ways to think about this, being that you would either have to use:

  1. the internal TF2 currency of keys and metal as to value items, where players can deposit items onto the site and they will immediately be put up for wager / be held in an inventory on the site to be wagered later, where another player must offer the same refined value as of Backpack.tf community prices.
  2. the $ dollar pricing to value items, where players can deposit items on the site, and get a specified amount of currency upon the site (i.e coins) as to be able to then use that on the site. Users win coins depending on the result of their duels, and then can use those coins to withdraw items from the bot inventory system you have on the site.

The idea of number 1 is the most straightforward and least resource-heavy, given that you wouldn't need to hold additional data for each user for how much currency they have on the site, however, number 2 offers the chance to profit more off commission, simply because the ability to initiate duels for a user is greater as one wouldn't need to always deposit an item every single time. I'd probably suggest option 1, as it's much easier to program.

 

As you've stated, the user's backpack will need to be obtained with the SteamAPI, with items whitelisted and then use the backpack.tf API as to price check all the other items and allow them to deposit those items. Of course, you'll need to create a user interface, such as through a website page, or either you could have users just send in trade offers to the bot and value them accordingly upon the site when it receives the items. For a user to be able to retrieve their own inventory, no matter before or after depositing, this would require the user to login first to the site through steam authentication. You can find applicable modules (other people's pre-built and pre-tested code) online that help provide this service to you if you search for "steam <Programming Language> login", where searching "steam php login" on Google will provide you with the necessary modules when building a site in PHP.

 

 

II: Usage of an API

Such a module can provide you with the user's identification details such as their unique SteamID64 number that is often used for finding that specific profile, and you'll be able to use this for access the user's backpack through the public SteamAPI as you've said. An API is, to put it simply in the context of this guide, a place you can access through a URL on a website that will provide you with information in a programmatically-formatted way so that your application can then take that information and interpret it. One of the most popular formats used is called JSON, which uses arrays and objects (programming language data structures - you may need to go more in-depth with some programming tutorials), as to present this information, like shown before.

 

Some APIs are public, meaning that the information is publicly available to anyone who visits the link to retrieve the require information, and others are private, meaning that they require a key as to access it. For example, to access my TF2 inventory from the SteamAPI in the JSON format, anyone can simply go on this link. I should warn you that it is very long and may be hard to understand, but when you put it into an application, it is much easier to understand and decompose.

 

https://steamcommunity.com/inventory/76561198081082634/440/2?l=english&count=5000

 

You can check on other people's TF2 inventories (as long as they're not private) by changing the SteamID64 just in between "...inventory/" and "/440...". You'll notice that 440 is the appid of TF2, and yes, you can change that to other appids such as 730 (for CS:GO inventories), provided the given game has an item system like TF2's. You'll notice at the end of the URL that it ends with "l=english&count=5000", which are pieces of information known as "queries" or "URL queries", which are required to change what sort of information is presented and how it is presented. For example, you can infer that "l" denotes the language you want the JSON to be in, whereas the "count" is the maximum number of inventory items that you want presented. Some APIs allow for this functionality to choose how you pick to have the data, so that you can integrate it into your system better or for when it is necessary, and will tell you what queries may or may not be needed in their documentation, as well as how the information will be presented to you.

 

For some APIs like the backpack.tf api, the information is not publicly available as some of it is personal data or data that should only be used by the owner of the key. Hence, it is required for you to enter your backpack.tf api key as one of the queries of the URL to be verify who you are and allow you access to the data. Now that you have elevated access, you can now access all of the latest community prices of the backpack.tf API, when you go on the respective link when you replace the Xs with your API key:

 

https://backpack.tf/api/IGetPrices/v4?key=XXXXXXXXXXXXXXXXXX

 

You now know how to use the API, so you'll be able to now integrate it with your application.

 

 

III: Implementing API data into your system

 

The idea behind the SteamAPI inventory url is the fact that you'll be able to 'build' your own URL links to be able to access people's information, when needed. When someone is logged into your site through Steam Authentication and is on the deposit page, their SteamID information can be used to build the necessary URL as to get the correct information of the person's inventory. You can tell your website as to get this information from the website, without you having to be directed to that API page and doing it yourself. This is done by using an appropriate function in the programming language you're using, where you input the URL (after building it) that your site will search and retrieve the 'file' of the information that is presented upon going to that URL.

In PHP, this is file_get_contents(), NodeJS requires the https module to "get()" the API information, however, you may wish to use other technologies such as AJAX that you can look into.

 

Once you get the file of information from the API, you can then use a relevant function as to decode the JSON file into an object that your programming language recognises. You can then access the relevant information as if it was coded in the programming language you're using.

 

https://steamcommunity.com/inventory/76561198081082634/440/2?l=english&count=5000

 

For example, after decoding the information of my inventory from the SteamAPI, you can then access the items in it by accessing the information in the "rgDescriptions" object key as to get all the necessary items from my inventory.

 

You can then filter out the items from there by searching through each item and checking their name / other details and whether they're whitelisted, and then provide the list of applicable items as text, or images (requires more work). You can then use the market_hash_name's, craft status, quality as to align each inventory item with its respective price in the Backpack.tf API, but that'll probably be after you are able to create your interface first as to make it useful.

 

 

=====

Overall, it's quite an adventurous project, however, it requires a lot of work and learning for someone of your experience. I'd definitely suggest that you try to learn NodeJS and/or PHP (and other languages as well) first as to be able to create a deposit system with a working bot, before working on expanding it to implementing it similar to a coin flip site and then add on the MGE server functionalities to determine who wins. It's definitely quite a big project, but I would suggest you don't take that negatively if you're fully committed to doing it. I'd definitely make sure you know the fundamentals first before jumping right on in, so here are some links to help lead you in the right direction.

 

Learning the fundamentals of JavaScript - https://www.codecademy.com/learn/introduction-to-javascript

Learning PHP - https://www.tutorialspoint.com/php/index.htm

Using JSONs in JavaScript - https://www.w3schools.com/js/js_json.asp | https://www.w3schools.com/js/js_json_intro.asp

An assortment of Steam Modules - https://github.com/scholtzm/awesome-steam

Learning NodeJS - https://www.youtube.com/playlist?list=PL55RiY5tL51oGJorjEgl6NVeDbx_fO5jR

 

Creating SteamBots and implementing them for a website - https://github.com/andrewda/node-steam-guide

Working with APIs - https://www.youtube.com/watch?v=Az-EvazsFfo

 

IGetPrices API Documentation - https://backpack.tf/api/docs/IGetPrices

Kickback.com - https://www.youtube.com/watch?v=_TNGitOh22g

 

 

I don't have all the time in the world to write this, but feel free to message me through the forums or add me on Steam for any help whenever, or just leave a post here for others to see and help as well.

 

Wow there's a lot of good information in there. I've been learning the basics of some languages but it's going pretty slowly. Most tutorials I can find are actually pretty bad at teaching; They assume you already know a lot of what they're talking about and I end up having to ask a friend how to do everything. I can use the api's and build a basic html site, but I just don't know how to integrate everything together.

 

I did have one question for you which is why I came back here in the first place: Is it possible to build a site using html, put some php in there to log into steam (https://github.com/SmItH197/SteamAuthentication) and then still be able to have my bots connected to the website when they're using nodejs?

 

 

 

Link to comment
Share on other sites

Archived

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

  • Recently Browsing   0 members

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