Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Sat-14/tf2-express

 
 

Repository files navigation

tf2-express

License Stars Issues Size Discord Code style Ruff

Automated TF2 trading bot with GUI support, built with Python. Prices are by default provided by PriceDB.IO.

Donate

Donations are not required, but greatly appericated.

Features

  • GUI for adding and changing items, prices, max_stock + browsing trades
  • Supports automated price updates from Prices.TF
  • Creates, modifies and deletes listings on Backpack.TF
  • Accepts incoming friend requests
  • Supports buy/sell message commands (sell_5021_6)
  • Sends counter offer when user is trying to take items for free
  • Sends counter offer when values are incorrect
  • Supports Random Craft Hats [?]
  • Bank as many items as you want
  • Add items by either name or SKU
  • Uses MongoDB for saving items, prices and trades
  • Limited inventory fetching to mitigate rate-limits
  • Supports arbitraging items from different trading sites [?]
  • Supports 3rd party inventory providers [?]

All available options can be found here.

Key dependencies:

Showcase

GUI Showcase

Installation

You need to have Python 3.11 or above installed. If you want to run the bot using Docker see Using Docker.

git clone [email protected]:offish/tf2-express.git
cd tf2-express
pip install -r requirements.txt

Note

You need to host a MongoDB server for the bot to work. Download the free community version here. You may also want to install MongoDB Compass to access/modify/delete collections manually.

Setup

Note

Make a copy of config.example.json and name it config.json. Make sure it is in the same folder as the example file. Update credentials and set your preferred options.

Example config:

{
    "bots": [
        {
            "username": "username",
            "password": "password",
            "shared_secret": "Aa11aA1+1aa1aAa1a=",
            "identity_secret": "aA11aaaa/aa11a/aAAa1a1=",
            "options": {
                "use_backpack_tf": true,
                "backpack_tf_token": "token",
                "enable_arbitrage": false,
                "inventory_provider": "steamsupply",
                "inventory_api_key": "mySteamSupplyApiKey",
                "accept_donations": true,
                "decline_trade_hold": true,
                "enable_craft_hats": true,
                "save_trade_offers": true,
                "owners": [
                    "76511111111111111",
                    "76522222222222222"
                ]
            }
        }
    ]
}

Note

As of v3.0.0 tf2-express only supports running one bot instance at a time. It will use the first entry in bots in the config.

Options

Option Description Default
username Username for the Steam account to use the bot with. Also used as the MongoDB database name.
use_backpack_tf Whether to list items on Backpack.TF or not. false
backpack_tf_token Access token from backpack.tf API access.
pricing_provider Provider for item pricing. pricedb
inventory_provider Provider for inventory. Default is Steam Community, can use third-party like Steam.Supply or Express-Load. steamcommunity
inventory_api_key API key for inventory provider. Not needed if using default Steam provider.
backpack_tf_user_agent User agent shown on next.backpack.tf.
accept_donations Whether to accept donations or not. false
auto_counter_bad_offers Whether to counter offers with wrong values or not. false
decline_trade_hold Whether to decline trades that have trade hold. false
auto_cancel_sent_offers Whether to automatically cancel sent offers after some time. false
cancel_sent_offers_after_seconds Time (in seconds) to wait before auto-cancelling sent offers.
max_price_age_seconds Maximum age (in seconds) of a price before it is fetched again.
enable_arbitrage Whether to enable arbitrage or not. [?] false
enable_craft_hats Whether to enable Random Craft Hats or not. [?] false
save_trade_offers Whether to save trade offers in the MongoDB database. true
groups List of group IDs to join. []
owners List of owner SteamID64s. Bot will accept offers from owners regardless of other conditions. []

Running

# tf2-express/
python main.py # start the bot
python panel.py # start the gui

Now you can visit the GUI at http://127.0.0.1:5000/

Logs will be available under logs/express.log. Level is set to DEBUG, so here you will be able to see every request etc. and more information than is shown in the terminal.

Warning

Do NOT share your logs or config files with anyone before removing sensitive information. This might leak your API_KEY and more.

Updating

# tf2-express/
git pull
pip install --upgrade -r requirements.txt
# update packages like bptf, tf2-utils, tf2-data and tf2-sku
# which the bot is dependant on

Using Docker

First configure the bot like shown in Setup. Then change the timezone in the Dockerfile, it is set to use Oslo time by default.

make build # will build the tf2-express docker image and install dependencies
make run # will start mongodb and tf2-express

The GUI does not start automatically. To start the GUI run this:

make gui

The GUI will then be available at http://127.0.0.1:5000/

Explanation

Random Craft Hats

If a craftable hat does not have a specific price in the database, it will be viewed as a Random Craft Hat (SKU: -100;6), if enable_craft_hats is enabled.

Caution

This applies to any craftable unique hat, which includes hats such as The Team Captain, Earbuds, Max Heads etc. If these do not have their own price in the database, they will be priced as a Random Craft Hat, if this option is enabled. Be careful when using this option, as it can lead to unwanted trades.

Simply open the GUI and add "Random Craft Hat" or -100;6 to the pricelist. Set the buy and sell price to whatever you want. Random Craft Hats cannot get automatic price updates.

Arbitrage

"Arbitraging is the process of taking advantage of a price difference between two or more markets". In this case, it is used to buy items from one trade site and sell to another for profit. tf2-express can act on deals from tf2-arbitrage and send or receive offers.

Important

As of tf2-express v3.0.0 arbitrage is currently broken.

3rd Party Inventory Providers

Steam can rate-limit inventory fetch requests if they are called too often. This can be avoided using a third party provider like SteamApis, Steam.Supply, Express-Load or your own. This is especially useful if you are running multiple bots.

Note

If you want to use Express-Load you can use the promo code offish to receive free credits and try out their API for free.

Testing

# tf2-express/
pytest

Every test should succeed except for the version check. The version needs to be incremented to pass this test.

License

MIT License

Copyright (c) 2020-2025 offish (confern)

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.

About

Automated TF2 trading bot with automatic pricing and GUI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 87.5%
  • HTML 11.7%
  • Other 0.8%