Tools and utilities for TF2 trading
Project description
tf2-utils
Tools and utilities for TF2 trading. Use 3rd party inventory providers, get SKUs directly from inventories, listen to BackpackTF's websocket and more.
Donate
- BTC:
bc1qntlxs7v76j0zpgkwm62f6z0spsvyezhcmsp0z2
- Steam Trade Offer
Features
- Uses tf2-sku
- Uses tf2-data
- Get SKUs directly from inventories/offers
- Convert name to SKU and vice versa
- Fetch inventories using 3rd party providers (avoid being rate-limited)
- Listen for Backpack.TF websocket events
- Listen for Prices.TF websocket events
- Interact with Prices.TF's API
- Get item properties (
is_craft_hat
,get_paint
,get_effect
etc.) - Fetch TF2 Schema data
- Convert SKU/defindex to item image URL
- Calculate scrap and refined prices
Setup
Install
pip install tf2-utils
# or
python -m pip install tf2-utils
Updating
pip install --upgrade tf2-utils tf2-sku tf2-data
# or
python -m pip install --upgrade tf2-utils tf2-sku tf2-data
Usage
See examples or tests for more usage examples.
Inventory fetching
from tf2_utils import Inventory
# using 3rd party provider to avoid being rate-limited
provider = Inventory("steamsupply", "9st947vs0qmgfpeqde1gj92l0oqmhysm")
# using steam as inventory provider
provider = Inventory() # or Inventory("steamcommunity")
# get an inventory
inventory = provider.fetch("76561198253325712")
Gettings SKUs from inventories
NOTE: NOT ALL SKU ATTRIBUTES ARE ADDED YET
Get SKUs implicitly
from tf2_utils import Inventory, map_inventory
provider = Inventory("steamcommunity")
user_inventory = provider.fetch("76561198253325712")
inventory = map_inventory(user_inventory, add_skus=True)
Get a particular item's SKU
from tf2_utils import get_sku
inventory = map_inventory(user_inventory)
for item in inventory:
sku = get_sku(item)
BackpackTF Websocket
Handle one listing at a time
from tf2_utils import BackpackTFSocket
def my_function(data: dict):
print("got data!", data)
socket = BackpackTFSocket(my_function)
socket.listen()
Handle list of listings at a time
from tf2_utils import BackpackTFSocket
def my_function(data: list[dict]):
print("got listings")
for listing in data:
print("listing", listing)
socket = BackpackTFSocket(my_function, solo_entries=False)
socket.listen()
PricesTF Websocket
from tf2_utils import PricesTFSocket
def my_function(data: dict):
print("got data!", data)
socket = PricesTFSocket(my_function)
socket.listen()
Testing
# tf2-utils/
python -m unittest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tf2-utils-2.1.0.tar.gz
(101.8 kB
view hashes)
Built Distribution
tf2_utils-2.1.0-py3-none-any.whl
(15.6 kB
view hashes)
Close
Hashes for tf2_utils-2.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c99999c3abb5cb6b3235848184328b0b68ba4ead508b4cef7dabdf76afea361 |
|
MD5 | f0c723a57bc48b086e8d541b1d225b11 |
|
BLAKE2b-256 | 462a06e9e72890bbbc21e154dd4468f84ce8809962376d60b61fa1f76be8e6b3 |